Skip to main content
Glama
deepseek-web-search

deepseek-web-search

by RedrockerLi
README.md
# deepseek-app-mcp

把 [DeepSeek](https://api-docs.deepseek.com/zh-cn/guides/search) 的 Web Search、Fetch 和 [OCR](https://api-docs.deepseek.com/zh-cn/guides/ocr/) 接口暴露给 AI 客户端的本地 stdio MCP server。原样返回 DeepSeek 的 JSON,不过滤、不重排、不截断。

## 安装

要求 Node.js >= 22.12。

```bash
npm install
npm run build
```

## 配置

server 只从环境变量读 Key,不读 `.env`。Key 已在 shell 中 export 时,一条命令完成注册:

```bash
claude mcp add-json --scope user deepseek-app-mcp \
  '{"type":"stdio","command":"/home/redrocker/.nvm/versions/node/v22.23.2/bin/node","args":["/home/redrocker/File/deepseek-app-mcp/dist/index.js"],"env":{"DEEPSEEK_API_KEY":"${DEEPSEEK_API_KEY}"},"timeout":300000}'
```

也可以把 `${DEEPSEEK_API_KEY}` 换成实际 Key。

- `--scope`:`user` 全局可用,`local` 仅当前项目(默认),`project` 写入仓库 `.mcp.json` 并会提交 Key。
- `timeout`:单次工具调用上限。OCR 最坏约 180 秒,取 300000 留余量。
- `command`:node 绝对路径,避免取到 PATH 里系统自带的旧版本。

其他客户端用等价的 JSON 配置(`timeout` 字段可以删):

```json
{
  "mcpServers": {
    "deepseek-app-mcp": {
      "type": "stdio",
      "command": "/home/redrocker/.nvm/versions/node/v22.23.2/bin/node",
      "args": ["/home/redrocker/File/deepseek-app-mcp/dist/index.js"],
      "env": { "DEEPSEEK_API_KEY": "sk-..." },
      "timeout": 300000
    }
  }
}
```

工具名:`mcp__deepseek-app-mcp__search`、`mcp__deepseek-app-mcp__fetch`、`mcp__deepseek-app-mcp__ocr`。改了 `src/` 要重新 `npm run build` 并重启会话。

## 工具

### search

| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| `query` | string | 必填 | 1~128 字符,支持 `site:` `-site:` `-` `"..."` `lang:` `after:` `before:` |
| `count` | integer | 10 | 1~50 |
| `need_content` | boolean | false | 返回网页正文,可能非常大 |
| `ori_question` | string | — | 用户原始问题 |
| `site` / `exclude_sites` | string[] | — | 限定 / 排除站点,多站点用 `OR` |
| `lang` | string[] | — | 如 `["zh","en"]` |
| `after` / `before` | string | — | `YYYY`、`YYYY-MM` 或 `YYYY-MM-DD` |
| `exact_phrase` | string | — | 精确匹配短语 |
| `exclude_terms` | string[] | — | 排除包含这些词的网页 |

结构化参数追加到 `query` 后面,与 `query` 里手写的操作符叠加,不去重。

### fetch

| 参数 | 类型 | 说明 |
|---|---|---|
| `url` | string | 绝对 HTTP/HTTPS URL,≤8192 字符,不能带凭据 |

### ocr

| 参数 | 类型 | 说明 |
|---|---|---|
| `file_path` | string | 必填。本地待识别文件路径,建议绝对路径;相对路径按 server 进程 cwd 解析。≤100 MiB |
| `purpose` | string | 必填。`text_recognition`:无图 Word/PPT 直接提取文字,其他文件逐页识别;`rich_layout_recognition`:所有文件逐页识别 |

支持 PDF、Word(DOC、DOCX)、PowerPoint(PPT、PPTX)以及 PNG、JPEG、WebP、GIF、BMP、TIFF。上游限制 1000 页、总时长 180 秒;逐页识别的文本保留 `<|ref|>`、`<|box|>` 等标记与坐标。文件不会存入 Files API。计费 1.5 元 / 1000 成功页,每账号最多同时 15 个识别。

## 返回与错误

- HTTP 2xx:一个 text block,DeepSeek 响应体原文(OCR 识别期间的前导换行也原样保留)。
- HTTP 非 2xx:两个 text block(`HTTP <status>` + 原文),`isError: true`。
- 配置、参数、本地文件、网络错误:一个 text block 说明原因,`isError: true`。
- 不截断:`need_content=true`、抓取长页面或 OCR 长文档时结果可能很大。Claude Code 会把超过约 50k 字符的 MCP 结果写入 tool-results 文件并给出路径;server 本身不截断。
- OCR 识别开始后 HTTP 已是 200,失败时响应体是 `{"error": {...}}`;此时按 2xx 原样返回,不置 `isError`,由 agent 根据响应体判断。

## 环境变量

| 变量 | 必填 | 说明 |
|---|---|---|
| `DEEPSEEK_API_KEY` | 是 | 缺失时 server 仍能启动,调用工具返回配置错误 |
| `DEEPSEEK_BASE_URL` | 否 | 默认 `https://api.deepseek.com`,不要带 `/v1` 或凭据 |

## 超时

- 单次超时:search 30 秒,fetch 60 秒,ocr 200 秒;每次调用只发一次请求,不重试。
- 上游返回的状态码与响应体原样返回;非 2xx 时工具结果标记 `isError`。
- OCR 调用超过 2 分钟会被 Claude Code 自动转入后台任务,结果稍后返回;客户端断开不会取消上游识别,已完成的识别照常计费。
- 限速与计费:search 100 QPS、5 元 / 1000 次成功请求;fetch 25 QPS、5 元 / 1000 次成功请求;OCR 每账号并发 15、1.5 元 / 1000 成功页。

## 开发

```bash
npm run typecheck
npm test
npm run dev
DEEPSEEK_INTEGRATION=1 DEEPSEEK_API_KEY=... npm run test:integration
```

集成测试通过 stdio 启动 `dist/index.js`,实际发起 1 次 search + 1 次 fetch + 1 次 OCR(测试内生成 1×1 PNG);未设置 `DEEPSEEK_INTEGRATION=1` 时跳过。默认 `npm test` 只运行不产生费用的单元测试。

## 安全

Key 只从环境变量读取,不写入日志或工具输出;stdio 下 stdout 只承载 MCP 协议,日志走 stderr;除非设置 `DEEPSEEK_BASE_URL`,只连接 `api.deepseek.com`。OCR 会把 `file_path` 指定的本地文件上传到 DeepSeek。

## License

MIT

TDQS

A4.1/5.0

Scored across 2 tools

Disambiguation5/5

search and fetch have clearly distinct purposes: discovery via query vs. retrieval of a specific known URL. The search description even explicitly redirects agents to fetch for a specific URL, eliminating any overlap.

Naming Consistency5/5

Both tools use a single lowercase verb with no mixed conventions (no camelCase, no noun-only names). The pattern is fully predictable across the two-tool surface.

Tool Count4/5

Two tools is on the thin side, but for a narrowly scoped search-and-retrieve proxy it is exactly the right surface — no tool feels extraneous and none is missing. Slightly below 5 only because the count leaves no room for filter/parameter discovery aids.

Completeness4/5

Search plus fetch covers the full web-retrieval lifecycle with no dead ends, and both tools return raw upstream JSON. Minor gap: structured filters are mentioned as being 'appended to query' without explicit parameters, so agents must guess the syntax.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues