dsh-mcp 1.13.0 → 1.14.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 CHANGED
@@ -9,9 +9,48 @@ 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.1.6-alpha.2`** — developed and verified on `0.1.6-alpha.2` (declared in `package.json` → `dsh.supported`). 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).
12
+ - **Supported DSH version**: **dsh `0.2.0-rc.2`** — the latest release is developed and verified on `0.2.0-rc.2` (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.14.1] - 2026-10-20
16
+
17
+ - **Supported DSH version**: **dsh `0.2.0-rc.2`**
18
+
19
+ ### Fixed
20
+
21
+ - **Plugin styles no longer leak into the host UI, and controls are styled by class only ([#14](https://github.com/ArvinQi/dsh-mcp/issues/14))**: `ServerForm.module.css` and `McpSettingsSection.module.css` each carried an unqualified `button { … }` rule, and several selectors ended in an element (`.field input`, `.row input`, `.actions button`, `.retryRow button`). The client stylesheets are injected into the host's `<head>` verbatim — the build's CSS Modules are an identity class map, not a scoping boundary — so those rules matched **every** matching element in the host page. The DSH composer's attach button (28×28, bottom-left) and send button (34×34, bottom-right) center their SVG with `display: grid; place-items: center` and declare no `padding` of their own; the leaked `padding: 5px 12px` shrank their content box from 16px / 22px to 4px / 10px, the 14px / 16px icon overflowed horizontally and was aligned to the start edge, so the icon drifted right inside the circle (measured +5.0 px and +3.0 px). **No style targets an element any more** (`button` / `input` / `select` / `textarea` / `label` / `p` are all gone): the base control styles now live in the new `src/client/controls.module.css` as classes — `.button` (with `:hover` / `:focus-visible` / `:disabled`), `.buttonSmall`, `.primary`, `.control` (shared by `<input>` / `<select>` / `<textarea>`), `.controlMono` and `.checkbox`. Components import that module for the class **names** only; their own sheets keep layout plus the `.active` / `.danger` / `.dangerButton` / `.moduleTitle` modifiers, all matched by class. Because an identity class map makes class names global, the shared classes are defined exactly once, in `controls.module.css`; specificity no longer needs tricks (the previous `:where()` wrappers are gone) — within that one sheet `.primary` follows `.button`, and the component sheets are injected after it
22
+
23
+ ### Notes
24
+
25
+ - `test/client-style-scope.test.mjs` was rewritten: (1) every selector of `src/client/*.module.css` must be a pure class chain (an element selector, `*` or `:root` fails); (2) the bundle is loaded through the shell's loader wire format and the stylesheets it actually injects are checked the same way; (3) the shared classes must be defined once, `controls.module.css` must be injected first, and the `.primary` / `.buttonSmall` / `.controlMono` rules must follow their base classes; (4) every `<button>` in the `.tsx` sources must carry `controls.button` so a missed class cannot silently render an unstyled control. It fails against the pre-fix build
26
+ - `scripts/build.mjs` strips CSS comments before computing the identity class map, so class names mentioned only in a comment no longer become dead keys; the build header now states that injected styles are global, that every rule must be a pure class selector, and that shared control classes live in `controls.module.css`
27
+ - Only the client half changed (the host `lib/index.js` and all Remote interfaces are untouched), so upgrading the plugin and hard-refreshing the DSH page is enough to see the centered icons
28
+
29
+ ## [1.14.0] - 2026-10-13
30
+
31
+ - **Supported DSH version**: **dsh `0.2.0-rc.2`**
32
+
33
+ ### Changed
34
+
35
+ - **HTTPS servers are verified against the system trust store by default**: the host's `streamable-http` connections and its OAuth metadata discovery / dynamic registration / token exchange all went through Node's bundled root store, so intranet hosts (Ctrip Root CA, Zscaler/Sangfor proxy roots — CAs that only live in the OS keychain) failed with `fetch failed` / `UNABLE_TO_VERIFY_LEAF_SIGNATURE` unless `dsh web` was started with `NODE_OPTIONS=--use-system-ca` or `NODE_EXTRA_CA_CERTS`. The new `lib/system-ca.js` merges the operating system's roots into Node's default store at plugin start (`tls.getCACertificates('system')`, keeping every bundled root, idempotent), so HTTPS requests verify exactly what the OS trusts; on older hosts (Node < 24.9, no such API) it falls back to a scoped fetch bound to an undici Agent carrying the system roots. Neither path touches `http` servers or sites that were already trusted. Measured on the user's machine: 135 system roots are merged; and the DSH desktop runtime drops `NODE_OPTIONS` outright (`Node.js environment variables are disabled…`), so intranet HTTPS works exactly because of this merge — a server whose certificate is issued by `Ctrip Root Certificate Authority` connects without the variable
36
+ - **OAuth authorization is now a button plus 5s polling, and the Host opens the browser**: the server card shows an "Authorize" button when authorization is missing (new `oauthStart` / `oauthStatus` Remotes). Clicking it makes the **Host** open the authorization page in the system browser — a client-side `window.open` is denied inside the DSH shell and only flashes a blank tab, which was the "nothing happens" root cause. The row then shows "authorizing…" and polls the status every 5 seconds; once tokens land the existing `credentials/reference-updated` path remounts the server, the button disappears and the tools appear. Mounts and "Test connection" share one loopback flow (`createToolAuthorizationUrl` now dedupes concurrent requests per server)
37
+ - **The editor no longer carries its own authorization button**: the "open authorization page" button and link paragraph are gone (they cannot open in the shell and only added noise); the editor keeps the OAuth switch, a one-line hint and an "authorizing… / authorization complete" status, and "Test connection" remains its probe
38
+ - **The authorization outcome is visible**: the Host records the last flow's result per server, `oauthStatus` returns `pending` and `error` (the authorization server's `access_denied`, or a token-exchange failure), and the row renders "authorizing… / authorization failed: reason / authorization did not complete (retry)". The server view gained `oauthAuthorized` (list/upsert/adopt results) as the basis for the button and badge
39
+
40
+ ### Fixed
41
+
42
+ - **No more "authorization failed" before the user authorized**: an OAuth server used to render a red "mount failed" with the raw error as soon as it needed authorization, and Test connection popped the browser and could block for up to 5 minutes. `test` no longer opens a browser or blocks for an OAuth server — it returns an `oauthRequired` marker immediately; the mount records `status.oauthRequired` from a provider callback before the error is thrown (the `mcp-client` wrapper replaces the error, so the flag must be set early); the page renders that as an "awaiting authorization" badge and a one-line hint
43
+ - **The loopback callback port no longer leaks, and a retry is no longer shadowed by a stale connection**: the callback answered with keep-alive, so `server.close()` waited for the connection to end and the next authorization on the same stable port could have its callback delivered to the previous (closed) listener — the new one never fired and the page polled forever. Callbacks now answer with `Connection: close` and are force-closed via `closeAllConnections()`; the regression test proves a deny-then-retry succeeds without leaving a listening port behind
44
+ - **A working OAuth server is no longer flagged as unauthorized**: a server that is `live` and serving tools (its static headers are enough) keeps its normal status badge and a plain "Authorize" button; the red "not authorized" badge/button and the hint are reserved for servers the missing authorization actually blocks
45
+ - **No more raw authorization-link text when authorization is missing**: the several-hundred-character authorization URL embedded in the mount error (it contains `response_type=code`) is recognized and reduced to a one-line "click Authorize to finish"; real failures still show their diagnostic text
46
+
47
+ ### Notes
48
+
49
+ - Added `test/oauth-flow.test.mjs`: a built-in fake OAuth server (RFC 9728 resource metadata + RFC 8414 authorization-server metadata + registration/token endpoints, with `/mcp` always answering a 401 challenge) drives the real SDK flow, covering `oauthStart` payload validation and "the Host opens the browser", the `pending → authorized` poll, Test connection reporting `oauthRequired` instead of a failure, the mount's `status.oauthRequired`, and a deny (`access_denied`) followed by a successful retry that leaves no listening port behind
50
+ - Added `test/system-ca.test.mjs`: it mints a 127.0.0.1 self-signed certificate with openssl, serves HTTPS, and asserts that `fetch` fails before the merge and succeeds after while every bundled root survives (skipped without openssl or on Node < 24.9)
51
+ - Added `test/client-bundle.test.mjs`: it loads the built artifact through the shell's `__ModuleLoader__` wire format and asserts the exports plus the new copy/Remotes, so a stale `lib/client.js` fails the suite
52
+ - Verified live against a `dsh web` host (`web` profile): `mcpManager/oauthStart` and `oauthStatus` answer (`octop-memory-oauth: authorized:false`, `bigdata-adhoc-mcp-oauth: authorized:true`), `list` returns `oauthAuthorized`, and the served client bundle rev matches the repository build
53
+
15
54
  ## [1.13.0] - 2026-10-08
16
55
 
17
56
  - **Supported DSH version**: **dsh `0.1.6-alpha.2`**
package/CHANGELOG.md CHANGED
@@ -9,9 +9,48 @@
9
9
 
10
10
  ## 兼容性
11
11
 
12
- - **支持版本**:**dsh `0.1.6-alpha.2`** —— 本插件在 `0.1.6-alpha.2` 上开发与验证(`package.json` → `dsh.supported` 同步声明)。DSH 与插件版本不匹配时,设置页会给出排查诊断(核对 bundle 是否已选中 → 重启 `dsh web` → 硬刷新 → 同步升级)。
12
+ - **支持版本**:**dsh `0.2.0-rc.2`** —— 最新版本在 `0.2.0-rc.2` 上开发与验证(`package.json` → `dsh.supported` 同步声明);历史版本条目各自声明当时验证的版本。DSH 与插件版本不匹配时,设置页会给出排查诊断(核对 bundle 是否已选中 → 重启 `dsh web` → 硬刷新 → 同步升级)。
13
13
  - **发版约定**:每个版本条目都要声明 `- **支持版本**:dsh <版本>`,并在 GitHub Release notes 中同步。Release 正文用**中文**(与本文档一致),标题层级与条目一致。
14
14
 
15
+ ## [1.14.1] - 2026-10-20
16
+
17
+ - **支持版本**:**dsh `0.2.0-rc.2`**
18
+
19
+ ### 修复
20
+
21
+ - **插件样式不再泄漏到宿主界面,控件样式一律改为 class([#14](https://github.com/ArvinQi/dsh-mcp/issues/14))**:`ServerForm.module.css` 与 `McpSettingsSection.module.css` 里各有一条没有父级限定的 `button { … }` 规则,另外还有 `.field input` / `.row input` / `.actions button` / `.retryRow button` 等以元素为右端的选择器;而客户端样式表是原样注入宿主 `<head>` 的——构建的 CSS Modules 只做恒等类名映射,没有任何作用域边界——于是这些规则命中了宿主页面上对应的**每一个**元素。DSH 输入框左下角的加号按钮(28×28)与右下角的发送按钮(34×34)靠 `display: grid; place-items: center` 让图标居中、自身不声明 `padding`,被泄漏的 `padding: 5px 12px` 把内容盒从 16px / 22px 挤到 4px / 10px,14px / 16px 的图标横向溢出、按起始边对齐,图标因此在圆内向右偏移(实测 +5.0 px 与 +3.0 px)。现在**不再有任何以元素为目标的样式**(`button` / `input` / `select` / `textarea` / `label` / `p` 全部消失):基础控件样式集中到新的 `src/client/controls.module.css`,以类名定义——`.button`(连同 `:hover` / `:focus-visible` / `:disabled`)、`.buttonSmall`、`.primary`、`.control`(`<input>` / `<select>` / `<textarea>` 共用)、`.controlMono`、`.checkbox`;各组件只从这个模块取**类名**,自己的样式表保留布局与 `.active` / `.danger` / `.dangerButton` / `.moduleTitle` 等修饰类,也全部只按 class 匹配。因为恒等类名映射下同名类就是全局的,共享类只在 `controls.module.css` 里定义一次;优先级也不再依赖技巧(此前用 `:where()` 压低权重),改为「同一个表内 `.primary` 排在 `.button` 之后 + 组件样式表固定在共享表之后注入」
22
+
23
+ ### 说明
24
+
25
+ - 重写 `test/client-style-scope.test.mjs`:① 逐条检查 `src/client/*.module.css` 的选择器,要求是纯 class 链(出现元素选择器 / `*` / `:root` 即失败);② 按宿主加载器格式装载 `lib/client.js`,检查它实际注入的样式表同样没有元素选择器;③ 断言共享控件类只定义一次、`controls.module.css` 排在其它样式表之前,且 `.primary` / `.buttonSmall` / `.controlMono` 规则顺序保证变体覆盖基础类;④ 扫描所有 `.tsx`,每个 `<button>` 必须带 `controls.button`(避免漏类名退回无样式)。用修复前的构建产物跑该测试会失败
26
+ - `scripts/build.mjs` 生成恒等类名表前先剥离 CSS 注释(注释里提到的类名不再成为死 key);构建脚本头部改为说明「注入的样式表是全局的,规则必须是纯 class 选择器,控件共享类集中在 controls.module.css」
27
+ - 本次只有客户端包内容变化(宿主 `lib/index.js` 与所有 Remote 接口未变),升级插件后硬刷新 DSH 页面即可看到图标居中
28
+
29
+ ## [1.14.0] - 2026-10-13
30
+
31
+ - **支持版本**:**dsh `0.2.0-rc.2`**
32
+
33
+ ### 变更
34
+
35
+ - **HTTPS 服务器默认按系统证书校验**:宿主的 `streamable-http` 连接、OAuth 元数据发现/动态注册/token 交换此前都走 Node 自带的根证书库,于是内网域名(Ctrip Root CA、Zscaler/Sangfor 代理根等只装在系统钥匙串里的 CA)报 `fetch failed` / `UNABLE_TO_VERIFY_LEAF_SIGNATURE`,必须先给 `dsh web` 加 `NODE_OPTIONS=--use-system-ca` 或 `NODE_EXTRA_CA_CERTS` 才能用。现在新模块 `lib/system-ca.js` 在插件启动时把**操作系统信任库的根证书并入 Node 默认库**(`tls.getCACertificates('system')`,保留 Node 自带根、重复调用幂等),HTTPS 请求即按系统证书校验;宿主 Node 较旧(< 24.9,无该 API)时退回用 undici Agent 携带系统根做定向 fetch,两条路径都不影响 `http` 服务器与原本就信任的站点。真机实测:本机识别 135 条系统根证书;且 DSH 桌面的 Electron-as-Node 运行时会直接丢弃 `NODE_OPTIONS`(日志 `Node.js environment variables are disabled…`),所以内网 HTTPS 正是靠这个合并才通——证书签发者为 `Ctrip Root Certificate Authority` 的 MCP 服务器在未设该环境变量时也能连通
36
+ - **OAuth 授权改为「按钮 + 5 秒轮询」,浏览器由宿主打开**:服务器卡片在授权缺失时显示「OAuth 授权」按钮(新增 Remote `oauthStart` / `oauthStatus`);点击后由**宿主**用系统浏览器打开授权页——客户端 `window.open` 在 DSH 外壳里会被拒绝、只闪一下空白标签页,这是"点了没反应"的根因;随后行上显示「授权中…」并每 5 秒查询一次授权状态,token 落库后照旧经 `credentials/reference-updated` 自动重挂载,按钮消失、工具出现。挂载与「测试连接」共用同一个回环回调流程(`createToolAuthorizationUrl` 增加同服务器并发去重),先挂载再点按钮不会重复起监听、不会抢同一个固定端口
37
+ - **编辑表单不再有自己的授权按钮**:删掉「打开授权页面」按钮与链接段落(外壳里打不开、只会制造噪音),编辑页只保留 OAuth 勾选、一行说明与「授权中/授权成功」状态;「测试连接」仍是表单里的探测方式
38
+ - **授权结果可见**:宿主按服务器记录最近一次流程结果,`oauthStatus` 返回 `pending` 与 `error`(授权服务器回的 `access_denied`、或 token 交换失败),列表行据此显示「授权中… / 授权失败: 原因 / 授权未完成(可重试)」,不再是"点完没有任何反馈";新增 `oauthAuthorized` 视图字段(列表/upsert/adopt 结果)作为按钮与徽标的依据
39
+
40
+ ### 修复
41
+
42
+ - **授权完成前不再显示「授权失败」**:此前 OAuth 服务器的挂载/测试在用户尚未授权时就以红色「挂载失败」+ 原文错误呈现,测试连接还会自动弹浏览器并最多阻塞 5 分钟。现在 `test` 对 OAuth 服务器不再自动开浏览器、不再阻塞,改为立即返回带 `oauthRequired` 标记的结果;挂载侧由 provider 回调在抛错前标记 `status.oauthRequired`(`mcp-client` 会包装错误、吞掉稳定错误码,所以标记必须提前完成);设置页遇到该标记只显示「等待授权」徽标与一行提示
43
+ - **回环回调端口不再泄漏,重试不再被旧连接顶掉**:回调此前用 keep-alive 应答,`server.close()` 会一直等连接释放;同一稳定端口的下一次授权可能把回环请求投递给上一个已关闭的监听器,新监听器永远收不到回调(表现为一直"授权中")。现在回调响应带 `Connection: close`,处理结束强制 `closeAllConnections()`,回归测试里"先拒绝再重试"必须成功且进程不残留端口
44
+ - **不再把正常工作的 OAuth 服务器标成未授权**:服务器 `live` 且有工具(静态 token 已够用)时保持正常状态徽标,只留一个普通「OAuth 授权」按钮;红色「未授权」徽标/红色按钮与提示仅用于授权确实卡住挂载(失败、无工具)的服务器
45
+ - **未授权时不再显示授权链接长文本**:挂载错误里那条几百字符的授权 URL(带 `response_type=code`)被识别并收敛成一行「点击「OAuth 授权」完成授权即可」,其余真实故障仍原样显示
46
+
47
+ ### 说明
48
+
49
+ - 新增 `test/oauth-flow.test.mjs`:用一个内置的假 OAuth 服务器(RFC 9728 资源元数据 + RFC 8414 授权服务器元数据 + 注册/token 端点,`/mcp` 一律回 401 挑战)真跑 SDK 授权链路,覆盖 `oauthStart` 参数校验与"宿主负责打开浏览器"、`pending → authorized` 轮询、测试连接返回 `oauthRequired` 而非失败、挂载 `status.oauthRequired`、以及"先拒绝(`access_denied`)再重试必须成功且不残留监听端口"
50
+ - 新增 `test/system-ca.test.mjs`:用 openssl 现造 127.0.0.1 自签证书起 HTTPS 服务,断言合并前 `fetch` 失败、合并后成功,且 Node 自带根证书全部保留(无 openssl 或 Node < 24.9 的环境自动跳过)
51
+ - 新增 `test/client-bundle.test.mjs`:按 shell 的 `__ModuleLoader__` 线上格式加载构建产物,断言导出与新增文案/Remote,防止 `lib/client.js` 陈旧
52
+ - 真机验证:`dsh web`(`web` profile)宿主 `mcpManager/oauthStart` / `oauthStatus` 正常应答(`octop-memory-oauth: authorized:false`、`bigdata-adhoc-mcp-oauth: authorized:true`),`list` 返回 `oauthAuthorized`,客户端包 rev 与仓库构建一致
53
+
15
54
  ## [1.13.0] - 2026-10-08
16
55
 
17
56
  - **支持版本**:**dsh `0.1.6-alpha.2`**
package/README.en.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![dshfind](https://dshfind.com/api/badge/ArvinQi/dsh-mcp?lang=en)](https://dshfind.com/en/plugins/ArvinQi/dsh-mcp?ref=badge)
4
4
 
5
- > **Supported DSH version**: `dsh 0.1.6-alpha.2` — developed and verified on `0.1.6-alpha.2`, 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).
5
+ > **Supported DSH version**: `dsh 0.2.0-rc.2` — the latest release is developed and verified on `0.2.0-rc.2`, 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
  ![Settings preview](static/snapshot.en.webp)
8
8
 
@@ -23,7 +23,8 @@
23
23
  - **Image result passthrough**: images returned by MCP tools (screenshots/charts) are projected through the attachment service into model image context, with strict preflight and bounded fallbacks (PR #4)
24
24
  - **Two injection modes**: `search` (on-demand, token-saving) and `full` (inject everything)
25
25
  - **Zero npm dependencies**: plugs into DeepSeek Harness internals, install and go
26
- - **OAuth authentication**: for `streamable-http` servers using MCP OAuth (authorization-code + PKCE), the browser opens automatically for authorization on connect; tokens and OAuth client info are persisted and refreshed automatically by the SDK (auto-renewed while active within 24h), with automatic re-authorization after expiry
26
+ - **OAuth authentication**: for `streamable-http` servers using MCP OAuth (authorization-code + PKCE), the server card has an **Authorize** button and the **Host opens the system browser** for the login; the page then polls the authorization status every 5 seconds. Tokens and OAuth client info are persisted and refreshed automatically by the SDK (auto-renewed while active within 24h), with re-authorization after expiry. **Before you authorize it only says "authorizing"; a real failure reports its reason**
27
+ - **HTTPS verified against the system trust store by default**: intranet/corporate CAs (roots installed in the OS keychain) no longer need `NODE_OPTIONS=--use-system-ca` on `dsh web`; the plugin merges the OS store into Node's default root store at startup
27
28
  - **Three install paths**: npm / GitHub git source / local link; bilingual UI and docs
28
29
 
29
30
  Migrated and merged from uncommitted MCP work in the `deepseek-harness` repository:
@@ -47,9 +48,13 @@ Migrated and merged from uncommitted MCP work in the `deepseek-harness` reposito
47
48
  - Injection mode: `search` (on-demand, default — the model hot-injects tools via `mcp_tool_search`) and `full` (inject every enabled tool each request).
48
49
  - Expandable per-server tool list, all checked by default; unchecking a tool keeps it out of injection. Changes take effect immediately.
49
50
  - **OAuth authentication** (host, `lib/oauth.js`): on a 401 + OAuth challenge from a `streamable-http`
50
- server, runs the authorization-code + PKCE flow automatically — opens the browser, receives the
51
- callback on a loopback server, persists tokens, and refreshes them on demand; test connection and
52
- mounts share the same token.
51
+ server, runs the authorization-code + PKCE flow — receives the callback on a loopback server,
52
+ persists tokens, and refreshes them on demand; the settings page offers an "Authorize" button
53
+ (Remote `oauthStart`, the Host opens the system browser) and a 5s `oauthStatus` poll returning
54
+ `pending` / `authorized` / the failure reason. Test connections share the mount's token.
55
+ - **System certificate verification** (host, `lib/system-ca.js`): at startup the OS trust store's roots
56
+ are merged into Node's default store, so HTTPS connections and OAuth discovery/registration/token
57
+ exchange verify against the system store (on Node < 24.9 it falls back to a scoped undici-Agent fetch).
53
58
  - **Remote self-mount**: the client half mounts the `mcpManager` Remote namespace itself via `ctx.remote.$mount()` in `apply()`,
54
59
  so no in-box package modification is required.
55
60
  - **Declared servers are read too** (host, `lib/cordis-servers.js`): `@deepseek-ai/dsh-mcp-client` rows
@@ -80,7 +85,7 @@ Since 1.11.0 those declarations appear in Settings → MCP, badged "cordis decla
80
85
  - **Imported into storages as mirrors**: at startup and on every refresh the declarations are imported into the storage domain (id `cordis:<rowId>`, with `origin/declaredIn/declaredRowId`), **import only** — a row created in the plugin is never overwritten; a mirror whose declaration disappeared is **removed automatically** (a mirror is only a copy of a declaration, so an ownerless one must not pile up); a declaration containing a `!!js` expression is skipped and flagged with the reason (its value only resolves inside the Loader). Mirrors are never mounted — the composition owns the mount.
81
86
  - **Take over / give back**: clicking "Take over" makes the plugin write an id-targeted `disabled: true` into its own **managed block** in `cordis.patch.yml` (a `.dsh-mcp.bak` backup is taken before the first write; atomic, idempotent, reversible, confined to that block). The declaration releases the `serverName` and the plugin mounts its own row instead — enabling **OAuth authorization, managed credentials, `${VAR}` header substitution and connection tests**. A hard mount failure rolls back automatically (the block is removed and the row returns to mirror state) and reports why; "Give back" hands the mount back to the declaration and deletes the managed row. A declaration without an explicit `id`, or one containing a `!!js` expression, cannot be taken over.
82
87
  - **OAuth / placeholder limit (`needsPlugin`)**: a declaration can carry neither an OAuth provider nor `${VAR}` / bare-name placeholder substitution — only the plugin does those. Such a declaration can therefore only work while the plugin owns the mount: the page reports it as **failed with the reason** (not "connecting"), "Give back" makes its tools disappear (the confirmation and the result warning both say so), and taking it over again restores them.
83
- - **OAuth is an explicit switch (since 1.11.1)**: an OAuth provider is attached only when the server sets `oauth: true` (the form's "Use OAuth authorization" checkbox, off by default). **Do not tick it for servers that authenticate with static tokens or custom headers** — otherwise a 401 is treated as an OAuth challenge and the plugin keeps opening the browser (with its `127.0.0.1:<port>/callback` loopback listener). The plugin also opens the browser **at most once per server per process**; later automatic attempts return the authorization-link error, and "Test connection" can still start one on demand. Upgrading migrates automatically from existing OAuth credentials, so servers that genuinely need OAuth are unaffected.
88
+ - **OAuth is an explicit switch (since 1.11.1)**: an OAuth provider is attached only when the server sets `oauth: true` (the form's "Use OAuth authorization" checkbox, off by default). **Do not tick it for servers that authenticate with static tokens or custom headers** — otherwise a 401 is treated as an OAuth challenge and the plugin starts a `127.0.0.1:<port>/callback` loopback flow. Authorization is started from the settings page's button: a mount still opens the browser **at most once per server per process**, an unauthorized server renders "awaiting authorization" and polls every 5s instead of a failure, and "Test connection" no longer opens a browser — it returns the authorization-required marker and the button opens the page. Upgrading migrates automatically from existing OAuth credentials, so servers that genuinely need OAuth are unaffected.
84
89
  - **Safe degradation when the hot reload does not commit**: if the native tools have not unregistered within 5 seconds of writing the disable block (that profile's patch hot reload did not commit — a sibling entry failing its re-apply rolls the whole generation back), the plugin **registers the takeover without mounting** (the managed row is marked `pendingTakeover`); the next dsh start mounts it, and "Give back" reports the same need for a restart. A mount is also always skipped when same-named `mcp__<server>__` tools already exist without a local mount, so the plugin never fights a still-mounted declaration for one name.
85
90
  - **Tool search covers them**: search/hot injection and per-tool switches work by `mcp__` prefix across the whole tool set, so declared tools need no extra configuration.
86
91
 
@@ -96,6 +101,7 @@ dsh-mcp/
96
101
  │ ├── patch-writer.js managed-block writer: disables a declaration on takeover (backup/atomic/idempotent)
97
102
  │ ├── mcp-client.js vendored MCP client (from @deepseek-ai/dsh-mcp-client, with tool-list stability extension)
98
103
  │ ├── oauth.js MCP OAuth client provider (authorization-code + PKCE, loopback callback, token persistence)
104
+ │ ├── system-ca.js system CA trust: merges the OS roots into Node's default store (1.14.0)
99
105
  │ ├── probe.js vendored connection probe (from mcp-client/src/probe.ts)
100
106
  │ ├── transport.js vendored transport factory (from mcp-client/src/transport.ts)
101
107
  │ └── client.js browser half (esbuild bundle, ModuleLoader wire format)
@@ -258,8 +264,11 @@ Check in order:
258
264
  `Authorization` header, so a 401 is never mistaken for an OAuth challenge that opens the browser.
259
265
  For a static-token server, make sure the request headers are correct;
260
266
  - If an HTTPS intranet host reports `fetch failed` / `unable to verify the first certificate`, the
261
- host Node does not trust the internal CA: start `dsh web` with `NODE_OPTIONS=--use-system-ca`
262
- (or add the root cert to `NODE_EXTRA_CA_CERTS`), then restart the host and hard-refresh.
267
+ host Node does not trust the internal CA. **Since 1.14.0 the plugin merges the system trust store
268
+ into Node's default store at startup** (see the system-certificate note under "OAuth servers"), so
269
+ no extra configuration is normally needed; if it still fails, check that the root really is installed
270
+ in the OS keychain, or fall back to `NODE_OPTIONS=--use-system-ca` / `NODE_EXTRA_CA_CERTS`, then
271
+ restart the host and hard-refresh.
263
272
 
264
273
  **Add a server**:
265
274
 
@@ -292,16 +301,34 @@ Check in order:
292
301
 
293
302
  **OAuth servers** (`streamable-http` using MCP OAuth, e.g. OAuth-protected gateway services):
294
303
 
295
- - Just fill in the URL and test the connection; when the server responds with a 401 + OAuth challenge,
296
- the plugin **opens the browser automatically** for authorization.
297
- - Log in / approve in the browser and return to DSH; the test result refreshes automatically
298
- ("connection succeeded + tool count").
304
+ - Fill in the URL and tick "Use OAuth authorization"; when authorization is missing the card shows an
305
+ **Authorize** button (the editor has no button of its own — just the switch, a one-line hint and an
306
+ "authorizing / authorization complete" status).
307
+ - Clicking it makes the **Host open the system browser** (a client-side `window.open` is denied inside the
308
+ DSH shell and only flashes), the row shows "authorizing…" and **checks the status every 5 seconds**; a
309
+ manual link in the row covers the case where the browser did not come up.
310
+ - On success the button disappears and the tools appear; a failure reports its reason (e.g.
311
+ "authorization failed: access_denied"), and an expired callback says "authorization did not complete
312
+ (retry)". Nothing is reported as failed before you authorize.
299
313
  - Tokens and the registered OAuth client are persisted in the credentials document (scoped by `serverName`)
300
314
  and refreshed automatically by the MCP SDK (auto-renewed while active within 24h); after authorizing once,
301
315
  mounts and later test connections reuse the same token, and an expired token triggers a fresh
302
- browser authorization automatically.
303
- - The first authorization needs browser interaction, so the test/connect wait budget is relaxed to
304
- 5 minutes; non-OAuth servers are unaffected and fail fast.
316
+ authorization automatically.
317
+ - A server that is already live and serving tools (its static token is enough) is not flagged red; the red
318
+ badge/button is reserved for servers the missing authorization actually blocks.
319
+ - The first mount (`allowBrowserOnMount`, on by default) may still open the browser once; set
320
+ `allowBrowserOnMount: false` in the profile patch to make authorization fully button-driven. Non-OAuth
321
+ servers are unaffected and fail fast.
322
+
323
+ **HTTPS intranet certificates**:
324
+
325
+ - At startup the plugin merges the **operating system trust store** into Node's default root store
326
+ (`lib/system-ca.js`), so `streamable-http` connections and OAuth discovery/registration/token exchange
327
+ trust exactly what the browser and curl trust: a root installed in the OS keychain (corporate CA,
328
+ Zscaler/Sangfor proxy root, ...) needs no `NODE_OPTIONS=--use-system-ca` / `NODE_EXTRA_CA_CERTS`.
329
+ - Every bundled Node root survives (merge, not replace; idempotent); on hosts below Node 24.9 (no
330
+ `tls.getCACertificates`) it falls back to a scoped undici-Agent fetch carrying the system roots, and
331
+ keeps the previous behaviour if even that is unavailable.
305
332
 
306
333
  **Day-to-day management**:
307
334
 
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  [![dshfind](https://dshfind.com/api/badge/ArvinQi/dsh-mcp?lang=zh)](https://dshfind.com/zh/plugins/ArvinQi/dsh-mcp?ref=badge)
6
6
 
7
- > **支持版本**:`dsh 0.1.6-alpha.2` —— 本插件在 `0.1.6-alpha.2` 上开发与验证,`package.json` → `dsh.supported` 同步声明。DSH 与插件两侧版本不匹配时,设置页会给出排查诊断(检查 bundle 是否已选中 → 重启 `dsh web` → 硬刷新 → 同步升级)。
7
+ > **支持版本**:`dsh 0.2.0-rc.2` —— 最新版本在 `0.2.0-rc.2` 上开发与验证,`package.json` → `dsh.supported` 同步声明。DSH 与插件两侧版本不匹配时,设置页会给出排查诊断(检查 bundle 是否已选中 → 重启 `dsh web` → 硬刷新 → 同步升级)。
8
8
 
9
9
  ![设置页预览](static/snapshot.webp)
10
10
 
@@ -25,7 +25,8 @@
25
25
  - **图片结果透传**:MCP 工具返回的图片(截图/图表等)经附件服务投影为图片引用进入模型上下文,带严格预检与有界降级文案(PR #4)
26
26
  - **双注入模式**:`search`(按需检索,省 token)与 `full`(全量注入)
27
27
  - **零 npm 依赖**:直接对接 DeepSeek Harness 内部能力,安装即用
28
- - **OAuth 认证支持**:`streamable-http` 服务器若走 MCP OAuth(授权码 + PKCE),连接时自动打开浏览器授权;token 与 client 信息持久化、由 SDK 自动刷新(24 小时内活跃自动续期),失效后自动重新授权
28
+ - **OAuth 认证支持**:`streamable-http` 服务器若走 MCP OAuth(授权码 + PKCE),服务器卡片点「OAuth 授权」按钮,**由宿主打开系统浏览器**完成授权,本页每 5 秒轮询授权状态;token 与 client 信息持久化、由 SDK 自动刷新(24 小时内活跃自动续期),失效后重新授权。**授权完成前只显示「授权中」,授权失败会写明原因**
29
+ - **HTTPS 默认按系统证书校验**:内网/公司 CA(只装在系统钥匙串里的根证书)无需再给 `dsh web` 加 `NODE_OPTIONS=--use-system-ca`,插件启动时把系统信任库并入 Node 默认根证书库
29
30
  - **三种安装方式**:npm / GitHub git 源 / 本地 link;中英文界面与文档
30
31
 
31
32
  ## 功能
@@ -34,9 +35,12 @@
34
35
  `@deepseek-ai/dsh-mcp-client` 实例、环境变量注入(明文入定义、secret 走 credentials)、
35
36
  连接探测(test)。
36
37
  - **Web 设置管理页**(client):Settings → MCP,列表/编辑/删除/测试服务器。
37
- - **OAuth 认证**(host,`lib/oauth.js`):`streamable-http` 服务器遇 401 + OAuth 挑战时自动走
38
- 授权码 + PKCE 流程,打开浏览器授权、回环回调收码、token 持久化并按需自动刷新;
39
- 测试连接与挂载共用同一份 token。
38
+ - **OAuth 认证**(host,`lib/oauth.js`):`streamable-http` 服务器遇 401 + OAuth 挑战时走
39
+ 授权码 + PKCE 流程,回环回调收码、token 持久化并按需自动刷新;设置页提供「OAuth 授权」按钮
40
+ (Remote `oauthStart`,浏览器由宿主用系统浏览器打开)与每 5 秒一次的 `oauthStatus` 轮询
41
+ (返回 `pending` / `authorized` / 失败原因),测试连接与挂载共用同一份 token。
42
+ - **系统证书校验**(host,`lib/system-ca.js`):启动时把操作系统信任库的根证书并入 Node 默认库,
43
+ HTTPS 连接与 OAuth 发现/注册/token 交换因此按系统证书校验(Node < 24.9 时退回 undici Agent 定向 fetch)。
40
44
  - **Remote 自挂载**:client 半部在 `apply()` 里自行 `ctx.remote.$mount()` 挂载 `mcpManager`
41
45
  命名空间(原实现依赖 api-remotes 的 in-box 修改,独立版不再需要任何 in-box 包改动)。
42
46
  - **读取声明式服务器**(host,`lib/cordis-servers.js`):把 patch 层里原生声明的
@@ -80,8 +84,9 @@ DSH 原生支持在组合里直接声明 MCP 服务器:**一行一台**,`nam
80
84
  重新「接管」。
81
85
  - **OAuth 是显式开关(1.11.1 起)**:服务器配置里的 `oauth: true`(设置页「使用 OAuth 授权」勾选,默认关)
82
86
  才会挂 OAuth provider。**用静态 token 或自定义头认证的服务器不要勾**——否则它返回 401 时会被当成 OAuth
83
- 挑战,插件会反复打开浏览器授权(并起 `127.0.0.1:<port>/callback` 回环回调)。另外,同一服务器**每个进程
84
- 最多自动弹一次**浏览器,之后只返回带授权链接的错误;手动「测试连接」仍可随时发起授权。升级时会按已有
87
+ 挑战,起 `127.0.0.1:<port>/callback` 回环回调。授权由设置页的按钮发起(见下节):挂载阶段同一服务器
88
+ **每个进程最多自动弹一次**浏览器,未授权时页面显示「等待授权」并每 5 秒轮询状态,不报授权失败;
89
+ 「测试连接」不再自动弹浏览器,而是返回需要授权的标记,由按钮打开授权页。升级时会按已有
85
90
  OAuth 凭据自动迁移,真正需要 OAuth 的服务器不受影响。
86
91
  - **热重载未提交时的安全降级**:写入停用块后若原生工具 5 秒内没有注销(该 profile 的 patch 热重载未提交,
87
92
  例如某个兄弟条目重建失败导致整代回滚),插件会**登记接管但暂不挂载**(管理行标记 `pendingTakeover`),
@@ -102,6 +107,7 @@ dsh-mcp/
102
107
  │ ├── patch-writer.js 受管块写入器:接管时在 patch 文件里停用声明行(备份/原子/幂等)
103
108
  │ ├── mcp-client.js vendored MCP 客户端(源自 @deepseek-ai/dsh-mcp-client,含工具列表稳定扩展)
104
109
  │ ├── oauth.js MCP OAuth 客户端提供者(授权码 + PKCE、回环回调、token 持久化)
110
+ │ ├── system-ca.js 系统证书信任:把操作系统根证书并入 Node 默认库(1.14.0)
105
111
  │ ├── probe.js vendored 连接探测(源自 mcp-client/src/probe.ts)
106
112
  │ ├── transport.js vendored 传输工厂(源自 mcp-client/src/transport.ts)
107
113
  │ └── client.js 浏览器半部(esbuild 打包,ModuleLoader wire format)
@@ -252,8 +258,9 @@ dsh plugin --profile web add link:<本仓库绝对路径>
252
258
  401 被误当成 OAuth 挑战而打开浏览器授权。若你连的是需要静态 token 的服务器,确认请求头
253
259
  正确即可;
254
260
  - 若 https 内网域名报 `fetch failed` / `unable to verify the first certificate`,是宿主 Node
255
- 不信任公司内网 CA:用 `NODE_OPTIONS=--use-system-ca` 启动 `dsh web`(或把根证书加入
256
- `NODE_EXTRA_CA_CERTS`),再重启宿主与硬刷新浏览器。
261
+ 不信任公司内网 CA。**1.14.0 起插件启动时已自动把系统信任库并入 Node 默认库**(见「OAuth 服务器」下方的
262
+ 系统证书说明),通常无需额外配置;仍失败时再检查系统钥匙串里是否装了该根证书,或临时用
263
+ `NODE_OPTIONS=--use-system-ca` / `NODE_EXTRA_CA_CERTS` 启动 `dsh web` 兜底,并重启宿主与硬刷新浏览器。
257
264
 
258
265
  **添加服务器**:
259
266
 
@@ -280,11 +287,27 @@ dsh plugin --profile web add link:<本仓库绝对路径>
280
287
 
281
288
  **OAuth 服务器**(`streamable-http` 走 MCP OAuth,如受 OAuth 保护的网关服务):
282
289
 
283
- - 只需正常填写 URL 并测试连接;服务器返回 401 + OAuth 挑战时,插件**自动打开浏览器**完成授权
284
- - 在浏览器中登录/同意后返回 DSH,测试结果自动刷新(「连接成功 + 工具数」)
290
+ - 正常填写 URL 并勾选「使用 OAuth 授权」;授权缺失时服务器卡片会出现 **「OAuth 授权」按钮**
291
+ (编辑页不再有自己的按钮,只保留勾选、一行说明与「授权中/授权成功」状态)
292
+ - 点击按钮**由宿主打开系统浏览器**(客户端 `window.open` 在 DSH 外壳里会被拒绝、只闪一下),
293
+ 行上显示「授权中…」并**每 5 秒检查一次授权状态**;浏览器没起来时可以点行内的手动链接
294
+ - 授权成功后按钮消失、工具出现;失败会写明原因(如「授权失败: access_denied」),
295
+ 回调消失则显示「授权未完成(可重试)」——授权完成前不会报失败
285
296
  - token 与 OAuth client 信息持久化在凭据文档(按 `serverName` 隔离),由 MCP SDK 自动刷新
286
- (24 小时内活跃自动续期);失效后自动重新授权,授权一次后挂载与测试复用
287
- - 首次授权需浏览器交互,测试/连接等待时间放宽至 5 分钟;非 OAuth 服务器不受影响,连接失败即时返回
297
+ (24 小时内活跃自动续期);失效后重新授权,授权一次后挂载与测试复用
298
+ - 已经 `live` 且有工具的服务器(静态 token 够用)不会被打上红色「未授权」,只保留一个普通授权按钮;
299
+ 红色徽标/红色按钮只用于授权确实卡住挂载的服务器
300
+ - 第一次挂载(`allowBrowserOnMount`,默认开)仍可能自动弹一次浏览器;把 profile 的
301
+ `allowBrowserOnMount` 设为 `false` 即可完全改为「按钮驱动」。非 OAuth 服务器不受影响,连接失败即时返回
302
+
303
+ **HTTPS 内网证书**:
304
+
305
+ - 插件启动时把**操作系统信任库**的根证书并入 Node 默认根证书库(`lib/system-ca.js`),
306
+ `streamable-http` 连接、OAuth 元数据发现/注册/token 交换因此与浏览器、curl 的信任一致:
307
+ 只要根证书装在系统钥匙串里(公司内网 CA、Zscaler/Sangfor 代理根等),就无需再设置
308
+ `NODE_OPTIONS=--use-system-ca` / `NODE_EXTRA_CA_CERTS`
309
+ - Node 自带根证书全部保留(并入而非替换,幂等);宿主 Node 低于 24.9(无 `tls.getCACertificates`)时
310
+ 退回用 undici Agent 携带系统根做定向 fetch,失败则维持原行为
288
311
 
289
312
  **日常管理**:
290
313