Tavily MCP Load Balancer logo

Tavily MCP Load Balancer

Community
yatotm

Load-balanced Tavily MCP server with API key pool management

Publisheryatotm
Repositorytavily-mcp-loadbalancer
LanguageTypeScript
Forks
13
Stars
72
Available tools
0
Transport typestdio, streamable-http
Categories
LicenseMIT
Links
  • Connect tools to AI workflows

    Tavily MCP Load Balancer exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    72 stars and 13 forks from the linked repository.

Tavily MCP Load Balancer

Docker Hub Docker Image Size License: MIT

Language / 语言: English | 中文

一个支持多 API 密钥负载均衡的 Tavily MCP 服务器,提供 SSE 和 streamableHTTP 接口,自动轮询多个 API 密钥以实现高可用性。

v3.1.0 (2026-07-24)

  • 低频配额队列:所有 /usage 请求统一排队、去重并遵守 Tavily 独立限流
  • 双同步入口:支持同步过期 Key 和后台同步全部 Key
  • 异步 Key 测试:勾选测试进入高优先级队列,成功后同时更新额度
  • 额度显示修复:免费账户正确同步 1000 上限,未知额度不再显示为无限

v3.0.0 (2025-01-06)

  • 官方 MCP 对齐:完整适配 tavily-mcp v0.2.12 工具参数与行为
  • 智能错误处理:精细区分配额耗尽、速率限制与网络问题
  • 持久化存储:SQLite 存储 API Key、配额与请求日志
  • Web 管理后台:可视化管理 Key、统计、日志与设置
  • 自动配额刷新:UTC 自然月自动更新配额状态

v2.2.0 (2025-08-15)

  • 多架构镜像:linux/amd64 与 linux/arm64

v2.1.0 (2025-08-14)

  • streamableHTTP 支持:HTTP POST /mcp 端点
  • 多协议兼容:SSE + streamableHTTP

v2.0.0 (2025-08-12)

  • 架构重构:原生 SSE 实现
  • 工具更新:新增 tavily-crawl 和 tavily-map
  • 安全改进:响应数据清理和字符编码处理

v1.0.0 (2025-08-05)

  • 初始版本:多 API 密钥负载均衡

功能特性

  • 智能负载均衡 — 轮询 + 权重调度,多 Key 高可用
  • 错误分级处理 — 速率限制 / 配额耗尽 / 鉴权错误精确识别
  • 多协议支持 — MCP stdio / SSE / streamableHTTP 全覆盖
  • 数据持久化 — SQLite 存储 Key、配额与日志
  • Web 管理后台 — Dashboard、Key 管理、统计、日志、设置
  • 实时更新 — WebSocket 推送统计刷新
  • 数据安全 — Key 加密存储 + 脱敏展示

快速开始

Docker 部署(推荐)

bash
docker run -d \
  --name tavily-mcp-lb \
  -p 60002:60002 \
  -e DATABASE_ENCRYPTION_KEY="your-32-byte-random-key" \
  -e ADMIN_PASSWORD="optional-admin-password" \
  -e TAVILY_API_KEYS="your-key1,your-key2,your-key3" \
  yatotm1994/tavily-mcp-loadbalancer:latest

镜像支持 amd64 / arm64,Docker 会自动匹配本机架构。

本地开发

bash
# 1. 克隆并安装
git clone https://github.com/yatotm/tavily-mcp-loadbalancer.git
cd tavily-mcp-loadbalancer
npm install

# 2. 配置环境变量
cp .env.example .env
# 编辑 .env,设置 DATABASE_ENCRYPTION_KEY(必填)与 ADMIN_PASSWORD(可选)

# 3. 启动服务
npm run build-and-start

服务启动后访问:

端点地址
管理后台http://localhost:60002
SSE 接口http://localhost:60002/sse
streamableHTTPhttp://localhost:60002/mcp
APIhttp://localhost:60002/api
WebSocketws://localhost:60002/ws

首次启动后在管理后台添加 API Key。环境变量 TAVILY_API_KEYS 仅用于初始导入。

Docker Compose

bash
git clone https://github.com/yatotm/tavily-mcp-loadbalancer.git
cd tavily-mcp-loadbalancer
cp .env.example .env
docker-compose up -d
docker-compose logs -f

自定义构建

bash
docker build -t tavily-mcp-loadbalancer .
docker run -d --name tavily-mcp-lb -p 60002:60002 \
  -e TAVILY_API_KEYS="key1,key2" tavily-mcp-loadbalancer

开发模式

bash
npm run start-gateway   # HTTP + UI
npm run dev             # MCP stdio
./start.sh              # 脚本启动

可用工具

工具名称功能描述主要参数
search / tavily-search网络搜索query, max_results, search_depth
tavily-extract网页内容提取urls, extract_depth, format
tavily-crawl网站爬虫url, max_depth, limit
tavily-map网站地图生成url, max_depth, max_breadth

接口说明

接口地址
SSEhttp://localhost:60002/sse
消息http://localhost:60002/message
streamableHTTPhttp://localhost:60002/mcp
健康检查http://localhost:60002/health

streamableHTTP 示例

bash
# 初始化
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"}
    }
  }'

# 获取工具列表
curl -X POST http://localhost:60002/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "id": 2, "method": "tools/list"}'

# 调用搜索
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}
    }
  }'

工具参数

search / tavily-search

json
{
  "query": "OpenAI GPT-4",
  "search_depth": "basic",
  "topic": "general",
  "max_results": 10,
  "country": "united states"
}

tavily-extract

json
{
  "urls": ["https://example.com/article"],
  "extract_depth": "basic",
  "format": "markdown"
}

tavily-crawl

json
{
  "url": "https://example.com",
  "max_depth": 2,
  "limit": 50,
  "extract_depth": "basic"
}

tavily-map

json
{
  "url": "https://example.com",
  "max_depth": 1,
  "limit": 50
}

配置

环境变量

变量名描述默认值
PORT服务端口60002
HOST绑定地址0.0.0.0
DATABASE_PATH数据库路径./data/tavily.db
DATABASE_ENCRYPTION_KEY加密密钥(必填)-
ADMIN_PASSWORD管理后台密码-
ENABLE_WEB_UI启用 Web UItrue
MAX_CONCURRENT_REQUESTS最大并发4
REQUEST_TIMEOUT请求超时(ms)30000
MAX_KEY_ERRORSKey 最大错误次数5
USAGE_SYNC_MIN_INTERVAL_MS/usage 队列请求最小间隔(ms)75000
USAGE_SYNC_RETRY_DELAY_MS上游未返回 retry-after 时的全局冷却(ms)600000
USAGE_SYNC_STALE_AFTER_MS配额数据过期时间(ms)21600000
USAGE_SYNC_SCHEDULE_INTERVAL_MS自动扫描过期 Key 的间隔(ms)21600000
LOG_RETENTION_DAYS日志保留天数30
LOG_LEVEL日志级别info
TAVILY_API_KEYS初始 Key(逗号分隔)-

配置示例

bash
# .env
PORT=60002
DATABASE_ENCRYPTION_KEY=your-32-byte-random-key
ADMIN_PASSWORD=optional-password
TAVILY_API_KEYS=tvly-key1,tvly-key2

故障排除

问题解决方案
无可用 API 密钥在管理后台检查 Key 状态和配额
连接超时检查网络和防火墙设置
端口被占用lsof -i :60002 检查端口占用
bash
# 健康检查
curl http://localhost:60002/health

# 查看日志
docker logs tavily-mcp-lb

建议在 Web 管理后台查看请求统计、错误日志与 Key 状态。


许可证

MIT License


如果这个项目对你有帮助,欢迎 Star ⭐

Installation

TypingMind
{
  "mcpServers": {
    "tavily-mcp-loadbalancer": {
      "command": "npm",
      "args": [
        "run",
        "build-and-start"
      ]
    }
  }
}

Use Tavily MCP Load Balancer MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once Tavily MCP Load Balancer is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. You can run MCP locally on your device or connect to a remote MCP server URL.

Option 1: Use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add Tavily MCP Load Balancer as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the Tavily MCP Load Balancer MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "tavily-mcp-loadbalancer": {
      "command": "npx",
      "args": [
        "-y",
        "tavily-mcp-loadbalancer"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the Tavily MCP Load Balancer MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the Tavily MCP Load Balancer MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use Tavily MCP Load Balancer to help me with this task?
Tavily MCP Load Balancer
Sure. I read it.
Here is what I found using Tavily MCP Load Balancer.

Option 2: Add an MCP server URL

Use this when Tavily MCP Load Balancer is already hosted remotely or your team wants one shared connector that multiple users can access.

1

Open MCP connectors

In TypingMind, go to Plugins, open MCP connectors, then choose Add URL.

  1. Open TypingMind in your browser.
  2. Go to Plugins.
  3. Open MCP connectors.
  4. Click Add URL.
TypingMind Add Custom MCP Server URL form
2

Paste the server URL

Enter the MCP server URL from the provider in the Server URL field. Add a connection name, description, icon, custom HTTP headers, or OAuth client settings if the server requires them.

  1. Paste the MCP server URL from the provider into the Server URL field.
  2. Enter a connection name for Tavily MCP Load Balancer.
  3. Add a description and icon if you want it to be easier to identify.
  4. Add custom HTTP headers or OAuth client details if the server requires authentication.
3

Create the connection

Click Create connection, then return to the Plugins list and confirm the new MCP connection is active.

  1. Click Create connection.
  2. Return to the MCP connectors list.
  3. Confirm the Tavily MCP Load Balancer connection appears as active.
  4. Refresh the plugin list if the connection does not appear immediately.
4

Switch models without reconnecting

Start a chat with your preferred model, enable the Tavily MCP Load Balancer tools from Plugins, and switch to another model whenever needed. The MCP connection stays available to the TypingMind workspace.

  1. Start a new chat in TypingMind.
  2. Select the AI model you want to use.
  3. Enable the Tavily MCP Load Balancer tools from Plugins.
  4. Ask the model to use the tool when needed.
  5. Switch to another AI model and reuse the same MCP connection.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use Tavily MCP Load Balancer to help me with this task?
Tavily MCP Load Balancer
Sure. I read it.
Here is what I found using Tavily MCP Load Balancer.

Frequently asked questions

What is the Tavily MCP Load Balancer MCP server used for?

Tavily MCP Load Balancer is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use Tavily MCP Load Balancer MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use Tavily MCP Load Balancer with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use Tavily MCP Load Balancer MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With Tavily MCP Load Balancer connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect Tavily MCP Load Balancer MCP to TypingMind?

Tavily MCP Load Balancer can be connected in TypingMind with the local MCP connector or by adding a remote MCP server URL. Use the local connector when the server needs access to files, apps, or private resources on your device, and use a server URL when the MCP server is hosted remotely.

What tools does Tavily MCP Load Balancer MCP provide in TypingMind?

Tavily MCP Load Balancer exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use Tavily MCP Load Balancer MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If Tavily MCP Load Balancer requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇