dsh-mcp 1.14.1 → 1.14.3

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
@@ -12,6 +12,33 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
12
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.3] - 2026-10-31
16
+
17
+ - **Supported DSH version**: **dsh `0.2.0-rc.2`**
18
+
19
+ ### Fixed
20
+
21
+ - **Authorization fails after the browser already reports success when the authorization server advertises RFC 9207 `iss` support but never sends `iss` ([#18](https://github.com/ArvinQi/dsh-mcp/issues/18))**: Notion's authorization-server metadata (`https://mcp.notion.com/.well-known/oauth-authorization-server`) says `authorization_response_iss_parameter_supported: true`, yet its real callback URL carries **no** `iss` parameter. MCP SDK 2.0.0's `validateAuthorizationResponseIssuer()` reads "advertised + absent" as an authorization-server mix-up attack and throws `IssuerMismatchError`, so the browser shows a successful authorization while the plugin reports `Issuer mismatch in authorization response (RFC 9207): expected "https://mcp.notion.com", received undefined` — with no way around it until the server fixes its metadata. Two changes in `lib/oauth.js`: (1) the `iss` from the callback URL is now handed to `exchangeAuthorization()` as-is — it used to be **dropped**, so the SDK only ever saw `undefined` and that was wrong in both directions: a server that advertises support *and* sends the correct `iss` was also rejected, while a **mix-up response carrying a wrong `iss` from a non-advertising server was silently accepted**; (2) only when the callback really carries no `iss` and the metadata claims support is that one claim removed (from a copy, so registration/authorization-URL construction see the original) before the token exchange, with one warning logged — RFC 9207 makes `iss` OPTIONAL, so an absent value is not by itself an attack signal, the advertisement is simply inaccurate for this response. A callback that does carry `iss` still goes through the SDK's strict string comparison and still throws on a mismatch. Both the settings-page / tool-auth callback listener and the legacy no-`serverUrl` fallback listener are fixed
22
+
23
+ ### Notes
24
+
25
+ - Three regression cases added to `test/oauth-flow.test.mjs` (that file needs the DSH module closure, so it runs only where a DSH installation is present): (1) advertises support but sends no `iss` → authorizes (the #18 reproduction, which failed before the fix); (2) callback with the correct `iss` → authorizes (also failed before the fix: with the parameter dropped, validation saw `undefined`); (3) callback with a wrong `iss` → still rejected with `Issuer mismatch` and no tokens stored
26
+ - Host-side `lib/oauth.js` only: the client bundle `lib/client.js` and every Remote interface are untouched, so no rebuild is needed after upgrading
27
+
28
+ ## [1.14.2] - 2026-10-29
29
+
30
+ - **Supported DSH version**: **dsh `0.2.0-rc.2`**
31
+
32
+ ### Fixed
33
+
34
+ - **Windows OAuth authorization page never opens ([#16](https://github.com/ArvinQi/dsh-mcp/issues/16))**: `openBrowser` used to run `spawn("start", [url])` on Windows, but `start` is a `cmd.exe` builtin rather than an executable, so spawning it without a shell only ever produced `ENOENT` — and `child.on("error", () => {})` swallowed that error. The result was that on Windows the authorization page never opened and nothing was reported (both call sites in `lib/oauth.js`, `oauthStart` and `allowBrowserOnMount`, were affected). It now uses `rundll32.exe url.dll,FileProtocolHandler`, passing the authorization URL as **one untouched argument** with no shell involved, so `&` in the query string cannot split the command — which also avoids the command-injection surface of handing the URL back to a shell via `cmd /c start "" <url>`. The macOS (`open`) / Linux (`xdg-open`) openers and the best-effort semantics (error callback, `detached`, `unref`) are unchanged (PR [#17](https://github.com/ArvinQi/dsh-mcp/pull/17), thanks [@Nyarlathoteppppp](https://github.com/Nyarlathoteppppp))
35
+
36
+ ### Notes
37
+
38
+ - New zero-dependency module `lib/browser-command.js`: `browserCommand(url, platform)` returns the "command + argument array" per platform, lifting "which program opens the URL" out of `openBrowser` so it can be asserted
39
+ - New `test/oauth-browser.test.mjs`: asserts that on win32 an authorization URL containing `&` is handed to `rundll32.exe url.dll,FileProtocolHandler` as a single argument, and that the darwin / linux commands are unchanged; the test does not need the DSH module closure, so it also runs in CI's `npm test` (unlike `oauth-flow.test.mjs`, which is skipped there)
40
+ - Only the host-side way of opening the browser changed: the client bundle `lib/client.js` and every Remote interface are untouched, so no rebuild is needed after upgrading
41
+
15
42
  ## [1.14.1] - 2026-10-20
16
43
 
17
44
  - **Supported DSH version**: **dsh `0.2.0-rc.2`**
package/CHANGELOG.md CHANGED
@@ -12,6 +12,33 @@
12
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.3] - 2026-10-31
16
+
17
+ - **支持版本**:**dsh `0.2.0-rc.2`**
18
+
19
+ ### 修复
20
+
21
+ - **授权服务器「声明支持 RFC 9207 `iss` 却不在回调里带」时,浏览器已显示授权成功、插件仍判失败([#18](https://github.com/ArvinQi/dsh-mcp/issues/18))**:Notion 的授权服务器元数据(`https://mcp.notion.com/.well-known/oauth-authorization-server`)写着 `authorization_response_iss_parameter_supported: true`,但真实的回调 URL 里**没有** `iss` 参数;MCP SDK 2.0.0 的 `validateAuthorizationResponseIssuer()` 把「声明支持 + 回调缺失」直接当作授权服务器混同攻击并抛 `IssuerMismatchError`,于是浏览器页面上授权已经成功、插件侧却报 `Issuer mismatch in authorization response (RFC 9207): expected "https://mcp.notion.com", received undefined`,在服务端修好元数据之前无法绕过。修复包含两点(`lib/oauth.js`):① 回调 URL 里的 `iss` 现在会原样交给 `exchangeAuthorization()`——此前它被**丢弃**,SDK 只能拿到 `undefined`,于是反过来两头都错:「声明支持 `iss` 且确实回了正确 `iss` 的服务器」照样被判失败,「没声明支持、却带回错误 `iss` 的混同响应」反倒被静默放行;② 只有当回调**确实没带** `iss`、而元数据又声明支持时,才把这一条声明从交给令牌交换的元数据**副本**上去掉,并打一条 warning 日志(RFC 9207 中 `iss` 本就是可选参数,缺失本身不是攻击信号,声明只是与本次响应不符)。带着 `iss` 的回调仍走 SDK 的严格字符串比对,`iss` 与 `metadata.issuer` 不一致照样抛错;设置页 / tool-auth 的回调监听器与「无 serverUrl」的旧版兜底监听器两条路径都已修正
22
+
23
+ ### 说明
24
+
25
+ - 新增 3 个回归用例到 `test/oauth-flow.test.mjs`(该文件依赖 DSH 模块闭包,只在本地装有 DSH 的环境执行):① 声明支持但回调不带 `iss` → 授权成功(#18 的复现,修复前失败);② 回调带正确的 `iss` → 授权成功(修复前同样失败:`iss` 被丢弃后校验看到的是 `undefined`);③ 回调带错误的 `iss` → 仍然拒绝并报 `Issuer mismatch`,且不落任何 token
26
+ - 本次只改宿主侧 `lib/oauth.js`:客户端包 `lib/client.js` 与所有 Remote 接口未变,升级后无需重新构建产物
27
+
28
+ ## [1.14.2] - 2026-10-29
29
+
30
+ - **支持版本**:**dsh `0.2.0-rc.2`**
31
+
32
+ ### 修复
33
+
34
+ - **Windows OAuth 授权页无法打开([#16](https://github.com/ArvinQi/dsh-mcp/issues/16))**:此前 `openBrowser` 在 Windows 上执行 `spawn("start", [url])`,而 `start` 是 `cmd.exe` 的内置命令、并非可执行文件,不经过 shell 启动只会得到 `ENOENT`,该错误又被 `child.on("error", () => {})` 静默吞掉,于是 Windows 上发起 OAuth 授权时浏览器根本不打开、也没有任何提示(`lib/oauth.js` 里 `oauthStart` 与 `allowBrowserOnMount` 两处调用都受影响)。现改用 `rundll32.exe url.dll,FileProtocolHandler`,授权 URL 作为**单个原样参数**传递、不经过 shell,因此查询参数中的 `&` 不会被拆成命令;同时也避免了 `cmd /c start "" <url>` 那种把 URL 重新交给 shell 解析带来的命令注入面。macOS(`open`)/ Linux(`xdg-open`)的打开方式与「尽力打开」(错误回调、`detached`、`unref`)语义均保持不变(PR [#17](https://github.com/ArvinQi/dsh-mcp/pull/17),感谢 [@Nyarlathoteppppp](https://github.com/Nyarlathoteppppp))
35
+
36
+ ### 说明
37
+
38
+ - 新增零依赖模块 `lib/browser-command.js`:`browserCommand(url, platform)` 按平台返回「命令 + 参数数组」,把「用哪个程序打开」从 `openBrowser` 里剥出来以便断言
39
+ - 新增 `test/oauth-browser.test.mjs`:断言 win32 下含 `&` 的授权 URL 作为单个参数交给 `rundll32.exe url.dll,FileProtocolHandler`,且 darwin / linux 的启动命令保持不变;该测试不依赖 DSH 模块闭包,因此在 CI 的 `npm test` 中也会执行(不会像 `oauth-flow.test.mjs` 那样被跳过)
40
+ - 本次只改变宿主侧打开浏览器的方式:客户端包 `lib/client.js` 与所有 Remote 接口未变,升级后无需重新构建产物
41
+
15
42
  ## [1.14.1] - 2026-10-20
16
43
 
17
44
  - **支持版本**:**dsh `0.2.0-rc.2`**
package/README.en.md CHANGED
@@ -101,6 +101,7 @@ dsh-mcp/
101
101
  │ ├── patch-writer.js managed-block writer: disables a declaration on takeover (backup/atomic/idempotent)
102
102
  │ ├── mcp-client.js vendored MCP client (from @deepseek-ai/dsh-mcp-client, with tool-list stability extension)
103
103
  │ ├── oauth.js MCP OAuth client provider (authorization-code + PKCE, loopback callback, token persistence)
104
+ │ ├── browser-command.js per-platform browser opener: rundll32 on Windows, URL never through a shell (1.14.2)
104
105
  │ ├── system-ca.js system CA trust: merges the OS roots into Node's default store (1.14.0)
105
106
  │ ├── probe.js vendored connection probe (from mcp-client/src/probe.ts)
106
107
  │ ├── transport.js vendored transport factory (from mcp-client/src/transport.ts)
@@ -270,6 +271,20 @@ Check in order:
270
271
  in the OS keychain, or fall back to `NODE_OPTIONS=--use-system-ca` / `NODE_EXTRA_CA_CERTS`, then
271
272
  restart the host and hard-refresh.
272
273
 
274
+ **Q5: The browser already shows a successful authorization, but the plugin reports `Issuer mismatch in authorization response (RFC 9207)`?**
275
+
276
+ - The authorization server's metadata does not match its behaviour: it advertises
277
+ `authorization_response_iss_parameter_supported: true` in
278
+ `/.well-known/oauth-authorization-server`, yet its callback URL carries no `iss` parameter (Notion's
279
+ `https://mcp.notion.com` does exactly this — see
280
+ [#18](https://github.com/ArvinQi/dsh-mcp/issues/18)). Such an inaccurate claim is tolerated **since
281
+ 1.14.3**: the claim is ignored, with a warning in the log, only when the callback
282
+ really carries no `iss`, while a callback that does carry `iss` is still compared strictly. Upgrade and
283
+ restart `dsh web`, then click "Authorize with OAuth" once more;
284
+ - If the log line instead shows a callback that carried an `iss` differing from the metadata `issuer`,
285
+ that is **not** a metadata problem but a genuine authorization-server mix-up risk, still rejected per
286
+ RFC 9207 — check that the MCP server URL and the authorization server really belong together.
287
+
273
288
  **Add a server**:
274
289
 
275
290
  1. Click **Add server** (the form expands inline above the list).
package/README.md CHANGED
@@ -107,6 +107,7 @@ dsh-mcp/
107
107
  │ ├── patch-writer.js 受管块写入器:接管时在 patch 文件里停用声明行(备份/原子/幂等)
108
108
  │ ├── mcp-client.js vendored MCP 客户端(源自 @deepseek-ai/dsh-mcp-client,含工具列表稳定扩展)
109
109
  │ ├── oauth.js MCP OAuth 客户端提供者(授权码 + PKCE、回环回调、token 持久化)
110
+ │ ├── browser-command.js 按平台选择浏览器打开命令:Windows 走 rundll32,URL 不经过 shell(1.14.2)
110
111
  │ ├── system-ca.js 系统证书信任:把操作系统根证书并入 Node 默认库(1.14.0)
111
112
  │ ├── probe.js vendored 连接探测(源自 mcp-client/src/probe.ts)
112
113
  │ ├── transport.js vendored 传输工厂(源自 mcp-client/src/transport.ts)
@@ -262,6 +263,17 @@ dsh plugin --profile web add link:<本仓库绝对路径>
262
263
  系统证书说明),通常无需额外配置;仍失败时再检查系统钥匙串里是否装了该根证书,或临时用
263
264
  `NODE_OPTIONS=--use-system-ca` / `NODE_EXTRA_CA_CERTS` 启动 `dsh web` 兜底,并重启宿主与硬刷新浏览器。
264
265
 
266
+ **Q5:浏览器里已经显示授权成功,插件却报 `Issuer mismatch in authorization response (RFC 9207)`?**
267
+
268
+ - 这是授权服务器的元数据与真实行为不一致:它在 `/.well-known/oauth-authorization-server` 里声明
269
+ `authorization_response_iss_parameter_supported: true`,但回调 URL 里并不带 `iss` 参数
270
+ (Notion 的 `https://mcp.notion.com` 就是如此,见 [#18](https://github.com/ArvinQi/dsh-mcp/issues/18))。
271
+ 该不实声明自 **1.14.3** 起已自动容忍:只有当回调确实没带 `iss` 时,才忽略该声明并打一条
272
+ warning 日志,带 `iss` 的回调仍会严格比对;升级并重启 `dsh web` 后,重新点一次
273
+ 「OAuth 授权」即可;
274
+ - 若日志里的 warning 显示回调带了 `iss` 但与元数据 `issuer` 不一致,那**不是**元数据问题,而是真正的
275
+ 授权服务器混同风险,按 RFC 9207 仍会拒绝——请核对 MCP 服务器 URL 与授权服务器是否配对。
276
+
265
277
  **添加服务器**:
266
278
 
267
279
  1. 点击「添加服务器」(表单在列表上方就地展开)
@@ -0,0 +1,5 @@
1
+ /** Choose a browser opener without passing the URL through a shell. */
2
+ export function browserCommand(url, platform = process.platform) {
3
+ if (platform === "win32") return ["rundll32.exe", ["url.dll,FileProtocolHandler", url]];
4
+ return [platform === "darwin" ? "open" : "xdg-open", [url]];
5
+ }
package/lib/oauth.js CHANGED
@@ -21,6 +21,7 @@ import {
21
21
  startAuthorization,
22
22
  } from "@modelcontextprotocol/client";
23
23
  import { credentialRef } from "@deepseek-ai/dsh-credentials";
24
+ import { browserCommand } from "./browser-command.js";
24
25
  import { hostText } from "./host-locales.js";
25
26
  import { systemFetch } from "./system-ca.js";
26
27
 
@@ -93,11 +94,8 @@ export function oauthCredentialRefs(serverId) {
93
94
 
94
95
  /** Open the system browser to one URL, best effort. */
95
96
  function openBrowser(url) {
96
- const command =
97
- process.platform === "darwin" ? "open"
98
- : process.platform === "win32" ? "start"
99
- : "xdg-open";
100
- const child = spawn(command, [url], { detached: true, stdio: "ignore" });
97
+ const [command, args] = browserCommand(url);
98
+ const child = spawn(command, args, { detached: true, stdio: "ignore" });
101
99
  child.on("error", () => {});
102
100
  child.unref();
103
101
  }
@@ -129,6 +127,46 @@ function jwtExp(accessToken) {
129
127
  }
130
128
  }
131
129
 
130
+ /**
131
+ * Prepare authorization-server metadata for the RFC 9207 check that the MCP
132
+ * SDK runs when an authorization code is redeemed, tolerating a server whose
133
+ * advertisement is not honoured.
134
+ *
135
+ * `validateAuthorizationResponseIssuer()` throws `IssuerMismatchError` when the
136
+ * metadata advertises `authorization_response_iss_parameter_supported: true`
137
+ * and the callback URL carries no `iss` parameter — the SDK reads that
138
+ * combination as an authorization-server mix-up attack. Some servers advertise
139
+ * the parameter and then never send it (Notion's `https://mcp.notion.com`,
140
+ * issue #18), so every attempt fails with
141
+ *
142
+ * Issuer mismatch in authorization response (RFC 9207): expected "…", received undefined
143
+ *
144
+ * right after the browser has already shown the success page. RFC 9207 makes
145
+ * `iss` OPTIONAL, so an absent value is not by itself evidence of an attack;
146
+ * the advertisement is simply inaccurate for this response.
147
+ *
148
+ * When — and only when — the callback really came without `iss`, drop that one
149
+ * claim from the metadata handed to the exchange, and say so in the log. A
150
+ * callback that does carry `iss` keeps the SDK's strict
151
+ * `iss === metadata.issuer` comparison, so mix-up protection is unchanged for
152
+ * servers that implement RFC 9207. The claim is cleared on a copy because the
153
+ * discovered document is shared with client registration and with building the
154
+ * authorization URL.
155
+ *
156
+ * @param metadata - discovered authorization-server metadata.
157
+ * @param iss - the `iss` parameter from the callback, when one was sent.
158
+ * @param log - caller logger, for the one-line diagnostic.
159
+ * @param tag - log prefix carrying the server id.
160
+ * @returns the metadata to pass to `exchangeAuthorization`.
161
+ */
162
+ function metadataForAuthorizationResponse(metadata, iss, log, tag) {
163
+ if (metadata === undefined || metadata === null) return metadata;
164
+ if (iss !== undefined) return metadata;
165
+ if (metadata.authorization_response_iss_parameter_supported !== true) return metadata;
166
+ log.warn?.(`${tag}: authorization server advertises RFC 9207 iss support but the callback carried no iss; ignoring the claim for this exchange`);
167
+ return { ...metadata, authorization_response_iss_parameter_supported: undefined };
168
+ }
169
+
132
170
  /**
133
171
  * Derive a stable loopback port from the server id. The redirect URI must
134
172
  * stay identical across processes because the registered OAuth client's
@@ -334,6 +372,9 @@ export function createOAuthProvider(serverId, ctx, options = {}) {
334
372
  const url = new URL(req.url, redirectUrl);
335
373
  const code = url.searchParams.get("code");
336
374
  const error = url.searchParams.get("error");
375
+ // RFC 9207: keep the issuer the server sent, so the SDK can compare
376
+ // it strictly at exchange time instead of us dropping it silently.
377
+ const iss = url.searchParams.get("iss") ?? undefined;
337
378
  res.setHeader("content-type", "text/html; charset=utf-8");
338
379
  // No keep-alive: the stable port may be reused by the next flow (see
339
380
  // closeCallbackServer).
@@ -347,7 +388,7 @@ export function createOAuthProvider(serverId, ctx, options = {}) {
347
388
  }
348
389
  res.end(hostText(ctx, "oauthOkPage"));
349
390
  log.info(`${tag}: authorization callback received (code)`);
350
- resolveResult({ code });
391
+ resolveResult({ code, iss });
351
392
  });
352
393
  server.on("error", (error) => {
353
394
  log.error(`${tag}: callback server error: ${error instanceof Error ? error.message : String(error)}`);
@@ -370,9 +411,10 @@ export function createOAuthProvider(serverId, ctx, options = {}) {
370
411
  const clientInformation = await this.clientInformation();
371
412
  const codeVerifier = await this.codeVerifier();
372
413
  const tokens = await exchangeAuthorization(authServerUrl, {
373
- metadata,
414
+ metadata: metadataForAuthorizationResponse(metadata, result.iss, log, tag),
374
415
  clientInformation,
375
416
  authorizationCode: result.code,
417
+ iss: result.iss,
376
418
  codeVerifier,
377
419
  redirectUri: redirectUrl,
378
420
  fetchFn: systemFetch(),
@@ -529,6 +571,9 @@ async function createToolAuthorizationUrlOnce(serverId, ctx, serverUrl) {
529
571
  const callbackUrl = new URL(req.url, redirectUrl);
530
572
  const code = callbackUrl.searchParams.get("code");
531
573
  const error = callbackUrl.searchParams.get("error");
574
+ // RFC 9207: keep the issuer the server sent, so the SDK can compare it
575
+ // strictly at exchange time instead of us dropping it silently.
576
+ const iss = callbackUrl.searchParams.get("iss") ?? undefined;
532
577
  res.setHeader("content-type", "text/html; charset=utf-8");
533
578
  // Never keep the callback connection alive: the stable loopback port is
534
579
  // reused by the next flow, and a pooled keep-alive socket would deliver
@@ -549,9 +594,10 @@ async function createToolAuthorizationUrlOnce(serverId, ctx, serverUrl) {
549
594
  const authServerUrl = new URL(authorizationUrl.origin);
550
595
  const metadata = await discoverAuthorizationServerMetadata(authServerUrl, { fetchFn: systemFetch() });
551
596
  const tokens = await exchangeAuthorization(authServerUrl, {
552
- metadata,
597
+ metadata: metadataForAuthorizationResponse(metadata, iss, log, tag),
553
598
  clientInformation: clientInfo,
554
599
  authorizationCode: code,
600
+ iss,
555
601
  codeVerifier,
556
602
  redirectUri: redirectUrl,
557
603
  fetchFn: systemFetch(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-mcp",
3
- "version": "1.14.1",
3
+ "version": "1.14.3",
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",