插件目录 / Developer / dsh-workspace-mcp
dsh-workspace-mcp
未验证 Momojie-S
功能简介
workspace 级 MCP 加载——读 <session-cwd>/.dsh/mcp.servers.yml,agent 作用域,随项目自动加载/卸载。
未验证 — 尚未实测
workspace 级 MCP 加载——读 <session-cwd>/.dsh/mcp.servers.yml,agent 作用域,随项目自动加载/卸载。 尚未验证——请自行安装测试。
「未验证」表示我们的自动化 CI 尚未安装过该插件。功能描述与版本兼容性均为作者声明。这不是安全审计,也不代表对第三方代码的背书。
README
@momojie-s/dsh-workspace-mcp
DSH 插件:按 workspace(session cwd) 自动加载/卸载 MCP server——每个项目自己的 .dsh/mcp.servers.yml 只在自己的会话生效,MCP 工具注册到 agent scope,随 agent 生灭自动回收,不同项目的 MCP 互不干扰。
环境要求
- DSH
0.1.0-rc.6(已验证)
用法
项目根放 .dsh/mcp.servers.yml:
servers:
my-server:
transport: stdio
command: npx
args: ["-y", "some-mcp-server@latest"]
env: {}
remote:
transport: streamable-http
url: https://example.com/mcp
headers:
Authorization: "Bearer <token>"
字段与 @deepseek-ai/dsh-mcp-client 对齐(transport / command / args / env / url / headers / toolCallTimeoutMs / reconnect)。
- agent 创建即连接注册(
agent/created),首个模型请求就含这些工具;headless "create 后立刻发消息" 的竞速场景第 1 步可能没有,第 2 步必有 - 断线自动重连(移植官方 dsh-mcp-client 的 supervisor):启动失败与中途断线均按指数退避重连并重新注册工具;重连期间旧工具保持注册(调用会失败),server 恢复后自动换新。stdio = 重新 spawn,http = 重新握手
- server 发
toolListChanged通知时自动重同步工具列表 - 改配置文件由 chokidar 监听,保存即重载;无该文件的目录不加载任何 MCP
安装
本插件是组合包(dsh.bundle),用 dsh plugin 安装进 profile,自动追加配置层,无需手编 patch:
# GitHub(私仓需 git 凭据;pnpm ≥10 首次 add 会提示授权构建,按提示把包键
# 写进 ~/.dsh/profiles/web/pnpm-workspace.yaml 的 allowBuilds 后重新 add)
dsh plugin --profile web add github:Momojie-S/dsh-workspace-mcp
# 或 tarball(pnpm pack 产物,无授权要求)
dsh plugin --profile web add momojie-s-dsh-workspace-mcp-0.2.0.tgz
验证层就位后重启 DSH:
dsh web --dump-config | Select-String workspace-mcp # 应看到对应层
开发模式:源码直连(改代码 → 重启验证)
编译 npm install && npm run build,profile 的 cordis.patch.yml 手动加行(name 用 file:/// URL 指向 lib/index.js):
- insert:
- id: workspace-mcp
name: file:///D:/code/workspace/deepseek-harness-101/plugins/dsh-workspace-mcp/lib/index.js
config:
configFile: '.dsh/mcp.servers.yml'
verbose: true
配置
插件级(patch config 字段):
| 字段 | 默认值 | 说明 |
|---|---|---|
configFile |
.dsh/mcp.servers.yml |
相对 workspace 根的配置文件路径 |
verbose |
false |
输出连接/注册详细日志,排查用 |
reconnect.enabled |
true |
断线/启动失败是否自动重连 |
reconnect.initialDelayMs |
500 |
首次重连延迟,此后指数翻倍 |
reconnect.maxDelayMs |
30000 |
退避封顶;连接存活超此值则重置尝试预算(偶发崩的能无限恢复,crash-loop 的被掐掉) |
reconnect.maxAttempts |
10 |
一次断线周期内最大连续失败次数,耗尽后卸载该 server 全部工具;改配置文件或重启恢复 |
per-server 覆盖(.dsh/mcp.servers.yml,同名项优先于插件级):
servers:
flaky:
transport: stdio
command: npx
args: ["-y", "some-mcp"]
reconnect:
enabled: true
initialDelayMs: 1000
maxAttempts: 5
验证
项目根放 .dsh/mcp.servers.yml 配一个测试 server(如 MCP 官方 server-everything),在会话里让 agent 列工具:
mcp__<serverName>__<toolName>
工具出现即生效;切到无配置的目录,这些工具不再出现,即隔离生效。
断线重连的可执行验证(不经 DSH host):
npm test # 杀 server 子进程 → 自动重连恢复;启动失败 → 退避重试 → 放弃卸载
设计文档见 docs/design/overview.md;MCP 配置详解与踩坑见合集仓库 docs/usage/mcp.md。
安装
装一次目录插件,之后本站所有插件都能让 DeepSeek Harness 自动找、自动装:
dsh plugin add dshbase-catalog 然后对 agent 说「帮我装 dsh-workspace-mcp」,它会在目录里找到并自动安装。文档:dshbase-catalog · 已验证场景包。
该插件是 GitHub 源码(未发 npm)——直接从仓库装:
Web profile:
dsh plugin --profile web add github:Momojie-S/dsh-workspace-mcp Headless(CLI)profile:
dsh plugin --profile headless add github:Momojie-S/dsh-workspace-mcp 实测报告
尚未 L3 验证——若已跑过,见下方失败备注。
备注:验证: install-fail (0.1.0-rc.6) 浏览全部待验证失败 →
使用场景
从 .dsh/mcp.servers.yml 按项目加载 MCP server,切换工作区时自动加载/卸载。
适合谁
有项目专属外部工具、想让它们限定在某个目录而非全局串会话的人。
二次开发建议
YAML schema 和 server 启动器是缝——加 server 类型、环境注入和健康检查。