Tavily Load Balancer MCP server

Manages multiple Tavily API keys through intelligent load balancing and rotation to prevent rate limiting while providing reliable access to web search, content extraction, crawling, and mapping capabilities.
Back to servers
Setup instructions
Provider
yatotm
Release date
Aug 05, 2025
Language
Go
Stats
35 stars

The Tavily MCP Load Balancer is a multi-API key load balancing server that supports both SSE and streamableHTTP interfaces, enabling automatic rotation between multiple API keys to provide higher availability and increased request limits.

Getting Started

Docker Deployment (Recommended)

# Quickly start using Docker Hub image (automatically matches architecture, supports amd64/arm64)
docker run -d \
  --name tavily-mcp-lb \
  -p 60002:60002 \
  -e TAVILY_API_KEYS="your-key1,your-key2,your-key3" \
  yatotm1994/tavily-mcp-loadbalancer:latest

Local Setup

# 1. Clone and install
git clone https://github.com/yatotm/tavily-mcp-loadbalancer.git
cd tavily-mcp-loadbalancer
npm install

# 2. Configure environment variables
cp .env.example .env
# Edit .env file and add your API keys

# 3. Start the service
npm run build-and-start

After starting, access:

  • SSE endpoint: http://localhost:60002/sse
  • streamableHTTP endpoint: http://localhost:60002/mcp
  • Health check: http://localhost:60002/health

Available Tools

The server provides 5 Tavily tools supporting search, content extraction, website crawling, and more:

Tool Name Description Main Parameters
search / tavily-search Web search query, max_results, search_depth
tavily-extract Web page content extraction urls, extract_depth, format
tavily-crawl Website crawler url, max_depth, limit
tavily-map Site map generation url, max_depth, max_breadth

Using the streamableHTTP Interface

# Initialize connection
curl -X POST http://localhost:60002/mcp \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "initialize",
    "params": {
      "protocolVersion": "2024-11-05",
      "capabilities": {},
      "clientInfo": {"name": "test-client", "version": "1.0.0"}
    }
  }'

# Get tool list
curl -X POST http://localhost:60002/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "id": 2, "method": "tools/list"}'

# Call the search tool
curl -X POST http://localhost:60002/mcp \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 3,
    "method": "tools/call",
    "params": {
      "name": "search",
      "arguments": {
        "query": "OpenAI GPT-4",
        "max_results": 3
      }
    }
  }'

Tool Parameters

1. search / tavily-search - Web Search

{
  "name": "search",
  "arguments": {
    "query": "OpenAI GPT-4",
    "search_depth": "basic",
    "topic": "general",
    "max_results": 10,
    "start_date": "2024-01-01",
    "end_date": "2024-12-31",
    "country": "US",
    "include_favicon": false
  }
}

2. tavily-extract - Web Page Content Extraction

{
  "name": "tavily-extract",
  "arguments": {
    "urls": ["https://example.com/article"],
    "extract_depth": "basic",
    "format": "markdown",
    "include_favicon": false
  }
}

3. tavily-crawl - Website Crawler

{
  "name": "tavily-crawl",
  "arguments": {
    "url": "https://example.com",
    "max_depth": 2,
    "max_breadth": 20,
    "limit": 50,
    "instructions": "Focus on technical content",
    "select_paths": ["/docs", "/api"],
    "select_domains": ["example.com"],
    "allow_external": false,
    "categories": ["technology"],
    "extract_depth": "basic",
    "format": "markdown",
    "include_favicon": false
  }
}

4. tavily-map - Site Map Generation

{
  "name": "tavily-map",
  "arguments": {
    "url": "https://example.com",
    "max_depth": 1,
    "max_breadth": 20,
    "limit": 50,
    "instructions": "Map the main structure",
    "select_paths": ["/"],
    "select_domains": ["example.com"],
    "allow_external": false,
    "categories": ["general"]
  }
}

Monitoring and Testing

Quick Tests

# Test server status
./manage.sh stats

# Test all tools
./manage.sh test

# Batch test API keys
./manage.sh weather

Configuration

Environment Variables

Variable Name Description Default Value
TAVILY_API_KEYS API key list (comma-separated) Required
TAVILY_API_KEY Single API key Optional
SUPERGATEWAY_PORT Service port 60002

Configuration Example

# .env file
TAVILY_API_KEYS=tvly-dev-key1,tvly-dev-key2,tvly-dev-key3
SUPERGATEWAY_PORT=60002

Troubleshooting

Common Issues

Issue Solution
No available API keys Check the TAVILY_API_KEYS environment variable
Connection timeout Check network and firewall settings
Port in use Use lsof -i :60002 to check port
SSE connection failure Run node test_sse_validation.cjs

Quick Diagnostics

# Check service status
curl http://localhost:60002/health

# Test connection
node check_stats_direct.cjs

# View logs
docker logs tavily-mcp-lb

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "tavily-mcp-loadbalancer" '{"command":"docker","args":["run","--rm","-p","60002:60002","-e","TAVILY_API_KEYS=${TAVILY_API_KEYS}","yatotm1994/tavily-mcp-loadbalancer:latest"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "tavily-mcp-loadbalancer": {
            "command": "docker",
            "args": [
                "run",
                "--rm",
                "-p",
                "60002:60002",
                "-e",
                "TAVILY_API_KEYS=${TAVILY_API_KEYS}",
                "yatotm1994/tavily-mcp-loadbalancer:latest"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "tavily-mcp-loadbalancer": {
            "command": "docker",
            "args": [
                "run",
                "--rm",
                "-p",
                "60002:60002",
                "-e",
                "TAVILY_API_KEYS=${TAVILY_API_KEYS}",
                "yatotm1994/tavily-mcp-loadbalancer:latest"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later