tavily-proxy
A Cloudflare Worker that proxies requests to the Tavily API with automatic key rotation from a pool, providing search, extract, crawl, and map tools via MCP.
README
tavily-proxy
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 key with the highest remaining credit
- Key Management API — HTTP endpoints to add/delete keys and query their status
- Auth Protected — All endpoints (except health check) require an
x-api-keyheader
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 remaining credits |
GET |
/ |
Health check (no auth required) |
All endpoints except GET / require the x-api-key header matching your configured AUTH_KEY.
Setup
Prerequisites
- Node.js v18+
- Wrangler CLI (
npm install -g wrangler) - A Cloudflare account
Local Development
# Install dependencies
npm install
# Set your auth key for local dev (already in .dev.vars)
# AUTH_KEY=test-secret-key
# Start local server
npm run dev
Wrangler simulates KV locally — no Cloudflare account needed for development.
Deploy to Production
-
Create a KV namespace:
npx wrangler kv namespace create KV -
Update
wrangler.toml— replaceYOUR_KV_NAMESPACE_IDwith the real ID from step 1. -
Set the auth secret:
npx wrangler secret put AUTH_KEY -
Deploy:
npm run deploy -
Add Tavily API keys to the pool:
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"}'
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"
}
}
}
}
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"
# 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"}'
How the Key Pool Works
- When a tool is called,
KV.list()retrieves all stored API keys - The key with the largest remaining credit is selected
- The request is proxied to
api.tavily.comusing that key - After the call, the estimated credit cost is deducted locally in KV
- When a key is added via
/api/keys, its real remaining credit is fetched from Tavily's/usageendpoint
License
ISC
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.
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.
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.
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.