tavily-proxy
A Cloudflare Worker that proxies the Tavily API through MCP, offering search, extract, crawl, and map tools with automatic API key rotation and health-based routing.
README
Tavily-Proxy
<p align="center"> <img src="https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=white" alt="TypeScript" /> <img src="https://img.shields.io/badge/Cloudflare%20Workers-F38020?logo=cloudflare&logoColor=white" alt="Cloudflare Workers" /> <img src="https://img.shields.io/badge/Cloudflare%20KV-F38020?logo=cloudflare&logoColor=white" alt="Cloudflare KV" /> <img src="https://img.shields.io/badge/Hono-E36002?logo=hono&logoColor=white" alt="Hono" /> <img src="https://img.shields.io/badge/MCP%20SDK-000000" alt="MCP SDK" /> <img src="https://img.shields.io/badge/Zod-3E67B1?logo=zod&logoColor=white" alt="Zod" /> </p>
A Cloudflare Worker that acts as an MCP (Model Context Protocol) proxy for the Tavily API. It provides the same tools as the official Tavily MCP server, but with an API key pool — automatically rotating through multiple Tavily keys and selecting the one with the most remaining credit.
Features
- MCP Server — Streamable HTTP transport at
POST /mcp, compatible with any MCP client - 4 Tavily Tools —
tavily-search,tavily-extract,tavily-crawl,tavily-map - API Key Pool — Multiple Tavily API keys stored in Cloudflare KV; each request picks the least-recently-used healthy key
- Health-aware routing — Tavily 432 (quota exhausted) keys are skipped until the next UTC month; 429 rate limits apply a transient cooldown; 401/403 keys are invalidated
- Key Management API + Admin Panel — HTTP endpoints plus an embedded web panel (
GET /admin) to add/delete keys and monitor usage - Auth Protected — All endpoints except
GET /andGET /adminrequire anx-api-keyheader
Usage
Connect MCP Clients
With mcp-remote (for clients like Cursor, Claude Desktop, etc.):
{
"mcpServers": {
"tavily-proxy": {
"command": "npx",
"args": [
"-y", "mcp-remote",
"https://your-worker.workers.dev/mcp",
"--header", "x-api-key:${AUTH_KEY}"
],
"env": {
"AUTH_KEY": "your-auth-key"
}
}
}
}
Admin Panel
Open https://your-worker.workers.dev/admin in a browser. The panel asks for your AUTH_KEY (kept in the browser's sessionStorage), then lets you:
- List all keys — masked key, status (
active/exhausted/ cooling), credit availability, last-used and last-synced times - Add and delete keys
- Force a usage sync via the Sync usage now button
Key Management
# Add a key (auto-queries remaining credit from Tavily)
curl -X POST https://your-worker.workers.dev/api/keys \
-H "Content-Type: application/json" \
-H "x-api-key: your-auth-key" \
-d '{"apiKey": "tvly-xxx"}'
# List all keys and credits
curl https://your-worker.workers.dev/api/keys \
-H "x-api-key: your-auth-key"
# Force a usage sync for all keys
curl -X POST https://your-worker.workers.dev/api/keys/sync \
-H "x-api-key: your-auth-key"
# Delete a key
curl -X DELETE https://your-worker.workers.dev/api/keys \
-H "Content-Type: application/json" \
-H "x-api-key: your-auth-key" \
-d '{"apiKey": "tvly-xxx"}'
Setup
Web
Click the button below to deploy your own instance of tavily-proxy directly to Cloudflare Workers:
-
Configure KV Namespace: The API key pool is stored in Cloudflare KV. You need create a namespace (
Workers & Pages→KV→ Create a namespace(name don't important). -
Configure KV Binding: After creating the namespace, you need to bind it to your Worker. Go to your Cloudflare Worker dashboard → Settings → Bindings → Add binding and select the KV namespace you created.
-
Configure Secrets: Once deployed successfully, go to your Cloudflare Worker dashboard → Settings → Variables. Add
AUTH_KEYas an encrypted secret — it is thex-api-keyheader that protects the admin panel and management API. -
Redeploy: Trigger a redeploy for the secret to take effect.
-
Add Keys: Visit your Worker URL at
/admin, log in with yourAUTH_KEY, and add your Tavily API key(s). The pool is ready — requests are served throughPOST /mcp. -
(Optional) If you need custom domain, go to your Cloudflare Worker dashboard → Settings → Custom domains → Add a custom domain.
How the Key Pool Works
The design follows tavily-hikari: the request hot path does not estimate or deduct credits locally. Key health is driven by real upstream signals:
- Each request picks the least-recently-used healthy key (LRU).
- HTTP 432 (Tavily quota exhausted) → the key is marked
exhaustedand skipped for the rest of the current UTC month; it is restored automatically at the next monthly reset. - HTTP 429 (rate limited) → the key is cooled down for the
Retry-Afterwindow (fallback 60s) and the next key is tried. - HTTP 401/403 → the key is marked
exhaustedand retried against the next key. - Remaining credit is only a display field, synced from Tavily's
/usageendpoint in the background:POST /api/keysqueries usage when adding a key.GET /api/keysreturns cached values and kicks off a background sync when they are stale (>30 min).POST /api/keys/syncforces a full sync.
Workers Free Plan Note
Cron triggers do not fire on the Workers Free plan. The scheduled handler is still included, but on Free you should rely on the lazy sync built into GET /api/keys and the admin panel's Sync usage now button. Uncomment the [triggers] block in wrangler.toml to enable hourly cron syncs after upgrading to a paid plan.
Endpoints
| Method | Path | Description |
|---|---|---|
POST |
/mcp |
MCP Streamable HTTP endpoint (tool calls) |
POST |
/api/keys |
Add a Tavily API key to the pool |
DELETE |
/api/keys |
Remove a Tavily API key from the pool |
GET |
/api/keys |
List all keys and their status (auto-triggers lazy sync) |
POST |
/api/keys/sync |
Force a /usage sync for all keys |
GET |
/admin |
Admin panel (opens without auth; prompts for AUTH_KEY) |
GET |
/ |
Health check (no auth required) |
All endpoints except GET / and GET /admin require the x-api-key header matching your configured AUTH_KEY.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。