dsh-mcp 1.14.4 → 1.15.1
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.en.md +34 -1
- package/CHANGELOG.md +35 -1
- package/README.en.md +1 -1
- package/README.md +1 -1
- package/lib/client.js +168 -160
- package/lib/index.js +75 -37
- package/lib/tool-admission.js +111 -0
- package/lib/tool-assembly.js +73 -0
- package/package.json +2 -2
- package/scripts/build.mjs +7 -1
- package/src/client/McpSettingsSection.tsx +6 -3
- package/src/client/ServerForm.tsx +23 -4
- package/src/client/index.ts +23 -10
package/CHANGELOG.en.md
CHANGED
|
@@ -9,9 +9,42 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
9
9
|
|
|
10
10
|
## Compatibility
|
|
11
11
|
|
|
12
|
-
- **Supported DSH version**: **dsh `0.2.
|
|
12
|
+
- **Supported DSH version**: **dsh `0.2.2-rc.1`** — the latest release is developed and verified on `0.2.2-rc.1` (declared in `package.json` → `dsh.supported`); older entries state the version verified at their time. When the DSH and plugin versions do not match, the Settings page reports a diagnosis (check whether the bundle is selected → restart `dsh web` → hard-refresh → upgrade both sides).
|
|
13
13
|
- **Release convention**: every version entry states `- **Supported DSH version**: dsh <version>`, mirrored in the GitHub Release notes. The release body is written in **Chinese** (matching [CHANGELOG.md](CHANGELOG.md)), with heading levels mirroring the entry.
|
|
14
14
|
|
|
15
|
+
## [1.15.1] - 2026-11-10
|
|
16
|
+
|
|
17
|
+
- **Supported DSH version**: **dsh `0.2.2-rc.1`**
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
|
|
21
|
+
- **Search mode and per-tool switches were complete no-ops on DSH 0.2.2, which kept injecting every MCP tool (issue #23)**: 0.2.2 no longer hands the tool list to `system-prompt/assemble` — the model-facing set is built by `systemPrompt.tools()` from a **per-step admission set** (`tools.resolve()` → `registration.when(context)`), so "filter an already-built list" is not a thing that can work: a tool outside the set never arrives no matter how it is filtered, and one inside cannot be removed. The result was 314 tools ≈ 305.6 KB ≈ 82k tokens on every request, with `mcp_tool_search` and the checkboxes both inert. The plugin now declares `when` **at registration time**: `installToolControl()` wraps `ctx.tools.register` synchronously before any mount registers a tool, attaching "switched off → refuse; `search` mode → admit only the hot set; `full` mode → admit everything" to every `mcp__*` registration for the core to resolve each step. `mcp_tool_search` sits outside the `mcp__` namespace, so it stays visible and callable — it records the matched tools as hot, which admits them on the next step, which is what finally makes `search` mode save tokens. A caller-supplied `when` is preserved and ANDed after the plugin's admission; cores ≤ 0.2.1 take a single-argument `register`, so the extra `when` is ignored and the existing waterfall filter still applies. Unload/reload restores the original `register` and never overwrites a wrapper added later
|
|
22
|
+
- **The degraded-path log no longer misleads**: when the "no tool list" seam of 0.2.2 is hit but the admission gate is live, the message drops to `info` and states that switches and search mode are enforced at registration time; only a core with neither seam nor admission capability gets a `warn` that the configuration is inert
|
|
23
|
+
- **`toolsList()` now reports `enforcement`**: `admission` (per-step, 0.2.2) / `waterfall` (hook filtering, ≤ 0.2.1) / `unavailable` (neither), so the settings page and diagnostics can tell whether the injection mode and switches actually take effect
|
|
24
|
+
|
|
25
|
+
### Notes
|
|
26
|
+
|
|
27
|
+
- New `test/tool-admission.test.mjs` (no DSH module closure — runs anywhere): covers ① the admission matrix (`search`/`full` × switches × hot set); ② only the `mcp__` namespace is wrapped, `mcp_tool_search` and ordinary tools are untouched; ③ a caller-supplied `when` is preserved and can still veto; ④ the ≤ 0.2.1 single-argument registration shape is unchanged; ⑤ idempotent install and disposer restoration
|
|
28
|
+
- No client source changes: `lib/client.js` rebuilds byte-for-byte identically
|
|
29
|
+
|
|
30
|
+
## [1.15.0] - 2026-11-06
|
|
31
|
+
|
|
32
|
+
- **Supported DSH version**: **dsh `0.2.0-rc.2`** (this release also lets the plugin load on `0.2.2-rc.1`, see below)
|
|
33
|
+
|
|
34
|
+
### Fixed
|
|
35
|
+
|
|
36
|
+
- **On DSH 0.2.2 every turn threw `assembly.tools is not iterable` during assembly, killing the whole turn**: DSH ≤ 0.2.1 passed the `system-prompt/assemble` waterfall an assembly that already carried `tools`; 0.2.2 runs the waterfall **first** and attaches the tool list afterwards, so the hook receives only `sections`/`contexts`/`variables`. The old `installToolControl()` hook iterated `assembly.tools` unconditionally → `TypeError: assembly.tools is not iterable` right in pre-step assembly, before the model was ever called, surfacing as "this turn failed". The transform now lives in `lib/tool-assembly.js` (no DSH module dependency): when the assembly carries no tool array it degrades to "this seam is unavailable on this core" — it does not mutate the assembly, does not throw, and simply `return next()`, with a one-shot `warn` explaining that per-tool switches / search-mode injection are inactive on such a core (the core overwrites the hook's tool list afterwards anyway, so neither capability can work on 0.2.2)
|
|
37
|
+
- **The settings page "Save" button did nothing, even with an otherwise valid form**: the editor `<form>` never disabled native constraint validation, so the `type="url"` address field and the `min` numeric field could silently block submit — no bubble, no error line, just "clicked save and nothing happened". The form is now `noValidate` and input legality is decided by the Host's `validateServerInput`, which reports failures as `MCP_INVALID_SPEC` with a readable message
|
|
38
|
+
- **A Host-side save/delete failure was reported as success in the UI**: `save` and `remove` inspected the Remote carrier's `ok` (transport success) instead of `value.ok` inside it (the Host's business outcome), so errors like "name conflict" or "missing required field" were swallowed — no list refresh and no message. The carrier is now unwrapped before checking `value.ok`, and the Host's code/message surface unchanged
|
|
39
|
+
- **A successful save still threw `TypeError: Cannot read properties of null (reading 'serverName')`**: `cancelEdit()` nulls `draft` before `onSaved` runs, and reading `state.draft.serverName` there threw; the save `catch` then reported it as a save failure, and the two "refresh badge/tool count after save" timers were never scheduled. The form now passes the name out through `onSaved(serverName)`
|
|
40
|
+
- **On Windows the client bundle failed to load and the Web shell would not boot**: the CSS module loader in `scripts/build.mjs` split `args.path` on `/` only, but Windows hands esbuild backslash paths, so the emitted `<style data-file>` kept the full `C:\Users\...` prefix and the runtime `querySelector('style[data-file="C:\Users\..."]')` threw `DOMException: not a valid selector`, aborting the whole bundle import. It now splits on `/[/\\]/` so both platforms yield the same basename
|
|
41
|
+
|
|
42
|
+
### Notes
|
|
43
|
+
|
|
44
|
+
- New `test/tool-assembly.test.mjs` (**needs no DSH module closure**, so it runs everywhere): covers (1) an assembly without `tools` neither throws nor mutating the payload, (2) `all` mode still filters switched-off tools and keeps the stable "non-MCP first + MCP sorted by name" order (the prompt-cache prerequisite), (3) `search` mode keeps only hot tools and replaces — never duplicates — the `mcp-tool-control` section, (4) the `lib/index.js` hook must delegate to that transform and must not iterate `assembly.tools` directly
|
|
45
|
+
- Host side adds `lib/tool-assembly.js` and reworks the assemble hook in `lib/index.js`; the client side changes are in `src/client/` (save path and build script), with `lib/client.js` rebuilt to match
|
|
46
|
+
- Saving **no longer runs a mandatory connectivity probe first**: the Host is the authority on the spec, and a server that is temporarily unreachable must still be savable. If the user already ran "Test connection" in this editor and it failed, the page shows an advisory notice after a successful save instead of blocking it
|
|
47
|
+
|
|
15
48
|
## [1.14.4] - 2026-11-03
|
|
16
49
|
|
|
17
50
|
- **Supported DSH version**: **dsh `0.2.0-rc.2`**
|
package/CHANGELOG.md
CHANGED
|
@@ -9,9 +9,43 @@
|
|
|
9
9
|
|
|
10
10
|
## 兼容性
|
|
11
11
|
|
|
12
|
-
- **支持版本**:**dsh `0.2.
|
|
12
|
+
- **支持版本**:**dsh `0.2.2-rc.1`** —— 最新版本在 `0.2.2-rc.1` 上开发与验证(`package.json` → `dsh.supported` 同步声明);历史版本条目各自声明当时验证的版本。DSH 与插件版本不匹配时,设置页会给出排查诊断(核对 bundle 是否已选中 → 重启 `dsh web` → 硬刷新 → 同步升级)。
|
|
13
13
|
- **发版约定**:每个版本条目都要声明 `- **支持版本**:dsh <版本>`,并在 GitHub Release notes 中同步。Release 正文用**中文**(与本文档一致),标题层级与条目一致。
|
|
14
14
|
|
|
15
|
+
## [1.15.1] - 2026-11-10
|
|
16
|
+
|
|
17
|
+
- **支持版本**:**dsh `0.2.2-rc.1`**
|
|
18
|
+
|
|
19
|
+
### 修复
|
|
20
|
+
|
|
21
|
+
- **DSH 0.2.2 上「按需检索」与单工具开关完全失效,每轮仍注入全部 MCP 工具(issue #23)**:0.2.2 不再把工具列表交给 `system-prompt/assemble`——模型可见的工具集由 `systemPrompt.tools()` 按**每步准入集合**(`tools.resolve()` → `registration.when(context)`)构建,因此「过滤一份已经建好的列表」这条路不复存在:集合外的工具再怎么过滤也进不来,集合内的也删不掉。结果是 314 个工具 ≈ 305.6 KB ≈ 82k tokens 每轮全量注入,`mcp_tool_search` 与勾选开关都成了空操作。现在改为在**注册时**声明 `when`:`installToolControl()` 在任何挂载注册工具之前同步包装 `ctx.tools.register`,为 `mcp__*` 注册挂上「被开关禁用 → 拒绝;`search` 模式 → 仅热集合准入;`full` 模式 → 全部准入」的条件,由核心逐步求值。`mcp_tool_search` 不在 `mcp__` 命名空间内,始终可见可调用——它把命中工具写入热集合,下一步即被准入,`search` 模式这才真正省下 token。调用方自带的 `when` 会保留并与插件准入相与;≤ 0.2.1 的核心 `register` 只接受一个参数,多余的 `when` 被忽略,原有 waterfall 过滤路径照旧生效。插件卸载/重载时还原原始 `register`,且不会覆盖后续插件加的包装
|
|
22
|
+
- **降级日志不再误导**:命中 0.2.2 的「无工具列表」接缝时,若准入门已生效则降为 `info`,说明「开关与 search 模式已在注册期由准入 `when` 执行」;只有核心既无该接缝又无准入能力时才 `warn`「配置不生效」
|
|
23
|
+
- **`toolsList()` 新增 `enforcement`**:取值 `admission`(0.2.2 按步准入)/ `waterfall`(≤ 0.2.1 钩子过滤)/ `unavailable`(两者皆无),设置页与诊断可据此判断注入模式与工具开关是否真的生效
|
|
24
|
+
|
|
25
|
+
### 说明
|
|
26
|
+
|
|
27
|
+
- 新增 `test/tool-admission.test.mjs`(不依赖 DSH 模块闭包,任何环境都会执行):覆盖 ① 准入判定矩阵(`search`/`full` × 开关 × 热集合);② 只包装 `mcp__` 命名空间、`mcp_tool_search` 与普通工具不受影响;③ 调用方 `when` 保留且仍可否决;④ ≤ 0.2.1 单参数注册形态不变;⑤ 幂等安装与卸载还原
|
|
28
|
+
- 未改客户端源码:`lib/client.js` 重建后字节零变化
|
|
29
|
+
|
|
30
|
+
## [1.15.0] - 2026-11-06
|
|
31
|
+
|
|
32
|
+
- **支持版本**:**dsh `0.2.0-rc.2`**(本版本同时让插件可在 `0.2.2-rc.1` 上加载,见下)
|
|
33
|
+
|
|
34
|
+
### 修复
|
|
35
|
+
|
|
36
|
+
- **DSH 0.2.2 上每一轮都在装配阶段抛 `assembly.tools is not iterable`,会话整轮失败**:DSH ≤ 0.2.1 调用 `system-prompt/assemble` waterfall 时 assembly 里已经带 `tools`,0.2.2 改成**先跑 waterfall、再挂工具列表**,所以进钩子的 assembly 只有 `sections`/`contexts`/`variables`。`installToolControl()` 的旧钩子无条件 `for (const tool of assembly.tools)` → `TypeError: assembly.tools is not iterable`,抛在 pre-step 装配、模型还没被调用,界面上只显示「本轮运行失败」。现在这段变换抽到不依赖 DSH 模块的 `lib/tool-assembly.js`:assembly 没有工具数组时按「该接缝在本核心不可用」降级——不修改 assembly、不抛错、直接 `return next()`,并用一条一次性 `warn` 说明「按工具开关过滤 / search 模式注入在此核心不生效」(核心随后会用自己那份 `tools` 覆盖钩子写回的值,这两项能力本来也无法在 0.2.2 上生效)
|
|
37
|
+
- **设置页点「保存」没反应,即使表单内容本身合法**:编辑器 `<form>` 没有关闭浏览器原生约束校验,`type="url"` 的地址框和 `min` 的数值框会静默拦下 submit——不弹提示、也没有错误行,用户看到的就是「点了保存但什么都没发生」。现在表单改为 `noValidate`,输入合法性统一由宿主的 `validateServerInput` 判定,失败时以 `MCP_INVALID_SPEC` 加可读消息回显
|
|
38
|
+
- **保存 / 删除宿主明确返回失败,界面却当成成功**:`save`、`remove` 检查的是 Remote carrier 的 `ok`(传输层成功),而不是 carrier 里 `value.ok`(宿主业务结果),于是「名称冲突 / 必填缺失」这类错误被整条吞掉,列表不刷新、也没有任何提示。现在先解包 carrier 再判 `value.ok`,宿主的错误码与消息原样透出
|
|
39
|
+
- **保存成功后仍抛 `TypeError: Cannot read properties of null (reading 'serverName')`**:`cancelEdit()` 会先把 `draft` 置空,紧接着 `onSaved` 又去读 `state.draft.serverName`,异常被 save 的 `catch` 捕获后当成保存失败显示;同时「保存后 2s/6s 自动刷新徽标与工具数」的两个定时器再也不会被挂上。现在由表单把 serverName 通过 `onSaved(serverName)` 传出
|
|
40
|
+
- **Windows 上客户端包加载失败、Web 壳起不来**:`scripts/build.mjs` 的 CSS module loader 只按 `/` 切分路径,而 Windows 传给 esbuild 的 `args.path` 是反斜杠,生成的 `<style data-file>` 里残留完整 `C:\Users\...`,运行时 `querySelector('style[data-file="C:\Users\..."]')` 抛 `DOMException: not a valid selector`,整个 client bundle 导入失败。现在按 `/[/\\]/` 切分,跨平台取到同一个基名
|
|
41
|
+
|
|
42
|
+
### 说明
|
|
43
|
+
|
|
44
|
+
- 保存流程**不再强制先跑一次连通性测试**:宿主才是 spec 的权威,临时连不上的服务器也必须允许保存。若本次编辑里用户已经点过「测试连接」且失败,保存成功后以「操作提示」形式给出警告,而不是阻断保存
|
|
45
|
+
- 本次改动包含客户端(`src/client/*`),`lib/client.js` 已按仓库既有构建流程重建;产物差异只反映上述源码改动,未引入任何依赖版本变化
|
|
46
|
+
- 新增 `test/tool-assembly.test.mjs`(**不依赖 DSH 模块闭包**,任何环境都会执行):覆盖 ① 无 `tools` 的 assembly 不抛错、原对象不被修改;② all 模式仍按开关过滤,并保持「非 MCP 工具在前 + MCP 工具按名排序」的稳定顺序(prompt-cache 前提);③ search 模式只注入热工具,且 `mcp-tool-control` 段落重复执行时幂等替换、不叠加;④ `lib/index.js` 的钩子必须委托给该变换,禁止再直接遍历 `assembly.tools`
|
|
47
|
+
- 宿主侧新增 `lib/tool-assembly.js` 并改造 `lib/index.js` 的装配钩子;客户端侧改动集中在 `src/client/`(保存链路与构建脚本),`lib/client.js` 为对应重建产物
|
|
48
|
+
|
|
15
49
|
## [1.14.4] - 2026-11-03
|
|
16
50
|
|
|
17
51
|
- **支持版本**:**dsh `0.2.0-rc.2`**
|
package/README.en.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://dshfind.com/en/plugins/ArvinQi/dsh-mcp?ref=badge)
|
|
4
4
|
|
|
5
|
-
> **Supported DSH version**: `dsh 0.2.
|
|
5
|
+
> **Supported DSH version**: `dsh 0.2.2-rc.1` — the latest release is developed and verified on `0.2.2-rc.1`, declared in `package.json` → `dsh.supported`. When the DSH and plugin versions do not match, the Settings page shows a diagnosis (check whether the bundle is selected → restart `dsh web` → hard-refresh → upgrade both sides).
|
|
6
6
|
|
|
7
7
|

|
|
8
8
|
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
[](https://dshfind.com/zh/plugins/ArvinQi/dsh-mcp?ref=badge)
|
|
6
6
|
|
|
7
|
-
> **支持版本**:`dsh 0.2.
|
|
7
|
+
> **支持版本**:`dsh 0.2.2-rc.1` —— 最新版本在 `0.2.2-rc.1` 上开发与验证,`package.json` → `dsh.supported` 同步声明。DSH 与插件两侧版本不匹配时,设置页会给出排查诊断(检查 bundle 是否已选中 → 重启 `dsh web` → 硬刷新 → 同步升级)。
|
|
8
8
|
|
|
9
9
|

|
|
10
10
|
|
package/lib/client.js
CHANGED
|
@@ -15597,14 +15597,16 @@ function McpServerForm(props) {
|
|
|
15597
15597
|
setSaveError(null);
|
|
15598
15598
|
actions.setBusy("save");
|
|
15599
15599
|
try {
|
|
15600
|
+
const observed = test?.probe;
|
|
15601
|
+
const warning = observed !== void 0 && observed.ok === false && observed.oauthRequired !== true ? `${t("testFail")}: ${observed.message}` : void 0;
|
|
15600
15602
|
const failure = await injected.save(draft);
|
|
15601
15603
|
if (failure !== null) {
|
|
15602
15604
|
setSaveError(`${failure.code}: ${failure.message}`);
|
|
15603
15605
|
return;
|
|
15604
15606
|
}
|
|
15605
15607
|
if (!await refresh()) return;
|
|
15608
|
+
onSaved?.(draft.serverName.trim(), warning);
|
|
15606
15609
|
actions.cancelEdit();
|
|
15607
|
-
onSaved?.();
|
|
15608
15610
|
} catch (error51) {
|
|
15609
15611
|
console.error("[dsh-mcp] save failed:", error51);
|
|
15610
15612
|
setSaveError(errorText(error51));
|
|
@@ -15643,187 +15645,194 @@ function McpServerForm(props) {
|
|
|
15643
15645
|
};
|
|
15644
15646
|
const stdio = draft.transport === "stdio";
|
|
15645
15647
|
const probe = test?.probe;
|
|
15646
|
-
return
|
|
15647
|
-
|
|
15648
|
-
|
|
15649
|
-
|
|
15650
|
-
|
|
15651
|
-
|
|
15652
|
-
|
|
15653
|
-
|
|
15654
|
-
|
|
15655
|
-
|
|
15656
|
-
|
|
15657
|
-
|
|
15658
|
-
|
|
15659
|
-
|
|
15660
|
-
|
|
15661
|
-
|
|
15662
|
-
|
|
15663
|
-
|
|
15664
|
-
className: controls_default.control,
|
|
15665
|
-
value: draft.serverName,
|
|
15666
|
-
placeholder: t("serverNameHint"),
|
|
15667
|
-
onChange: (event) => update({ serverName: event.currentTarget.value })
|
|
15668
|
-
}
|
|
15669
|
-
)
|
|
15670
|
-
] }),
|
|
15671
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: ServerForm_default.field, children: [
|
|
15672
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: t("transport") }),
|
|
15673
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
15674
|
-
"select",
|
|
15675
|
-
{
|
|
15676
|
-
className: controls_default.control,
|
|
15677
|
-
value: draft.transport,
|
|
15678
|
-
onChange: (event) => update({ transport: event.currentTarget.value }),
|
|
15679
|
-
children: [
|
|
15680
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "stdio", children: t("transportStdio") }),
|
|
15681
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "streamable-http", children: t("transportHttp") })
|
|
15682
|
-
]
|
|
15683
|
-
}
|
|
15684
|
-
)
|
|
15685
|
-
] }),
|
|
15686
|
-
stdio ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
15648
|
+
return (
|
|
15649
|
+
// `noValidate` keeps the browser's native constraint validation out of the
|
|
15650
|
+
// way: `type="url"` rejected values the Host accepts (e.g. a bare
|
|
15651
|
+
// `host:port`), and the blocked submit produced no error line at all —
|
|
15652
|
+
// "保存没有触发即便格式合法". The Host validates the spec and reports
|
|
15653
|
+
// `MCP_INVALID_SPEC` with a localized message.
|
|
15654
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", { className: ServerForm_default.form, noValidate: true, onSubmit: (event) => {
|
|
15655
|
+
event.preventDefault();
|
|
15656
|
+
void submit();
|
|
15657
|
+
}, children: [
|
|
15658
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: ServerForm_default.titleRow, children: [
|
|
15659
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { className: ServerForm_default.title, children: draft.id === null ? t("newTitle") : t("editTitle") }),
|
|
15660
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: ServerForm_default.titleActions, children: [
|
|
15661
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: controls_default.button, onClick: () => actions.cancelEdit(), children: t("backToList") }),
|
|
15662
|
+
draft.id !== null ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: `${controls_default.button} ${ServerForm_default.danger}`, disabled: busy !== null, onClick: () => void removeServer(), children: busy === "remove" ? t("removing") : t("remove") }) : null
|
|
15663
|
+
] })
|
|
15664
|
+
] }),
|
|
15665
|
+
saveError !== null ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: ServerForm_default.error, role: "alert", children: saveError }) : null,
|
|
15687
15666
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: ServerForm_default.field, children: [
|
|
15688
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: t("
|
|
15667
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: t("serverName") }),
|
|
15689
15668
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
15690
15669
|
"input",
|
|
15691
15670
|
{
|
|
15692
15671
|
type: "text",
|
|
15693
15672
|
className: controls_default.control,
|
|
15694
|
-
value: draft.
|
|
15695
|
-
placeholder: t("
|
|
15696
|
-
onChange: (event) => update({
|
|
15673
|
+
value: draft.serverName,
|
|
15674
|
+
placeholder: t("serverNameHint"),
|
|
15675
|
+
onChange: (event) => update({ serverName: event.currentTarget.value })
|
|
15697
15676
|
}
|
|
15698
15677
|
)
|
|
15699
15678
|
] }),
|
|
15700
15679
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: ServerForm_default.field, children: [
|
|
15701
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: t("
|
|
15702
|
-
/* @__PURE__ */ (0, import_jsx_runtime.
|
|
15703
|
-
"
|
|
15680
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: t("transport") }),
|
|
15681
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
15682
|
+
"select",
|
|
15704
15683
|
{
|
|
15705
15684
|
className: controls_default.control,
|
|
15706
|
-
|
|
15707
|
-
|
|
15708
|
-
|
|
15709
|
-
|
|
15685
|
+
value: draft.transport,
|
|
15686
|
+
onChange: (event) => update({ transport: event.currentTarget.value }),
|
|
15687
|
+
children: [
|
|
15688
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "stdio", children: t("transportStdio") }),
|
|
15689
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "streamable-http", children: t("transportHttp") })
|
|
15690
|
+
]
|
|
15710
15691
|
}
|
|
15711
|
-
)
|
|
15712
|
-
|
|
15713
|
-
|
|
15714
|
-
|
|
15715
|
-
|
|
15716
|
-
|
|
15717
|
-
|
|
15718
|
-
|
|
15719
|
-
|
|
15720
|
-
|
|
15721
|
-
|
|
15722
|
-
|
|
15723
|
-
|
|
15692
|
+
)
|
|
15693
|
+
] }),
|
|
15694
|
+
stdio ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
15695
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: ServerForm_default.field, children: [
|
|
15696
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: t("command") }),
|
|
15697
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
15698
|
+
"input",
|
|
15699
|
+
{
|
|
15700
|
+
type: "text",
|
|
15701
|
+
className: controls_default.control,
|
|
15702
|
+
value: draft.command,
|
|
15703
|
+
placeholder: t("commandPlaceholder"),
|
|
15704
|
+
onChange: (event) => update({ command: event.currentTarget.value })
|
|
15705
|
+
}
|
|
15706
|
+
)
|
|
15707
|
+
] }),
|
|
15708
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: ServerForm_default.field, children: [
|
|
15709
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: t("args") }),
|
|
15710
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
15711
|
+
"textarea",
|
|
15712
|
+
{
|
|
15713
|
+
className: controls_default.control,
|
|
15714
|
+
rows: 3,
|
|
15715
|
+
value: draft.argsText,
|
|
15716
|
+
placeholder: t("argsPlaceholder"),
|
|
15717
|
+
onChange: (event) => update({ argsText: event.currentTarget.value })
|
|
15718
|
+
}
|
|
15719
|
+
),
|
|
15720
|
+
(() => {
|
|
15721
|
+
const parsed = parseArgs(draft.argsText);
|
|
15722
|
+
if (parsed.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: ServerForm_default.muted, children: t("argsPreviewEmpty") });
|
|
15723
|
+
const shown = parsed.map((arg) => arg.length > 48 ? `${arg.slice(0, 45)}\u2026` : arg).join(" | ");
|
|
15724
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: ServerForm_default.muted, children: [
|
|
15725
|
+
t("argsPreview"),
|
|
15726
|
+
": ",
|
|
15727
|
+
parsed.length,
|
|
15728
|
+
" \xB7 ",
|
|
15729
|
+
shown
|
|
15730
|
+
] });
|
|
15731
|
+
})()
|
|
15732
|
+
] }),
|
|
15733
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: ServerForm_default.field, children: [
|
|
15734
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: t("cwd") }),
|
|
15735
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
15736
|
+
"input",
|
|
15737
|
+
{
|
|
15738
|
+
type: "text",
|
|
15739
|
+
className: controls_default.control,
|
|
15740
|
+
value: draft.cwd,
|
|
15741
|
+
placeholder: t("cwdPlaceholder"),
|
|
15742
|
+
onChange: (event) => update({ cwd: event.currentTarget.value })
|
|
15743
|
+
}
|
|
15744
|
+
),
|
|
15745
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: ServerForm_default.muted, children: t("cwdHint") })
|
|
15746
|
+
] })
|
|
15747
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
15748
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: ServerForm_default.field, children: [
|
|
15749
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: t("url") }),
|
|
15750
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
15751
|
+
"input",
|
|
15752
|
+
{
|
|
15753
|
+
type: "url",
|
|
15754
|
+
className: controls_default.control,
|
|
15755
|
+
value: draft.url,
|
|
15756
|
+
placeholder: t("urlPlaceholder"),
|
|
15757
|
+
onChange: (event) => update({ url: event.currentTarget.value })
|
|
15758
|
+
}
|
|
15759
|
+
)
|
|
15760
|
+
] }),
|
|
15761
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: ServerForm_default.field, children: [
|
|
15762
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: t("headers") }),
|
|
15763
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
15764
|
+
"textarea",
|
|
15765
|
+
{
|
|
15766
|
+
className: controls_default.control,
|
|
15767
|
+
rows: 2,
|
|
15768
|
+
value: draft.headersText,
|
|
15769
|
+
placeholder: t("headersPlaceholder"),
|
|
15770
|
+
onChange: (event) => update({ headersText: event.currentTarget.value })
|
|
15771
|
+
}
|
|
15772
|
+
)
|
|
15773
|
+
] })
|
|
15724
15774
|
] }),
|
|
15725
15775
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: ServerForm_default.field, children: [
|
|
15726
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: t("
|
|
15776
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: t("toolCallTimeoutMs") }),
|
|
15727
15777
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
15728
15778
|
"input",
|
|
15729
15779
|
{
|
|
15730
|
-
type: "
|
|
15780
|
+
type: "number",
|
|
15731
15781
|
className: controls_default.control,
|
|
15732
|
-
|
|
15733
|
-
|
|
15734
|
-
onChange: (event) => update({
|
|
15782
|
+
min: 1,
|
|
15783
|
+
value: draft.toolCallTimeoutMs,
|
|
15784
|
+
onChange: (event) => update({ toolCallTimeoutMs: event.currentTarget.value })
|
|
15785
|
+
}
|
|
15786
|
+
)
|
|
15787
|
+
] }),
|
|
15788
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: ServerForm_default.checkRow, children: [
|
|
15789
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
15790
|
+
"input",
|
|
15791
|
+
{
|
|
15792
|
+
type: "checkbox",
|
|
15793
|
+
checked: draft.oauth,
|
|
15794
|
+
onChange: (event) => update({ oauth: event.currentTarget.checked })
|
|
15735
15795
|
}
|
|
15736
15796
|
),
|
|
15737
|
-
|
|
15738
|
-
] })
|
|
15739
|
-
|
|
15740
|
-
/* @__PURE__ */ (0, import_jsx_runtime.
|
|
15741
|
-
|
|
15797
|
+
t("oauthAuth")
|
|
15798
|
+
] }),
|
|
15799
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: ServerForm_default.hint, children: t("oauthAuthHint") }),
|
|
15800
|
+
draft.oauth && !stdio && oauthPhase !== "idle" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: oauthPhase === "authorized" ? ServerForm_default.oauthOk : ServerForm_default.oauthWaiting, role: "status", children: oauthPhase === "authorized" ? t("oauthAuthorized") : t("oauthWaiting") }) : null,
|
|
15801
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: ServerForm_default.checkRow, children: [
|
|
15742
15802
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
15743
15803
|
"input",
|
|
15744
15804
|
{
|
|
15745
|
-
type: "
|
|
15746
|
-
|
|
15747
|
-
|
|
15748
|
-
placeholder: t("urlPlaceholder"),
|
|
15749
|
-
onChange: (event) => update({ url: event.currentTarget.value })
|
|
15805
|
+
type: "checkbox",
|
|
15806
|
+
checked: draft.failOnStartupError,
|
|
15807
|
+
onChange: (event) => update({ failOnStartupError: event.currentTarget.checked })
|
|
15750
15808
|
}
|
|
15751
|
-
)
|
|
15809
|
+
),
|
|
15810
|
+
t("failOnStartupError")
|
|
15752
15811
|
] }),
|
|
15753
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: ServerForm_default.
|
|
15754
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: t("headers") }),
|
|
15812
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: ServerForm_default.checkRow, children: [
|
|
15755
15813
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
15756
|
-
"
|
|
15814
|
+
"input",
|
|
15757
15815
|
{
|
|
15758
|
-
|
|
15759
|
-
|
|
15760
|
-
|
|
15761
|
-
placeholder: t("headersPlaceholder"),
|
|
15762
|
-
onChange: (event) => update({ headersText: event.currentTarget.value })
|
|
15816
|
+
type: "checkbox",
|
|
15817
|
+
checked: draft.enabled,
|
|
15818
|
+
onChange: (event) => update({ enabled: event.currentTarget.checked })
|
|
15763
15819
|
}
|
|
15764
|
-
)
|
|
15820
|
+
),
|
|
15821
|
+
t("enabled")
|
|
15822
|
+
] }),
|
|
15823
|
+
test !== null ? probe !== void 0 && !probe.ok && probe.oauthRequired === true ? (
|
|
15824
|
+
// Pending authorization is a waiting state, not a failure; once
|
|
15825
|
+
// authorized the panel above reports success and this clears.
|
|
15826
|
+
oauthPhase === "authorized" ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: ServerForm_default.oauthRequired, role: "status", children: t("oauthRequired") })
|
|
15827
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: `${ServerForm_default.testResult} ${probe !== void 0 && probe.ok ? ServerForm_default.testOk : ServerForm_default.testFail}`, role: "status", children: probe !== void 0 && probe.ok ? `${t("testOk")} (${probe.tools.length} ${t("toolCount")}, ${test.elapsedMs}ms)` : probe !== void 0 && !probe.ok ? `${t("testFail")}: ${probe.message}` : t("testUnknown") }) : null,
|
|
15828
|
+
testRunning && draft.transport === "streamable-http" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: ServerForm_default.muted, role: "status", children: t("testBrowserHint") }) : null,
|
|
15829
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: ServerForm_default.actions, children: [
|
|
15830
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: controls_default.button, disabled: testRunning || busy !== null, onClick: () => void runTest(), children: testRunning ? t("testRunning") : t("test") }),
|
|
15831
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "submit", className: `${controls_default.button} ${controls_default.primary}`, disabled: busy !== null || testRunning, children: busy === "save" ? t("saving") : t("save") }),
|
|
15832
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: controls_default.button, disabled: busy !== null, onClick: () => actions.cancelEdit(), children: t("cancel") })
|
|
15765
15833
|
] })
|
|
15766
|
-
] }),
|
|
15767
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: ServerForm_default.field, children: [
|
|
15768
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: t("toolCallTimeoutMs") }),
|
|
15769
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
15770
|
-
"input",
|
|
15771
|
-
{
|
|
15772
|
-
type: "number",
|
|
15773
|
-
className: controls_default.control,
|
|
15774
|
-
min: 1,
|
|
15775
|
-
value: draft.toolCallTimeoutMs,
|
|
15776
|
-
onChange: (event) => update({ toolCallTimeoutMs: event.currentTarget.value })
|
|
15777
|
-
}
|
|
15778
|
-
)
|
|
15779
|
-
] }),
|
|
15780
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: ServerForm_default.checkRow, children: [
|
|
15781
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
15782
|
-
"input",
|
|
15783
|
-
{
|
|
15784
|
-
type: "checkbox",
|
|
15785
|
-
checked: draft.oauth,
|
|
15786
|
-
onChange: (event) => update({ oauth: event.currentTarget.checked })
|
|
15787
|
-
}
|
|
15788
|
-
),
|
|
15789
|
-
t("oauthAuth")
|
|
15790
|
-
] }),
|
|
15791
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: ServerForm_default.hint, children: t("oauthAuthHint") }),
|
|
15792
|
-
draft.oauth && !stdio && oauthPhase !== "idle" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: oauthPhase === "authorized" ? ServerForm_default.oauthOk : ServerForm_default.oauthWaiting, role: "status", children: oauthPhase === "authorized" ? t("oauthAuthorized") : t("oauthWaiting") }) : null,
|
|
15793
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: ServerForm_default.checkRow, children: [
|
|
15794
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
15795
|
-
"input",
|
|
15796
|
-
{
|
|
15797
|
-
type: "checkbox",
|
|
15798
|
-
checked: draft.failOnStartupError,
|
|
15799
|
-
onChange: (event) => update({ failOnStartupError: event.currentTarget.checked })
|
|
15800
|
-
}
|
|
15801
|
-
),
|
|
15802
|
-
t("failOnStartupError")
|
|
15803
|
-
] }),
|
|
15804
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: ServerForm_default.checkRow, children: [
|
|
15805
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
15806
|
-
"input",
|
|
15807
|
-
{
|
|
15808
|
-
type: "checkbox",
|
|
15809
|
-
checked: draft.enabled,
|
|
15810
|
-
onChange: (event) => update({ enabled: event.currentTarget.checked })
|
|
15811
|
-
}
|
|
15812
|
-
),
|
|
15813
|
-
t("enabled")
|
|
15814
|
-
] }),
|
|
15815
|
-
test !== null ? probe !== void 0 && !probe.ok && probe.oauthRequired === true ? (
|
|
15816
|
-
// Pending authorization is a waiting state, not a failure; once
|
|
15817
|
-
// authorized the panel above reports success and this clears.
|
|
15818
|
-
oauthPhase === "authorized" ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: ServerForm_default.oauthRequired, role: "status", children: t("oauthRequired") })
|
|
15819
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: `${ServerForm_default.testResult} ${probe !== void 0 && probe.ok ? ServerForm_default.testOk : ServerForm_default.testFail}`, role: "status", children: probe !== void 0 && probe.ok ? `${t("testOk")} (${probe.tools.length} ${t("toolCount")}, ${test.elapsedMs}ms)` : probe !== void 0 && !probe.ok ? `${t("testFail")}: ${probe.message}` : t("testUnknown") }) : null,
|
|
15820
|
-
testRunning && draft.transport === "streamable-http" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: ServerForm_default.muted, role: "status", children: t("testBrowserHint") }) : null,
|
|
15821
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: ServerForm_default.actions, children: [
|
|
15822
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: controls_default.button, disabled: testRunning || busy !== null, onClick: () => void runTest(), children: testRunning ? t("testRunning") : t("test") }),
|
|
15823
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "submit", className: `${controls_default.button} ${controls_default.primary}`, disabled: busy !== null || testRunning, children: busy === "save" ? t("saving") : t("save") }),
|
|
15824
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: controls_default.button, disabled: busy !== null, onClick: () => actions.cancelEdit(), children: t("cancel") })
|
|
15825
15834
|
] })
|
|
15826
|
-
|
|
15835
|
+
);
|
|
15827
15836
|
}
|
|
15828
15837
|
|
|
15829
15838
|
// src/client/ServersJsonEditor.tsx
|
|
@@ -16608,8 +16617,9 @@ function McpSettingsSection(props) {
|
|
|
16608
16617
|
t,
|
|
16609
16618
|
actions,
|
|
16610
16619
|
injected: { save, remove, test, list, oauthStart, oauthStatus },
|
|
16611
|
-
onSaved: () => {
|
|
16612
|
-
|
|
16620
|
+
onSaved: (serverName, warning) => {
|
|
16621
|
+
if (warning !== void 0) setActionNotice(warning);
|
|
16622
|
+
if (serverName.length === 0) return;
|
|
16613
16623
|
timersRef.current.push(window.setTimeout(() => refreshServer(serverName), 2e3));
|
|
16614
16624
|
timersRef.current.push(window.setTimeout(() => refreshServer(serverName), 6e3));
|
|
16615
16625
|
}
|
|
@@ -17120,17 +17130,15 @@ async function apply(ctx) {
|
|
|
17120
17130
|
},
|
|
17121
17131
|
save: async (draft) => {
|
|
17122
17132
|
const submission = draftToSubmission(draft);
|
|
17123
|
-
const
|
|
17133
|
+
const outcome = await unwrap(() => manager.upsert({
|
|
17124
17134
|
...draft.id === null ? {} : { id: draft.id },
|
|
17125
17135
|
server: submission.server
|
|
17126
|
-
});
|
|
17127
|
-
|
|
17128
|
-
return failureOf(result.error);
|
|
17136
|
+
}));
|
|
17137
|
+
return outcome.ok ? null : failureOf(outcome.error);
|
|
17129
17138
|
},
|
|
17130
17139
|
remove: async (id) => {
|
|
17131
|
-
const
|
|
17132
|
-
|
|
17133
|
-
return failureOf(result.error);
|
|
17140
|
+
const outcome = await unwrap(() => manager.delete({ id }));
|
|
17141
|
+
return outcome.ok ? null : failureOf(outcome.error);
|
|
17134
17142
|
},
|
|
17135
17143
|
upsertJson: async (servers) => {
|
|
17136
17144
|
const result = await unwrap(() => manager.upsertJson({ servers }));
|
package/lib/index.js
CHANGED
|
@@ -7,6 +7,8 @@ import { ensureSystemCaTrust } from "./system-ca.js";
|
|
|
7
7
|
import { probeConnection } from "./probe.js";
|
|
8
8
|
import { Remote, TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
|
|
9
9
|
import { hostText } from "./host-locales.js";
|
|
10
|
+
import { applyToolControl } from "./tool-assembly.js";
|
|
11
|
+
import { installAdmissionGate, shouldAdmitTool } from "./tool-admission.js";
|
|
10
12
|
import { readDeclaredServers, toMirrorRecord } from "./cordis-servers.js";
|
|
11
13
|
import { managedIds, writeManagedIds } from "./patch-writer.js";
|
|
12
14
|
import z from "@deepseek-ai/schemastery";
|
|
@@ -623,6 +625,19 @@ let McpManagerService = (() => {
|
|
|
623
625
|
/** LRU bound for {@link hotTools}. */
|
|
624
626
|
static HOT_LIMIT = 60;
|
|
625
627
|
/**
|
|
628
|
+
* Restores the patched `ctx.tools.register`; set only on cores that expose
|
|
629
|
+
* the per-step admission seam (DSH ≥ 0.2.2, see lib/tool-admission.js).
|
|
630
|
+
*/
|
|
631
|
+
disposeAdmissionGate;
|
|
632
|
+
/** Whether the adapter's registration gate is enforcing switches and `search` mode. */
|
|
633
|
+
admissionGateInstalled = false;
|
|
634
|
+
/**
|
|
635
|
+
* Set once a `system-prompt/assemble` payload arrives without a tool list,
|
|
636
|
+
* i.e. the core moved admission outside the waterfall. Distinguishes "the
|
|
637
|
+
* gate carries this core" from "nothing filters here".
|
|
638
|
+
*/
|
|
639
|
+
assembleSeamBlocked = false;
|
|
640
|
+
/**
|
|
626
641
|
* @param ctx - Host context carrying storage, credentials, and the tool registry.
|
|
627
642
|
* @param config - Resolved manager configuration.
|
|
628
643
|
*/
|
|
@@ -1892,12 +1907,41 @@ let McpManagerService = (() => {
|
|
|
1892
1907
|
return s;
|
|
1893
1908
|
}
|
|
1894
1909
|
/**
|
|
1895
|
-
* Register the `mcp_tool_search` model tool and the
|
|
1896
|
-
*
|
|
1897
|
-
*
|
|
1898
|
-
*
|
|
1910
|
+
* Register the `mcp_tool_search` model tool and the two seams that decide
|
|
1911
|
+
* which MCP tools the model sees: a registration-time admission gate for
|
|
1912
|
+
* cores that resolve tools per step (DSH ≥ 0.2.2) and the
|
|
1913
|
+
* `system-prompt/assemble` transform for cores that still hand the tool
|
|
1914
|
+
* list to the waterfall (≤ 0.2.1). Also tracks the hot set on real calls.
|
|
1915
|
+
*
|
|
1916
|
+
* The gate is installed first, and synchronously: `reconcileDeclared()`
|
|
1917
|
+
* mounts servers asynchronously, so wrapping before this point catches
|
|
1918
|
+
* every registration a mount will make.
|
|
1899
1919
|
*/
|
|
1900
1920
|
installToolControl() {
|
|
1921
|
+
// DSH ≥ 0.2.2 builds the model-facing list from a per-step admission
|
|
1922
|
+
// set, so filtering inside `system-prompt/assemble` has nothing to
|
|
1923
|
+
// filter (the hook never receives `tools`). Declaring `when` at
|
|
1924
|
+
// registration time is the seam that still works, and it is what makes
|
|
1925
|
+
// `search` mode save tokens again instead of injecting all 300+ tools.
|
|
1926
|
+
this.disposeAdmissionGate = installAdmissionGate(this.ctx.tools, (name) => shouldAdmitTool(name, {
|
|
1927
|
+
toolMode: this.toolMode,
|
|
1928
|
+
toolSwitches: this.toolSwitches,
|
|
1929
|
+
hotTools: this.hotTools
|
|
1930
|
+
}));
|
|
1931
|
+
this.admissionGateInstalled = typeof this.disposeAdmissionGate === "function";
|
|
1932
|
+
if (this.admissionGateInstalled) {
|
|
1933
|
+
const disposeGate = this.disposeAdmissionGate;
|
|
1934
|
+
this.ctx.effect(() => () => {
|
|
1935
|
+
this.admissionGateInstalled = false;
|
|
1936
|
+
this.disposeAdmissionGate = undefined;
|
|
1937
|
+
disposeGate();
|
|
1938
|
+
}, "mcp-manager.admissionGate");
|
|
1939
|
+
// A tool registered before this point keeps the old (unconditional)
|
|
1940
|
+
// registration; surface it rather than silently mixing behaviours.
|
|
1941
|
+
// At boot the count is zero because mounts have not resolved yet.
|
|
1942
|
+
const preRegistered = this.toolSnapshot().length;
|
|
1943
|
+
if (preRegistered > 0) this.ctx.logger?.warn?.(`mcp-manager: ${preRegistered} MCP tool(s) registered before the admission gate; they stay unconditionally visible until their server remounts`);
|
|
1944
|
+
}
|
|
1901
1945
|
this.ctx.tools.register({
|
|
1902
1946
|
name: "mcp_tool_search",
|
|
1903
1947
|
description: hostText(this.ctx, "toolSearchDesc"),
|
|
@@ -1952,40 +1996,27 @@ let McpManagerService = (() => {
|
|
|
1952
1996
|
}
|
|
1953
1997
|
});
|
|
1954
1998
|
this.ctx.on("system-prompt/assemble", (assembly, _context, next) => {
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1999
|
+
// Cores ≤ 0.2.1 hand the tool list to this waterfall; filter it here.
|
|
2000
|
+
// Cores ≥ 0.2.2 attach the list after the waterfall, so `assembly`
|
|
2001
|
+
// carries none — the admission gate above is what filters there. Never
|
|
2002
|
+
// read `assembly.tools` unconditionally: doing that threw
|
|
2003
|
+
// `assembly.tools is not iterable` on every turn and killed the whole
|
|
2004
|
+
// pre-step assembly (issue #22).
|
|
2005
|
+
const applied = applyToolControl(assembly, {
|
|
2006
|
+
toolSwitches: this.toolSwitches,
|
|
2007
|
+
toolMode: this.toolMode,
|
|
2008
|
+
hotTools: this.hotTools,
|
|
2009
|
+
serverOf: (name) => this.serverOf(name),
|
|
2010
|
+
promptText: (key, vars) => hostText(this.ctx, key, vars)
|
|
2011
|
+
});
|
|
2012
|
+
if (!applied) {
|
|
2013
|
+
this.assembleSeamBlocked = true;
|
|
2014
|
+
if (!this.assembleToolsUnavailableLogged) {
|
|
2015
|
+
this.assembleToolsUnavailableLogged = true;
|
|
2016
|
+
if (this.admissionGateInstalled) this.ctx.logger?.info?.("mcp-manager: system-prompt/assemble carries no tool list (DSH >= 0.2.2) — per-tool switches and search mode are enforced at registration time through the admission `when` hook");
|
|
2017
|
+
else this.ctx.logger?.warn?.("mcp-manager: system-prompt/assemble carries no tool list and this core exposes no admission hook — per-tool switches and search mode are inactive on this core");
|
|
1970
2018
|
}
|
|
1971
|
-
const servers = [...new Set(Object.keys(mcpByName).map((name) => this.serverOf(name)))].sort();
|
|
1972
|
-
assembly.sections = (assembly.sections || []).filter((section) => section.name !== "mcp-tool-control");
|
|
1973
|
-
assembly.sections.push({
|
|
1974
|
-
name: "mcp-tool-control",
|
|
1975
|
-
text: hostText(this.ctx, "toolControlPrompt", { servers: servers.join(", ") || hostText(this.ctx, "noServers") })
|
|
1976
|
-
});
|
|
1977
2019
|
}
|
|
1978
|
-
assembly.tools = kept;
|
|
1979
|
-
// Canonical tool order: render MCP tools sorted by name so the
|
|
1980
|
-
// system prompt stays byte-stable for the same tool set no
|
|
1981
|
-
// matter the registration or hot-set order (hot tools move on
|
|
1982
|
-
// every call, and servers may reorder tools/list) — stable
|
|
1983
|
-
// output is what preserves prompt-cache hits.
|
|
1984
|
-
const mcpKept = [];
|
|
1985
|
-
const otherKept = [];
|
|
1986
|
-
for (const tool of assembly.tools) (tool.name.startsWith("mcp__") ? mcpKept : otherKept).push(tool);
|
|
1987
|
-
mcpKept.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
|
|
1988
|
-
assembly.tools = [...otherKept, ...mcpKept];
|
|
1989
2020
|
return next();
|
|
1990
2021
|
});
|
|
1991
2022
|
this.ctx.on("tools/result", (exec) => {
|
|
@@ -2008,7 +2039,14 @@ let McpManagerService = (() => {
|
|
|
2008
2039
|
ok: true,
|
|
2009
2040
|
tools,
|
|
2010
2041
|
mode: this.toolMode,
|
|
2011
|
-
hotSize: this.hotTools.size
|
|
2042
|
+
hotSize: this.hotTools.size,
|
|
2043
|
+
/**
|
|
2044
|
+
* How this core enforces `mode` and the per-tool switches: `admission`
|
|
2045
|
+
* (declared at registration, resolved per step — DSH ≥ 0.2.2),
|
|
2046
|
+
* `waterfall` (filtered inside `system-prompt/assemble` — ≤ 0.2.1), or
|
|
2047
|
+
* `unavailable` (neither seam exists, so the stored config is inert).
|
|
2048
|
+
*/
|
|
2049
|
+
enforcement: this.admissionGateInstalled ? "admission" : this.assembleSeamBlocked ? "unavailable" : "waterfall"
|
|
2012
2050
|
};
|
|
2013
2051
|
}
|
|
2014
2052
|
/**
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registration-time admission gate: search mode and per-tool switches on the
|
|
3
|
+
* DSH cores that filter tools *before* the system prompt is built.
|
|
4
|
+
*
|
|
5
|
+
* Why this exists
|
|
6
|
+
* ---------------
|
|
7
|
+
* DSH ≤ 0.2.1 handed `system-prompt/assemble` an assembly with `tools` already
|
|
8
|
+
* attached, so `lib/tool-assembly.js` could filter that list in the waterfall.
|
|
9
|
+
*
|
|
10
|
+
* DSH ≥ 0.2.2 does not: `@deepseek-ai/dsh-tools` publishes the model-facing
|
|
11
|
+
* tool list through a `systemPrompt.tools()` contributor built from a
|
|
12
|
+
* **per-step admission set** (`tools.resolve()` → `registration.when(context)`),
|
|
13
|
+
* and the waterfall runs without a tool list. Filtering an already-built list
|
|
14
|
+
* therefore cannot work — a tool outside the admission set never reaches the
|
|
15
|
+
* prompt, and a tool inside it cannot be removed afterwards.
|
|
16
|
+
*
|
|
17
|
+
* The only seam that still carries a decision is the registration itself:
|
|
18
|
+
* `register(definition, { when })` stores a condition that `resolve()` evaluates
|
|
19
|
+
* once per step. So the plugin declares `when` at registration time and lets the
|
|
20
|
+
* core do the admission — which is also cheaper, because the model never sees
|
|
21
|
+
* the tool it was not admitted for.
|
|
22
|
+
*
|
|
23
|
+
* Bare core compatibility: `register` on ≤ 0.2.1 takes a single argument and
|
|
24
|
+
* ignores the extra one, so the waterfall transform in `tool-assembly.js` keeps
|
|
25
|
+
* working there untouched. This gate is installed only when the core actually
|
|
26
|
+
* exposes the admission seam (`tools.resolve`).
|
|
27
|
+
* @module dsh-mcp/tool-admission
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/** Marks one wrapper as this plugin's gate, so a reload cannot stack a second. */
|
|
31
|
+
const GATE_MARK = Symbol.for("dsh-mcp.admission-gate");
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Whether one MCP tool may enter a step's model-facing tool set.
|
|
35
|
+
*
|
|
36
|
+
* - a switched-off tool is never admitted;
|
|
37
|
+
* - `search` mode admits only the hot set (recently searched or called) plus
|
|
38
|
+
* whatever `mcp_tool_search` injected for the next step;
|
|
39
|
+
* - `full` mode admits every tool that is not switched off.
|
|
40
|
+
*
|
|
41
|
+
* The hot set is read live: `when` is evaluated per step, so a tool that
|
|
42
|
+
* `mcp_tool_search` just recorded becomes admissible on the very next step.
|
|
43
|
+
* @param {string} name - public tool name (`mcp__<server>__<tool>`).
|
|
44
|
+
* @param {object} state - live plugin state.
|
|
45
|
+
* @param {string} state.toolMode - `search` or `full`.
|
|
46
|
+
* @param {Map<string, boolean>} state.toolSwitches - public name → enabled.
|
|
47
|
+
* @param {Map<string, number>} state.hotTools - the resident/hot tool names.
|
|
48
|
+
* @returns {boolean} whether the tool may be shown to the model this step.
|
|
49
|
+
*/
|
|
50
|
+
export function shouldAdmitTool(name, state) {
|
|
51
|
+
const { toolMode, toolSwitches, hotTools } = state;
|
|
52
|
+
if (toolSwitches.get(name) === false) return false;
|
|
53
|
+
if (toolMode === "search") return hotTools.has(name);
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Install the admission gate on a tool registry, or report that this core does
|
|
59
|
+
* not need it.
|
|
60
|
+
*
|
|
61
|
+
* Every `mcp__*` registration is wrapped so the core receives a `when`
|
|
62
|
+
* condition built from `isAdmitted`. A caller-supplied `when` is preserved and
|
|
63
|
+
* still wins: the plugin's admission is ANDed after it, never in front of it.
|
|
64
|
+
* Registrations outside the `mcp__` namespace — notably `mcp_tool_search`
|
|
65
|
+
* itself, which must stay callable to admit anything at all — pass through
|
|
66
|
+
* untouched.
|
|
67
|
+
*
|
|
68
|
+
* @param {object} tools - the core's `tools` service (`ctx.tools`).
|
|
69
|
+
* @param {(name: string) => boolean} isAdmitted - live admission decision.
|
|
70
|
+
* @returns {(() => void) | undefined} a disposer restoring the original
|
|
71
|
+
* `register`, or `undefined` when this core has no admission seam (in which
|
|
72
|
+
* case the waterfall transform remains the only filter and nothing is
|
|
73
|
+
* monkey-patched).
|
|
74
|
+
*/
|
|
75
|
+
export function installAdmissionGate(tools, isAdmitted) {
|
|
76
|
+
if (tools === null || typeof tools !== "object") return undefined;
|
|
77
|
+
if (typeof tools.register !== "function") return undefined;
|
|
78
|
+
// `tools.resolve()` is the per-step admission pass introduced with the
|
|
79
|
+
// `when` option; without it the extra argument would be dead weight and the
|
|
80
|
+
// waterfall transform is still the working path.
|
|
81
|
+
if (typeof tools.resolve !== "function") return undefined;
|
|
82
|
+
if (tools.register[GATE_MARK] === true) return () => {};
|
|
83
|
+
|
|
84
|
+
const original = tools.register;
|
|
85
|
+
const hadOwnRegister = Object.prototype.hasOwnProperty.call(tools, "register");
|
|
86
|
+
|
|
87
|
+
const gate = function registerWithAdmission(definition, options) {
|
|
88
|
+
const name = definition !== null && typeof definition === "object" && typeof definition.name === "string"
|
|
89
|
+
? definition.name
|
|
90
|
+
: undefined;
|
|
91
|
+
if (name === undefined || !name.startsWith("mcp__")) {
|
|
92
|
+
return original.call(this, definition, options);
|
|
93
|
+
}
|
|
94
|
+
const base = options !== null && typeof options === "object" ? options : {};
|
|
95
|
+
const callerWhen = base.when;
|
|
96
|
+
const when = typeof callerWhen === "function"
|
|
97
|
+
? async (context) => (await callerWhen(context)) && isAdmitted(name)
|
|
98
|
+
: () => isAdmitted(name);
|
|
99
|
+
return original.call(this, definition, { ...base, when });
|
|
100
|
+
};
|
|
101
|
+
gate[GATE_MARK] = true;
|
|
102
|
+
tools.register = gate;
|
|
103
|
+
|
|
104
|
+
return () => {
|
|
105
|
+
// Only undo our own patch: a later plugin may have wrapped register in
|
|
106
|
+
// turn, and deleting their wrapper would re-open the admission hole.
|
|
107
|
+
if (tools.register !== gate) return;
|
|
108
|
+
if (hadOwnRegister) tools.register = original;
|
|
109
|
+
else delete tools.register;
|
|
110
|
+
};
|
|
111
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool-control transform for the `system-prompt/assemble` waterfall.
|
|
3
|
+
*
|
|
4
|
+
* Kept out of `lib/index.js` on purpose: this transform is the part that broke
|
|
5
|
+
* when DSH moved the tool list outside the seam, and it has to stay testable
|
|
6
|
+
* without the DSH module closure (`lib/index.js` imports `@deepseek-ai/*`).
|
|
7
|
+
*
|
|
8
|
+
* Context: DSH ≤ 0.2.1 handed `assembly` to the waterfall with `tools` already
|
|
9
|
+
* attached. DSH ≥ 0.2.2 attaches the tool list **after** the waterfall runs, so
|
|
10
|
+
* an assembly reaching this hook has `sections` / `contexts` / `variables` but
|
|
11
|
+
* no `tools`. The old inline hook iterated `assembly.tools` unconditionally, so
|
|
12
|
+
* every turn threw `TypeError: assembly.tools is not iterable` during pre-step
|
|
13
|
+
* assembly — the model was never called and the UI showed "本轮运行失败".
|
|
14
|
+
*
|
|
15
|
+
* On such a core this seam simply cannot filter tools (the core overwrites the
|
|
16
|
+
* list afterwards anyway), so the transform reports "not applied" instead of
|
|
17
|
+
* throwing, and the host logs the degraded state once.
|
|
18
|
+
* @module dsh-mcp/tool-assembly
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Apply per-tool switches, search-mode hot-tool injection and the canonical
|
|
23
|
+
* (prompt-cache friendly) tool order.
|
|
24
|
+
*
|
|
25
|
+
* @param {object} assembly - the `system-prompt/assemble` payload. It may or
|
|
26
|
+
* may not carry `tools`; when it does not, nothing is mutated.
|
|
27
|
+
* @param {object} state - live plugin state / helpers.
|
|
28
|
+
* @param {Map<string, boolean>} state.toolSwitches - public tool name → enabled.
|
|
29
|
+
* @param {'all'|'search'} state.toolMode - injection mode.
|
|
30
|
+
* @param {Map<string, number>} state.hotTools - recently used MCP tool names.
|
|
31
|
+
* @param {(name: string) => string} state.serverOf - server namespace of a tool.
|
|
32
|
+
* @param {(key: string, vars?: object) => string} state.promptText - localized
|
|
33
|
+
* host copy for the injected `mcp-tool-control` section.
|
|
34
|
+
* @returns {boolean} `true` when the transform ran; `false` when this core does
|
|
35
|
+
* not expose the tool list at this seam (degraded, not an error).
|
|
36
|
+
*/
|
|
37
|
+
export function applyToolControl(assembly, state) {
|
|
38
|
+
if (!assembly || !Array.isArray(assembly.tools)) return false;
|
|
39
|
+
const { toolSwitches, toolMode, hotTools, serverOf, promptText } = state;
|
|
40
|
+
const kept = [];
|
|
41
|
+
const mcpByName = {};
|
|
42
|
+
for (const tool of assembly.tools) {
|
|
43
|
+
if (!tool.name.startsWith("mcp__")) {
|
|
44
|
+
kept.push(tool);
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (toolSwitches.get(tool.name) === false) continue;
|
|
48
|
+
mcpByName[tool.name] = tool;
|
|
49
|
+
if (toolMode !== "search") kept.push(tool);
|
|
50
|
+
}
|
|
51
|
+
if (toolMode === "search") {
|
|
52
|
+
for (const name of hotTools.keys()) {
|
|
53
|
+
const tool = mcpByName[name];
|
|
54
|
+
if (tool) kept.push(tool);
|
|
55
|
+
}
|
|
56
|
+
const servers = [...new Set(Object.keys(mcpByName).map((name) => serverOf(name)))].sort();
|
|
57
|
+
assembly.sections = (assembly.sections || []).filter((section) => section.name !== "mcp-tool-control");
|
|
58
|
+
assembly.sections.push({
|
|
59
|
+
name: "mcp-tool-control",
|
|
60
|
+
text: promptText("toolControlPrompt", { servers: servers.join(", ") || promptText("noServers") })
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
// Canonical tool order: render MCP tools sorted by name so the system prompt
|
|
64
|
+
// stays byte-stable for the same tool set no matter the registration or
|
|
65
|
+
// hot-set order (hot tools move on every call, and servers may reorder
|
|
66
|
+
// tools/list) — stable output is what preserves prompt-cache hits.
|
|
67
|
+
const mcpKept = [];
|
|
68
|
+
const otherKept = [];
|
|
69
|
+
for (const tool of kept) (tool.name.startsWith("mcp__") ? mcpKept : otherKept).push(tool);
|
|
70
|
+
mcpKept.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
|
|
71
|
+
assembly.tools = [...otherKept, ...mcpKept];
|
|
72
|
+
return true;
|
|
73
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-mcp",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.1",
|
|
4
4
|
"description": "MCP 管理界面 + tool search:可视化配置/启停/刷新 MCP 服务器与工具勾选,按需检索(tool search)热注入;工具列表稳定命中缓存、不撑爆上下文。DeepSeek Harness plugin: MCP management UI + tool search — stable tool list, cache-friendly, no context bloat.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"url": "https://github.com/ArvinQi/dsh-mcp/issues"
|
|
42
42
|
},
|
|
43
43
|
"dsh": {
|
|
44
|
-
"supported": "0.2.
|
|
44
|
+
"supported": "0.2.2-rc.1",
|
|
45
45
|
"bundle": {
|
|
46
46
|
"patch": "./cordis.patch.yml"
|
|
47
47
|
},
|
package/scripts/build.mjs
CHANGED
|
@@ -101,7 +101,13 @@ function cssModuleLoader() {
|
|
|
101
101
|
[...selectorText.matchAll(/\.([A-Za-z_][A-Za-z0-9_-]*)/g)].map((match) => match[1]),
|
|
102
102
|
)]
|
|
103
103
|
const map = Object.fromEntries(classes.map((name) => [name, name]))
|
|
104
|
-
|
|
104
|
+
// Windows hands the CSS module loader backslash-separated paths.
|
|
105
|
+
// Splitting only on '/' keeps the whole `C:\Users\...` prefix inside
|
|
106
|
+
// `data-file`, and the runtime lookup below then builds
|
|
107
|
+
// `style[data-plugin="dsh-mcp"][data-file="C:\Users\..."]` — an
|
|
108
|
+
// invalid selector, so querySelector throws and the client bundle
|
|
109
|
+
// never loads (the Web shell fails to boot).
|
|
110
|
+
const file = args.path.split(/[/\\]/).pop()
|
|
105
111
|
const contents = [
|
|
106
112
|
`(function () {`,
|
|
107
113
|
` if (typeof document !== 'undefined') {`,
|
|
@@ -442,11 +442,14 @@ export function McpSettingsSection(props: McpSettingsSectionProps): ReactNode {
|
|
|
442
442
|
t={t}
|
|
443
443
|
actions={actions}
|
|
444
444
|
injected={{ save, remove, test, list, oauthStart, oauthStatus }}
|
|
445
|
-
onSaved={() => {
|
|
445
|
+
onSaved={(serverName, warning) => {
|
|
446
446
|
// Mounting is asynchronous: refresh again after the connection
|
|
447
447
|
// settles so the badge and tool count reflect the live state without
|
|
448
|
-
// a manual refresh (mirrors the enable-toggle path).
|
|
449
|
-
|
|
448
|
+
// a manual refresh (mirrors the enable-toggle path). The name is
|
|
449
|
+
// carried out of the form because `cancelEdit` nulls the draft
|
|
450
|
+
// before this callback runs.
|
|
451
|
+
if (warning !== undefined) setActionNotice(warning)
|
|
452
|
+
if (serverName.length === 0) return
|
|
450
453
|
timersRef.current.push(window.setTimeout(() => refreshServer(serverName), 2000))
|
|
451
454
|
timersRef.current.push(window.setTimeout(() => refreshServer(serverName), 6000))
|
|
452
455
|
}}
|
|
@@ -44,8 +44,13 @@ export interface McpServerFormProps {
|
|
|
44
44
|
t: (key: McpSettingsLocaleKey) => string
|
|
45
45
|
actions: McpServerFormActions
|
|
46
46
|
injected: McpServerFormRemote
|
|
47
|
-
/**
|
|
48
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Called after a successful save, before the editor closes. Carries the
|
|
49
|
+
* server name (the draft is nulled by `cancelEdit`, so reading it back from
|
|
50
|
+
* the store here threw a TypeError and lost the post-save refresh) and an
|
|
51
|
+
* optional advisory: a connection failure already observed for this draft.
|
|
52
|
+
*/
|
|
53
|
+
onSaved?: (serverName: string, warning?: string) => void
|
|
49
54
|
}
|
|
50
55
|
|
|
51
56
|
/** Render the editor for one server draft. */
|
|
@@ -126,14 +131,23 @@ export function McpServerForm(props: McpServerFormProps): ReactNode {
|
|
|
126
131
|
setSaveError(null)
|
|
127
132
|
actions.setBusy('save')
|
|
128
133
|
try {
|
|
134
|
+
// Saving never runs a mandatory probe: the Host is the authority on the
|
|
135
|
+
// spec, and a server that is temporarily unreachable (or still
|
|
136
|
+
// authorizing) must still be savable. A connection failure the user
|
|
137
|
+
// already observed in this editor is passed along as an advisory so the
|
|
138
|
+
// page can warn instead of silently pretending everything is healthy.
|
|
139
|
+
const observed = test?.probe
|
|
140
|
+
const warning = observed !== undefined && observed.ok === false && observed.oauthRequired !== true
|
|
141
|
+
? `${t('testFail')}: ${observed.message}`
|
|
142
|
+
: undefined
|
|
129
143
|
const failure = await injected.save(draft)
|
|
130
144
|
if (failure !== null) {
|
|
131
145
|
setSaveError(`${failure.code}: ${failure.message}`)
|
|
132
146
|
return
|
|
133
147
|
}
|
|
134
148
|
if (!await refresh()) return
|
|
149
|
+
onSaved?.(draft.serverName.trim(), warning)
|
|
135
150
|
actions.cancelEdit()
|
|
136
|
-
onSaved?.()
|
|
137
151
|
} catch (error) {
|
|
138
152
|
console.error('[dsh-mcp] save failed:', error)
|
|
139
153
|
setSaveError(errorText(error))
|
|
@@ -176,7 +190,12 @@ export function McpServerForm(props: McpServerFormProps): ReactNode {
|
|
|
176
190
|
const stdio = draft.transport === 'stdio'
|
|
177
191
|
const probe = test?.probe
|
|
178
192
|
return (
|
|
179
|
-
|
|
193
|
+
// `noValidate` keeps the browser's native constraint validation out of the
|
|
194
|
+
// way: `type="url"` rejected values the Host accepts (e.g. a bare
|
|
195
|
+
// `host:port`), and the blocked submit produced no error line at all —
|
|
196
|
+
// "保存没有触发即便格式合法". The Host validates the spec and reports
|
|
197
|
+
// `MCP_INVALID_SPEC` with a localized message.
|
|
198
|
+
<form className={css.form} noValidate onSubmit={(event) => { event.preventDefault(); void submit() }}>
|
|
180
199
|
<div className={css.titleRow}>
|
|
181
200
|
<h3 className={css.title}>{draft.id === null ? t('newTitle') : t('editTitle')}</h3>
|
|
182
201
|
<div className={css.titleActions}>
|
package/src/client/index.ts
CHANGED
|
@@ -20,15 +20,26 @@ type McpRemoteResult<Value> =
|
|
|
20
20
|
| { readonly ok: true; readonly value: Value }
|
|
21
21
|
| { readonly ok: false; readonly error: { readonly code: string; readonly message: string } }
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Business outcome the Host returns *inside* a carrier result. `upsert` and
|
|
25
|
+
* `delete` reject invalid specs and conflicts here rather than as a carrier
|
|
26
|
+
* failure, so the caller must inspect `value.ok` — checking the carrier's own
|
|
27
|
+
* `ok` swallows the Host's error and reports a false success.
|
|
28
|
+
*/
|
|
29
|
+
type McpHostOutcome<Value = unknown> =
|
|
30
|
+
| ({ readonly ok: true } & Value)
|
|
31
|
+
| { readonly ok: false; readonly error: { readonly code: string; readonly message: string } }
|
|
32
|
+
|
|
23
33
|
/** Wire face of the self-mounted `mcpManager` Remote namespace. */
|
|
24
34
|
interface McpManagerRemote {
|
|
25
35
|
list(): Promise<McpRemoteResult<{ readonly servers: readonly McpServerView[] }>>
|
|
26
36
|
upsert(request: {
|
|
27
37
|
readonly id?: McpServerId
|
|
28
38
|
readonly server: unknown
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
39
|
+
/** Omitted or empty keeps the stored env unchanged. */
|
|
40
|
+
readonly env?: readonly unknown[]
|
|
41
|
+
}): Promise<McpRemoteResult<McpHostOutcome<{ readonly server: McpServerView }>>>
|
|
42
|
+
delete(request: { readonly id: McpServerId }): Promise<McpRemoteResult<McpHostOutcome>>
|
|
32
43
|
upsertJson(request: { readonly servers: readonly unknown[] }): Promise<McpRemoteResult<{
|
|
33
44
|
readonly added: number
|
|
34
45
|
readonly updated: number
|
|
@@ -138,17 +149,19 @@ export async function apply(ctx: Context): Promise<void> {
|
|
|
138
149
|
},
|
|
139
150
|
save: async (draft) => {
|
|
140
151
|
const submission = draftToSubmission(draft)
|
|
141
|
-
|
|
152
|
+
// Two layers: the carrier (`ok`/`value`) from the Remote transport, then
|
|
153
|
+
// the Host's own outcome inside it. Unwrapping the carrier and reading
|
|
154
|
+
// `value.ok` is what surfaces "invalid spec" / "name conflict" instead of
|
|
155
|
+
// reporting a save that never happened.
|
|
156
|
+
const outcome = await unwrap(() => manager.upsert({
|
|
142
157
|
...draft.id === null ? {} : { id: draft.id },
|
|
143
158
|
server: submission.server,
|
|
144
|
-
})
|
|
145
|
-
|
|
146
|
-
return failureOf(result.error)
|
|
159
|
+
}))
|
|
160
|
+
return outcome.ok ? null : failureOf(outcome.error)
|
|
147
161
|
},
|
|
148
162
|
remove: async (id) => {
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
return failureOf(result.error)
|
|
163
|
+
const outcome = await unwrap(() => manager.delete({ id }))
|
|
164
|
+
return outcome.ok ? null : failureOf(outcome.error)
|
|
152
165
|
},
|
|
153
166
|
upsertJson: async (servers) => {
|
|
154
167
|
const result = await unwrap(() => manager.upsertJson({ servers }))
|