Skip to main content
Glama
deepseek-web-search-mcp

deepseek-web-search-mcp

by LS-King

DeepSeek Web Search MCP

基于 Python(uv + FastMCP)实现的独立 Model Context Protocol (MCP) 服务,直接封装 DeepSeek 官方独立的网页搜索(Search)与网页抓取(Fetch)工具 API。

让你在 Antigravity、Claude Desktop、Cursor、Cline、Claude Code 等任意支持 MCP 的客户端中,复用已有的 DeepSeek API Key 获得低延迟、低成本的实时联网搜索与网页 Markdown 正文提取能力,不消耗对话模型 Token。


核心特性

  • 双工具闭环:

    • deepseek_search:调用 POST /v1/tools/search,支持 site:、-site:、lang:、after:/before:、精确短语等搜索语法,支持 summary(600~800 字模型友好长摘要)/ snippet / full 三档返回粒度与 min_score 质量过滤。

    • deepseek_fetch:调用 POST /v1/tools/fetch,抓取单个网页并转为干净的 Markdown 正文,带最大字符截断保护。

  • 官方计费友好:直接调用工具接口(官方标准定价 5 元 / 1,000 次成功请求,失败或空结果不计费;不走对话模型推理)。

  • 健壮与安全:

    • 自动截断超过 128 字符的 query / ori_question,避免触发 HTTP 400。

    • 严格校验 deepseek_fetch URL(仅允许 http/https、禁止携带 userinfo、限制最大 8192 字符)。

    • 针对 408、429(支持 Retry-After)、5xx 及网络超时自动指数退避重试;401/402/404 快速失败并给出清晰提示,绝不泄露 API Key。

    • 严格分离 stdio 协议输出与 stderr 日志,杜绝 JSON-RPC 解析损坏;在返回结果头部标注外部网页为不可信参考数据。

  • 零克隆一键运行:支持 uvx --from git+https://github.com/LS-King/deepseek-web-search-mcp 直接拉起。


Related MCP server: DeepSeek Search MCP

前置准备

  1. 已安装 uv(包含 uvx)且系统具备 Python 3.11+。

  2. 在 DeepSeek 开放平台 申请一个 DEEPSEEK_API_KEY,并确保账户有可用余额。


快速配置(MCP 客户端)

方式 A:使用 uvx 直接从 GitHub 启动(推荐,无需手动克隆)

在任意支持标准 mcpServers 配置的客户端中填入以下配置:

{
  "mcpServers": {
    "deepseek-web-search": {
      "command": "uvx",
      "args": [
        "--from",
        "git+https://github.com/LS-King/deepseek-web-search-mcp",
        "deepseek-web-search-mcp"
      ],
      "env": {
        "DEEPSEEK_API_KEY": "sk-your-deepseek-api-key"
      }
    }
  }
}

方式 B:本地克隆后通过 uv run 启动(适合本地二次开发)

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

客户端配置示例(请将路径替换为你的实际克隆目录):

{
  "mcpServers": {
    "deepseek-web-search": {
      "command": "uv",
      "args": [
        "run",
        "--directory",
        "/path/to/deepseek-web-search-mcp",
        "deepseek-web-search-mcp"
      ],
      "env": {
        "DEEPSEEK_API_KEY": "sk-your-deepseek-api-key"
      }
    }
  }
}

常见客户端配置路径

客户端

配置文件位置 / 添加方式

Antigravity

全局 ~/.gemini/config/mcp_config.json 或工作区 .agents/mcp_config.json

Claude Desktop

Windows: %APPDATA%\Claude\claude_desktop_config.json;macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

Cursor

Settings → MCP → Add New MCP Server

Claude Code

claude mcp add deepseek-web-search -e DEEPSEEK_API_KEY=sk-... -- uvx --from git+https://github.com/LS-King/deepseek-web-search-mcp deepseek-web-search-mcp


工具说明

1. deepseek_search

调用 DeepSeek 独立 Search API 搜索互联网。

参数

类型

必填

默认值

说明

query

string

是

—

搜索词(1~128 Unicode 字符,超长会自动截断)。支持 site:、-site:、-关键词、"精确短语"、lang:zh,en、after:、before:。

count

integer

否

10

返回条数(1~50)。

detail_level

"summary" | "snippet" | "full"

否

"summary"

summary(推荐,600800 字长摘要)、snippet(100200 字短摘要)、full(开启 need_content 并返回截断保护后的正文)。

min_score

number

否

0.0

最低 rerank_score 过滤阈值(0.0~3.0,官方认为 >= 1.5 为优质结果)。

ori_question

string | null

否

null

触发搜索的用户原始问题(最多 128 字符),有助于理解意图。

localization

string

否

""

可选 IP 地址字符串,用于优先返回本地化搜索结果。

2. deepseek_fetch

调用 DeepSeek 独立 Fetch API 抓取单个网页并返回 Markdown 正文。

参数

类型

必填

默认值

说明

url

string

是

—

完整的 http:// 或 https:// 网址(≤8192 字符,不允许携带用户名/密码)。

max_chars

integer | null

否

DEEPSEEK_FETCH_MAX_CHARS (12000)

返回 Markdown 的最大字符数(≥500),超出时自动截断并提示总长度。


环境变量与自检命令

环境变量

必填

默认值

说明

DEEPSEEK_API_KEY

是

—

DeepSeek 开放平台 API Key(sk-...)。

DEEPSEEK_BASE_URL

否

https://api.deepseek.com

自定义 API 地址(用于企业网关或私有代理)。

DEEPSEEK_TIMEOUT_SECONDS

否

30

单次 HTTP 请求超时秒数。

DEEPSEEK_MAX_RETRIES

否

2

遇到 408/429/5xx 或网络超时时的最大重试次数(0~10)。

DEEPSEEK_FETCH_MAX_CHARS

否

12000

deepseek_fetch 默认最大返回字符数(≥500)。

运行配置自检(不发网络请求、不扣费,并对 Key 自动脱敏):

DEEPSEEK_API_KEY=sk-your-key uv run deepseek-web-search-mcp --check

本地开发与测试

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

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

# 运行全部单元测试与 FastMCP 协议测试(全离线,无需真实 API Key)
uv run pytest -v

License

MIT License

Available Tools

2 tools
deepseek_fetchDeepSeek Web FetchA
Read-onlyIdempotent

Fetch a single webpage and return its cleaned Markdown content (/v1/tools/fetch).

Inputs: url (required), max_chars. 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 2 tools

    Disambiguation5/5

    deepseek_search and deepseek_fetch target clearly distinct actions: querying a search endpoint versus retrieving and cleaning a single known URL. There is no plausible scenario where an agent would confuse the two.

    Naming Consistency5/5

    Both tools follow an identical namespace_verb snake_case pattern (deepseek_search, deepseek_fetch), matching the server name and each other perfectly. No mixed conventions.

    Tool Count4/5

    Two tools is on the thin side, but for a search-and-fetch API wrapper they are exactly the two primitives needed, so each earns its place. The surface is minimal rather than padded.

    Completeness4/5

    Search plus fetch covers the standard discover-then-read workflow with no dead ends. Minor gaps exist (no batch fetch, crawling, or result-pagination control), but agents can work around them with repeated calls.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      Enables MCP-capable AI clients to run web searches through DeepSeek's search engine and fetch individual webpages as Markdown. Search results include relevance scores, authority, and publication times, and support advanced query syntax such as site:, lang:, and date filters.
      2
      52 npm
      1
      Apache 2.0
    • A
      license
      A
      quality
      C
      maintenance
      Enables any MCP-compatible AI agent to search the live web and fetch pages as clean Markdown, including batch fetching with rate limiting, retries, and context-safe truncation.
      3
      MIT