dsh-mcp-ops 0.2.1 → 0.2.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/README.md +25 -8
- package/lib/client.js +2 -1
- package/lib/index.js +7 -1
- package/lib/mount.js +366 -148
- package/lib/oauth-store.js +81 -0
- package/lib/oauth-web.js +2 -1
- package/lib/oauth.js +29 -1
- package/lib/probe.js +20 -39
- package/lib/refs.js +10 -2
- package/lib/service.js +85 -16
- package/lib/sources/cordis-source.js +35 -13
- package/lib/system-ca.js +79 -0
- package/lib/tool-control.js +43 -3
- package/package.json +13 -12
package/lib/tool-control.js
CHANGED
|
@@ -144,6 +144,13 @@ class ToolControl {
|
|
|
144
144
|
hotLimit;
|
|
145
145
|
/** 已知服务器名(`serverOf` 的集合匹配输入;由服务在每次 `sync()` 时刷新)。 */
|
|
146
146
|
serverNames = [];
|
|
147
|
+
/**
|
|
148
|
+
* **本插件实际注册**的服务器名(rc.2 起 deny 只限定到这些名字)。
|
|
149
|
+
*
|
|
150
|
+
* 官方 `ctx.mcpManager` 也会注册 `mcp__*` 工具;若逐工具开关/搜索模式按"所有 mcp__ 前缀"
|
|
151
|
+
* 计算,会把官方 manager 的服务器一并挡掉。这里只认本插件 MountManager 当前存活的注册。
|
|
152
|
+
*/
|
|
153
|
+
ownServers;
|
|
147
154
|
/** 逐工具开关(只存显式值;缺席 = 启用)。 */
|
|
148
155
|
switches = /* @__PURE__ */ new Map();
|
|
149
156
|
/** 注入模式。 */
|
|
@@ -232,6 +239,7 @@ class ToolControl {
|
|
|
232
239
|
() => this.ctx.tools.guard((execution) => {
|
|
233
240
|
const name = execution?.name;
|
|
234
241
|
if (typeof name !== "string") return void 0;
|
|
242
|
+
if (!this.isOwnedTool(name)) return void 0;
|
|
235
243
|
if (!isToolDeniedBySwitch(name, (candidate) => this.isEnabled(candidate))) return void 0;
|
|
236
244
|
if (!this.isVisibleTo(execution?.agent, name)) return void 0;
|
|
237
245
|
return hostText(this.ctx, "toolDisabled", { name });
|
|
@@ -289,12 +297,14 @@ class ToolControl {
|
|
|
289
297
|
* @param switches - 工具开关记录(键 = 公开工具名)。
|
|
290
298
|
* @param mode - 注入模式;非法值忽略(保留当前值)。
|
|
291
299
|
* @param serverNames - 已知服务器名(工具名归属判定用;省略则保留旧值)。
|
|
300
|
+
* @param ownServers - **本插件实际注册**的服务器名(deny 的边界;省略则保留旧值)。
|
|
292
301
|
*/
|
|
293
|
-
load(switches, mode, serverNames) {
|
|
302
|
+
load(switches, mode, serverNames, ownServers) {
|
|
294
303
|
this.switches.clear();
|
|
295
304
|
for (const [name, enabled] of switches) this.switches.set(name, enabled);
|
|
296
305
|
if (mode === "search" || mode === "full") this.mode = mode;
|
|
297
306
|
if (serverNames !== void 0) this.serverNames = [...serverNames];
|
|
307
|
+
if (ownServers !== void 0) this.ownServers = new Set(ownServers);
|
|
298
308
|
this.refreshMasks();
|
|
299
309
|
}
|
|
300
310
|
/**
|
|
@@ -317,7 +327,14 @@ class ToolControl {
|
|
|
317
327
|
enabled: this.isEnabled(tool.name),
|
|
318
328
|
hot: this.hot.has(tool.name)
|
|
319
329
|
}));
|
|
320
|
-
return {
|
|
330
|
+
return {
|
|
331
|
+
tools,
|
|
332
|
+
mode: this.mode,
|
|
333
|
+
hotSize: this.hot.size,
|
|
334
|
+
hotLimit: this.hotLimit,
|
|
335
|
+
// rc.2 基线的 restrict() 是唯一执行入口;缺它时配置仍然保存,但不会生效。
|
|
336
|
+
enforcement: typeof this.ctx.tools.restrict === "function" && this.maskScope !== void 0 ? "mask" : "unavailable"
|
|
337
|
+
};
|
|
321
338
|
}
|
|
322
339
|
/**
|
|
323
340
|
* 设置一个工具的开关。
|
|
@@ -441,13 +458,32 @@ class ToolControl {
|
|
|
441
458
|
serverNameOf(name) {
|
|
442
459
|
return serverOf(name, this.serverNames);
|
|
443
460
|
}
|
|
461
|
+
/**
|
|
462
|
+
* 工具名是否属于**本插件自有服务器**。
|
|
463
|
+
*
|
|
464
|
+
* 必须按"最长已知服务器前缀"判定,不能退回 `serverOfToolName()` 的首个 `__` 切分:
|
|
465
|
+
* 官方 manager 的 `foo_extra` 会被切成 `foo`,而 `foo` 恰好是本插件自有服务器时,
|
|
466
|
+
* 它就会混进 deny / 检索。已知集合包含文件行、组合层行与 manager 的 configured 项。
|
|
467
|
+
*
|
|
468
|
+
* @param name - 公开工具名。
|
|
469
|
+
* @returns 属于自有服务器时为 true(未配置边界时一律 true,供零依赖单测)。
|
|
470
|
+
*/
|
|
471
|
+
isOwnedTool(name) {
|
|
472
|
+
if (this.ownServers === void 0) return true;
|
|
473
|
+
let best = "";
|
|
474
|
+
for (const candidate of this.serverNames) {
|
|
475
|
+
if (candidate.length <= best.length) continue;
|
|
476
|
+
if (name.startsWith(`${TOOL_PREFIX}${candidate}__`)) best = candidate;
|
|
477
|
+
}
|
|
478
|
+
return best !== "" && this.ownServers.has(best);
|
|
479
|
+
}
|
|
444
480
|
/**
|
|
445
481
|
* 当前已注册的 MCP 工具(按名排序 = 字节稳定)。
|
|
446
482
|
* @returns 工具列表。
|
|
447
483
|
*/
|
|
448
484
|
snapshot() {
|
|
449
485
|
const all = this.ctx.tools.schemas();
|
|
450
|
-
return all.filter((tool) => typeof tool?.name === "string" && tool.name.startsWith(TOOL_PREFIX)).sort(compareName);
|
|
486
|
+
return all.filter((tool) => typeof tool?.name === "string" && tool.name.startsWith(TOOL_PREFIX)).filter((tool) => this.isOwnedTool(tool.name)).sort(compareName);
|
|
451
487
|
}
|
|
452
488
|
/**
|
|
453
489
|
* 为一个新建 agent 建掩码作用域,并立即同步一次可见性。
|
|
@@ -528,6 +564,10 @@ class ToolControl {
|
|
|
528
564
|
mask.lift = () => {
|
|
529
565
|
};
|
|
530
566
|
mask.denied = signature;
|
|
567
|
+
if (process.env.DSH_MCP_OPS_DEBUG !== void 0 && denied.length > 0) {
|
|
568
|
+
process.stderr.write(`dsh-mcp-ops: mask mode=${this.mode} denied=${denied.join(",")} own=${[...this.ownServers ?? []].join(",")}
|
|
569
|
+
`);
|
|
570
|
+
}
|
|
531
571
|
if (denied.length === 0) return;
|
|
532
572
|
mask.lift = mask.scope.ctx.tools.restrict({ deny: denied });
|
|
533
573
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-mcp-ops",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "MCP 服务管理:增删改查与启停、连接测试、工具按需检索与全量注入、进程级与服务级环境变量(含密钥);MCP service management: CRUD, connection tests, tool injection, environment variables and secrets",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
],
|
|
43
43
|
"engines": {
|
|
44
44
|
"node": ">=24.9.0",
|
|
45
|
-
"dsh": "^0.2.2-rc.
|
|
45
|
+
"dsh": "^0.2.2-rc.2"
|
|
46
46
|
},
|
|
47
47
|
"dsh": {
|
|
48
48
|
"manifestVersion": 1,
|
|
@@ -70,18 +70,19 @@
|
|
|
70
70
|
"peerDependencies": {
|
|
71
71
|
"@deepseek-ai/cordis": "^4.1.0",
|
|
72
72
|
"@deepseek-ai/cordis-plugin-include": "^1.1.0",
|
|
73
|
-
"@deepseek-ai/dsh": "^0.2.2-rc.
|
|
74
|
-
"@deepseek-ai/dsh-atomic-write": "^0.2.2-rc.
|
|
75
|
-
"@deepseek-ai/dsh-credentials": "^0.2.2-rc.
|
|
76
|
-
"@deepseek-ai/dsh-mcp-client": "^0.2.2-rc.
|
|
77
|
-
"@deepseek-ai/dsh-
|
|
78
|
-
"@deepseek-ai/dsh-
|
|
79
|
-
"@deepseek-ai/dsh-
|
|
80
|
-
"@deepseek-ai/dsh-
|
|
81
|
-
"@deepseek-ai/dsh-
|
|
73
|
+
"@deepseek-ai/dsh": "^0.2.2-rc.2",
|
|
74
|
+
"@deepseek-ai/dsh-atomic-write": "^0.2.2-rc.2",
|
|
75
|
+
"@deepseek-ai/dsh-credentials": "^0.2.2-rc.2",
|
|
76
|
+
"@deepseek-ai/dsh-mcp-client": "^0.2.2-rc.2",
|
|
77
|
+
"@deepseek-ai/dsh-mcp-manager": "^0.2.2-rc.2",
|
|
78
|
+
"@deepseek-ai/dsh-scope": "^0.2.2-rc.2",
|
|
79
|
+
"@deepseek-ai/dsh-subprocess": "^0.2.2-rc.2",
|
|
80
|
+
"@deepseek-ai/dsh-system-prompt": "^0.2.2-rc.2",
|
|
81
|
+
"@deepseek-ai/dsh-tools": "^0.2.2-rc.2",
|
|
82
|
+
"@deepseek-ai/dsh-typert-protocol": "^0.2.2-rc.2",
|
|
82
83
|
"@deepseek-ai/schemastery": "^3.19.0",
|
|
83
84
|
"js-yaml": "^4.3.2",
|
|
84
|
-
"zod": "^4.6.
|
|
85
|
+
"zod": "^4.6.6"
|
|
85
86
|
},
|
|
86
87
|
"scripts": {
|
|
87
88
|
"build": "node scripts/build-host.mjs && node scripts/build-client.mjs && node scripts/check-client-bundle.mjs",
|