dsh-mcp 1.14.2 → 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,19 @@ 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
+
15
28
  ## [1.14.2] - 2026-10-29
16
29
 
17
30
  - **Supported DSH version**: **dsh `0.2.0-rc.2`**
package/CHANGELOG.md CHANGED
@@ -12,6 +12,19 @@
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
+
15
28
  ## [1.14.2] - 2026-10-29
16
29
 
17
30
  - **支持版本**:**dsh `0.2.0-rc.2`**
package/README.en.md CHANGED
@@ -271,6 +271,20 @@ Check in order:
271
271
  in the OS keychain, or fall back to `NODE_OPTIONS=--use-system-ca` / `NODE_EXTRA_CA_CERTS`, then
272
272
  restart the host and hard-refresh.
273
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
+
274
288
  **Add a server**:
275
289
 
276
290
  1. Click **Add server** (the form expands inline above the list).
package/README.md CHANGED
@@ -263,6 +263,17 @@ dsh plugin --profile web add link:<本仓库绝对路径>
263
263
  系统证书说明),通常无需额外配置;仍失败时再检查系统钥匙串里是否装了该根证书,或临时用
264
264
  `NODE_OPTIONS=--use-system-ca` / `NODE_EXTRA_CA_CERTS` 启动 `dsh web` 兜底,并重启宿主与硬刷新浏览器。
265
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
+
266
277
  **添加服务器**:
267
278
 
268
279
  1. 点击「添加服务器」(表单在列表上方就地展开)
package/lib/oauth.js CHANGED
@@ -127,6 +127,46 @@ function jwtExp(accessToken) {
127
127
  }
128
128
  }
129
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
+
130
170
  /**
131
171
  * Derive a stable loopback port from the server id. The redirect URI must
132
172
  * stay identical across processes because the registered OAuth client's
@@ -332,6 +372,9 @@ export function createOAuthProvider(serverId, ctx, options = {}) {
332
372
  const url = new URL(req.url, redirectUrl);
333
373
  const code = url.searchParams.get("code");
334
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;
335
378
  res.setHeader("content-type", "text/html; charset=utf-8");
336
379
  // No keep-alive: the stable port may be reused by the next flow (see
337
380
  // closeCallbackServer).
@@ -345,7 +388,7 @@ export function createOAuthProvider(serverId, ctx, options = {}) {
345
388
  }
346
389
  res.end(hostText(ctx, "oauthOkPage"));
347
390
  log.info(`${tag}: authorization callback received (code)`);
348
- resolveResult({ code });
391
+ resolveResult({ code, iss });
349
392
  });
350
393
  server.on("error", (error) => {
351
394
  log.error(`${tag}: callback server error: ${error instanceof Error ? error.message : String(error)}`);
@@ -368,9 +411,10 @@ export function createOAuthProvider(serverId, ctx, options = {}) {
368
411
  const clientInformation = await this.clientInformation();
369
412
  const codeVerifier = await this.codeVerifier();
370
413
  const tokens = await exchangeAuthorization(authServerUrl, {
371
- metadata,
414
+ metadata: metadataForAuthorizationResponse(metadata, result.iss, log, tag),
372
415
  clientInformation,
373
416
  authorizationCode: result.code,
417
+ iss: result.iss,
374
418
  codeVerifier,
375
419
  redirectUri: redirectUrl,
376
420
  fetchFn: systemFetch(),
@@ -527,6 +571,9 @@ async function createToolAuthorizationUrlOnce(serverId, ctx, serverUrl) {
527
571
  const callbackUrl = new URL(req.url, redirectUrl);
528
572
  const code = callbackUrl.searchParams.get("code");
529
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;
530
577
  res.setHeader("content-type", "text/html; charset=utf-8");
531
578
  // Never keep the callback connection alive: the stable loopback port is
532
579
  // reused by the next flow, and a pooled keep-alive socket would deliver
@@ -547,9 +594,10 @@ async function createToolAuthorizationUrlOnce(serverId, ctx, serverUrl) {
547
594
  const authServerUrl = new URL(authorizationUrl.origin);
548
595
  const metadata = await discoverAuthorizationServerMetadata(authServerUrl, { fetchFn: systemFetch() });
549
596
  const tokens = await exchangeAuthorization(authServerUrl, {
550
- metadata,
597
+ metadata: metadataForAuthorizationResponse(metadata, iss, log, tag),
551
598
  clientInformation: clientInfo,
552
599
  authorizationCode: code,
600
+ iss,
553
601
  codeVerifier,
554
602
  redirectUri: redirectUrl,
555
603
  fetchFn: systemFetch(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-mcp",
3
- "version": "1.14.2",
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",