@huanlin/dsh-plugin-mcp-manager 0.1.0 → 0.1.2

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.
Files changed (4) hide show
  1. package/README.md +24 -11
  2. package/lib/index.js +1229 -268
  3. package/lib/index.mjs +147 -13
  4. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
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) 插件超市,点击上方徽章直达主页。
1
+ <p align="center">
2
+ <a href="https://dshfind.com/zh/plugins/huanlinoto/dsh-plugin-mcp-manager"><img src="https://dshfind.com/api/card/huanlinoto/dsh-plugin-mcp-manager?lang=zh" alt="dsh-plugin-mcp-manager card"></a>
3
+ </p>
4
4
 
5
5
  # dsh-mcp-manager
6
6
 
@@ -23,6 +23,11 @@ GUI 状态/工具浏览 <──ctx.tools.schemas() 过滤 mcp__──┘
23
23
  每台 MCP 服务器 = profile `cordis.patch.yml` 中一条 `name: '@deepseek-ai/dsh-mcp-client'` 的
24
24
  insert 行。配置 HMR 实时挂载/卸载/热替换,无需重启 web。
25
25
 
26
+ **禁用 ≠ 删除**:禁用写入 entry-level `disabled: true`(与 `id`/`name`/`config` 同级),
27
+ loader 跳过挂载该 mcp-client 实例 → 工具不注册(模型不可见),config 原样保留在 patch
28
+ 文件中。重新启用只需移除该字段,loader HMR 重新挂载。适合「暂时不让模型用某台服务器」
29
+ 而不丢失配置。
30
+
26
31
  ## 开发
27
32
 
28
33
  ### 依赖
@@ -45,11 +50,11 @@ pnpm build # tsdown 双 bundle:lib/index.mjs(Node half)+ lib/index.j
45
50
 
46
51
  | 文件 | 职责 |
47
52
  |------|------|
48
- | `src/registry.ts` | 服务器注册表:eemeli `yaml` Document API 读写 insert 行 + `loadOverlayPatches` 校验 + serverName 唯一 |
49
- | `src/tools.ts` | agent 面 `mcp_*` ×4 工具(defineTool,规范 JSON 输出) |
53
+ | `src/registry.ts` | 服务器注册表:eemeli `yaml` Document API 读写 insert 行 + `loadOverlayPatches` 校验 + serverName 唯一 + entry-level `disabled` 字段 |
54
+ | `src/tools.ts` | agent 面 `mcp_*` ×5 工具(defineTool,规范 JSON 输出) |
50
55
  | `src/index.ts` | Node half:`/api/mcp-manager` 路由 + `ctx.tools.schemas()` 过滤 + mcp 工具注册 |
51
56
  | `src/client/index.ts` | client half:`settings.section` 注册「MCP」面板 |
52
- | `src/client/Panel.tsx` | 面板 UI:服务器列表 + 增删改表单 + 工具浏览 |
57
+ | `src/client/Panel.tsx` | 面板 UI:服务器列表 + 增删改表单(内联卡片下方)+ 禁用/启用 + 工具浏览 |
53
58
 
54
59
  ### 数据模型
55
60
 
@@ -59,6 +64,7 @@ pnpm build # tsdown 双 bundle:lib/index.mjs(Node half)+ lib/index.j
59
64
  - insert:
60
65
  - id: mcp-github # 行 id(mcp-<serverName>)
61
66
  name: '@deepseek-ai/dsh-mcp-client'
67
+ disabled: true # 可选 entry-level 字段:loader 跳过挂载,工具不注册,config 保留
62
68
  config:
63
69
  serverName: github # 工具命名空间 mcp__github__*
64
70
  transport: stdio # stdio | streamable-http
@@ -71,6 +77,8 @@ pnpm build # tsdown 双 bundle:lib/index.mjs(Node half)+ lib/index.j
71
77
 
72
78
  - 支持 `stdio`(command/args/env/cwd)与 `streamable-http`(url/headers)。
73
79
  - 编辑 = 整块替换 config(不深合并,与 loader patch 语义一致)。
80
+ - **禁用** = 设置 entry-level `disabled: true`(与 id/name/config 同级,不在 config 内)。
81
+ loader 跳过挂载 → 工具不注册 → 模型不可见;启用 = 移除该字段。
74
82
  - 写前用 eemeli yaml 解析 + 可选 `loadOverlayPatches`(app-boot)校验;写后失败自动回滚。
75
83
  - **保留**其他行的 `!!js` 表达式与注释(eemeli Document API 往返保留)。
76
84
 
@@ -90,19 +98,24 @@ dsh plugin --profile web add "github:dsh-external/dsh-mcp-manager"
90
98
 
91
99
  ### 使用
92
100
 
93
- - **GUI**:设置页 → 「MCP」面板。新增/编辑/删除服务器;点击「工具」展开该服务器的 `mcp__*` 工具列表。
94
- - **Agent**:模型可调用 `mcp_server_list` / `mcp_server_add` / `mcp_server_update` / `mcp_server_remove`。
101
+ - **GUI**:设置页 → 「MCP」面板。
102
+ - 新增/编辑/删除服务器;编辑表单内联在对应卡片下方(不在全局底部)。
103
+ - 禁用/启用服务器(不删除配置;禁用后 loader 跳过挂载,工具不注册,模型不可见)。
104
+ - 点击「工具」展开该服务器的 `mcp__*` 工具列表(禁用状态下不可展开)。
105
+ - **Agent**:模型可调用 `mcp_server_list` / `mcp_server_add` / `mcp_server_update` /
106
+ `mcp_server_remove` / `mcp_server_set_enabled`。
95
107
 
96
108
  ### API 路由
97
109
 
98
110
  | 路由 | 方法 | 说明 |
99
111
  |------|------|------|
100
- | `/api/mcp-manager/servers` | GET | 列出服务器 + 工具数 + 状态 |
112
+ | `/api/mcp-manager/servers` | GET | 列出服务器 + 工具数 + 状态 + disabled |
101
113
  | `/api/mcp-manager/servers` | POST | 新增(body: `{config}`)→ HMR 挂载 |
102
114
  | `/api/mcp-manager/servers/<id>` | PUT | 编辑(整块替换 config) |
115
+ | `/api/mcp-manager/servers/<id>` | PATCH | 禁用/启用(body: `{disabled: boolean}`;config 保留) |
103
116
  | `/api/mcp-manager/servers/<id>` | DELETE | 删除 |
104
117
  | `/api/mcp-manager/tools` | GET | 工具浏览(`mcp__` 前缀按 serverName 分组) |
105
- | `/api/mcp-manager/status` | GET | 运行态状态 |
118
+ | `/api/mcp-manager/status` | GET | 运行态状态(含 disabled) |
106
119
 
107
120
  ### Secret 处理
108
121
 
@@ -121,7 +134,7 @@ README 明确警示:勿放长期密钥;部署隔离。P1 可接 `@deepseek-a
121
134
  - [x] **A4**:Config 校验用 `validateServerConfig`(fail loud,携带字段名)
122
135
  - [x] **A6**:不导出 default
123
136
  - [x] **C4**:工具返回规范 JSON 值 + render 投影分离
124
- - [x] **G**:测试分层(Unit:27 用例覆盖增删改/唯一/非法拒绝/!!js 保留/空文件/多行)
137
+ - [x] **G**:测试分层(Unit:35 用例覆盖增删改/禁用/唯一/非法拒绝/!!js 保留/空文件/多行)
125
138
  - [x] **README**:含开发/运行/检查三节
126
139
 
127
140
  ### 预构建策略说明