tavily-mcp-proxy
Reverse proxy for the Tavily MCP endpoint that bypasses geo-blocking, rotates API keys based on quota, and authenticates clients via access keys.
README
tavily-mcp-proxy
Reverse-proxy for the Tavily MCP endpoint, designed to:
- Bypass geo-blocking for clients on sanctioned-country IPs (RU, etc.) — the proxy lives on a VPS in a country where Tavily is reachable and forwards requests.
- Rotate across multiple Tavily API keys by picking the one with the largest remaining quota, automatically once per day. When all quota checks fail, the proxy returns HTTP 503 to every client (fail-loud) until the situation recovers.
- Authenticate clients by an
accessKeyquery parameter so that the real Tavily API keys never reach client machines and aren't exposed in client config files.
┌──────────┐ ?accessKey=tvmcp_… ┌─────────┐ ?tavilyApiKey=<active> ┌────────┐
│ Client │ ───────────────────────► │ nginx │ ───────────────────────────► │ Tavily │
└──────────┘ TLS + fail2ban │ (TLS) │ └────────┘
└────┬────┘
│ http://127.0.0.1:8741
▼
┌──────────────────────────────┐
│ tavily-mcp-backend (aiohttp) │
│ • checks accessKey │
│ • picks active Tavily key │
│ • streams SSE upstream │
└──────────────────────────────┘
▲
│ daily 05:00 Europe/Moscow
│
┌──────────────────────────────┐
│ quota_checker.py │
│ • GET /usage per key │
│ • writes active-key atomically │
└──────────────────────────────┘
What's in this repository
| Path | Purpose |
|---|---|
backend.py |
aiohttp service that authenticates clients and proxies /mcp/* to Tavily with the active key |
quota_checker.py |
Daily selector: picks the Tavily key with the most remaining quota, ties broken lexicographically |
requirements.txt |
aiohttp>=3.9 |
deploy/tavily-mcp-backend.service |
systemd unit for the backend |
deploy/tavily-mcp-quota.{service,timer} |
systemd oneshot + 05:00 Europe/Moscow timer |
deploy/tavily-mcp.nginx.conf |
nginx TLS + ACME + reverse proxy template (YOUR-HOST.sslip.io placeholder) |
deploy/tavily-keys.list.example |
Format example for /etc/tavily-mcp/tavily-keys.list (no real keys) |
deploy/access-keys.list.example |
Format example for /etc/tavily-mcp/access-keys.list (no real keys) |
AGENTS.md |
Full deployment guide, troubleshooting, security notes, and runbook |
fail2ban-vps.md |
Companion doc: fail2ban setup on VPSNL1 + GPBAGENT (SSH brute-force, HTTP scanners, tavily-mcp jail, self-ban recovery) |
Quick start (TL;DR)
See AGENTS.md for the full runbook. The shortest path is:
# On the VPS (Ubuntu 24.04) — see AGENTS.md for details
apt-get install -y nginx certbot python3-certbot-nginx fail2ban python3-venv python3-pip
mkdir -p /etc/tavily-mcp /opt/tavily-mcp
# populate /etc/tavily-mcp/tavily-keys.list and access-keys.list (see deploy/*.example)
cd /opt/tavily-mcp
python3 -m venv venv
venv/bin/pip install -r requirements.txt
cp deploy/tavily-mcp-backend.service deploy/tavily-mcp-quota.service \
deploy/tavily-mcp-quota.timer /etc/systemd/system/
cp deploy/tavily-mcp.nginx.conf /etc/nginx/sites-available/tavily-mcp
# edit YOUR-HOST.sslip.io in the nginx config, then:
ln -sf /etc/nginx/sites-available/tavily-mcp /etc/nginx/sites-enabled/tavily-mcp
nginx -t && systemctl reload nginx
systemctl daemon-reload
systemctl enable --now tavily-mcp-backend tavily-mcp-quota.timer
Configure your MCP client (e.g. OpenCode, Claude Desktop, MCP CLI) with:
https://YOUR-HOST.sslip.io/mcp/?accessKey=tvmcp_<your-generated-key>
Configuration files on the server
| Path | Mode | Format | Purpose |
|---|---|---|---|
/etc/tavily-mcp/tavily-keys.list |
0600 | one Tavily key per line | All keys the quota-checker rotates across |
/etc/tavily-mcp/access-keys.list |
0600 | <name><whitespace><key> per line |
Access keys clients must present |
/etc/tavily-mcp/active-key |
0644 | one line — the currently active Tavily key | Read fresh on every backend request |
/etc/tavily-mcp/active-key.status |
0644 | ok or unknown |
Tells the backend whether to serve or 503 |
active-key is rewritten atomically (tempfile → fsync → os.replace) by quota_checker.py. The backend reads it on every request, so rotation takes effect without restarting anything.
Generate an access key
python3 -c 'import secrets, base64; print("tvmcp_" + base64.urlsafe_b64encode(secrets.token_bytes(36)).decode().rstrip("="))'
After changing /etc/tavily-mcp/access-keys.list:
kill -HUP $(pgrep -f backend.py)
…or restart the systemd service.
Security highlights
- Real Tavily keys live only on the VPS (0600, root). They are never sent to clients.
- Real access keys (
tvmcp_…) live only on the VPS and in client config files you control — never commit them to a public repo. - nginx
mcp_nosecretlog format omits the query string, so neither Tavily keys nor access keys are written to access logs. - fail2ban: 5 × HTTP 401 from one IP within 24 h → permanent ban via nftables (ports 80/443). SSH (port 22) is never banned. Unban manually:
ssh vps 'fail2ban-client unban <IP>'.
License
MIT (placeholder — adjust to your preference).
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。