A Python-based system that connects a local LLM (Llama 3.2) to Google Calendar and Gmail through a simple web interface.
This project provides a web-based chat interface where you can ask questions about your Google Calendar and Gmail. The system uses:
- Llama 3.2 (3B) running locally via Ollama
- HTTP API server for Google Calendar/Gmail access
- Web chat interface in your browser
Your LLM can:
- π List calendar events
- π§ List and read emails
- π All data stays local - no cloud hosting needed
- Python 3.8+
- Ollama installed
- Google account
- Brave/Chrome/Firefox browser
- Get Google Credentials (see detailed guide below)
- Install dependencies
- Authenticate with Google
- Start the servers
- Open chat interface
- Go to Google Cloud Console
- Create a new project
- Enable these APIs:
- Google Calendar API
- Gmail API
- Configure OAuth consent screen:
- Choose "External"
- Add your email as a test user
- Create OAuth 2.0 credentials (Desktop app)
- Download
credentials.jsonand place in project root
cd mcp-google-services
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtsource .venv/bin/activate
python src/server_http.pyA browser will open for OAuth. Grant permissions. This creates token.pickle.
Press Ctrl+C to stop the server after authentication.
# Install Ollama (if not installed)
curl -fsSL https://ollama.com/install.sh | sh
# Pull Llama 3.2 3B model
ollama pull llama3.2:3bYou need 3 terminals running simultaneously:
cd mcp-google-services
source .venv/bin/activate
python src/server_http.pyShould show:
π Starting MCP Google Services HTTP Server...
π Server will be available at: http://localhost:8000
OLLAMA_ORIGINS="*" ollama serveShould show:
time=... level=INFO source=routes.go:... msg="Listening on 127.0.0.1:11434"
cd mcp-google-services
python3 -m http.server 8080Should show:
Serving HTTP on 0.0.0.0 port 8080
-
Open browser to:
http://localhost:8080/chat_interface.html -
Ask questions like:
- "What's on my calendar tomorrow?"
- "Show me my recent emails"
- "What events do I have this week?"
-
The LLM will automatically fetch data from Google and give you natural language answers
mcp-google-services/
βββ .venv/ # Virtual environment
βββ src/
β βββ server.py # MCP stdio server (not currently used)
β βββ server_http.py # HTTP API server (β main server)
βββ chat_interface.html # Web chat UI (β what you use)
βββ requirements.txt # Python dependencies
βββ credentials.json # OAuth credentials (YOU provide)
βββ token.pickle # Auth token (auto-generated)
βββ .gitignore # Prevents committing secrets
βββ README.md # This file
βββββββββββββββ
β Browser β You ask questions here
β (port 8080) β
ββββββββ¬βββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββ
β chat_interface.html β
β Determines which tool to use β
βββββββ¬βββββββββββββββββββββββ¬βββββββββββββ
β β
β Fetch data β Generate response
βΌ βΌ
ββββββββββββββββ ββββββββββββββββ
β HTTP Server β β Ollama β
β (port 8000) β β (port 11434) β
β β β β
β - Calendar β β Llama 3.2 3B β
β - Gmail β β β
ββββββββ¬ββββββββ ββββββββββββββββ
β
βΌ
ββββββββββββββββ
β Google β
β APIs β
ββββββββββββββββ
- You type a question in the browser
- JavaScript detects if it needs calendar or email data
- Fetches data from HTTP server (port 8000)
- HTTP server queries Google Calendar/Gmail APIs
- Data is sent to Ollama (port 11434) with your question
- Llama 3.2 generates a natural language response
- Answer appears in chat
The HTTP server exposes these endpoints:
| Endpoint | Method | Description |
|---|---|---|
/tools |
GET | List available tools |
/call_tool |
POST | Execute a tool |
Available tools:
calendar_list_events- List upcoming eventscalendar_create_event- Create new eventgmail_list_messages- List recent emailsgmail_read_message- Read specific emailgmail_send_message- Send an email
credentials.json- Your OAuth credentialstoken.pickle- Your access token
The .gitignore file prevents this automatically.
Access Control:
- HTTP server runs on
localhostonly (not accessible from internet) - Ollama runs locally
- All data stays on your machine
- No cloud services involved
Check all 3 servers are running:
curl http://localhost:8000 # HTTP server
curl http://localhost:11434 # Ollama
curl http://localhost:8080 # Web serverAll should respond without errors.
Make sure you started Ollama with:
OLLAMA_ORIGINS="*" ollama serveNot just ollama serve
ollama list # Check installed models
ollama pull llama3.2:3b # Pull if missingsource .venv/bin/activate
pip install -r requirements.txtDelete token and re-authenticate:
rm token.pickle
python src/server_http.pyExpected response times on CPU:
- Calendar queries: 3-5 seconds
- Email queries: 3-5 seconds
- Simple questions: 2-3 seconds
With GPU (if available):
- All queries: 1-2 seconds
To avoid typing OLLAMA_ORIGINS="*" every time:
# Add to ~/.bashrc
echo 'export OLLAMA_ORIGINS="*"' >> ~/.bashrc
source ~/.bashrc
# Now just use:
ollama servePress Ctrl+C in each terminal to stop the servers.
Or kill all at once:
pkill -f "python.*server_http"
sudo pkill ollama
pkill -f "python.*http.server"Possible improvements:
- β¨ Add email sending capability to chat
- β¨ Calendar event creation via chat
- β¨ Email search functionality
- β¨ Multiple calendar support
- β¨ Better conversation memory
- β¨ Voice input/output
Stack:
- Backend: Python 3.11 + FastAPI
- LLM: Llama 3.2 3B via Ollama
- APIs: Google Calendar API, Gmail API
- Frontend: Vanilla JavaScript + HTML/CSS
- No frameworks: Pure web technologies
Why this approach?
- β Simple setup
- β Everything runs locally
- β No external dependencies
- β Easy to modify
- β Works on modest hardware
Common issues:
- CORS errors β Restart Ollama with
OLLAMA_ORIGINS="*" - Slow responses β Normal on CPU, ~3-5 seconds
- Can't connect β Check all 3 servers are running
- Auth errors β Delete
token.pickle, re-authenticate
System Requirements:
- 8GB RAM minimum (16GB recommended)
- Any modern CPU
- ~10GB disk space (for models)
- Internet connection (for Google APIs)
MIT
# Start everything (use 3 separate terminals)
# Terminal 1:
cd mcp-google-services && source .venv/bin/activate && python src/server_http.py
# Terminal 2:
OLLAMA_ORIGINS="*" ollama serve
# Terminal 3:
cd mcp-google-services && python3 -m http.server 8080
# Then open browser to:
# http://localhost:8080/chat_interface.html