dsh-mcp-manager-plus 0.4.5 → 0.5.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.
- package/CHANGELOG.md +109 -0
- package/README.en.md +148 -6
- package/README.md +114 -7
- package/lib/client.js +403 -52
- package/lib/index.js +821 -20
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,112 @@
|
|
|
5
5
|
|
|
6
6
|
0.3.1 之前的开发发生在公开仓库建立之前,历史没有保留。
|
|
7
7
|
|
|
8
|
+
## [0.5.2] - 2026-11-21
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- **连接彻底失败的行仍显示「已连接」,与「0 个工具」自相矛盾**
|
|
13
|
+
([#6](https://github.com/appthin/dsh-mcp-manager-plus/issues/6)):状态徽章原来取的是
|
|
14
|
+
Cordis fiber 的生命周期(`FIBER_PHASE[2] = 'active'`),它只回答「插件条目挂载
|
|
15
|
+
成功了吗」。MCP 子进程是条目加载**之后**才 spawn 的,进程起不来、握手失败、
|
|
16
|
+
鉴权失败都不会回头改 `fiber.state`,于是 `chrome-devtools-mcp` 这种「Node 版本
|
|
17
|
+
不满足 engines、npx 一启动就退出」的服务器稳定显示「已连接 · 0 个工具」,而宿主
|
|
18
|
+
侧实际报 `server is disconnected`。
|
|
19
|
+
- 现在优先读 `dsh-mcp-client` 自己的连接状态(`connectionStatusOf(fiber)` →
|
|
20
|
+
`failed` / `closed` / `connecting` / `reconnecting` / `waiting-credentials` /
|
|
21
|
+
`connected`),映射成「连接失败 / 已断开 / 连接中 / 重连中 / 缺少凭据 / 已连接」,
|
|
22
|
+
失败原因与重连进度作为悬停提示。状态单元是 `WeakMap` 按 fiber 存的,所以按
|
|
23
|
+
**裸导入 → loader 内部 import → 各解析锚点(profile、插件目录、`app.asar/dsh`)**
|
|
24
|
+
依次尝试,拿到哪个副本就用哪个;**新旧两代 `dsh-mcp-client` 都能兼容**(老副本
|
|
25
|
+
没有这个导出,直接跳过)。
|
|
26
|
+
- 读不到状态时按工具数兜底:**已启用 + 已挂载 + 0 个工具**降级为「可能未连接」
|
|
27
|
+
(黄点),不再声称已连接;已有工具的行不加这个字段,因为工具注册本身已证明
|
|
28
|
+
握手成功过。
|
|
29
|
+
- 顺带修掉两处同源的矛盾:「已启用 ✓」在连接确认断开时不再绘制(原来它和
|
|
30
|
+
「连接失败」并排出现);展开后的空态在握手已确认时改用「服务器已连接,但未提供
|
|
31
|
+
任何工具」,不再用「可能未连接」的含糊说法。
|
|
32
|
+
- `live.phase` 的含义与取值**保持不变**(仍是对条目生命周期的回答),新增的
|
|
33
|
+
真实状态放在 `live.connection`,旧前端与旧测试不受影响。
|
|
34
|
+
- 回归用例 7 项(测试总数 149 → 157):握手失败但 fiber 为 `active`、确认连接且
|
|
35
|
+
0 工具不降级、无状态可读且 0 工具的兜底、有工具时不加字段、已停用行不报连接
|
|
36
|
+
问题,以及客户端侧的状态映射、勾选条件与空态文案。测试通过
|
|
37
|
+
`DSH_MCP_MANAGER_STATUS_MODULE` 注入一个假的桥接模块,不依赖真机安装的包。
|
|
38
|
+
- **行预览工具丢掉 `style` 对象**(仅开发脚本 `tools/preview-row.mjs`):序列化
|
|
39
|
+
JSX 树时把 `style={{...}}` 整个跳过,头像的底色是行内样式,于是预览页渲染成
|
|
40
|
+
白字白底,任何按预览页做对比度检查都会误报 1:1。现在会把样式对象写成内联
|
|
41
|
+
CSS,预览与真实渲染一致。
|
|
42
|
+
|
|
43
|
+
## [0.5.0] - 2026-11-11
|
|
44
|
+
|
|
45
|
+
### Added
|
|
46
|
+
|
|
47
|
+
- **项目绑定**:把某个 MCP 服务器限定在指定的项目目录里,其它项目看不到、也调不动
|
|
48
|
+
它的工具;清空路径即恢复全局可用。
|
|
49
|
+
- 页面每行新增「项目绑定」入口(bundle 提供的行也可以绑,因为绑定表是本插件
|
|
50
|
+
自己的数据);弹窗每行填一个绝对路径,列表上以标签显示当前状态
|
|
51
|
+
(「全局可用」/「仅限 N 个项目」),展开服务器时也有一条绑定摘要;
|
|
52
|
+
已有绑定再点一次会预填当前路径,改完即生效;
|
|
53
|
+
- 新增宿主路由 `POST /mcp-manager-plus/bind`;清单投影为每个服务器带上
|
|
54
|
+
`binding: { paths, restricted }`,并回传绑定文件路径 `bindingsPath`;
|
|
55
|
+
- 绑定数据写在
|
|
56
|
+
`$DSH_HOME/profiles/<profile>/plugin-data/dsh-mcp-manager-plus/bindings.json`
|
|
57
|
+
(可用环境变量 `DSH_MCP_MANAGER_BINDINGS` 指向别处)。**刻意不写补丁层**:
|
|
58
|
+
补丁层决定运行中的插件树,写进去意味着每改一次绑定都要重新编排整棵树、重挂
|
|
59
|
+
所有 MCP 连接;绑定只是本插件的数据,改完在运行中的进程里立刻生效;
|
|
60
|
+
- 执行分两层:**会话作用域**的 `ctx.tools.restrict()` 把工具从该会话的可见集合里
|
|
61
|
+
摘掉(所以工具列表里直接看不到),**根作用域**的 `ctx.tools.guard()` 再拦一次
|
|
62
|
+
调用 —— 守卫在可扩展的 `tools/pre-execute` 放行之后运行,且没有任何守卫能把
|
|
63
|
+
别人拒绝的调用改回允许,因此就算模型硬报一个工具名也执行不了;
|
|
64
|
+
- 在 `agent/created` 与 `agent/pre-step` 两处同步:新会话、已经开着的会话、
|
|
65
|
+
中途换了工作目录的会话都会被重新判定。目录取值顺序是
|
|
66
|
+
`workingDirectory.get(session)` → 会话头的 `cwd` → `workingDirectory.defaultDirectory`;
|
|
67
|
+
- 匹配规则:只认绝对路径,`~` 展开为主目录,Windows 下大小写不敏感、`/` 与 `\`
|
|
68
|
+
等价、结尾分隔符可有可无;判定「就是它或在它下面」,所以绑定 `E:\work\alpha`
|
|
69
|
+
不会放过名字只差前缀的兄弟目录 `E:\work\alphabeta`;
|
|
70
|
+
- 有意留的边界(都写进了 README):工作目录判断不出来时不拦截(宁可少拦一次,
|
|
71
|
+
也不误伤);`bindings.json` 缺失或损坏时按「没有绑定」处理,一次坏编辑不会让
|
|
72
|
+
服务器在所有项目里都用不了;绑定按 **serverName** 记录,与补丁层的行 `id` 无关。
|
|
73
|
+
- 回归用例 18 项(测试总数 131 → 149)。项目绑定 14 项:清单投影与绑定文件不因读取
|
|
74
|
+
而创建、绑定落盘与解除、路径归一化与去重、相对路径被拒、未知服务器被拒、守卫的
|
|
75
|
+
放行/拒绝(含大小写、子目录、前缀兄弟目录、无会话、非 MCP 工具名、带下划线的
|
|
76
|
+
serverName)、`agent/created` 与 `agent/pre-step` 的按会话限制与去重、改绑定后对
|
|
77
|
+
活动会话的回收、目录判断不出来时两侧一致地不拦截、绑定文件损坏时照常可用,以及
|
|
78
|
+
声明过的 effect 在 dispose 时全部撤销。图标按钮 4 项:四个动作共用同一个构造函数、
|
|
79
|
+
三处标签载体齐备、样式表真的把 `data-tip` 画成提示且不参与命中;用户行不再渲染
|
|
80
|
+
「配置文件」且该字典项已删除;绑定状态紧跟工具数量、来源标签只出现在非用户行;
|
|
81
|
+
卡片不裁切、底角仍圆、悬停抬起。
|
|
82
|
+
- 三个预览脚本,用真实组件与真实样式表把这一块渲染成静态页,便于目测:
|
|
83
|
+
`tools/preview-row.mjs`(各种行形态)、`tools/preview-actions.mjs`(逐个按钮 +
|
|
84
|
+
3× 放大)、`tools/preview-tips.mjs`(提示越界与底角)。
|
|
85
|
+
- 重新截了 `screenshot1.jpg` / `screenshot5.jpg`,它们现在显示图标按钮与绑定状态。
|
|
86
|
+
|
|
87
|
+
### Changed
|
|
88
|
+
|
|
89
|
+
- **每行的操作按钮改为图标按钮**:编辑、重启、删除、项目绑定四个动作现在只画图标
|
|
90
|
+
(铅笔 / 圆箭头 / 垃圾桶 / 带锁的文件夹),文字移到悬停提示里。名称同时写在
|
|
91
|
+
`title`、`aria-label` 与 `data-tip` 上:`aria-label` 是读屏用的无障碍名称,
|
|
92
|
+
`title` 是触控与不支持 CSS 时的原生提示,`data-tip` 由样式表画出更快、可截图的
|
|
93
|
+
提示气泡(原生 `title` 要等约一秒)。提示在键盘聚焦时同样出现,且
|
|
94
|
+
`pointer-events:none`,不会把触发它的悬停吃掉。按钮尺寸与原来一样是
|
|
95
|
+
30×26(`.mcpmp-icon` 定宽,`.mcpmp-btn-sm` 定高),不会因为只剩图标而变小。
|
|
96
|
+
- **行尾那个「配置文件」标签去掉了**:用户自己的服务器是最常见的一行,这个标签只是
|
|
97
|
+
把有用信息挤到第二行的噪音;服务器来源只对 bundle 行与内置行还有意义,所以它们的
|
|
98
|
+
「部署内置」/「内置能力」标签保留。空出来的位置改放**项目绑定状态**
|
|
99
|
+
(「全局可用」/「仅限 N 个项目」),已绑定时标签文字变绿、悬停可看目录;
|
|
100
|
+
字典里随之失效的 `sourceUser` 已删除(中英两处)。
|
|
101
|
+
- `inject` 由 `['webServer']` 变为 `['webServer', 'tools']`:守卫与按会话限制就是本
|
|
102
|
+
特性的执行方式,声明成硬依赖会让插件在缺少 `tools` 时停泊,而不是「挂载了却没有
|
|
103
|
+
执行者」。
|
|
104
|
+
- README.md / README.en.md 增补「服务器行」与「项目绑定」两节、更新截图说明,
|
|
105
|
+
并写明它不是沙箱、以及上面那些有意留的边界。
|
|
106
|
+
|
|
107
|
+
### Fixed
|
|
108
|
+
|
|
109
|
+
- **悬停提示会被卡片裁掉**:`.mcpmp-card` 原本靠 `overflow:hidden` 给底角收圆,
|
|
110
|
+
而图标按钮的提示要画在按钮上方、越出卡片边界,于是被裁成两半。现在卡片不再裁切,
|
|
111
|
+
底角改由 `> *:last-child` 自己承担;卡片同时建立堆叠上下文,悬停时抬高一层,
|
|
112
|
+
提示不会被上面那张卡片盖住。
|
|
113
|
+
|
|
8
114
|
## [0.4.5] - 2026-11-08
|
|
9
115
|
|
|
10
116
|
### Fixed
|
|
@@ -174,6 +280,9 @@
|
|
|
174
280
|
JSON 编辑、宿主路由、bundle 加载、profile 组合与真实 profile 只读验证;
|
|
175
281
|
另附 e2e 导入、往返校验、图标预览等辅助脚本
|
|
176
282
|
|
|
283
|
+
[0.5.2]: https://github.com/appthin/dsh-mcp-manager-plus/compare/v0.5.0...v0.5.2
|
|
284
|
+
[0.5.0]: https://github.com/appthin/dsh-mcp-manager-plus/compare/v0.4.5...v0.5.0
|
|
285
|
+
[0.4.5]: https://github.com/appthin/dsh-mcp-manager-plus/compare/v0.4.4...v0.4.5
|
|
177
286
|
[0.4.4]: https://github.com/appthin/dsh-mcp-manager-plus/compare/v0.4.3...v0.4.4
|
|
178
287
|
[0.4.3]: https://github.com/appthin/dsh-mcp-manager-plus/compare/v0.4.2...v0.4.3
|
|
179
288
|
[0.4.2]: https://github.com/appthin/dsh-mcp-manager-plus/compare/v0.4.1...v0.4.2
|
package/README.en.md
CHANGED
|
@@ -4,7 +4,8 @@ English | [中文](README.md) | [Changelog](CHANGELOG.md)
|
|
|
4
4
|
|
|
5
5
|
An MCP server manager plugin for DeepSeek Harness: it adds an "MCP" page to the
|
|
6
6
|
settings sidebar, where you can inspect, enable/disable, edit, restart, delete
|
|
7
|
-
and add MCP servers
|
|
7
|
+
and add MCP servers — and **bind a server to specific project directories** so
|
|
8
|
+
that only those projects can use it.
|
|
8
9
|
|
|
9
10
|
Why this plugin exists:
|
|
10
11
|
|
|
@@ -17,11 +18,15 @@ If this plugin stops working on a newer DSH release, please open an issue.
|
|
|
17
18
|
## Screenshots
|
|
18
19
|
|
|
19
20
|
**Settings → MCP**: the server list, connection state and enable/disable toggles.
|
|
21
|
+
Each row's edit / restart / delete / project-binding actions are icon buttons whose
|
|
22
|
+
labels appear on hover; the second line carries the connection state, the tool
|
|
23
|
+
count and the project-binding state.
|
|
20
24
|
|
|
21
25
|

|
|
22
26
|
|
|
23
27
|
**Expand a server**: every tool the server currently registers with the model,
|
|
24
|
-
with descriptions.
|
|
28
|
+
with descriptions. An expanded row also opens with a project-binding summary
|
|
29
|
+
listing the directories it is restricted to.
|
|
25
30
|
|
|
26
31
|

|
|
27
32
|
|
|
@@ -105,9 +110,71 @@ profile patch layer — that is your configuration data and will not be deleted.
|
|
|
105
110
|
| Edit | Two switchable modes: **form** (field by field) or **JSON** (one large textarea), see below |
|
|
106
111
|
| Restart | Destroys and re-initializes the server's connection in place (config unchanged); for recovering from dropped connections |
|
|
107
112
|
| Delete | Removes the server and all of its override rows from the config file |
|
|
113
|
+
| Icon actions | Each row's edit / restart / delete / project-binding actions are **icon buttons**; hovering (or reaching them with Tab) shows the label, which is also carried in `aria-label` for screen readers |
|
|
108
114
|
| Add | Paste an MCP configuration from **any mainstream tool**; the format is detected, and multiple servers per paste are supported (see table below) |
|
|
115
|
+
| Project binding | Restrict a server to a few project directories: sessions in other projects never see its tools and calls to them are refused. Takes effect on save, without touching the MCP connection (see below) |
|
|
109
116
|
| Bilingual | Chinese / English. Defaults to the harness UI language (falling back to the browser's language when unavailable); switch anytime from the page header — the choice is remembered, and host-side messages follow along |
|
|
110
117
|
|
|
118
|
+
## The server row
|
|
119
|
+
|
|
120
|
+
A row answers "how is this server doing right now", read left to right and top to
|
|
121
|
+
bottom:
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
⌄ [D] dbx ✓
|
|
125
|
+
● Connected 25 tools All projects
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
- **⌄** expands or collapses the server's tool list;
|
|
129
|
+
- the **square avatar** holds the server name's first letter, coloured from the
|
|
130
|
+
name — a different name gets a different colour, which makes a long list
|
|
131
|
+
scannable;
|
|
132
|
+
- **dbx ✓** is the server name; the check means it is enabled (it is withheld
|
|
133
|
+
while the connection is known to be down — see below);
|
|
134
|
+
- the second line carries the **connection state** (Connected / Connecting /
|
|
135
|
+
Reconnecting / Pending / Failed / Disconnected / Missing credentials / May be
|
|
136
|
+
disconnected / Unloading / Disabled), the **tool count**, and the
|
|
137
|
+
**project-binding state** (`All projects`, or `Bound to N project(s)`). A bound
|
|
138
|
+
row paints that chip's **text** green, and hovering it lists the bound
|
|
139
|
+
directories;
|
|
140
|
+
- the badge reports the **MCP handshake**, not "the plugin entry mounted". A
|
|
141
|
+
child process that never starts, a failed handshake or a failed auth all happen
|
|
142
|
+
after the entry loaded, so the entry stays `active` forever — which is how a
|
|
143
|
+
row could claim "Connected · 0 tools"
|
|
144
|
+
([#6](https://github.com/appthin/dsh-mcp-manager-plus/issues/6)). The order is
|
|
145
|
+
now:
|
|
146
|
+
1. use the connection state from `dsh-mcp-client` when it can be read:
|
|
147
|
+
`failed` → Failed, `closed` → Disconnected, `connecting` / `reconnecting` →
|
|
148
|
+
Connecting / Reconnecting, `waiting-credentials` → Missing credentials,
|
|
149
|
+
`connected` → Connected;
|
|
150
|
+
2. when it cannot be read, an **enabled, mounted row exposing zero tools**
|
|
151
|
+
degrades to "May be disconnected" (amber dot) instead of claiming a
|
|
152
|
+
connection; a row with tools gets no such field, because registered tools
|
|
153
|
+
already prove the handshake happened.
|
|
154
|
+
|
|
155
|
+
Failure details (`spawn ENOENT` and friends) and reconnect progress go in the
|
|
156
|
+
badge's hover title.
|
|
157
|
+
- the far right is the **enable/disable switch**, preceded by up to four icon
|
|
158
|
+
buttons (which ones a row has depends on what it can do, see the table):
|
|
159
|
+
|
|
160
|
+
| Icon | Action | Notes |
|
|
161
|
+
| --- | --- | --- |
|
|
162
|
+
| Pencil | Edit | Opens the edit dialog (form / JSON modes); only on rows from the config file |
|
|
163
|
+
| Circular arrow | Restart | Reconnects in place, configuration unchanged; shown only while the server is mounted |
|
|
164
|
+
| Bin (red) | Delete | Removes the row and its override rows from the config file; only on rows from the config file |
|
|
165
|
+
| Locked folder | Project binding | Opens the binding dialog; its outline turns green once bound. Shown whenever the row has a serverName |
|
|
166
|
+
|
|
167
|
+
The buttons are icons only, with their names in a hover tooltip. So that a mouse
|
|
168
|
+
is not required, the name is carried in three places: `aria-label` (the
|
|
169
|
+
accessible name), `title` (the native tooltip for touch and for anything that
|
|
170
|
+
ignores CSS), and `data-tip` (the tooltip the stylesheet paints immediately —
|
|
171
|
+
the native `title` waits about a second).
|
|
172
|
+
|
|
173
|
+
Deployment-provided and built-in rows cannot be edited or deleted, so they carry
|
|
174
|
+
only restart and project-binding, plus a source tag at the end of the second line
|
|
175
|
+
(`Deployment` / `Built-in`). **Servers you added yourself no longer show a
|
|
176
|
+
"Config file" style tag** — that slot now holds the more useful binding state.
|
|
177
|
+
|
|
111
178
|
## The two edit modes
|
|
112
179
|
|
|
113
180
|
When editing an existing server, the dialog header carries a **segmented
|
|
@@ -208,6 +275,68 @@ the plugin tree within about a second of each save, so config changes are both
|
|
|
208
275
|
tree; it only writes the file, then the browser briefly polls to observe the
|
|
209
276
|
converged state.
|
|
210
277
|
|
|
278
|
+
## Project binding
|
|
279
|
+
|
|
280
|
+
MCP servers are globally available to the whole DSH instance by default. If you
|
|
281
|
+
want a server to exist in **one project only**, click the **locked-folder icon**
|
|
282
|
+
at the right of its row (its tooltip reads "Project binding") and list one
|
|
283
|
+
absolute project directory per line:
|
|
284
|
+
|
|
285
|
+
```
|
|
286
|
+
D:\work\my-project
|
|
287
|
+
~/work/another-project
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
Once saved:
|
|
291
|
+
|
|
292
|
+
- Only sessions whose **working directory is one of those directories (or inside
|
|
293
|
+
one)** can see and call its tools;
|
|
294
|
+
- In every other project its tools **do not appear in the tool list at all**
|
|
295
|
+
(they are filtered per session), and even if a model insists on a name, the
|
|
296
|
+
call is refused before execution with a message naming the bound directories;
|
|
297
|
+
- Sessions that are already open are re-evaluated immediately — no dsh restart,
|
|
298
|
+
and the MCP connection itself is never touched;
|
|
299
|
+
- An existing binding can be changed at any time by clicking that icon again; the
|
|
300
|
+
dialog opens pre-filled with its current paths;
|
|
301
|
+
- Clearing every path **removes the binding**, returning the server to
|
|
302
|
+
"available everywhere".
|
|
303
|
+
|
|
304
|
+
Matching rules (`pathKey` / `isWithin` in `lib/index.js`):
|
|
305
|
+
|
|
306
|
+
- Only **absolute paths** are accepted; `~` expands to the current user's home
|
|
307
|
+
directory. A relative path is refused with a reason;
|
|
308
|
+
- On Windows matching is case-insensitive, `/` and `\` are equivalent, and a
|
|
309
|
+
trailing separator is optional;
|
|
310
|
+
- The test is "is it this directory, or below it", so binding `E:\work\alpha`
|
|
311
|
+
does **not** let the name-prefix sibling `E:\work\alphabeta` through.
|
|
312
|
+
|
|
313
|
+
Bindings live in **this plugin's own file**, not in the patch layer:
|
|
314
|
+
|
|
315
|
+
```
|
|
316
|
+
$DSH_HOME/profiles/<profile>/plugin-data/dsh-mcp-manager-plus/bindings.json
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
(override with the `DSH_MCP_MANAGER_BINDINGS` environment variable). Keeping them
|
|
320
|
+
out of the patch layer is deliberate: that layer composes the running plugin
|
|
321
|
+
tree, so a binding written there would remount every MCP connection on each
|
|
322
|
+
edit. Bindings are just plugin data, and an edit applies immediately in the
|
|
323
|
+
running process.
|
|
324
|
+
|
|
325
|
+
Deliberate limits, so you know what you are getting:
|
|
326
|
+
|
|
327
|
+
- **It is not a sandbox.** What it restricts is *which tools a model can see and
|
|
328
|
+
call*. The MCP server process and its connection still exist (the config row
|
|
329
|
+
remains global); only this session's visibility of, and access to, its tools
|
|
330
|
+
is constrained.
|
|
331
|
+
- **When the working directory cannot be determined, nothing is blocked**
|
|
332
|
+
(fail-open): better to miss a block than to lock a user out of their own
|
|
333
|
+
project.
|
|
334
|
+
- **A damaged or missing `bindings.json` reads as "no bindings"**, i.e. back to
|
|
335
|
+
globally available — one bad edit cannot make a server unusable everywhere.
|
|
336
|
+
- A binding is keyed by **serverName**, independent of the row's `id` in the
|
|
337
|
+
patch layer; renaming the server (a new serverName) is a different server and
|
|
338
|
+
must be bound again.
|
|
339
|
+
|
|
211
340
|
## Security model
|
|
212
341
|
|
|
213
342
|
- **Loopback only.** The API lives on the same loopback web server; non-loopback
|
|
@@ -223,11 +352,15 @@ converged state.
|
|
|
223
352
|
browser echoes them back; real secrets never appear on the page.
|
|
224
353
|
- **Bundle-provided servers are read-only.** Rows contributed by the bundle
|
|
225
354
|
layer can be enabled/disabled but not edited or deleted.
|
|
355
|
+
- **Project bindings only ever hold local data.** The binding table is served by
|
|
356
|
+
the same loopback API, accepts absolute paths only, and is re-parsed before
|
|
357
|
+
writing; it never enters the patch layer, so editing a binding cannot affect
|
|
358
|
+
how the plugin tree is composed.
|
|
226
359
|
|
|
227
360
|
## Development
|
|
228
361
|
|
|
229
362
|
```sh
|
|
230
|
-
node test/run.mjs # all eight suites (
|
|
363
|
+
node test/run.mjs # all eight suites (149 assertions)
|
|
231
364
|
```
|
|
232
365
|
|
|
233
366
|
| Suite | Coverage |
|
|
@@ -236,8 +369,8 @@ node test/run.mjs # all eight suites (127 assertions)
|
|
|
236
369
|
| `test/yaml.test.mjs` | the `js-yaml` compatibility layer: capability probing, skipping an incompatible copy, and `!!js` fidelity under the degraded parser |
|
|
237
370
|
| `test/import.test.mjs` | config formats of 14 tools, the TOML subset, JSON comments and trailing commas |
|
|
238
371
|
| `test/editjson.test.mjs` | JSON-mode editing: in-place updates, renames keeping id and overrides, multi-server rejection |
|
|
239
|
-
| `test/host.test.mjs` | every host-side HTTP route, driving the real `apply()` through a fake Cordis context |
|
|
240
|
-
| `test/client.test.mjs` | whether the shell can load the browser bundle and register the settings page
|
|
372
|
+
| `test/host.test.mjs` | every host-side HTTP route, driving the real `apply()` through a fake Cordis context; project-binding guard denials and per-session tool restrictions included |
|
|
373
|
+
| `test/client.test.mjs` | whether the shell can load the browser bundle and register the settings page; the mode switch, the icon buttons' three label carriers, and that the card does not clip its tooltips |
|
|
241
374
|
| `test/compose.test.mjs` | composing a real profile from the bundle layer, confirming this plugin's rows mount |
|
|
242
375
|
| `test/live.test.mjs` | read-only run against the real profile, confirming live configs read correctly with secrets masked |
|
|
243
376
|
|
|
@@ -245,11 +378,17 @@ The tests use no test framework — just Node's built-in `node:test` — and reu
|
|
|
245
378
|
the `js-yaml` from the profile (the same parse path as the runtime, compatibility
|
|
246
379
|
layer in `lib/yaml.js` included).
|
|
247
380
|
|
|
381
|
+
> One case in `test/compose.test.mjs` composes the real profile's plugin tree and
|
|
382
|
+
> asserts that no two bundles insert the same row id. It reads the profile on
|
|
383
|
+
> **this machine**, so if two installed plugins collide on an id that case fails
|
|
384
|
+
> — that is a problem with your profile, not a regression in this plugin, and the
|
|
385
|
+
> failure names the colliding id.
|
|
386
|
+
|
|
248
387
|
### Layout
|
|
249
388
|
|
|
250
389
|
| File | Purpose |
|
|
251
390
|
| --- | --- |
|
|
252
|
-
| `lib/index.js` | host side: HTTP API, inventory projection, write operations |
|
|
391
|
+
| `lib/index.js` | host side: HTTP API, inventory projection, write operations, and project-binding storage plus enforcement |
|
|
253
392
|
| `lib/import.js` | import parsing: each tool's config format → this plugin's server shape |
|
|
254
393
|
| `lib/patch.js` | patch-layer read/write: segmentation, parsing, validation, generation |
|
|
255
394
|
| `lib/yaml.js` | `js-yaml` compatibility: capability probing, skipping an incompatible copy, and a degraded parser when no copy can carry the custom type |
|
|
@@ -265,6 +404,9 @@ layer in `lib/yaml.js` included).
|
|
|
265
404
|
| `node tools/check-client-bundle.mjs` | loads the client bundle the way the shell does and checks the registration result and nav-icon CSS |
|
|
266
405
|
| `node tools/check-segmented.mjs` | checks the segmented switch's slider geometry (inset, half-width, offset) against the track assumptions |
|
|
267
406
|
| `node tools/preview-edit-modes.mjs` | renders both edit-dialog modes with the real components into `edit-modes-preview.html` |
|
|
407
|
+
| `node tools/preview-row.mjs` | renders every shape of server row (user / bundle / builtin / disabled / bound / expanded) into `row-preview.html` |
|
|
408
|
+
| `node tools/preview-actions.mjs` | renders each icon button with its tooltip, one at a time and at 3×, into `actions-preview.html` |
|
|
409
|
+
| `node tools/preview-tips.mjs` | checks that a tooltip escapes the card, that the last button's tip stays right-aligned, and that the bottom corners survive without `overflow:hidden`, into `tips-preview.html` |
|
|
268
410
|
| `node tools/check-nav-icon.mjs` | checks that the nav icon's mask payload is a drawable 16×16 template |
|
|
269
411
|
| `node tools/gen-icon-preview.cjs` | extracts icons from the dsh web bundle into the `icon-options.html` comparison page |
|
|
270
412
|
| `node tools/dump-icon.cjs <IconName>` | prints an icon's SVG path for hand-written overrides |
|
package/README.md
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
[English](README.en.md) | 中文 | [更新日志](CHANGELOG.md)
|
|
4
4
|
|
|
5
5
|
MCP 服务器管理插件:在 DeepSeek Harness 设置界面的左侧边栏新增「MCP 管理」页面,
|
|
6
|
-
可直接查看、启用/停用、编辑、重启、删除与添加 MCP
|
|
6
|
+
可直接查看、启用/停用、编辑、重启、删除与添加 MCP 服务器,
|
|
7
|
+
也可以把某个服务器**绑定到指定项目目录**,让它只在那些项目里可用。
|
|
7
8
|
|
|
8
9
|
为什么要开发这个插件?
|
|
9
10
|
- 为了方便管理 DeepSeek Harness 中的 MCP 服务器,无需打开配置文件。
|
|
@@ -13,11 +14,13 @@ MCP 服务器管理插件:在 DeepSeek Harness 设置界面的左侧边栏新
|
|
|
13
14
|
|
|
14
15
|
## 截图
|
|
15
16
|
|
|
16
|
-
**设置 → MCP
|
|
17
|
+
**设置 → MCP 管理**:服务器列表、连接状态与启停开关。每行的编辑 / 重启 / 删除 /
|
|
18
|
+
项目绑定都是图标按钮,悬停显示名称;第二行依次是连接状态、工具数、以及项目绑定状态。
|
|
17
19
|
|
|
18
20
|

|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
**展开服务器**:查看该服务器当前注册到模型的全部工具及描述;展开后顶部还会有一条
|
|
23
|
+
项目绑定摘要,列出它被限定在哪些目录。
|
|
21
24
|
|
|
22
25
|

|
|
23
26
|
|
|
@@ -89,9 +92,55 @@ MCP 服务器行会原样保留——它们是你的配置数据,不会被连
|
|
|
89
92
|
| 编辑 | 两种模式可随时切换:**表单**(逐字段)或 **JSON**(大输入框),见下节 |
|
|
90
93
|
| 重启 | 就地销毁并重新初始化该服务器的连接(配置不变),用于连接中断后恢复 |
|
|
91
94
|
| 删除 | 从配置文件中移除该服务器及其所有覆盖行 |
|
|
95
|
+
| 图标操作 | 每行的编辑 / 重启 / 删除 / 项目绑定都是**图标按钮**,鼠标移上去(或键盘 Tab 聚焦)显示文字提示;名称同时写在 `aria-label` 里,读屏能读到 |
|
|
92
96
|
| 添加 | 粘贴**任意主流工具**的 MCP 配置即可,自动识别格式,支持一次导入多个(见下表) |
|
|
97
|
+
| 项目绑定 | 把某个服务器限定在几个项目目录里:其它项目的会话看不到它的工具,硬调也会被拒绝;保存即生效,不动 MCP 连接(见下节) |
|
|
93
98
|
| 多语言 | 中文 / English。默认跟随界面语言(取不到时按浏览器语言探测),页面右上角可随时切换并记住选择;宿主端的错误与提示文案同样跟随 |
|
|
94
99
|
|
|
100
|
+
## 服务器行
|
|
101
|
+
|
|
102
|
+
一行里放的是「这台服务器现在怎么样」,从上到下、从左到右:
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
⌄ [D] dbx ✓
|
|
106
|
+
● 已连接 25 个工具 全局可用
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
- **⌄** 展开 / 收起该服务器的工具列表;
|
|
110
|
+
- **方头像**里是服务名的首字母,颜色由服务名决定,换一个名字换一种颜色,便于扫视;
|
|
111
|
+
- **dbx ✓** 是服务名,后面那个勾表示已启用(连接已确认断开时不画这个勾,见下);
|
|
112
|
+
- 第二行依次是**连接状态**(已连接 / 连接中 / 重连中 / 等待中 / 连接失败 /
|
|
113
|
+
已断开 / 缺少凭据 / 可能未连接 / 卸载中 / 已停用)、**工具数**、以及
|
|
114
|
+
**项目绑定状态**(`全局可用` 或 `仅限 N 个项目`)。
|
|
115
|
+
已绑定时这个标签的**文字**会变成绿色,鼠标悬停可直接看到绑定的目录;
|
|
116
|
+
- 状态徽章读的是 **MCP 握手结果**,不是「插件条目挂载成功」。进程没起来、
|
|
117
|
+
握手失败、鉴权失败都发生在条目加载之后,条目本身一直是 `active`,所以
|
|
118
|
+
只按条目判断会出现「已连接 · 0 个工具」这种自相矛盾的行(
|
|
119
|
+
[#6](https://github.com/appthin/dsh-mcp-manager-plus/issues/6))。现在的取值顺序是:
|
|
120
|
+
1. 能读到 `dsh-mcp-client` 的连接状态就用它:`failed` → 连接失败、
|
|
121
|
+
`closed` → 已断开、`connecting` / `reconnecting` → 连接中 / 重连中、
|
|
122
|
+
`waiting-credentials` → 缺少凭据、`connected` → 已连接;
|
|
123
|
+
2. 读不到时,**已启用、已挂载、但工具数为 0** 的行降级为「可能未连接」
|
|
124
|
+
(黄点),不再声称已连接;有工具的行不加这个字段,因为工具已注册本身
|
|
125
|
+
就证明握手成功过。
|
|
126
|
+
失败原因(`spawn ENOENT` 之类)与重连进度写在徽章的悬停提示里。
|
|
127
|
+
- 行的最右边是**启用开关**;开关左边最多四个图标按钮(取决于该行能做什么,见下表):
|
|
128
|
+
|
|
129
|
+
| 图标 | 动作 | 说明 |
|
|
130
|
+
| --- | --- | --- |
|
|
131
|
+
| 铅笔 | 编辑 | 打开编辑弹窗(表单 / JSON 两种模式);仅出现在配置文件里的行 |
|
|
132
|
+
| 圆箭头 | 重启 | 就地重连,配置不变;仅在该服务器已挂载时出现 |
|
|
133
|
+
| 垃圾桶(红) | 删除 | 从配置文件移除该行及其覆盖行;仅出现在配置文件里的行 |
|
|
134
|
+
| 带锁文件夹 | 项目绑定 | 打开项目绑定弹窗;已绑定时描边变绿。只要该行有 serverName 就出现 |
|
|
135
|
+
|
|
136
|
+
按钮只画图标,名称在悬停提示里。为了不只依赖鼠标,名称同时写在三个地方:
|
|
137
|
+
`aria-label`(读屏用的无障碍名称)、`title`(触控与不支持 CSS 时的原生提示)、
|
|
138
|
+
`data-tip`(样式表画的即时气泡,原生 `title` 要等约一秒才出来)。
|
|
139
|
+
|
|
140
|
+
部署内置与内置能力的行不能编辑或删除,所以它们只有重启与项目绑定两个按钮,
|
|
141
|
+
并在第二行末尾多一个来源标签(`部署内置` / `内置能力`)——**你自己添加的服务器
|
|
142
|
+
不再显示「配置文件」这类来源标签**,那个位置留给了更有用的绑定状态。
|
|
143
|
+
|
|
95
144
|
## 编辑时的两种模式
|
|
96
145
|
|
|
97
146
|
编辑已有服务器时,弹窗标题右侧有一个**分段开关**(带图标、带滑动指示块,`radiogroup` 语义,
|
|
@@ -177,6 +226,54 @@ $DSH_HOME/profiles/<profile>/cordis.patch.yml
|
|
|
177
226
|
所以配置改动**既是持久化的,也是热生效的** —— 插件本身不改动运行中的 loader 树,
|
|
178
227
|
只写文件,然后由浏览器端短暂轮询观察收敛后的实际状态。
|
|
179
228
|
|
|
229
|
+
## 项目绑定
|
|
230
|
+
|
|
231
|
+
MCP 服务器默认在整个 DSH 实例里全局可用。如果你希望某个服务器**只在某个项目里
|
|
232
|
+
出现**,点该行最右边那个**带锁文件夹图标**(悬停提示「项目绑定」),每行填一个
|
|
233
|
+
项目目录的绝对路径:
|
|
234
|
+
|
|
235
|
+
```
|
|
236
|
+
D:\work\my-project
|
|
237
|
+
~/work/another-project
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
保存后:
|
|
241
|
+
|
|
242
|
+
- 只有**工作目录落在这几个目录里(含其子目录)的会话**能看到并调用它的工具;
|
|
243
|
+
- 其它项目的会话里,它的工具**不出现在工具列表里**(被按会话过滤掉了),
|
|
244
|
+
即使模型硬报一个名字,调用也会在执行前被拒绝,并说明它被绑定到了哪些目录;
|
|
245
|
+
- 已经开着的会话也会被立即重新判定,不需要重启 dsh,也不动 MCP 连接本身;
|
|
246
|
+
- 已有服务器的绑定**随时可改**:再点一次那个图标即可,弹窗里预填当前路径;
|
|
247
|
+
- 清空全部路径即为**解除绑定**,它又回到「全局可用」。
|
|
248
|
+
|
|
249
|
+
匹配规则(`lib/index.js` 的 `pathKey` / `isWithin`):
|
|
250
|
+
|
|
251
|
+
- 只认**绝对路径**;`~` 会展开成当前用户的主目录。相对路径会被拒绝并提示原因;
|
|
252
|
+
- Windows 下大小写不敏感,`/` 与 `\` 等价,结尾的分隔符可有可无;
|
|
253
|
+
- 判断的是「就是它,或在它下面」,所以绑定 `E:\work\alpha` **不会**放过
|
|
254
|
+
名字只差一个前缀的兄弟目录 `E:\work\alphabeta`。
|
|
255
|
+
|
|
256
|
+
绑定数据存在**本插件自己的文件**里,而不是补丁层:
|
|
257
|
+
|
|
258
|
+
```
|
|
259
|
+
$DSH_HOME/profiles/<profile>/plugin-data/dsh-mcp-manager-plus/bindings.json
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
(可用环境变量 `DSH_MCP_MANAGER_BINDINGS` 指向别处。)刻意不写进补丁层,是因为补丁层
|
|
263
|
+
决定运行中的插件树 —— 把绑定写进去意味着每改一次绑定就要重新编排整棵树、重挂所有
|
|
264
|
+
MCP 连接;而绑定只是本插件的数据,改完在运行中的进程里立刻生效。
|
|
265
|
+
|
|
266
|
+
有意的边界,请知悉:
|
|
267
|
+
|
|
268
|
+
- **它不是沙箱**,挡的是「模型能看到并调用的工具」。MCP 服务器进程与连接照常存在
|
|
269
|
+
(配置行仍是全局的),被限制的是这个会话对它的工具可见性与调用权。
|
|
270
|
+
- **工作目录判断不出来时不拦截**(宁可不拦,也不误伤):宁可少拦一次,也不要把
|
|
271
|
+
用户挡在自己项目之外。
|
|
272
|
+
- **`bindings.json` 损坏或缺失时按「没有绑定」处理**,即回到全局可用 ——
|
|
273
|
+
一次坏编辑不会让服务器在所有项目里都用不了。
|
|
274
|
+
- 绑定按 **serverName** 记录,与该行在补丁层里的 `id` 无关;改名(换 serverName)
|
|
275
|
+
等于换了一个服务器,需要重新绑定。
|
|
276
|
+
|
|
180
277
|
## 安全约定
|
|
181
278
|
|
|
182
279
|
- **只响应本机请求。** API 挂在同一个 loopback web server 上,非 loopback 来源直接 403。
|
|
@@ -187,11 +284,13 @@ $DSH_HOME/profiles/<profile>/cordis.patch.yml
|
|
|
187
284
|
- **凭据不外传。** 形如 `KEY|PASSWORD|SECRET|TOKEN` 的配置值在读取时被掩码,
|
|
188
285
|
浏览器回传掩码时再从原值还原,真实密钥不会出现在页面里。
|
|
189
286
|
- **部署内置的服务器只读。** 由 bundle 层提供的行可以停用/启用,但不能编辑或删除。
|
|
287
|
+
- **项目绑定只收本机数据。** 绑定表由同一个 loopback API 读写,同样只接受绝对路径,
|
|
288
|
+
写入前重解析;它不写入补丁层,因此不会因为一次绑定编辑而影响插件树的编排。
|
|
190
289
|
|
|
191
290
|
## 开发
|
|
192
291
|
|
|
193
292
|
```sh
|
|
194
|
-
node test/run.mjs # 全部八个测试套件(共
|
|
293
|
+
node test/run.mjs # 全部八个测试套件(共 149 项)
|
|
195
294
|
```
|
|
196
295
|
|
|
197
296
|
| 套件 | 覆盖范围 |
|
|
@@ -200,19 +299,24 @@ node test/run.mjs # 全部八个测试套件(共 127 项)
|
|
|
200
299
|
| `test/yaml.test.mjs` | `js-yaml` 兼容层:能力探测、跳过硬编码不兼容的副本、降级解析下 `!!js` 的语义保真 |
|
|
201
300
|
| `test/import.test.mjs` | 14 种工具的配置格式、TOML 子集、JSON 注释与尾逗号 |
|
|
202
301
|
| `test/editjson.test.mjs` | JSON 模式编辑:原地更新、重命名保留 id 与覆盖、多条拒绝 |
|
|
203
|
-
| `test/host.test.mjs` | 宿主端全部 HTTP 路由,用假的 Cordis 上下文驱动真实 `apply()
|
|
204
|
-
| `test/client.test.mjs` | 浏览器 bundle 能否被 shell
|
|
302
|
+
| `test/host.test.mjs` | 宿主端全部 HTTP 路由,用假的 Cordis 上下文驱动真实 `apply()`;含项目绑定的守卫拦截与按会话工具限制 |
|
|
303
|
+
| `test/client.test.mjs` | 浏览器 bundle 能否被 shell 加载并注册设置页;含模式开关、图标按钮的三处标签载体、卡片不裁切提示 |
|
|
205
304
|
| `test/compose.test.mjs` | 用真实的 bundle 层组合 profile,确认本插件的行能挂载 |
|
|
206
305
|
| `test/live.test.mjs` | 只读地跑真实 profile,确认线上配置能被正确读出且凭据已掩码 |
|
|
207
306
|
|
|
208
307
|
测试不依赖任何测试框架,只用 Node 内置的 `node:test`,并复用 profile 中已有的
|
|
209
308
|
`js-yaml`(与运行时同一条解析路径,含 `lib/yaml.js` 的兼容层)。
|
|
210
309
|
|
|
310
|
+
> `test/compose.test.mjs` 里有一条用例会拿真实的 profile 组合出插件树,然后检查
|
|
311
|
+
> 没有两个 bundle 插入了同一个行 id。它读的是**当前机器上的 profile**,所以如果
|
|
312
|
+
> 你装的某个插件与另一个撞了 id,这条会失败——那是那套 profile 的问题,不是本插件
|
|
313
|
+
> 的回归,报错里会直接给出撞车的 id。
|
|
314
|
+
|
|
211
315
|
### 结构
|
|
212
316
|
|
|
213
317
|
| 文件 | 作用 |
|
|
214
318
|
| --- | --- |
|
|
215
|
-
| `lib/index.js` | 宿主端:HTTP API
|
|
319
|
+
| `lib/index.js` | 宿主端:HTTP API、清单投影、写操作、项目绑定的读写与执行 |
|
|
216
320
|
| `lib/import.js` | 导入解析:各工具配置格式 → 本插件的服务器形状 |
|
|
217
321
|
| `lib/patch.js` | 补丁层读写:分段、解析、校验、生成 |
|
|
218
322
|
| `lib/yaml.js` | `js-yaml` 兼容层:副本能力探测、跳过硬编码不兼容的副本、无自定义类型时的降级解析 |
|
|
@@ -228,6 +332,9 @@ node test/run.mjs # 全部八个测试套件(共 127 项)
|
|
|
228
332
|
| `node tools/check-client-bundle.mjs` | 按 shell 的方式加载客户端 bundle,检查注册结果与导航图标 CSS |
|
|
229
333
|
| `node tools/check-segmented.mjs` | 校验分段开关的滑块几何(内缩、半宽、位移)与轨道假设一致 |
|
|
230
334
|
| `node tools/preview-edit-modes.mjs` | 用真实组件渲染编辑弹窗的两种模式,生成 `edit-modes-preview.html` |
|
|
335
|
+
| `node tools/preview-row.mjs` | 用真实组件渲染服务器行的各种形态(用户行 / 内置行 / 停用行 / 已绑定 / 展开),生成 `row-preview.html` |
|
|
336
|
+
| `node tools/preview-actions.mjs` | 逐个渲染图标按钮与它的悬停提示(含 3× 放大),生成 `actions-preview.html` |
|
|
337
|
+
| `node tools/preview-tips.mjs` | 验证提示不被卡片裁切、最后一个按钮的提示右对齐、去掉 `overflow:hidden` 后底部圆角仍在,生成 `tips-preview.html` |
|
|
231
338
|
| `node tools/check-nav-icon.mjs` | 校验导航图标的 mask 载荷是合法可绘制的 16×16 模板 |
|
|
232
339
|
| `node tools/gen-icon-preview.cjs` | 从 dsh 前端 bundle 提取图标,生成 `icon-options.html` 对照页 |
|
|
233
340
|
| `node tools/dump-icon.cjs <IconName>` | 打印某个内置图标的 SVG 路径,便于手写覆盖 |
|