tavily-proxy

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.

Category
Visit Server

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 Toolstavily-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-key header

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

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

  1. Create a KV namespace:

    npx wrangler kv namespace create KV
    
  2. Update wrangler.toml — replace YOUR_KV_NAMESPACE_ID with the real ID from step 1.

  3. Set the auth secret:

    npx wrangler secret put AUTH_KEY
    
  4. Deploy:

    npm run deploy
    
  5. 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

  1. When a tool is called, KV.list() retrieves all stored API keys
  2. The key with the largest remaining credit is selected
  3. The request is proxied to api.tavily.com using that key
  4. After the call, the estimated credit cost is deducted locally in KV
  5. When a key is added via /api/keys, its real remaining credit is fetched from Tavily's /usage endpoint

License

ISC

Recommended Servers

playwright-mcp

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.

Official
Featured
TypeScript
Magic Component Platform (MCP)

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.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

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.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

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.

Official
Featured
TypeScript
Kagi MCP Server

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.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

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.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured