dsh-mcp 1.12.0 → 1.12.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
@@ -10,7 +10,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
10
10
  ## Compatibility
11
11
 
12
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 the `cordis.patch.yml` row → restart `dsh web` → hard-refresh → upgrade both sides).
13
- - **Release convention**: every version entry states `- **Supported DSH version**: dsh <version>`, mirrored in the GitHub Release notes.
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
+
15
+ ## [1.12.1] - 2026-10-07
16
+
17
+ - **Supported DSH version**: **dsh `0.1.6-alpha.2`**
18
+
19
+ ### Fixed
20
+
21
+ - **stdio servers now actually receive the process-level environment variables ([#11](https://github.com/ArvinQi/dsh-mcp/issues/11))**: `global_env` was only used for `streamable-http` header substitution — the stdio branch dropped it entirely — and the parent process environment is no substitute, because `dsh-mcp-client` strips `KEY`/`TOKEN`/`SECRET`/`PASSWORD`-shaped names out of the inherited env before merging the server's own. So a stdio server that only reads its key from the environment (such as `tavily`, `npx -y tavily-mcp`) and whose per-server env the form no longer edits could only start keyless (it surfaced as `tavily_research` reporting "requires an API key" while keyless `tavily_search`/`tavily_extract` worked). `toClientConfig()`'s stdio branch now merges `global_env` with the server's own env into the child process, with the **per-server entry winning** on a collision; the settings hint, both READMEs and this document now state the real scope (injected into stdio children *and* available to HTTP header substitution)
22
+ - **Automatic remount after a credential update works again ([#12](https://github.com/ArvinQi/dsh-mcp/issues/12))**: `managedServerId()` recovered the server id from `DSH_MCP_<serverId>_<name>` with `lastIndexOf("_")`, but both the id (`mcp_<12 hex>`) and the variable name may contain `_`: as soon as the name had an underscore (`TAVILY_API_KEY`, `MY_VAR`) it split in the wrong place and produced an id that is not in the table, so the `credentials/reference-updated` handler silently skipped the remount — **rotating a key through the credentials UI or another plugin left the server on its old value until a manual refresh**. It now matches the id's fixed shape (`mcp_[0-9a-f]{12}`) exactly, and keeps `DSH_MCP_ENV_*` (process-level) and `DSH_MCP_OAUTH_*` refs unresolved
23
+
24
+ ### Notes
25
+
26
+ - Each fix ships with a regression test: `test/stdio-env.test.mjs` spawns a real child through a real mount and reads the environment it received back (it fails against the old implementation), and `test/managed-server-id.test.mjs` runs a ref-resolution matrix against the shipped `lib/index.js` function
14
27
 
15
28
  ## [1.12.0] - 2026-09-18
16
29
 
package/CHANGELOG.md CHANGED
@@ -10,7 +10,20 @@
10
10
  ## 兼容性
11
11
 
12
12
  - **支持版本**:**dsh `0.1.6-alpha.2`** —— 本插件在 `0.1.6-alpha.2` 上开发与验证(`package.json` → `dsh.supported` 同步声明)。DSH 与插件版本不匹配时,设置页会给出排查诊断(核对 `cordis.patch.yml` 注册行 → 重启 `dsh web` → 硬刷新 → 同步升级)。
13
- - **发版约定**:每个版本条目都要声明 `- **支持版本**:dsh <版本>`,并在 GitHub Release notes 中同步。
13
+ - **发版约定**:每个版本条目都要声明 `- **支持版本**:dsh <版本>`,并在 GitHub Release notes 中同步。Release 正文用**中文**(与本文档一致),标题层级与条目一致。
14
+
15
+ ## [1.12.1] - 2026-10-07
16
+
17
+ - **支持版本**:**dsh `0.1.6-alpha.2`**
18
+
19
+ ### 修复
20
+
21
+ - **stdio 服务器现在真的能拿到进程级环境变量([#11](https://github.com/ArvinQi/dsh-mcp/issues/11))**:`global_env` 此前只用于 `streamable-http` 的请求头替换,stdio 分支把它整个丢掉;而父进程环境也不是替代通道——`dsh-mcp-client` 会把 `KEY`/`TOKEN`/`SECRET`/`PASSWORD` 形状的父环境变量剥离后再与服务器 env 合并。于是像 `tavily`(`npx -y tavily-mcp`)这类只吃环境变量、且表单不再编辑 per-server env 的 stdio 服务器,只能以「无密钥」状态启动(表现为 `tavily_research` 报 "requires an API key",而 keyless 的 `tavily_search`/`tavily_extract` 正常)。现在 `toClientConfig()` 的 stdio 分支把 `global_env` 与服务器自身 env 合并后注入子进程,同名时**服务器 env 优先**;设置页提示、README 中英与本文档同步改为「stdio 子进程注入 + HTTP 请求头引用」的实际作用域
22
+ - **凭据引用更新后的自动重挂载恢复正常([#12](https://github.com/ArvinQi/dsh-mcp/issues/12))**:`managedServerId()` 用 `lastIndexOf("_")` 从 `DSH_MCP_<serverId>_<变量名>` 反解服务器 id,而 id(`mcp_<12位十六进制>`)与变量名都可能含 `_`:只要变量名带下划线(`TAVILY_API_KEY`、`MY_VAR`)就切错位置、解析出表里不存在的 id,`credentials/reference-updated` 处理器于是静默跳过重挂载——**通过凭据管理界面或其它插件轮换密钥后,服务器继续用旧值直到手动刷新**。现在按 id 的固定格式 `mcp_[0-9a-f]{12}` 精确匹配,并对 `DSH_MCP_ENV_*`(进程级)与 `DSH_MCP_OAUTH_*` 引用保持不解析
23
+
24
+ ### 说明
25
+
26
+ - 两个修复各配一条回归测试:`test/stdio-env.test.mjs` 通过真实挂载 + 真实子进程读回环境变量(改回旧实现即失败),`test/managed-server-id.test.mjs` 直接读 `lib/index.js` 中发布态的函数做引用解析矩阵
14
27
 
15
28
  ## [1.12.0] - 2026-09-18
16
29
 
package/README.en.md CHANGED
@@ -17,7 +17,7 @@
17
17
  **Highlights:**
18
18
 
19
19
  - **Visual management**: server list / create / edit / delete / test connection / enable-disable / refresh, all in the UI
20
- - **Process-level environment variables**: a global key-value list (expanded by default, batch-add supported); header values can reference a variable by bare name or `${NAME}` and are substituted at connect time (e.g. `Authorization: Bearer ${TOKEN}`)
20
+ - **Process-level environment variables**: a global key-value list (expanded by default, batch-add supported); injected into every stdio server's child process and referenced by streamable-http header values by bare name or `${NAME}`, substituted at connect time (e.g. `Authorization: Bearer ${TOKEN}`); a per-server env entry wins on collision
21
21
  - **Whole-list JSON config**: the "JSON config editor" panel views/edits every server as one JSON array; applying saves immediately (create/update/delete)
22
22
  - **Fine-grained tool control**: expand each server to see its tools, all checked by default; uncheck to load only what you need
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)
@@ -240,7 +240,8 @@ Check in order:
240
240
 
241
241
  **Process env vars** (below the injection mode, expanded by default):
242
242
 
243
- - Configure global key-value pairs referenced by every server's header substitution;
243
+ - Configure global key-value pairs shared by every server: **injected into each stdio server's child
244
+ process**, and referenced by streamable-http header substitution;
244
245
  secret values are stored in the credentials document, a blank value keeps the stored one
245
246
  - **process.env wins**: if a variable already exists in the process environment (`process.env`)
246
247
  under the same name, that value is used verbatim (name unchanged) at connect/display time and
@@ -248,7 +249,9 @@ Check in order:
248
249
  (e.g. `export ADA_TOKEN=...`) then restart `dsh web`
249
250
  - Batch-add (paste one `NAME=value` per line) or add rows one by one
250
251
  - A header value can reference a variable by **bare name** or **`${NAME}`** (e.g. `Authorization: Bearer ${GITLAB_TOKEN}`),
251
- substituted at connect time (priority: server env > process-level env > system environment)
252
+ substituted at connect time (priority: server env > process-level env > system environment);
253
+ a stdio child's environment follows the same precedence, so a per-server env entry overrides
254
+ the process-level value
252
255
 
253
256
  **JSON config editor** (top-right of the MCP config module):
254
257
 
package/README.md CHANGED
@@ -19,7 +19,7 @@
19
19
  **功能优势:**
20
20
 
21
21
  - **可视化管理**:服务器列表 / 新建 / 编辑 / 删除 / 测试连接 / 启停 / 刷新,全 UI 操作
22
- - **进程级环境变量**:全局 KV 配置(默认展开、支持批量添加),服务器请求头 value 写 `变量名` 或 `${变量名}` 即可在连接时自动替换为配置值(如 `Authorization: Bearer ${TOKEN}`)
22
+ - **进程级环境变量**:全局 KV 配置(默认展开、支持批量添加);stdio 服务器的子进程直接注入,streamable-http 服务器的请求头 value 写 `变量名` 或 `${变量名}` 即可在连接时自动替换为配置值(如 `Authorization: Bearer ${TOKEN}`);同名时服务器自身 env 优先
23
23
  - **JSON 全量配置**:「JSON 维护配置」面板以一段 JSON 数组查看/编辑全部服务器配置,应用即保存(新增/更新/删除)
24
24
  - **工具级精细控制**:每个服务器展开工具列表,默认全选,可取消勾选只加载需要的部分
25
25
  - **图片结果透传**:MCP 工具返回的图片(截图/图表等)经附件服务投影为图片引用进入模型上下文,带严格预检与有界降级文案(PR #4)
@@ -238,12 +238,13 @@ dsh plugin --profile web add link:<本仓库绝对路径>
238
238
 
239
239
  **进程环境变量**(注入模式下方,默认展开):
240
240
 
241
- - 配置全局键值对,供所有服务器的请求头替换引用;secret 值写入凭据文档,留空保留原值
241
+ - 配置全局键值对,供所有服务器使用:**stdio 服务器的子进程直接注入**,streamable-http 服务器用于请求头替换引用;secret 值写入凭据文档,留空保留原值
242
242
  - **process.env 优先**:若变量在进程环境变量(`process.env`)中已存在同名值,连接/展示时直接采用该值(不改名),
243
243
  存储值仅作为兜底——请先在启动脚本里 `export ADA_TOKEN=...` 再重启 `dsh web`
244
244
  - 支持「批量添加」(粘贴多行 `NAME=value`)与「添加变量」逐行添加
245
245
  - 服务器请求头 value 可直接写**变量名**或 **`${变量名}`**(如 `Authorization: Bearer ${GITLAB_TOKEN}`),
246
- 连接时自动替换(优先级:服务器 env > 进程级 env > 系统环境变量)
246
+ 连接时自动替换(优先级:服务器 env > 进程级 env > 系统环境变量);stdio 子进程的环境与此一致,
247
+ 同名时服务器自身 env 覆盖进程级 env
247
248
 
248
249
  **JSON 维护配置**(MCP 配置模块右上角):
249
250
 
package/lib/client.js CHANGED
@@ -16632,7 +16632,7 @@ var zh = {
16632
16632
  serversJsonSaving: "\u5E94\u7528\u4E2D\u2026",
16633
16633
  serversJsonDone: "\u5DF2\u5E94\u7528",
16634
16634
  globalEnv: "\u8FDB\u7A0B\u73AF\u5883\u53D8\u91CF",
16635
- globalEnvHint: "\u8FDB\u7A0B\u7EA7\u73AF\u5883\u53D8\u91CF\uFF0C\u4F9B\u6240\u6709 MCP \u670D\u52A1\u5668\u7684\u8BF7\u6C42\u5934\u66FF\u6362\u5F15\u7528\uFF08headers \u503C\u5199 ${\u53D8\u91CF\u540D} \u6216\u76F4\u63A5\u5199\u53D8\u91CF\u540D\uFF09\u3002secret \u503C\u5199\u5165\u51ED\u636E\u6587\u6863\uFF0C\u4E0D\u5728\u6B64\u660E\u6587\u663E\u793A\uFF1B\u7559\u7A7A\u4FDD\u7559\u539F\u503C\u3002",
16635
+ globalEnvHint: "\u8FDB\u7A0B\u7EA7\u73AF\u5883\u53D8\u91CF\uFF0C\u4F9B\u6240\u6709 MCP \u670D\u52A1\u5668\u4F7F\u7528\uFF1Astdio \u670D\u52A1\u5668\u7684\u5B50\u8FDB\u7A0B\u76F4\u63A5\u6CE8\u5165\uFF0Cstreamable-http \u670D\u52A1\u5668\u7684\u8BF7\u6C42\u5934\u66FF\u6362\u5F15\u7528\uFF08headers \u503C\u5199 ${\u53D8\u91CF\u540D} \u6216\u76F4\u63A5\u5199\u53D8\u91CF\u540D\uFF09\uFF0C\u540C\u540D\u65F6\u670D\u52A1\u5668\u81EA\u8EAB env \u4F18\u5148\u3002secret \u503C\u5199\u5165\u51ED\u636E\u6587\u6863\uFF0C\u4E0D\u5728\u6B64\u660E\u6587\u663E\u793A\uFF1B\u7559\u7A7A\u4FDD\u7559\u539F\u503C\u3002",
16636
16636
  globalEnvName: "\u53D8\u91CF\u540D",
16637
16637
  globalEnvValue: "\u503C",
16638
16638
  globalEnvSecret: "\u79C1\u5BC6",
@@ -16757,7 +16757,7 @@ var en = {
16757
16757
  serversJsonSaving: "Applying\u2026",
16758
16758
  serversJsonDone: "Applied",
16759
16759
  globalEnv: "Process env vars",
16760
- globalEnvHint: "Process-level environment variables referenced by every server's header substitution (write ${NAME} or a bare name in a header value). Secret values are stored in the credentials document, never shown here; blank keeps the stored value.",
16760
+ globalEnvHint: "Process-level environment variables shared by every MCP server: injected into each stdio server's child process, and referenced by streamable-http header substitution (write ${NAME} or a bare name in a header value); a per-server env entry wins on collision. Secret values are stored in the credentials document, never shown here; blank keeps the stored value.",
16761
16761
  globalEnvName: "Name",
16762
16762
  globalEnvValue: "Value",
16763
16763
  globalEnvSecret: "secret",
package/lib/index.js CHANGED
@@ -97,9 +97,10 @@ const mcpServersDomainSpec = defineDomain({
97
97
  name: "mcp_servers",
98
98
  version: 0,
99
99
  tables: { servers: domainTable(mcpServerRowSchema),
100
- // Process-level environment variables: shared by every server's header
101
- // substitution. Plain values live here; secret values are stored in the
102
- // credentials document under DSH_MCP_ENV_<name>.
100
+ // Process-level environment variables: shared by every server — passed into
101
+ // every stdio child process's environment and available to streamable-http
102
+ // header substitution. Plain values live here; secret values are stored in
103
+ // the credentials document under DSH_MCP_ENV_<name>.
103
104
  global_env: domainTable(z$1.object({
104
105
  name: envVarNameSchema,
105
106
  secret: z$1.boolean(),
@@ -341,10 +342,12 @@ function sameRecord(left, right) {
341
342
  */
342
343
  function managedServerId(ref) {
343
344
  if (!ref.startsWith(SECRET_REF_PREFIX)) return void 0;
344
- const rest = ref.slice(8);
345
- const separator = rest.lastIndexOf("_");
346
- if (separator <= 0) return void 0;
347
- return rest.slice(0, separator);
345
+ // The ref is `<prefix><serverId>_<env name>`, and BOTH halves may contain
346
+ // `_` (ids are `mcp_<12 hex>`, env names are arbitrary POSIX names), so
347
+ // splitting on the last `_` misreads any name containing one. Match the id's
348
+ // fixed shape instead.
349
+ const match = /^(mcp_[0-9a-f]{12})_/.exec(ref.slice(SECRET_REF_PREFIX.length));
350
+ return match === null ? void 0 : match[1];
348
351
  }
349
352
  /** Credential reference holding one secret env value. */
350
353
  function secretRef(id, name) {
@@ -1007,7 +1010,8 @@ let McpManagerService = (() => {
1007
1010
  * Resolve the process-level env map. The process environment wins: a
1008
1011
  * variable present in process.env is used verbatim (by the same name);
1009
1012
  * otherwise the stored value (secret from credentials, plain from the
1010
- * table) is used as a fallback.
1013
+ * table) is used as a fallback. The map feeds every stdio child process's
1014
+ * environment and every `streamable-http` header substitution.
1011
1015
  */
1012
1016
  async resolveGlobalEnv() {
1013
1017
  const env = {};
@@ -1033,7 +1037,15 @@ let McpManagerService = (() => {
1033
1037
  command: spec.command,
1034
1038
  args: [...spec.args],
1035
1039
  cwd: spec.cwd,
1036
- env,
1040
+ // Process-level env vars reach the child too — the parent process
1041
+ // environment is not a channel (dsh-mcp-client merges the spec env
1042
+ // over a parent env scrubbed of credential-shaped names, so
1043
+ // `TAVILY_API_KEY` never survives inheritance). Per-server env
1044
+ // keeps priority over the process-level value.
1045
+ env: {
1046
+ ...globalEnv,
1047
+ ...env
1048
+ },
1037
1049
  toolCallTimeoutMs: spec.toolCallTimeoutMs,
1038
1050
  failOnStartupError: spec.failOnStartupError
1039
1051
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-mcp",
3
- "version": "1.12.0",
3
+ "version": "1.12.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",
package/scripts/test.mjs CHANGED
@@ -28,6 +28,7 @@ const ROOT = join(dirname(fileURLToPath(import.meta.url)), '..')
28
28
  const NEEDS_DSH_CLOSURE = new Set([
29
29
  'cordis-servers.test.mjs',
30
30
  'patch-writer.test.mjs',
31
+ 'stdio-env.test.mjs',
31
32
  'takeover.test.mjs',
32
33
  ])
33
34
 
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Process-level environment-variable editor: a global key-value list shared
3
- * by every MCP server's header substitution. Values are referenced from
4
- * server headers as `${NAME}` or by bare name; secret values are stored in
5
- * the credentials document and never shown back.
3
+ * by every MCP server — injected into each stdio server's child process, and
4
+ * referenced from streamable-http header values as `${NAME}` or by bare name.
5
+ * Secret values are stored in the credentials document and never shown back.
6
6
  * @module dsh-mcp/client/GlobalEnvEditor
7
7
  */
8
8
 
@@ -353,8 +353,9 @@ export function McpSettingsSection(props: McpSettingsSectionProps): ReactNode {
353
353
  injected={{ envList: props.envList, envSet: props.envSet }}
354
354
  t={t}
355
355
  onApplied={() => {
356
- // New process env may feed header substitution: refresh server
357
- // rows (connection attempts re-resolve env) but keep the tool list.
356
+ // New process env may feed stdio children and header
357
+ // substitution: refresh server rows (connection attempts
358
+ // re-resolve env) but keep the tool list.
358
359
  refreshServer('')
359
360
  }}
360
361
  />
@@ -108,7 +108,7 @@ export const zh = {
108
108
  serversJsonSaving: '应用中…',
109
109
  serversJsonDone: '已应用',
110
110
  globalEnv: '进程环境变量',
111
- globalEnvHint: '进程级环境变量,供所有 MCP 服务器的请求头替换引用(headers 值写 ${变量名} 或直接写变量名)。secret 值写入凭据文档,不在此明文显示;留空保留原值。',
111
+ globalEnvHint: '进程级环境变量,供所有 MCP 服务器使用:stdio 服务器的子进程直接注入,streamable-http 服务器的请求头替换引用(headers 值写 ${变量名} 或直接写变量名),同名时服务器自身 env 优先。secret 值写入凭据文档,不在此明文显示;留空保留原值。',
112
112
  globalEnvName: '变量名',
113
113
  globalEnvValue: '值',
114
114
  globalEnvSecret: '私密',
@@ -238,7 +238,7 @@ export const en = {
238
238
  serversJsonSaving: 'Applying…',
239
239
  serversJsonDone: 'Applied',
240
240
  globalEnv: 'Process env vars',
241
- globalEnvHint: 'Process-level environment variables referenced by every server\'s header substitution (write ${NAME} or a bare name in a header value). Secret values are stored in the credentials document, never shown here; blank keeps the stored value.',
241
+ globalEnvHint: 'Process-level environment variables shared by every MCP server: injected into each stdio server\'s child process, and referenced by streamable-http header substitution (write ${NAME} or a bare name in a header value); a per-server env entry wins on collision. Secret values are stored in the credentials document, never shown here; blank keeps the stored value.',
242
242
  globalEnvName: 'Name',
243
243
  globalEnvValue: 'Value',
244
244
  globalEnvSecret: 'secret',