dsh-mcp-proxy
ben7am1n
Context-cheap lazy MCP access for DeepSeek Harness
PROJECT TOPICS
PROJECT README
一个 DeepSeek Harness (DSH) 插件组合包:为 dsh 提供 运行时 MCP 服务器管理 能力。
官方的 @deepseek-ai/dsh-mcp-client 在 cordis.yml 中为每个 MCP 服务器挂一行静态插件行——增删服务器需要改配置并重启宿主。本插件补上缺失的管理面:
$DSH_HOME/mcp-manage/servers.json,重启后自动重连)mcp_manage_* 智能体工具,可在会话中直接增、删、启停、重连 MCP 服务器dsh-mcp-client 完全一致的命名契约 mcp__<serverName>__<rawName>,对模型而言动态管理的服务器与静态行毫无区别dsh plugin --profile <name> add /path/to/dsh-mcp-manager # 本地目录
dsh plugin --profile <name> add github:HenC49/dsh-mcp-manager # git 仓库安装(本包为纯手写 JS,无构建步骤)
安装后重启该 profile(dsh web 等)即可生效。重启后打开 Web UI 的设置面板,即可看到 MCP 服务器 页面;当前生产 Web profile 的 HMR 默认关闭,因此新增或更新插件包后需要重启宿主。
dsh plugin --profile <name> remove dsh-mcp-manager
dsh.profile.bundles 中的该层会被自动剔除(reconcile 逻辑),无需手工编辑 profile manifestdsh web 等)后:六个 mcp_manage_* 工具注销、所有被管理服务器的连接关闭、Web 设置页的 MCP 服务器 入口消失$DSH_HOME/mcp-manage/servers.json 不会被删除——它保存着你配置的服务器以及 env/headers(可能含敏感信息):$DSH_HOME/mcp-manage/ 目录进入 设置 → MCP 服务器:
stdio 本地命令和 streamable-http 远程端点;参数、环境变量和请求头均采用每行一项的编辑方式/mcp-manage/api/* 接口,接口使用 loopback/可信 Host 与 same-origin 检查,拒绝跨站请求聊天中的 mcp_manage_* 工具仍然保留,适合自动化或无法使用 Web UI 的场景。
| 工具 | 作用 |
|---|---|
mcp_manage_list |
列出已管理的服务器:名称、状态、传输方式、启停、已桥接的工具名、注册表路径 |
mcp_manage_add |
添加并立即连接一个 MCP 服务器(stdio 或 streamable-http),工具即刻注册为 mcp__<name>__<tool> |
mcp_manage_remove |
移除服务器:断开连接、注销工具、从注册表删除 |
mcp_manage_set_enabled |
启用/停用服务器(停用断开连接并注销工具,配置保留) |
mcp_manage_reload |
重连一个(按名)或全部(无名)已启用的服务器并重新发现工具 |
mcp_manage_tools |
列出某个服务器当前暴露的工具名,便于直接调用 |
示例——直接在会话里说:
帮我添加一个 filesystem MCP 服务器,命令
npx -y @modelcontextprotocol/server-filesystem /Users/me/project
模型会调用 mcp_manage_add,工具立即生效,无需重启。
$DSH_HOME/mcp-manage/servers.json(可用插件配置 dataDir 改路径,支持 ~ 前缀):
{
"version": 1,
"servers": {
"github": {
"enabled": true,
"transport": "stdio",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": { "GITHUB_TOKEN": "${GITHUB_TOKEN}" },
"toolCallTimeoutMs": 60000
},
"remote": {
"enabled": true,
"transport": "streamable-http",
"url": "https://mcp.example.com/mcp",
"headers": { "Authorization": "Bearer ${MCP_TOKEN}" }
}
}
}
env 值、headers 值和 url 支持 ${VAR} 展开(取自 dsh 宿主进程环境;未设置的变量保留字面量,便于在报错中暴露问题)mcp_manage_reload 后生效(本插件不监听文件变化)在 profile 的 cordis.patch.yml 中按行覆盖(补丁替换整行 config,需重述全部字段):
- id: mcp-manage
name: 'dsh-mcp-manager'
config:
dataDir: '' # 默认 $DSH_HOME/mcp-manage
autoStart: true # 宿主启动时自动连接已启用的服务器
defaultToolCallTimeoutMs: 60000
reconnect:
enabled: true
initialDelayMs: 500
maxDelayMs: 30000
maxAttempts: 10
mcp__<serverName>__<rawName>,超长/非法字符时按 SHA-256 身份哈希截断后缀——与 dsh-mcp-client 相同的确定性函数;同一服务器在静态行与本插件之间迁移,工具名不变dsh-mcp-client 行)重名时快速失败并明确报错,不消耗重连预算*KEY*/*TOKEN*/*SECRET*/*PASSWORD*,不区分大小写)与全部 DSH_*,再合并显式 env——与 dsh-subprocess 的擦洗启发式一致,显式传入的凭据得以保留maxDelayMs 则重置预算,连续失败超过 maxAttempts 次后停止并注销工具,等待 mcp_manage_reloadtools/list_changed 通知,整代换、失败保旧、冲突回滚整代isError: true 的调用结果转为工具错误路径;文本块拼接为模型可见文本,图像/音频/资源块降级为占位符(与 dsh-mcp-client 一致)mcp_manage_add 可以让智能体在宿主进程中 spawn 任意命令(stdio 传输)。这与会话中已有的 bash 工具权限同级——如果部署上需要收紧,可在权限预设中对该组工具启用审批策略。env/headers 中的 ${VAR} 展开读取的是 dsh 宿主进程的环境变量,不要将宿主的敏感凭据变量名透传给不可信的 MCP 服务器。
pnpm install
pnpm test # 22 项集成测试:使用内置 toy stdio MCP 服务器覆盖桥接/管理/持久化/重连/热同步/销毁
dsh-mcp-client 一样暂缓)dsh-mcp-client 一致)A DeepSeek Harness (DSH) plugin bundle adding runtime MCP server management.
The official @deepseek-ai/dsh-mcp-client mounts one static plugin row per MCP server in cordis.yml — adding or removing a server means editing the composition and restarting the host. This bundle adds the missing management plane: a persisted JSON server registry plus six mcp_manage_* agent tools that add, remove, enable/disable, and reconnect MCP servers at runtime. Bridged tools use the exact mcp__<serverName>__<rawName> naming contract of dsh-mcp-client, so dynamically managed servers look identical to static rows to the model.
dsh plugin --profile <name> add /path/to/dsh-mcp-manager
Restart the profile afterwards.
dsh plugin --profile <name> remove dsh-mcp-manager
dsh.profile.bundles automatically (reconcile) — no manual manifest edits.dsh web etc.): the six mcp_manage_* tools are unregistered, every managed connection closes, and the Settings → MCP page disappears.$DSH_HOME/mcp-manage/servers.json is not removed — it holds your servers plus env/headers, which may contain secrets. Keep it to restore the configuration on reinstall (servers reconnect automatically), or delete the $DSH_HOME/mcp-manage/ directory for a full cleanup.mcp_manage_list / mcp_manage_add / mcp_manage_remove / mcp_manage_set_enabled / mcp_manage_reload / mcp_manage_tools — see the tables above; each returns a concise text summary, and errors carry actionable hints (fix + reload).
$DSH_HOME/mcp-manage/servers.json (override with the plugin's dataDir config; ~ supported). env values, headers values, and url support ${VAR} expansion from the host process environment. Writes are atomic (tmp + rename). Hand edits apply on next host restart or mcp_manage_reload; the file is not watched.
Deterministic public names (hash-suffixed on lossy normalization, identical algorithm to dsh-mcp-client); fast-fail on namespace conflicts; credential-shaped env scrubbing (*KEY*/*TOKEN*/*SECRET*/*PASSWORD* and DSH_*) with explicit env merged after; exponential-backoff reconnect with a stability-reset budget and give-up + manual reload; tools/list_changed generation swap; isError results mapped to the tool error path; fully effect-scoped lifecycle.
mcp_manage_add lets the agent spawn arbitrary commands (stdio transport) — the same trust level as the session's bash tool; gate the tool group behind your permission presets if needed. ${VAR} expansion reads the dsh host environment.
pnpm install && pnpm test # 22 integration tests against a bundled toy stdio MCP server CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。