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.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.