Skip to main content
Glama
tavily-web-search

tavily-web-search

by LS-King

Tavily Web Search MCP

面向个人本地使用场景重构的 Tavily 号池管理 + Model Context Protocol (MCP) 服务,灵感与核心调度思路源自 IvanLi-CN/tavily-hikari,彻底裁剪了面向多租户/上游服务商的冗余模块(OAuth、充值计费、主备 HA、Xray 正向代理等),聚焦个人多 Key 号池维护与即开即用的本地联网搜索。

无需 Docker,无需手动提前启动任何后台服务——在 Antigravity、Cursor、Claude Desktop、Claude Code 等智能体中配好名为 tavily-web-search 的 MCP 服务即可直接使用,并在后台自动提供本地 Web 管理面板(默认 http://127.0.0.1:8787)随时配置 Key 与查看用量。


核心特性

  • 零前置启动(告别 Docker):

    • 默认以标准 stdio MCP 模式由智能体客户端自动拉起,同进程后台自动挂载本地 Web 面板(默认 http://127.0.0.1:8787),stdout 严格保持纯 JSON-RPC 零污染。

    • 多智能体窗口同时运行时,自动共享同一份 SQLite 数据库(~/.tavily/data.db,WAL 模式并发安全)与同一面板端口;首个进程退出后,其余进程会自动无缝接管面板端口。

    • 在面板中添加、禁用或同步 Key 实时生效,无需重启智能体。

  • 个人号池健康调度与自动故障切换:

    • 支持单条/多行批量导入 Key,导入前支持一键调用官方 /usage 预检有效性与真实余额。

    • 每个 Key 自动分配 4 位短 ID 与脱敏显示(tvly-dev-...xxxx),支持备注、启停、软删除回收站、明文显隐与复制。

    • 完整健康生命周期:

      • 401 自动标为 invalid 并切下一个 Key;

      • 429 自动进入 cooldown(遵守 Retry-After)并切下一个 Key;

      • 432/433 自动标为 exhausted 并切下一个 Key,跨 UTC 自然月或同步后自动复活;

      • 5xx/网络超时自动换号重试,400/422 参数错误快速失败不浪费其他 Key。

    • 支持 3 种面板可切换调度策略:balanced(均衡额度优先 + 避开连击单号,默认)、round_robin(严格 LRU 轮询)、drain_first(优先消耗低余额号)。

  • 直连 Tavily 官方 REST API,完整提供 6 个 MCP 工具:

    • tavily_search:实时网页搜索(支持深度、时间范围、域名过滤、国家、摘要答案、原文等完整参数)

    • tavily_extract:批量提取网页干净 Markdown / 文本正文

    • tavily_crawl:站点递归爬取与正文提取

    • tavily_map:网站 URL 结构测绘

    • tavily_research:多源深度研究与带引用报告(创建与轮询严格绑定同一 Key)

    • tavily_pool_status:0 消耗只读查询,随时在对话中查看号池健康度、剩余 Credits 与当前本地面板地址

  • 内置轻量可视化面板(浅色/深色双主题):

    • 总览仪表盘(KPI、近 7/14/30 天调用与 Credits 趋势图、工具分布、一键测试搜索)

    • 号池管理(批量导入预检、真实额度进度条、回收站)

    • 调用审计日志(按工具/状态/Key/关键字筛选、分页、错误信息与切换次数追踪)

    • 配置与接入(调度策略调整、一键复制各客户端 JSON 配置与 Cherry Studio 本地免密代理地址)


Related MCP server: Tavily MCP Server

前置准备

  1. 已安装 uv 且系统具备 Python 3.11+。

  2. 准备好 1 个或多个 Tavily API Key(免费 Researcher 账号每月 1,000 credits)。


快速开始

1. 克隆并同步环境

git clone https://github.com/LS-King/tavily-web-search-mcp.git
cd tavily-web-search-mcp
uv sync

2. 配置到你的 AI 智能体(零前置启动)

在 Antigravity(~/.gemini/config/mcp_config.json)、Claude Desktop、Cursor 等支持 mcpServers 的客户端中填入(将目录替换为你本机实际路径):

{
  "mcpServers": {
    "tavily-web-search": {
      "command": "uv",
      "args": [
        "run",
        "--directory",
        "E:/search_mcp/tavily-web-search-mcp",
        "tavily-web-search-mcp"
      ]
    }
  }
}

Claude Code 一键添加:

claude mcp add tavily-web-search -- uv run --directory "E:/search_mcp/tavily-web-search-mcp" tavily-web-search-mcp

也支持 uvx 免克隆运行:

{
  "mcpServers": {
    "tavily-web-search": {
      "command": "uvx",
      "args": [
        "--from",
        "git+https://github.com/LS-King/tavily-web-search-mcp",
        "tavily-web-search-mcp"
      ]
    }
  }
}

3. 打开面板配置 Key

当智能体加载 tavily-web-search 后,浏览器直接访问:

在「号池管理」中点击 + 添加 / 批量导入 Key,粘贴一个或多个 Tavily API Key,可先点击「预检有效性与余额」,确认导入后立刻生效,无需重启智能体。

如果想在打开智能体之前提前配好 Key(或单独作为本地 HTTP 代理给 Cherry Studio 使用),也可以在终端运行:

uv run tavily-web-search-mcp panel --open

该模式同时提供 Web 面板(/)、本地免密 Tavily HTTP 代理(/api/tavily/*)与 Streamable HTTP MCP 端点(/mcp)。


环境变量与命令行参数

环境变量

默认值

说明

TAVILY_DB_PATH

~/.tavily/data.db

SQLite 数据库文件路径

TAVILY_API_KEYS

(空)

可选,启动时幂等导入的初始 Key(逗号/换行分隔)

TAVILY_PANEL_ENABLED

true

stdio 模式下是否自动在后台挂载 Web 面板

TAVILY_PANEL_HOST

127.0.0.1

面板监听地址(强烈建议保持回环地址)

TAVILY_PANEL_PORT

8787

面板监听端口(若被无关程序占用会自动顺延 8788~8797)

TAVILY_BASE_URL

https://api.tavily.com

Tavily 上游 REST API 地址

TAVILY_TIMEOUT_SECONDS

30

单次常规请求超时秒数

TAVILY_RESEARCH_TIMEOUT_SECONDS

300

tavily_research 轮询总超时秒数

TAVILY_MAX_FAILOVER

5

单次调用最多尝试切换的不同 Key 数(1~20)

TAVILY_DEFAULT_MAX_CHARS

16000

网页提取/爬取正文默认最大返回字符数(>=500)

常用命令:

# 离线自检(不发网络请求,Key 自动脱敏)
uv run tavily-web-search-mcp --check

# 单独前台启动面板 + HTTP 代理 + /mcp,并自动打开浏览器
uv run tavily-web-search-mcp panel --open

# 禁用内嵌面板启动纯 stdio MCP
uv run tavily-web-search-mcp stdio --no-panel

本地开发与测试

# 安装运行与开发依赖
uv sync --dev

# 代码风格与静态检查
uv run ruff check src tests

# 运行全部离线单元测试、协议测试、面板测试与 stdio 纯净度测试
uv run pytest -v

致谢

License

MIT License

Available Tools

6 tools
tavily_crawlTavily Website CrawlB
Read-onlyIdempotent

Crawl a website starting from a root URL and return extracted Markdown pages.

Inputs: url (required), limit, format, max_chars, +9 more. Returns: result

tavily_extractTavily Webpage ExtractC
Read-onlyIdempotent

Extract clean webpage content from one or more URLs via Tavily Extract API.

Inputs: urls (required), query, format, max_chars, +3 more. Returns: result

tavily_mapTavily Website MapC
Read-onlyIdempotent

Map a website's URL structure starting from a base URL.

Inputs: url (required), limit, max_depth, max_breadth, +4 more. Returns: result

tavily_pool_statusTavily Key Pool StatusA
Read-onlyIdempotent

Inspect local key pool health, remaining credits, and web panel URL (0 credits).

Inputs: refresh. Returns: result

tavily_researchTavily Deep ResearchB
Read-onlyIdempotent

Run multi-source Tavily Deep Research and return a cited report.

Inputs: input (required), files, model, output_length, +3 more. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 6 tools

    Disambiguation4/5

    Each tool maps to a distinct Tavily capability: search (query), extract (fetch content from known URLs), crawl (recursive fetch from a root), map (URL structure only), research (deep multi-source report), and pool status (diagnostics). The only mild risk is confusion between tavily_search and tavily_research, or crawl vs map, but the descriptions clearly signal different depths and outputs.

    Naming Consistency4/5

    All tools share a consistent tavily_ prefix followed by a single action word, giving a predictable namespace. The one minor deviation is tavily_pool_status, which is a noun/status phrase rather than a verb like the other five.

    Tool Count5/5

    Six tools is well-scoped for a web search/extraction API wrapper, and each corresponds to a meaningful capability rather than a redundant variant. No tool feels padded or missing at this count.

    Completeness4/5

    The surface covers the core Tavily endpoint family—search, extract, crawl, map, and deep research—plus diagnostics, giving a full research workflow. Minor gap: pool status is read-only, with no tool to add/rotate/remove keys or otherwise manage the pool despite failover being a stated feature.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Provides AI assistants with real-time web search, intelligent data extraction from web pages, website mapping, and web crawling capabilities through Tavily's API. Enables comprehensive web research and content analysis through natural language interactions.
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to perform real-time web searches, extract data from web pages, map website structures, and crawl websites using the Tavily API.
      68 npm
      MIT