MCP Router
Extensible MCP server that aggregates multiple backends (email, browser, todoist, etc.) behind a single endpoint, with secure deployment via Cloudflare Tunnel and Workers.
README
MCP Router
Extensible MCP server that aggregates multiple backends behind a single endpoint.
Architecture
Claude → CF Worker (OAuth) → Workers VPC → CF Tunnel → MCP Router → [Backends]
│ ↓
(private backbone) email backend → ProtonMail Bridge
(add more backends here)
Security: No public DNS exposure. Traffic flows through Cloudflare's private network via Workers VPC binding to a Cloudflare Tunnel with no public hostname.
Quick Start
1. Clone and install
curl -LsSf https://astral.sh/uv/install.sh | sh
git clone https://github.com/marklubin/mcp-email-server.git mcp-infrastructure
cd mcp-infrastructure
2. Configure
cp .env.example .env
# Edit .env with your credentials
3. ProtonMail Bridge (one-time)
protonmail-bridge --cli
# > login
# > info (note the bridge password)
4. Run
uv run python router/server.py
Or with systemd:
./setup.sh
sudo systemctl enable --now mcp-router@$USER
5. Set up Cloudflare Tunnel (for private backend)
cloudflared tunnel login
cloudflared tunnel create mcp-router
# Configure ~/.cloudflared/config.yml (see cloudflare/tunnel-config.yml.example)
sudo systemctl enable --now cloudflared
6. Create Workers VPC Service
In Cloudflare Dashboard → Workers & Pages → Workers VPC:
- Create service:
mcp-router-vpc - Select tunnel:
mcp-router - Target:
http://127.0.0.1:8080
7. Deploy Worker
cd cloudflare/worker && npx wrangler deploy
Deployment
The canonical deployed instance runs on oxnard as the systemd unit mcp-router@mark.service.
Steady-state flow:
- Edit code locally on a dev machine (clone of this repo).
- Commit and push to
origin/master. - From the local clone, run
./scripts/deploy.sh— pushes (if needed), SSHes to the remote, runsgit pull, and restarts the service. - If dependencies changed (
pyproject.toml/uv.lock), deploy.sh'suv synckeeps the venv in sync. If it doesn't, restart will still pick up the new deps on nextuv run.
Do not edit code directly on oxnard. The repo is the source of truth — changes made only on the box will drift and get lost. If you must hotpatch in an emergency, copy the fix back into the repo and commit it before doing anything else.
Override the deploy target with MCP_REMOTE=hostname ./scripts/deploy.sh.
Backends
Each backend lives in router/backends/ and exposes tools under its mount prefix.
| Backend | Prefix | Purpose |
|---|---|---|
email |
email_ |
ProtonMail Bridge — list/search/get/send |
browser |
browser_ |
Playwright-over-CDP browser automation |
todoist |
todoist_ |
Todoist tasks/projects |
notifications |
notify_ |
Push notifications + inbox |
discord |
discord_ |
Discord (via user token) |
memory |
memory_ |
Agent memory store |
twitter |
twitter_ |
Twitter read via twitterapi.io |
web |
web_ |
Web search + contents via Exa |
Also available but not currently mounted in server.py:
unified_memory.py— proxies all synix MCP tools from the agent-mesh server on salinas. Wire it up by importing + mounting if you want to replace or augmentmemory.
Email Backend (prefix: email_)
| Tool | Description |
|---|---|
email_list_emails(mailbox, limit) |
List recent emails |
email_search_emails(query, mailbox, limit, search_body) |
Search by subject, sender, or body |
email_get_email(message_id, mailbox) |
Get full email content |
email_send_email(to, subject, body) |
Send email |
Web Backend (prefix: web_)
Uses Exa under the hood. Free tier: 1,000 searches/month.
| Tool | Description |
|---|---|
web_search(query, num_results, search_type, include_text, include_domains, exclude_domains) |
Web search; optional inline text excerpts |
web_get_contents(urls, max_chars) |
Fetch clean text for one or more URLs |
For detailed signatures of other backends, read the source — each tool's docstring is its contract.
Router
| Tool | Description |
|---|---|
health() |
Health check with backend status |
logs(lines, service) |
Tail service logs (mcp-router or cloudflared) |
Adding New Backends
- Create
router/backends/yourbackend.py:
from fastmcp import FastMCP
mcp = FastMCP('yourbackend')
@mcp.tool()
async def your_tool(arg: str) -> dict:
"""Your tool description."""
return {'result': 'value'}
- Mount in
router/server.py:
from backends import yourbackend
router.mount(yourbackend.mcp, prefix='yourbackend')
Also append the prefix to the health() backend list.
-
If the backend needs secrets, add them to
.env.exampleand.env. -
Commit and run
./scripts/deploy.sh. Tools appear asyourbackend_your_tool.
Claude Config
{
"mcpServers": {
"router": {
"url": "https://mcp-router-proxy.melubin.workers.dev/mcp",
"transport": "sse"
}
}
}
Environment Variables
See .env.example for the full list. Required for core operation:
MCP_SECRET= # API key for auth from CF Worker
ROUTER_HOST=127.0.0.1
ROUTER_PORT=8080
PROTON_BRIDGE_HOST=127.0.0.1
PROTON_BRIDGE_IMAP_PORT=1143
PROTON_BRIDGE_SMTP_PORT=1025
PROTON_BRIDGE_USER=you@proton.me
PROTON_BRIDGE_PASSWORD=bridge-password
Backend-specific keys (only required if the backend is mounted):
EXA_API_KEY= # web search
TODOIST_API_TOKEN= # todoist
TWITTERAPI_IO_KEY= # twitter
DISCORD_TOKEN= # discord
MESH_SERVER_URL= # memory
MESH_TOKEN= # memory
AGENT_MESH_MCP_URL= # unified_memory (if mounted)
Project Structure
mcp-infrastructure/
├── router/
│ ├── server.py # Main router, mounts backends
│ └── backends/
│ ├── __init__.py
│ ├── email.py # ProtonMail
│ ├── browser.py # Playwright over CDP
│ ├── todoist.py # Todoist
│ ├── notifications.py # Push/inbox
│ ├── discord.py # Discord user-token
│ ├── memory.py # Agent memory
│ ├── twitter.py # Twitter (twitterapi.io)
│ ├── web.py # Web search (Exa)
│ └── unified_memory.py # Synix proxy (not mounted by default)
├── services/
│ ├── mcp-router.service # systemd template for router
│ ├── cloudflared.service # systemd service for tunnel
│ ├── headless-brave.service # headless browser
│ └── protonmail-bridge.service # ProtonMail Bridge
├── cloudflare/
│ ├── tunnel-config.yml.example # Tunnel config template
│ └── worker/ # CF Worker for OAuth + VPC proxy
├── scripts/
│ ├── deploy.sh # Push and deploy to remote
│ ├── logs.sh # View service logs
│ ├── status.sh # Check service status
│ ├── tunnel.sh # Manage Cloudflare Tunnel
│ ├── test-email.sh # Test email tools
│ ├── test.sh # Run tests
│ ├── browser-connect.sh # Connect to CDP browser
│ ├── run-headless-brave.sh # Launch headless Brave
│ ├── run-headless-firefox.sh # Launch headless Firefox + VNC
│ └── notify-check.sh # Notification health check
├── setup.sh # One-shot setup script
├── pyproject.toml # Python dependencies
└── .env.example # Config template
Management Scripts
| Script | Purpose |
|---|---|
scripts/deploy.sh |
Push and deploy to remote (respects MCP_REMOTE env var) |
scripts/logs.sh [n] |
View last n log lines |
scripts/status.sh |
Check service status |
scripts/tunnel.sh [status|logs|restart] |
Manage tunnel |
scripts/test-email.sh |
Test email tools |
scripts/test.sh |
Run tests |
scripts/browser-connect.sh |
Connect to the CDP-exposed browser |
scripts/run-headless-brave.sh |
Launch headless Brave with CDP |
scripts/run-headless-firefox.sh |
Launch headless Firefox + VNC on :99 |
scripts/notify-check.sh |
Notification backend health check |
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。