This project adds a web search tool, mcp__bocha__search, to DSH (an agent program running on .223, with its Web UI at 127.0.0.1:19387), so that the agent can directly call the Bocha search API and obtain long Chinese summaries, with each call taking about 0.3–0.5 seconds. It does not interfere with Open WebUI's search toggle: the latter changes the Web UI search engine to Bocha, whereas this project adds a callable tool to the agent.
It was initially implemented as a DSH-native search provider plugin (provider id bocha), but testing showed that installing it at runtime cannot activate it: DSH's module resolution table is fixed at startup, and host plugins newly installed after startup cannot import @deepseek-ai/* dependencies. The entire process must be restarted for it to take effect, which interrupts the current conversation and invalidates the old GUI token. Therefore, we switched to an MCP configuration-based bundle: insert only one @deepseek-ai/dsh-mcp-client entry into the configuration, and configure a separate Node stdio MCP server to call Bocha. This requires no restart and takes effect immediately upon installation. The native provider code is retained for future use if, after restarting DSH, we want to switch back to the native web_search provider.
The default strategy prioritizes cost savings: DSH's own web_search still uses the free SearXNG, and Bocha is used manually as needed as an additional tool that is more accurate but paid. On 2026-10-24, automatic fallback was also added: the default is SEARCH_PROVIDER=auto, with Bocha preferred; on failure, HTTP error, or quota exhaustion, it automatically switches to DeepSeek's official search and circuit-breaks Bocha for 10 minutes. Bocha balance monitoring has been integrated into the .164 monitoring console.
Features
- 为 DSH agent 提供 `mcp__bocha__search` 联网搜索工具,支持 `query`、`count`、`freshness` 参数
- 采用 MCP 配置型 bundle,安装即热生效,无需重启 DSH 进程
- 默认博查优先,失败或额度用完自动回退 DeepSeek 官方搜索,并熔断博查 10 分钟
- 支持 `SEARCH_PROVIDER` 环境变量和工具 `provider` 参数强制 auto/bocha/deepseek
- 零依赖 Node stdio JSON-RPC MCP server,Key 通过独立文件读取
- 博查余额与消耗接入监控台,支持低余额 ntfy 提醒
Stack: Node.js · MCP · JSON-RPC · 博查搜索 API · DeepSeek Search API · Cordis/YAML · ntfy
Deployment and Usage
1. Prepare the Key
Write the Bocha API Key to /root/.dsh/secrets/bocha.key and set permissions to 600. The DeepSeek Key is read from /opt/projects-site/.deepseek-key by default and can be overridden with DEEPSEEK_KEY_FILE. In the configuration, only write the Key file path, not the Key itself.
2. Deploy the MCP Server and Bundle
Place the zero-dependency Node stdio MCP server server.mjs and the bundle definition (package.json, cordis.patch.yml, locale, icon) in /root/plugins-src/bocha-mcp/. Install the bundle into the profile /root/.dsh/profiles/web, actually referencing @local/bocha-mcp via link:/root/plugins-src/bocha-mcp.
3. Configure the MCP Client and Environment Variables
Insert an entry for @deepseek-ai/dsh-mcp-client into the DSH configuration (a package bundled with DSH that can be natively parsed). Add DEEPSEEK_KEY_FILE in cordis.patch.yml and set SEARCH_PROVIDER=auto. If you want to use only DeepSeek immediately, set it to deepseek.
4. Install and Confirm Hot Reload Takes Effect
Install @local/bocha-mcp via plugin_manager, and confirm that the result is application: applied with no warnings. Using Tool.listTools should show mcp__bocha__search, and "MCP server: bocha" should appear in the system prompt. This method does not require restarting DSH.
5. Verify Search
Ask questions such as "What is the weather in Shanghai today?" in the agent, and check whether Bocha results are returned. You can also use provider=deepseek to verify the official DeepSeek search results; the default auto prioritizes Bocha when Bocha has a balance. For fault injection, point BOCHA_ENDPOINT to an unavailable address and observe whether it automatically falls back and logs the event.
6. Restart the MCP Subprocess After Modification
After modifying server.mjs, disable and then re-enable @local/bocha-mcp in plugin_manager, or restart DSH, so that the MCP server reloads.
7. Query the Bocha Balance
Use curl -H "Authorization: Bearer <key>" https://api.bochaai.com/v1/fund/remaining to query the balance. The monitoring console samples every 15 minutes and sends an ntfy notification when the balance is below ¥5 / ¥2.