@huanlin/dsh-plugin-mcp-manager 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,131 @@
1
+ [![dshfind](https://dshfind.com/api/badge/huanlinoto/dsh-plugin-mcp-manager?lang=zh)](https://dshfind.com/zh/plugins/huanlinoto/dsh-plugin-mcp-manager?ref=badge)
2
+
3
+ > 📌 本插件已收录于 [dshfind](https://dshfind.com/zh) 插件超市,点击上方徽章直达主页。
4
+
5
+ # dsh-mcp-manager
6
+
7
+ > DSH MCP 服务器管理插件 — GUI 增删改 MCP 服务器配置 + 工具浏览 + agent 面 `mcp_*` 管理工具。
8
+
9
+ ## 定位
10
+
11
+ **服务器连接管理 + 工具浏览**。连接生命周期完全委托官方 `@deepseek-ai/dsh-mcp-client`——
12
+ 本插件是注册表的「写配置层」+「状态/工具浏览层」,不自己拉连接。
13
+
14
+ ```
15
+ GUI(settings.section「MCP」) ──HTTP──> /api/mcp-manager ──读写──> profile cordis.patch.yml
16
+ Agent 面 mcp_* 工具 ─────────────────────────────┘ (mcp-client insert 行)
17
+ │ 配置 HMR 实时挂载
18
+
19
+ 官方 mcp-client 实例(连接+注册工具)
20
+ GUI 状态/工具浏览 <──ctx.tools.schemas() 过滤 mcp__──┘
21
+ ```
22
+
23
+ 每台 MCP 服务器 = profile `cordis.patch.yml` 中一条 `name: '@deepseek-ai/dsh-mcp-client'` 的
24
+ insert 行。配置 HMR 实时挂载/卸载/热替换,无需重启 web。
25
+
26
+ ## 开发
27
+
28
+ ### 依赖
29
+
30
+ ```powershell
31
+ pnpm install
32
+ ```
33
+
34
+ `@deepseek-ai/*` peer deps 从公共 npm registry 解析(已发布)。`yaml`(eemeli)是唯一运行时依赖。
35
+
36
+ ### 三件套
37
+
38
+ ```powershell
39
+ pnpm typecheck # tsc --noEmit(src/ + tests/;src/client/ 由 tsdown 构建,不进 tsc)
40
+ pnpm test # vitest run(registry 单元测试,27 用例)
41
+ pnpm build # tsdown 双 bundle:lib/index.mjs(Node half)+ lib/index.js(client half)
42
+ ```
43
+
44
+ ### 架构
45
+
46
+ | 文件 | 职责 |
47
+ |------|------|
48
+ | `src/registry.ts` | 服务器注册表:eemeli `yaml` Document API 读写 insert 行 + `loadOverlayPatches` 校验 + serverName 唯一 |
49
+ | `src/tools.ts` | agent 面 `mcp_*` ×4 工具(defineTool,规范 JSON 输出) |
50
+ | `src/index.ts` | Node half:`/api/mcp-manager` 路由 + `ctx.tools.schemas()` 过滤 + mcp 工具注册 |
51
+ | `src/client/index.ts` | client half:`settings.section` 注册「MCP」面板 |
52
+ | `src/client/Panel.tsx` | 面板 UI:服务器列表 + 增删改表单 + 工具浏览 |
53
+
54
+ ### 数据模型
55
+
56
+ 存储 = profile `cordis.patch.yml` 的 mcp-client insert 行(单一事实来源):
57
+
58
+ ```yaml
59
+ - insert:
60
+ - id: mcp-github # 行 id(mcp-<serverName>)
61
+ name: '@deepseek-ai/dsh-mcp-client'
62
+ config:
63
+ serverName: github # 工具命名空间 mcp__github__*
64
+ transport: stdio # stdio | streamable-http
65
+ command: npx
66
+ args: ['-y', '@modelcontextprotocol/server-github']
67
+ env: { GITHUB_TOKEN: '' } # 明文(见下「Secret 处理」)
68
+ toolCallTimeoutMs: 60000
69
+ failOnStartupError: false
70
+ ```
71
+
72
+ - 支持 `stdio`(command/args/env/cwd)与 `streamable-http`(url/headers)。
73
+ - 编辑 = 整块替换 config(不深合并,与 loader patch 语义一致)。
74
+ - 写前用 eemeli yaml 解析 + 可选 `loadOverlayPatches`(app-boot)校验;写后失败自动回滚。
75
+ - **保留**其他行的 `!!js` 表达式与注释(eemeli Document API 往返保留)。
76
+
77
+ ## 运行
78
+
79
+ ### 安装
80
+
81
+ ```powershell
82
+ # 本地开发(link: 热更新——改源码后 pnpm build 即可见)
83
+ dsh plugin --profile web add "link:<本仓库路径>"
84
+
85
+ # 远端(预构建 lib/ 入库,无 prepare,开箱即用)
86
+ dsh plugin --profile web add "github:dsh-external/dsh-mcp-manager"
87
+ ```
88
+
89
+ 安装后**重启 dsh web**(bundle 层在 boot 时加载),浏览器硬刷新(`Ctrl+Shift+R`)。
90
+
91
+ ### 使用
92
+
93
+ - **GUI**:设置页 → 「MCP」面板。新增/编辑/删除服务器;点击「工具」展开该服务器的 `mcp__*` 工具列表。
94
+ - **Agent**:模型可调用 `mcp_server_list` / `mcp_server_add` / `mcp_server_update` / `mcp_server_remove`。
95
+
96
+ ### API 路由
97
+
98
+ | 路由 | 方法 | 说明 |
99
+ |------|------|------|
100
+ | `/api/mcp-manager/servers` | GET | 列出服务器 + 工具数 + 状态 |
101
+ | `/api/mcp-manager/servers` | POST | 新增(body: `{config}`)→ HMR 挂载 |
102
+ | `/api/mcp-manager/servers/<id>` | PUT | 编辑(整块替换 config) |
103
+ | `/api/mcp-manager/servers/<id>` | DELETE | 删除 |
104
+ | `/api/mcp-manager/tools` | GET | 工具浏览(`mcp__` 前缀按 serverName 分组) |
105
+ | `/api/mcp-manager/status` | GET | 运行态状态 |
106
+
107
+ ### Secret 处理
108
+
109
+ ⚠ **P0:env / headers 以明文存入 profile `cordis.patch.yml`**(与官方示例同形态)。
110
+ README 明确警示:勿放长期密钥;部署隔离。P1 可接 `@deepseek-ai/dsh-credentials`(待设计)。
111
+
112
+ ## 检查(合规自检,对照 plugin-development-guide.md §10)
113
+
114
+ - [x] **零源码 patch**:未修改 DSH checkout 任何文件
115
+ - [x] **B1**:`package.json` 声明 `dsh.bundle.patch`
116
+ - [x] **B2**:自带 `cordis.patch.yml`(insert 行 id/name 齐全)
117
+ - [x] **B3**:patch 行 `name` 用包名 `@huanlin/dsh-plugin-mcp-manager`
118
+ - [x] **F1**:`files` 含 `lib/` + `cordis.patch.yml`
119
+ - [x] **F2**:`peerDependencies` 含 cordis + `@deepseek-ai/*`(dsh-tools / dsh-app-boot / dsh-client-runtime / dsh-client-ui-primitives)
120
+ - [x] **F3**:typecheck / test / build 三 script 齐全(预构建策略:无 prepare,lib/ 入库)
121
+ - [x] **A4**:Config 校验用 `validateServerConfig`(fail loud,携带字段名)
122
+ - [x] **A6**:不导出 default
123
+ - [x] **C4**:工具返回规范 JSON 值 + render 投影分离
124
+ - [x] **G**:测试分层(Unit:27 用例覆盖增删改/唯一/非法拒绝/!!js 保留/空文件/多行)
125
+ - [x] **README**:含开发/运行/检查三节
126
+
127
+ ### 预构建策略说明
128
+
129
+ 含 `@deepseek-ai/*` private peer deps → 采用**预构建 `lib/` 入库**策略:
130
+ `lib/` 不进 `.gitignore`,无 `prepare` 脚本。`github:` 安装开箱即用(pnpm 在 git install 的
131
+ prepare 阶段拉不到 private 包,故不能用 prepare 策略)。
@@ -0,0 +1,5 @@
1
+ # dsh-mcp-manager bundle:向组合挂 MCP 管理面板(Node half 读写 profile
2
+ # cordis.patch.yml 的 mcp-client insert 行;client half 注册「MCP」设置面板)。
3
+ - insert:
4
+ - id: dsh-mcp-manager
5
+ name: '@huanlin/dsh-plugin-mcp-manager'