A full-stack web application that acts as a unified productivity gateway, allowing users to connect multiple email and calendar accounts (Google, Microsoft Outlook) and expose all functionality through a standardised MCP (Model Context Protocol) server endpoint.
Any MCP-compatible AI client — Claude Desktop, Cursor, VS Code, Windsurf, or a custom client — can query and act on email, calendar, and tasks via 23 tools.
┌────────────────────────────────────────────────────────┐
│ MCP Client (AI) │
│ Claude Desktop / Cursor / VS Code │
└───────────────────────┬────────────────────────────────┘
│ HTTP SSE (Bearer token)
┌───────────────────────▼────────────────────────────────┐
│ nginx reverse proxy :80 │
├──────────────────────────┬─────────────────────────────┤
│ Angular SPA :4200 │ FastAPI backend :8000 │
│ (TypeScript/Material) │ /api/v1/* REST API │
│ │ /mcp/sse MCP Server │
└──────────────────────────┴──────────┬──────────────────┘
│
┌───────▼──────┐
│ PostgreSQL 16 │
└──────────────┘
│
┌─────────────┴──────────────┐
Google APIs Microsoft Graph
Gmail, Calendar Mail, Calendar,
Tasks To-Do
- Docker and Docker Compose v2
- Google OAuth 2.0 credentials
- Microsoft Azure App Registration credentials
git clone <repo-url>
cd EmailApp
cp .env.example .envEdit .env with your credentials (see OAuth Registration sections below).
Generate the required secret keys:
# App secret key
openssl rand -hex 32
# Fernet encryption key for tokens
python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"docker compose up --buildThe first startup runs Alembic migrations automatically. Access the app at http://localhost.
Navigate to http://localhost → click Continue with Google or Continue with Microsoft.
- Go to Google Cloud Console → APIs & Services → Credentials
- Create OAuth 2.0 Client ID → Web application
- Add Authorised redirect URI:
http://localhost/api/v1/auth/google/callback - Enable APIs: Gmail API, Google Calendar API, Tasks API
- Copy Client ID and Secret to
.env
Required scopes (configured automatically):
gmail.readonly,gmail.send,gmail.compose,gmail.modifycalendar.readonly,calendar.eventstasks.readonly,tasks
- Go to Azure Portal → Azure Active Directory → App Registrations → New
- Set redirect URI:
http://localhost/api/v1/auth/microsoft/callback(Web platform) - Under Certificates & Secrets, create a new client secret
- Under API Permissions, add:
Mail.Read,Mail.Send,Mail.ReadWriteCalendars.Read,Calendars.ReadWriteTasks.Read,Tasks.ReadWriteopenid,email,profile,offline_access
- Copy Application (client) ID, client secret, and Directory (tenant) ID to
.env
After logging in and generating an API token at /tokens, use the MCP Setup Guide page (/mcp-guide) for auto-populated config snippets, or use the templates below.
~/Library/Application Support/Claude/claude_desktop_config.json (macOS)
%APPDATA%\Claude\claude_desktop_config.json (Windows)
{
"mcpServers": {
"email-mcp-gateway": {
"url": "http://localhost/mcp/sse",
"headers": {
"Authorization": "Bearer mcp_live_YOUR_TOKEN"
}
}
}
}.cursor/mcp.json or global Cursor settings:
{
"mcpServers": {
"email-mcp-gateway": {
"url": "http://localhost/mcp/sse",
"headers": {
"Authorization": "Bearer mcp_live_YOUR_TOKEN"
}
}
}
}settings.json:
{
"mcp.servers": {
"email-mcp-gateway": {
"type": "sse",
"url": "http://localhost/mcp/sse",
"headers": {
"Authorization": "Bearer mcp_live_YOUR_TOKEN"
}
}
}
}| Tool | Description |
|---|---|
search_emails |
Full-text search with date/folder filters |
get_email |
Fetch full email body by ID |
list_emails |
Paginated email listing |
send_email |
Compose and send HTML or plain-text email |
reply_to_email |
Reply or reply-all to a thread |
move_email |
Move to a folder/label |
delete_email |
Move to trash |
list_folders |
List all mailbox folders/labels |
| Tool | Description |
|---|---|
list_calendar_events |
Events in a date range |
search_calendar_events |
Search by title/description |
get_calendar_event |
Full event details |
create_calendar_event |
Create with attendees and timezone |
update_calendar_event |
Update any fields |
delete_calendar_event |
Delete/cancel event |
list_calendars |
List all calendars |
| Tool | Description |
|---|---|
list_tasks |
List active/completed tasks |
search_tasks |
Search by title or notes |
get_task |
Full task details |
create_task |
Create with due date |
update_task |
Update any fields |
complete_task |
Mark as complete |
delete_task |
Delete a task |
list_task_lists |
List all task lists |
All tools accept an optional account_email parameter to target a specific connected account.
| Variable | Description | Required |
|---|---|---|
APP_SECRET_KEY |
JWT signing secret (32+ char hex) | Yes |
TOKEN_ENCRYPTION_KEY |
Fernet key for OAuth token encryption | Yes |
DATABASE_URL |
PostgreSQL connection string | Yes |
FRONTEND_URL |
Frontend origin for CORS | Yes |
GOOGLE_CLIENT_ID |
Google OAuth client ID | For Google auth |
GOOGLE_CLIENT_SECRET |
Google OAuth client secret | For Google auth |
MICROSOFT_CLIENT_ID |
Azure app client ID | For Microsoft auth |
MICROSOFT_CLIENT_SECRET |
Azure client secret | For Microsoft auth |
MICROSOFT_TENANT_ID |
Azure tenant ID (common for multi-tenant) |
For Microsoft auth |
cd backend
uv venv && source .venv/bin/activate
uv pip install -e .
# Start local postgres first, then:
alembic upgrade head
uvicorn app.main:app --reload --port 8000API docs: http://localhost:8000/api/docs
cd frontend
npm install
npm start # http://localhost:4200- OAuth access and refresh tokens are encrypted at rest using Fernet (AES-128-CBC + HMAC-SHA256)
- MCP API tokens are stored as SHA-256 hashes with HMAC comparison — the plaintext is shown only once
- OAuth CSRF states expire after 10 minutes
- MCP endpoints are rate-limited to 100 requests/minute per token
- CORS is restricted to the configured
FRONTEND_URL - Background scheduler automatically refreshes tokens expiring within 5 minutes
THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. USE AT YOUR OWN RISK.
- This application handles sensitive authentication credentials (OAuth tokens, API keys). Ensure you understand the security implications before deploying.
- Never commit
.envfiles or real credentials to version control. Always use.env.exampleas a template. - The authors and contributors are not responsible for any data loss, security breaches, or damages arising from the use of this software.
- This is a demonstration/reference implementation. Additional security hardening (HTTPS, secret management, etc.) is required for production deployments.
Before deploying to production:
- Change all default secrets (
APP_SECRET_KEY,TOKEN_ENCRYPTION_KEY) - Use strong, unique passwords for database and services
- Enable HTTPS/TLS for all connections
- Review and restrict CORS origins
- Use proper secret management (AWS Secrets Manager, HashiCorp Vault, etc.)
- Enable firewall rules and network segmentation
- Set
DEBUG=falsein environment - Review OAuth redirect URIs and remove localhost
- Audit log retention and monitoring
- Regular security updates for dependencies
MIT