dsh-mcp 1.15.3 → 1.15.4

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,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
12
12
  - **Supported DSH version**: **dsh `0.2.2-rc.3`** — the latest release is developed and verified on `0.2.2-rc.3` (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.4] - 2026-11-21
16
+
17
+ - **Supported DSH version**: **dsh `0.2.2-rc.3`**
18
+
19
+ ### Fixed
20
+
21
+ - **OAuth token exchange failed: the callback rebuilt the authorization-server URL from `authorizationUrl.origin`, dropping the issuer's path (issue #27)**: `createToolAuthorizationUrlOnce()` already receives the path-bearing `info.authorizationServerUrl` from `discoverOAuthServerInfo()` (Appwrite's `https://fra.cloud.appwrite.io/v1/oauth2/console`, Keycloak's `/realms/<realm>`, …), but the token-exchange callback used `new URL(authorizationUrl.origin)`. For a path-based issuer that requests `<host>/.well-known/oauth-authorization-server`, which answers 404, so the SDK throws before sending any token request — the browser shows a successful authorization while tokens are never stored, and mount retries keep re-opening the authorization page
22
+ - New dependency-free `lib/oauth-server-url.js`: prefers the discovered authorization-server URL and falls back to the authorization page's origin only when no discovery result exists; the callback in `lib/oauth.js` now uses that helper
23
+ - New `test/oauth-server-url.test.mjs`: covers a path-based issuer (Appwrite), a string discovery result, the no-discovery fallback, and an invalid discovery result — asserting it never degrades to the origin
24
+
15
25
  ## [1.15.3] - 2026-11-18
16
26
 
17
27
  - **Supported DSH version**: **dsh `0.2.2-rc.3`**
package/CHANGELOG.md CHANGED
@@ -12,6 +12,16 @@
12
12
  - **支持版本**:**dsh `0.2.2-rc.3`** —— 最新版本在 `0.2.2-rc.3` 上开发与验证(`package.json` → `dsh.supported` 同步声明);历史版本条目各自声明当时验证的版本。DSH 与插件版本不匹配时,设置页会给出排查诊断(核对 bundle 是否已选中 → 重启 `dsh web` → 硬刷新 → 同步升级)。
13
13
  - **发版约定**:每个版本条目都要声明 `- **支持版本**:dsh <版本>`,并在 GitHub Release notes 中同步。Release 正文用**中文**(与本文档一致),标题层级与条目一致。
14
14
 
15
+ ## [1.15.4] - 2026-11-21
16
+
17
+ - **支持版本**:**dsh `0.2.2-rc.3`**
18
+
19
+ ### 修复
20
+
21
+ - **OAuth 换 token 失败:回调里用 `authorizationUrl.origin` 重建授权服务器地址,丢掉 issuer 的路径(issue #27)**:`createToolAuthorizationUrlOnce()` 已经通过 `discoverOAuthServerInfo()` 拿到带路径的 `info.authorizationServerUrl`(如 Appwrite 的 `https://fra.cloud.appwrite.io/v1/oauth2/console`、Keycloak 的 `/realms/<realm>`),但回调换 token 时改成了 `new URL(authorizationUrl.origin)`。对带路径的 issuer,这会请求 `<host>/.well-known/oauth-authorization-server` 并得到 404,SDK 在发出 token 请求之前就抛错——浏览器已显示授权成功,token 却永远不落库,挂载重试还会反复弹出授权页
22
+ - 新增无依赖模块 `lib/oauth-server-url.js`:优先使用发现结果中的授权服务器 URL,仅在没有任何发现结果时回退到授权页的 origin;`lib/oauth.js` 的回调改用该 helper
23
+ - 新增 `test/oauth-server-url.test.mjs`:覆盖带路径 issuer(Appwrite)、字符串形式的发现结果、无发现结果回退、以及非法发现结果回退,断言不会退化成 origin
24
+
15
25
  ## [1.15.3] - 2026-11-18
16
26
 
17
27
  - **支持版本**:**dsh `0.2.2-rc.3`**
package/README.en.md CHANGED
@@ -23,7 +23,7 @@
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 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 in the credentials document; when the access token expires the SDK **renews it silently** with the stored refresh token (no interruption, no browser), and only a revoked/expired refresh token needs re-authorization. **Before you authorize it only says "authorizing"; a real failure reports its reason**
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 in the credentials document; when the access token expires the SDK **renews it silently** with the stored refresh token (no interruption, no browser), and only a revoked/expired refresh token needs re-authorization. **Before you authorize it only says "authorizing"; a real failure reports its reason**. **Path-based issuers are supported** (Appwrite's `/v1/oauth2/console`, Keycloak's `/realms/<realm>`, …): both discovery and the token exchange keep the issuer's full path instead of degrading to the site root (which makes `.well-known` answer 404 and leaves a completed authorization without stored tokens)
27
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
28
28
  - **Three install paths**: npm / GitHub git source / local link; bilingual UI and docs
29
29
 
package/README.md CHANGED
@@ -25,7 +25,7 @@
25
25
  - **图片结果透传**:MCP 工具返回的图片(截图/图表等)经附件服务投影为图片引用进入模型上下文,带严格预检与有界降级文案(PR #4)
26
26
  - **双注入模式**:`search`(按需检索,省 token)与 `full`(全量注入)
27
27
  - **零 npm 依赖**:直接对接 DeepSeek Harness 内部能力,安装即用
28
- - **OAuth 认证支持**:`streamable-http` 服务器若走 MCP OAuth(授权码 + PKCE),服务器卡片点「OAuth 授权」按钮,**由宿主打开系统浏览器**完成授权,本页每 5 秒轮询授权状态;token 与 client 信息持久化在凭据文档;access token 过期后由 SDK 用存储的 refresh token **静默续期**(不会打断使用、也不会再弹浏览器),只有 refresh token 也被吊销/过期时才需要重新授权。**授权完成前只显示「授权中」,授权失败会写明原因**
28
+ - **OAuth 认证支持**:`streamable-http` 服务器若走 MCP OAuth(授权码 + PKCE),服务器卡片点「OAuth 授权」按钮,**由宿主打开系统浏览器**完成授权,本页每 5 秒轮询授权状态;token 与 client 信息持久化在凭据文档;access token 过期后由 SDK 用存储的 refresh token **静默续期**(不会打断使用、也不会再弹浏览器),只有 refresh token 也被吊销/过期时才需要重新授权。**授权完成前只显示「授权中」,授权失败会写明原因**。**支持 issuer 带路径的授权服务器**(如 Appwrite 的 `/v1/oauth2/console`、Keycloak 的 `/realms/<realm>`):元数据发现与换 token 都使用 issuer 的完整路径,不会退化成站点根路径(否则 `.well-known` 会 404、授权成功但 token 落不了库)
29
29
  - **HTTPS 默认按系统证书校验**:内网/公司 CA(只装在系统钥匙串里的根证书)无需再给 `dsh web` 加 `NODE_OPTIONS=--use-system-ca`,插件启动时把系统信任库并入 Node 默认根证书库
30
30
  - **三种安装方式**:npm / GitHub git 源 / 本地 link;中英文界面与文档
31
31
 
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Pick the authorization-server base URL for the token exchange.
3
+ *
4
+ * The exchange (metadata re-discovery + `exchangeAuthorization`) must talk to
5
+ * the authorization server the flow was STARTED against, not to the origin of
6
+ * the authorization page: an issuer may carry a path (`https://host/v1/oauth2/
7
+ * console`, Keycloak's `/realms/<realm>`, …), and `authorizationUrl.origin`
8
+ * silently drops it. Rebuilding from the origin then requests
9
+ * `<host>/.well-known/oauth-authorization-server`, which for a path-based
10
+ * issuer answers 404 — the SDK throws before any token request is made, so a
11
+ * completed authorization never produces stored tokens.
12
+ *
13
+ * The discovered URL is therefore preferred whenever it is available; the
14
+ * authorization URL's origin remains the last-resort fallback for the legacy
15
+ * provider path where no discovery result exists.
16
+ * @module dsh-mcp/oauth-server-url
17
+ */
18
+
19
+ /**
20
+ * Resolve the authorization-server base URL used by the token exchange.
21
+ * @param discoveredUrl - the URL returned by discovery (`info.authorizationServerUrl`), when one exists.
22
+ * @param authorizationUrl - the authorization URL handed to the browser (URL instance).
23
+ * @returns the URL to discover metadata from and to exchange the code against.
24
+ */
25
+ export function authorizationServerBaseUrl(discoveredUrl, authorizationUrl) {
26
+ if (discoveredUrl !== void 0 && discoveredUrl !== null) {
27
+ const text = String(discoveredUrl);
28
+ if (text.length > 0) {
29
+ try {
30
+ return new URL(text);
31
+ } catch {
32
+ /* not a URL — fall back to the authorization page's origin */
33
+ }
34
+ }
35
+ }
36
+ return new URL(authorizationUrl.origin);
37
+ }
package/lib/oauth.js CHANGED
@@ -22,6 +22,7 @@ import {
22
22
  } from "@modelcontextprotocol/client";
23
23
  import { credentialRef } from "@deepseek-ai/dsh-credentials";
24
24
  import { browserCommand } from "./browser-command.js";
25
+ import { authorizationServerBaseUrl } from "./oauth-server-url.js";
25
26
  import { hostText } from "./host-locales.js";
26
27
  import { systemFetch } from "./system-ca.js";
27
28
 
@@ -572,6 +573,16 @@ async function createToolAuthorizationUrlOnce(serverId, ctx, serverUrl) {
572
573
  });
573
574
  const url = String(authorizationUrl);
574
575
 
576
+ // The exchange must talk to the authorization server this flow was started
577
+ // against. Its issuer may carry a path (Appwrite's
578
+ // `https://fra.cloud.appwrite.io/v1/oauth2/console`, Keycloak's
579
+ // `/realms/<realm>`), and rebuilding it from `authorizationUrl.origin` drops
580
+ // that path — discovery then 404s against `<host>/.well-known/...` and the
581
+ // SDK throws before any token request, so a completed authorization never
582
+ // stores tokens. Keep the discovered URL and let the helper fall back to the
583
+ // origin only when no discovery result exists.
584
+ const discoveredAuthorizationServerUrl = info.authorizationServerUrl;
585
+
575
586
  // Background listener: wait for the user to open the URL and authorize.
576
587
  const pending = {
577
588
  url,
@@ -600,7 +611,7 @@ async function createToolAuthorizationUrlOnce(serverId, ctx, serverUrl) {
600
611
  res.end(hostText(ctx, "oauthOkPage"));
601
612
  log.info(`${tag}: tool-auth callback received (code)`);
602
613
  try {
603
- const authServerUrl = new URL(authorizationUrl.origin);
614
+ const authServerUrl = authorizationServerBaseUrl(discoveredAuthorizationServerUrl, authorizationUrl);
604
615
  const metadata = await discoverAuthorizationServerMetadata(authServerUrl, { fetchFn: systemFetch() });
605
616
  const tokens = await exchangeAuthorization(authServerUrl, {
606
617
  metadata: metadataForAuthorizationResponse(metadata, iss, log, tag),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-mcp",
3
- "version": "1.15.3",
3
+ "version": "1.15.4",
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",