Skip to main content
Glama
yatotm

Tavily MCP Load Balancer

by yatotm

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 加密存储 + 脱敏展示


Related MCP server: tavily-mcp-proxy

快速开始

Docker 部署(推荐)

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 会自动匹配本机架构。

本地开发

# 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

streamableHTTP

http://localhost:60002/mcp

API

http://localhost:60002/api

WebSocket

ws://localhost:60002/ws

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

Docker Compose

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

自定义构建

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

开发模式

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

接口说明

接口

地址

SSE

http://localhost:60002/sse

消息

http://localhost:60002/message

streamableHTTP

http://localhost:60002/mcp

健康检查

http://localhost:60002/health

streamableHTTP 示例

# 初始化
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

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

tavily-extract

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

tavily-crawl

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

tavily-map

{
  "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 UI

true

MAX_CONCURRENT_REQUESTS

最大并发

4

REQUEST_TIMEOUT

请求超时(ms)

30000

MAX_KEY_ERRORS

Key 最大错误次数

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(逗号分隔)

-

配置示例

# .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 检查端口占用

# 健康检查
curl http://localhost:60002/health

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

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


许可证

MIT License


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

Available Tools

5 tools
tavily-crawlA

A powerful web crawler that initiates a structured web crawl starting from a specified base URL. The crawler expands from that point like a tree, following internal links across pages. You can control how deep and wide it goes, and guide it to focus on specific sections of the site.

ParametersJSON Schema
NameRequiredDescriptionDefault
allow_externalNoWhether to allow following links that go to external domains
categoriesNoFilter URLs using predefined categories like documentation, blog, api, etc
extract_depthNoAdvanced extraction retrieves more data, including tables and embedded content, with higher success but may increase latencybasic
instructionsNoNatural language instructions for the crawler
limitNoTotal number of links the crawler will process before stopping
max_breadthNoMax number of links to follow per level of the tree (i.e., per page)
max_depthNoMax depth of the crawl. Defines how far from the base URL the crawler can explore.
select_domainsNoRegex patterns to select crawling to specific domains or subdomains (e.g., ^docs\.example\.com$)
select_pathsNoRegex patterns to select only URLs with specific path patterns (e.g., /docs/.*, /api/v1.*)
urlYesThe root URL to begin the crawl

TDQS

A3.9/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes the crawling behavior ('expands like a tree', 'following internal links'), scope control ('how deep and wide it goes'), and focus guidance. However, it doesn't mention important behavioral aspects like rate limits, authentication requirements, error handling, or what the output format looks like.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is perfectly sized at three sentences, each earning its place. It's front-loaded with the core purpose, followed by expansion behavior, and ending with control capabilities. Zero wasted words or redundant information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a 10-parameter web crawling tool with no annotations and no output schema, the description provides adequate high-level context but lacks details about output format, error conditions, performance characteristics, or specific use cases. For a tool this complex, more behavioral and output information would be helpful despite the excellent schema coverage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all 10 parameters thoroughly. The description adds some high-level context about controlling depth, breadth, and focusing on specific sections, which aligns with parameters like max_depth, max_breadth, and categories/select_paths. However, it doesn't provide additional semantic meaning beyond what's already in the comprehensive schema descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('initiates a structured web crawl', 'expands like a tree', 'following internal links') and identifies the resource ('starting from a specified base URL'). It distinguishes this crawl tool from sibling tools like 'search' or 'extract' by emphasizing its tree-based expansion approach.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context about when to use this tool: for structured crawling starting from a base URL with tree-like expansion. It mentions controlling depth, breadth, and focusing on specific site sections. However, it doesn't explicitly state when NOT to use it or name specific alternatives among the sibling tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

tavily-extractC

A powerful web content extraction tool that retrieves and processes raw content from specified URLs, ideal for data collection, content analysis, and research tasks.

ParametersJSON Schema
NameRequiredDescriptionDefault
extract_depthNoDepth of extraction - 'basic' or 'advanced', if urls are linkedin use 'advanced' or if explicitly told to use advancedbasic
formatNoThe format of the extracted web page content. markdown returns content in markdown format. text returns plain text and may increase latency.markdown
include_faviconNoWhether to include the favicon URL for each result
include_imagesNoInclude a list of images extracted from the urls in the response
urlsYesList of URLs to extract content from

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool 'retrieves and processes raw content' but doesn't mention critical behavioral traits like rate limits, authentication needs, error handling, or what 'processes' entails (e.g., cleaning, structuring). For a web extraction tool with potential complexity, this leaves significant gaps in understanding how it behaves beyond basic functionality.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately concise with two sentences that efficiently state the tool's purpose and ideal use cases. It's front-loaded with the core functionality. While it could be slightly more structured (e.g., separating purpose from guidelines), there's minimal waste, and every sentence adds value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of web content extraction (5 parameters, no output schema, no annotations), the description is incomplete. It lacks details on output format, error cases, performance characteristics, and how it differs from sibling tools. Without annotations or output schema, the description should compensate more to help an agent use it effectively, but it provides only basic functional overview.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already fully documents all 5 parameters. The description doesn't add any parameter-specific information beyond what's in the schema (e.g., it doesn't explain 'extract_depth' or 'format' further). Baseline 3 is appropriate when the schema does the heavy lifting, though the description could have provided higher-level context about parameter interactions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'retrieves and processes raw content from specified URLs' with specific verbs and resource. It mentions use cases like 'data collection, content analysis, and research tasks' which helps clarify intent. However, it doesn't explicitly differentiate from sibling tools like 'tavily-crawl' or 'tavily-search', which likely have overlapping web content functionality.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'tavily-crawl' or 'tavily-search'. It mentions it's 'ideal for data collection, content analysis, and research tasks', but this is generic and doesn't help an agent choose between sibling tools. There are no explicit when/when-not statements or named alternatives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

tavily-mapA

A powerful web mapping tool that creates a structured map of website URLs, allowing you to discover and analyze site structure, content organization, and navigation paths. Perfect for site audits, content discovery, and understanding website architecture.

ParametersJSON Schema
NameRequiredDescriptionDefault
allow_externalNoWhether to allow following links that go to external domains
categoriesNoFilter URLs using predefined categories like documentation, blog, api, etc
instructionsNoNatural language instructions for the crawler
limitNoTotal number of links the crawler will process before stopping
max_breadthNoMax number of links to follow per level of the tree (i.e., per page)
max_depthNoMax depth of the mapping. Defines how far from the base URL the crawler can explore
select_domainsNoRegex patterns to select crawling to specific domains or subdomains (e.g., ^docs\.example\.com$)
select_pathsNoRegex patterns to select only URLs with specific path patterns (e.g., /docs/.*, /api/v1.*)
urlYesThe root URL to begin the mapping

TDQS

A3.9/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It describes the tool as 'powerful' and for 'discovering and analyzing,' which implies it performs read-only operations, but doesn't specify behavioral traits like rate limits, authentication needs, or potential impacts on target websites. The description adds value by explaining the mapping purpose but lacks detailed behavioral disclosure.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded: it starts with the core purpose, then elaborates on use cases. Every sentence earns its place by adding value without redundancy, making it efficient and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (9 parameters, no annotations, no output schema), the description is somewhat complete but has gaps. It explains the tool's purpose and use cases well, but without annotations or output schema, it doesn't cover behavioral aspects or return values, leaving the agent to infer details from the schema alone.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, so the schema already documents all 9 parameters thoroughly. The description doesn't add specific parameter semantics beyond what the schema provides, such as explaining how 'categories' interact with mapping or the implications of 'max_depth.' Baseline 3 is appropriate since the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'creates a structured map of website URLs' with specific verbs like 'discover and analyze site structure, content organization, and navigation paths.' It distinguishes from siblings like 'search' or 'extract' by focusing on mapping and structural analysis rather than general search or content extraction.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool: 'Perfect for site audits, content discovery, and understanding website architecture.' It doesn't explicitly mention when not to use it or name alternatives among siblings, but the context strongly implies it's for structural mapping rather than other tasks like searching or crawling without mapping.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

TDQS

B3.1/5.0
Disambiguation2/5

The tool set has significant overlap and ambiguity, particularly between 'search' and 'tavily-search', which appear to be identical based on their descriptions. Additionally, 'tavily-crawl', 'tavily-extract', and 'tavily-map' all involve web content processing, making it unclear when to use one over the others without more specific distinctions in their purposes.

Naming Consistency3/5

The naming is mixed: four tools use a consistent 'tavily-' prefix with descriptive suffixes (crawl, extract, map, search), but one tool is named simply 'search' without the prefix. This deviation breaks full consistency, though the overall pattern is still readable and not chaotic.

Tool Count4/5

With 5 tools, the count is reasonable for a web search and content analysis server, aligning well with typical scopes. It's slightly under the ideal range but not overly thin, as each tool (despite overlaps) covers different aspects of web interaction.

Completeness3/5

The server covers core web operations like search, crawling, extraction, and mapping, but there are notable gaps. For example, there's no tool for updating or managing saved searches, filtering results beyond basic parameters, or handling authentication for restricted content, which could limit agent workflows in more advanced scenarios.

Maintenance

ActivitySlowing
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    B
    quality
    D
    maintenance
    A local MCP server that exposes Tavily search as a tool and rotates across multiple API keys for reliability.
    1
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    A proxy MCP server for Tavily search and extract APIs with support for multiple API keys, random rotation, and bearer token authentication.
    MIT
  • A
    license
    A
    quality
    A
    maintenance
    A proxy MCP server that connects to Tavily's official Streamable HTTP MCP, managing multiple API keys and automatically switching to the next one when the current key's quota is exhausted.
    5
    12
    1
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    A multi-provider MCP server that unifies Tavily and Brave Search APIs, with key management, admin UI, and flexible search strategies.
    15
    22
    MIT

Appeared in Searches

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/yatotm/tavily-mcp-loadbalancer'

If you have feedback or need assistance with the MCP directory API, please join our Discord server