@xxxyz/dsh-mcp-manager 2.0.4 → 2.0.6

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/README.md CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  <!-- Hero -->
4
4
  <div align="center">
5
- <b style="font-size: 1.15em;">Manage every MCP server in DeepSeek Harness from one settings page — install, configure, monitor.</b><br /><br />
6
- <code>server list</code> <code>add / edit / delete</code> <code>enable / disable</code> <code>restart</code> <code>tool-count health</code> <code>JSON export / import</code><br />
7
- <code>4 model tools</code> <code>HTTP API</code> <code>npx / npm / dsh plugin / scripts</code><br /><br />
8
- <b>Settings → MCP 管理</b> manages <code>@deepseek-ai/dsh-mcp-client</code> rows in your project-level and
9
- global <code>cordis.patch.yml</code> — no hand-editing, every change applies live via HMR, survives restarts and upgrades.
5
+ <b style="font-size: 1.15em;">DeepSeek Harness MCP 服务管理器:装没装、连没连、一页管完。</b><br /><br />
6
+ <code>服务器列表</code> <code>新增 / 编辑 / 删除</code> <code>启用 / 停用</code> <code>重启</code> <code>工具数健康</code> <code>JSON 导出 / 导入</code><br />
7
+ <code>4 个模型工具</code> <code>HTTP API</code> <code>npx / npm / dsh plugin / 脚本</code><br /><br />
8
+ <b>设置 → MCP 管理</b> 管理项目级与全局 <code>cordis.patch.yml</code> 中的 <code>@deepseek-ai/dsh-mcp-client</code> 行——<br />
9
+ 无需再手改配置文件,所有修改即改即生效(HMR 热应用),重启、升级后依然存在。
10
10
  </div>
11
11
 
12
12
  <div align="center">
@@ -19,12 +19,12 @@
19
19
  </div>
20
20
 
21
21
  <div align="center">
22
- 🌏 <a href="./README.md"><b>English</b></a> · <a href="./README.zh-CN.md">中文</a>
22
+ 🌏 <a href="./README.md"><b>中文</b></a> · <a href="./README_EN.md">English</a>
23
23
  </div>
24
24
 
25
25
  <br />
26
26
 
27
- <p align="center"><img src="show.png" alt="dsh-mcp-manager Settings → MCP 管理" /></p>
27
+ <p align="center"><img src="show.png" alt="dsh-mcp-manager 设置 → MCP 管理 页面图例" /></p>
28
28
 
29
29
  ## ✨ 功能一览
30
30
 
package/README_EN.md ADDED
@@ -0,0 +1,193 @@
1
+ # dsh-mcp-manager
2
+
3
+ <!-- Hero -->
4
+ <div align="center">
5
+ <b style="font-size: 1.15em;">Manage every MCP server in DeepSeek Harness from one settings page — install, configure, monitor.</b><br /><br />
6
+ <code>server list</code> <code>add / edit / delete</code> <code>enable / disable</code> <code>restart</code> <code>tool-count health</code> <code>JSON export / import</code><br />
7
+ <code>4 model tools</code> <code>HTTP API</code> <code>npx / npm / dsh plugin / scripts</code><br /><br />
8
+ <b>Settings → MCP 管理</b> manages <code>@deepseek-ai/dsh-mcp-client</code> rows in your project-level and
9
+ global <code>cordis.patch.yml</code> — no hand-editing, every change applies live via HMR, survives restarts and upgrades.
10
+ </div>
11
+
12
+ <div align="center">
13
+
14
+ [![npm version](https://img.shields.io/npm/v/@xxxyz/dsh-mcp-manager?logo=npm&color=cb3837)](https://www.npmjs.com/package/@xxxyz/dsh-mcp-manager)
15
+ [![License](https://img.shields.io/github/license/xxxyz/DeepSeekHarness-MCP-Manager?color=blue)](LICENSE)
16
+ [![Node](https://img.shields.io/badge/node-%3E%3D18-339933?logo=node.js)](package.json)
17
+ [![GitHub](https://img.shields.io/badge/GitHub-xxxyz%2FDeepSeekHarness--MCP--Manager-181717?logo=github)](https://github.com/xxxyz/DeepSeekHarness-MCP-Manager)
18
+
19
+ </div>
20
+
21
+ <div align="center">
22
+ 🌏 <a href="./README.md">中文</a> · <a href="./README_EN.md"><b>English</b></a>
23
+ </div>
24
+
25
+ <br />
26
+
27
+ <p align="center"><img src="show.png" alt="dsh-mcp-manager Settings → MCP 管理 page" /></p>
28
+
29
+ ## ✨ Features
30
+
31
+ - **📋 Server list** — every configured MCP server (`@deepseek-ai/dsh-mcp-client` instance): `serverName`, transport (`stdio` / `streamable-http`), URL / command, enabled state, live loader phase, registered tool count
32
+ - **➕ Add / ➖ Delete** — form-based (env / headers / args supported) with format and duplicate-name validation; one-click delete
33
+ - **🔌 Enable / Disable** — flip at any time, tools hot-connect / hot-disconnect
34
+ - **🔄 Restart** — disable + re-enable, reconnect and re-sync tools automatically
35
+ - **💾 Persistence** — written to the **project-level** (`profiles/<profile>/cordis.patch.yml`) or **global** (`~/.dsh/cordis.patch.yml`) patch file; survives restarts; the file path is shown at the bottom of the page
36
+ - **🩺 Health check** — live tool counts and loader phase per server, problems visible at a glance
37
+ - **📦 Backup / Restore** — JSON export / import; merges new entries, skips existing ones
38
+ - **🤖 Model tools** — four `mcp_manager_*` tools registered on the host, so the model can query and manage MCP servers directly
39
+ - **🌐 HTTP API** — `POST /dsh-mcp-manager/api` (JSON `{op, args}` → `{ok, ...}`) for the client and scripts
40
+ - **📦 Cross-platform install** — one command on Windows / macOS / Linux (npx / npm / `dsh plugin` / scripts)
41
+
42
+ ## 🚀 Install
43
+
44
+ **Prerequisite**: DSH installed and running (`dsh web` works), Node.js ≥ 18.
45
+
46
+ ### Method 1 · One-shot npx (recommended)
47
+
48
+ ```sh
49
+ npx -y @xxxyz/dsh-mcp-manager
50
+ ```
51
+
52
+ All flags pass through: `npx -y @xxxyz/dsh-mcp-manager --dsh-home /path/.dsh --profile web --repair --port 3080`.
53
+
54
+ ### Method 2 · Global npm install (for frequent use)
55
+
56
+ ```sh
57
+ npm i -g @xxxyz/dsh-mcp-manager
58
+ dsh-mcp-manager # install the plugin
59
+ dsh-mcp-manager-uninstall # uninstall the plugin
60
+ npm i -g @xxxyz/dsh-mcp-manager@latest # upgrade
61
+ ```
62
+
63
+ ### Method 3 · dsh command (bundle)
64
+
65
+ ```sh
66
+ dsh plugin --profile web add @xxxyz/dsh-mcp-manager
67
+ # or from GitHub (build artifacts are committed, no local build needed)
68
+ dsh plugin --profile web add github:xxxyz/DeepSeekHarness-MCP-Manager
69
+ ```
70
+
71
+ ### Method 4 · No npm account: straight from GitHub
72
+
73
+ ```sh
74
+ npx -y github:xxxyz/DeepSeekHarness-MCP-Manager
75
+ ```
76
+
77
+ <details>
78
+ <summary><b>Script install</b> (source checkout; idempotent)</summary>
79
+
80
+ **Windows (PowerShell)**:
81
+
82
+ ```powershell
83
+ .\dsh-mcp-manager\install.ps1 # default: ~/.dsh, web profile
84
+ .\dsh-mcp-manager\install.ps1 -DshHome D:\path\.dsh -Profile web
85
+ ```
86
+
87
+ **macOS / Linux (bash)** (run `chmod +x dsh-mcp-manager/install.sh` if needed):
88
+
89
+ ```sh
90
+ ./dsh-mcp-manager/install.sh # default: ~/.dsh, web profile
91
+ ./dsh-mcp-manager/install.sh --dsh-home /path/.dsh --profile web
92
+ ```
93
+
94
+ **Any platform (direct)**:
95
+
96
+ ```sh
97
+ node dsh-mcp-manager/install.mjs [--dsh-home <path>] [--profile <name>] [--port <n>] [--repair] [--skip-patch]
98
+ ```
99
+
100
+ The installer ① copies the package to `local-packages/` (source of record, untouched by DSH upgrades) ② copies it into `profiles/node_modules/` (a plain copy, not a symlink, so ESM resolves `@deepseek-ai/dsh-tools`) ③ appends the loader row (an `insert` block, idempotent).
101
+
102
+ </details>
103
+
104
+ After installing, **hard-refresh the browser** (Cmd/Ctrl+Shift+R) and open **Settings → MCP 管理**. If the page is missing, restart DSH once (the host half needs a first mount).
105
+
106
+ <details>
107
+ <summary><b>Uninstall</b></summary>
108
+
109
+ ```sh
110
+ dsh-mcp-manager-uninstall # if installed via npm -g
111
+ # or: .\uninstall.ps1 | ./uninstall.sh | node uninstall.mjs [--dsh-home <path>] [--profile <name>]
112
+ ```
113
+
114
+ Then restart DSH. Uninstall removes the deployed copy, the `local-packages` source, and the loader row (the patch stays a valid array).
115
+
116
+ </details>
117
+
118
+ <details>
119
+ <summary><b>After a DSH upgrade: --repair</b></summary>
120
+
121
+ If a DSH upgrade (or a broken HMR state) leaves the settings page or the `mcp_manager_*` tools missing, run one repair command: redeploy → bump the loader row's `config.version` (forces an HMR re-apply) → poll the API until `{ok:true}` (default 30 s).
122
+
123
+ ```sh
124
+ node dsh-mcp-manager/install.mjs --repair --port 3080
125
+ # PowerShell: .\install.ps1 -Repair -Port 3080 bash: ./install.sh --repair --port 3080
126
+ ```
127
+
128
+ If the API still does not answer, restart DSH once (the loader re-imports at boot).
129
+
130
+ </details>
131
+
132
+ <details>
133
+ <summary><b>FAQ</b></summary>
134
+
135
+ | Symptom | Cause & fix |
136
+ |---|---|
137
+ | No "MCP 管理" in Settings after install | Hard-refresh (Cmd/Ctrl+Shift+R); if still missing, restart DSH once. |
138
+ | **Two MCP tabs / duplicated tools** | Double mount: both install.mjs and `dsh plugin add` were used. Remove one (run `dsh-mcp-manager-uninstall`, or delete the extra loader row / `dsh.profile.bundles` entry). |
139
+ | Tools missing after a DSH upgrade | Run `--repair` (see above). |
140
+ | `npx` / `npm view` reports 404 | Local mirror (npmmirror) sync lag: add `--registry=https://registry.npmjs.org` or wait a moment. |
141
+ | Installer fails with `EPERM` | DSH is running and holds the files: quit DSH before installing. |
142
+ | Config changes don't take effect | All changes apply via HMR within 1–2 s; the page auto-polls. |
143
+
144
+ </details>
145
+
146
+ ## 📖 Usage
147
+
148
+ Open **Settings → MCP 管理**:
149
+
150
+ - **Add a server**: enter `serverName` (unique, 1–32 chars of `[A-Za-z0-9_-]`), the transport and its fields (`streamable-http` → URL / headers; `stdio` → command / args / env), and the level (project / global). The form validates format and duplicate names.
151
+ - Each card shows live status, the connection target and the tool count; you can **enable / disable**, **restart**, **edit** and **delete**.
152
+ - **Backup / Restore**: export the configuration as JSON with one click, or paste JSON to import (merges new entries, skips existing ones).
153
+ - The file path being edited is shown at the bottom of the page.
154
+
155
+ ## ⚙️ Configuration
156
+
157
+ Configuration of the plugin itself on its loader row:
158
+
159
+ | Field | Description |
160
+ |---|---|
161
+ | `version` | The loader row's `config.version`. `--repair` increments it to force an HMR re-apply; no manual edits needed. |
162
+
163
+ The loader row must be an **`insert` block** (in DSH's patch dialect a plain `- id:` row only overrides existing entries and can never add a new plugin):
164
+
165
+ ```yaml
166
+ - insert:
167
+ - id: dsh-mcp-manager
168
+ name: dsh-mcp-manager
169
+ config:
170
+ version: 1
171
+ ```
172
+
173
+ ## 🏗️ Architecture
174
+
175
+ - **Host half** (`src/index.ts` → `lib/index.js`, an object-form Cordis plugin `{name, inject, apply}`): `inject` declares `timer/fs/settings/sandboxPolicy/webServer/tools` — the framework guarantees they are ready and reloads the plugin if one disappears, which is how the plugin survives DSH upgrades. Registers four model tools (`ctx.tools.register(defineTool(...))`) and the exact route `POST /dsh-mcp-manager/api` (scoped cleanup via `ctx.effect`); line-level CRUD on `cordis.patch.yml` (mini YAML parser + per-file write lock).
176
+ - **Browser half** (`lib/client.js`, ModuleLoader CJS bundle): registers the Settings → MCP 管理 page (`settings.section` slot, order 16) and talks to the host through same-origin `fetch('/dsh-mcp-manager/api')` — it never touches the filesystem directly.
177
+ - **Loader row**: written into the profile's `cordis.patch.yml`; the client-modules service scans enabled entries and serves the client bundle.
178
+ - **Installers**: `install.mjs` (cross-platform core) / `install.ps1` / `install.sh`, plus matching `uninstall.*`; the npm package `@xxxyz/dsh-mcp-manager` exposes them as bins (`dsh-mcp-manager` / `dsh-mcp-manager-uninstall`).
179
+
180
+ ## 🛠️ Development
181
+
182
+ ```bash
183
+ npm install
184
+ npm run build # tsc -p tsconfig.json → lib/index.js (host half)
185
+ ```
186
+
187
+ - Host source: `src/index.ts`; browser bundle: `lib/client.js` (hand-written, no build step)
188
+ - The package is pure JS, zero-dependency and cross-platform; building only needs the devDependencies (typescript, `@deepseek-ai/cordis`, `@deepseek-ai/dsh-tools`, `@types/node`)
189
+ - Publishing: `npm version patch && npm publish` (`prepublishOnly` builds automatically; the scoped package has `publishConfig.access: public`)
190
+
191
+ ## License
192
+
193
+ MIT
package/install.mjs CHANGED
@@ -273,7 +273,7 @@ async function pollApi(port, timeoutMs) {
273
273
  try {
274
274
  const res = await fetch(url, {
275
275
  method: 'POST',
276
- headers: { 'content-type': 'application/json' },
276
+ headers: { 'content-type': 'application/json', 'x-dsh-plugin': 'dsh-mcp-manager' },
277
277
  body: JSON.stringify({ op: 'mcpm-list', args: {} }),
278
278
  signal: timeoutSignal(2000),
279
279
  })
package/lib/client.js CHANGED
@@ -61,9 +61,12 @@ const factory = (require) => {
61
61
  }
62
62
 
63
63
  function apiCall(op, args) {
64
+ // `x-dsh-plugin` is the cross-site (CSRF) gate header the host half
65
+ // requires on every request; a cross-origin page cannot attach it
66
+ // without a CORS preflight that this route never answers.
64
67
  return fetch('/dsh-mcp-manager/api', {
65
68
  method: 'POST',
66
- headers: { 'content-type': 'application/json' },
69
+ headers: { 'content-type': 'application/json', 'x-dsh-plugin': 'dsh-mcp-manager' },
67
70
  body: JSON.stringify({ op, args: args || {} }),
68
71
  }).then((r) => r.json()).catch((e) => ({ ok: false, error: String((e && e.message) || e) }))
69
72
  }
package/lib/index.js CHANGED
@@ -936,6 +936,42 @@ export default {
936
936
  kind: 'exact',
937
937
  path: '/dsh-mcp-manager/api',
938
938
  handler: async (req, res) => {
939
+ // Cross-site (CSRF) gate. This route mutates config files, so it
940
+ // must only be reachable from the DSH web UI (same origin) or
941
+ // local tooling. A browser cross-site request cannot attach a
942
+ // custom header without a CORS preflight, and this route never
943
+ // answers preflights — requiring `x-dsh-plugin` is the primary
944
+ // gate; POST-only and the Origin check are defense in depth.
945
+ const hdr = (name) => {
946
+ const v = req.headers?.[name];
947
+ return Array.isArray(v) ? v[0] ?? '' : v ?? '';
948
+ };
949
+ if (String(req.method || 'POST').toUpperCase() !== 'POST') {
950
+ res.writeHead(405, { 'content-type': 'application/json' });
951
+ res.end(JSON.stringify({ ok: false, error: 'method not allowed' }));
952
+ return;
953
+ }
954
+ if (hdr('x-dsh-plugin') !== 'dsh-mcp-manager') {
955
+ res.writeHead(403, { 'content-type': 'application/json' });
956
+ res.end(JSON.stringify({ ok: false, error: 'missing plugin gate header' }));
957
+ return;
958
+ }
959
+ const origin = hdr('origin');
960
+ if (origin) {
961
+ let sameOrigin = false;
962
+ try {
963
+ const u = new URL(origin);
964
+ const hostHdr = hdr('host') || '';
965
+ sameOrigin =
966
+ /^(localhost|127\.0\.0\.1|\[::1\])$/i.test(u.hostname) || u.host === hostHdr;
967
+ }
968
+ catch (e) { /* unparseable origin → rejected below */ }
969
+ if (!sameOrigin) {
970
+ res.writeHead(403, { 'content-type': 'application/json' });
971
+ res.end(JSON.stringify({ ok: false, error: 'cross-origin request rejected' }));
972
+ return;
973
+ }
974
+ }
939
975
  res.writeHead(200, { 'content-type': 'application/json' });
940
976
  try {
941
977
  let payload = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xxxyz/dsh-mcp-manager",
3
- "version": "2.0.4",
3
+ "version": "2.0.6",
4
4
  "description": "DSH-standard MCP manager plugin: Settings UI + HTTP API + model-facing mcp_manager_* tools. Composed as a loader entry, survives restarts. Install via npx, PowerShell, bash or node.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -23,7 +23,7 @@
23
23
  "uninstall.ps1",
24
24
  "uninstall.sh",
25
25
  "README.md",
26
- "README.zh-CN.md",
26
+ "README_EN.md",
27
27
  "安装方式.md",
28
28
  "LICENSE"
29
29
  ],
package/README.zh-CN.md DELETED
@@ -1,193 +0,0 @@
1
- # dsh-mcp-manager
2
-
3
- <!-- Hero -->
4
- <div align="center">
5
- <b style="font-size: 1.15em;">DeepSeek Harness 的 MCP 服务管理器:装没装、连没连、一页管完。</b><br /><br />
6
- <code>服务器列表</code> <code>新增 / 编辑 / 删除</code> <code>启用 / 停用</code> <code>重启</code> <code>工具数健康</code> <code>JSON 导出 / 导入</code><br />
7
- <code>4 个模型工具</code> <code>HTTP API</code> <code>npx / npm / dsh plugin / 脚本</code><br /><br />
8
- <b>设置 → MCP 管理</b> 管理项目级与全局 <code>cordis.patch.yml</code> 中的 <code>@deepseek-ai/dsh-mcp-client</code> 行——<br />
9
- 无需再手改配置文件,所有修改即改即生效(HMR 热应用),重启、升级后依然存在。
10
- </div>
11
-
12
- <div align="center">
13
-
14
- [![npm version](https://img.shields.io/npm/v/@xxxyz/dsh-mcp-manager?logo=npm&color=cb3837)](https://www.npmjs.com/package/@xxxyz/dsh-mcp-manager)
15
- [![License](https://img.shields.io/github/license/xxxyz/DeepSeekHarness-MCP-Manager?color=blue)](LICENSE)
16
- [![Node](https://img.shields.io/badge/node-%3E%3D18-339933?logo=node.js)](package.json)
17
- [![GitHub](https://img.shields.io/badge/GitHub-xxxyz%2FDeepSeekHarness--MCP--Manager-181717?logo=github)](https://github.com/xxxyz/DeepSeekHarness-MCP-Manager)
18
-
19
- </div>
20
-
21
- <div align="center">
22
- 🌏 <a href="./README.zh-CN.md"><b>中文</b></a> · <a href="./README.md">English</a>
23
- </div>
24
-
25
- <br />
26
-
27
- <p align="center"><img src="show.png" alt="dsh-mcp-manager 设置 → MCP 管理 页面图例" /></p>
28
-
29
- ## ✨ 功能一览
30
-
31
- - **📋 服务器列表**:列出所有已配置的 MCP 服务器(`@deepseek-ai/dsh-mcp-client` 实例)——`serverName`、传输方式(`stdio` / `streamable-http`)、URL / 命令、启用状态、loader 实时加载阶段、已注册工具数
32
- - **➕ 新增 / ➖ 删除**:表单添加 MCP 服务器(支持 env / headers / args),带格式与重名校验;一键删除
33
- - **🔌 启用 / 停用**:随时切换,工具随之热连接 / 热断开
34
- - **🔄 重启**:disable + re-enable,自动重连并重新同步工具
35
- - **💾 持久化**:写入**项目级**(`profiles/<profile>/cordis.patch.yml`)或**全局**(`~/.dsh/cordis.patch.yml`),重启后保留;页面底部显示文件路径
36
- - **🩺 健康检查**:每台服务器实时工具数与 loader 阶段,异常一目了然
37
- - **📦 备份 / 恢复**:JSON 导出 / 导入,合并新增、已存在自动跳过
38
- - **🤖 模型工具**:宿主注册 4 个 `mcp_manager_*` 工具,模型可直接查询与操作 MCP 服务
39
- - **🌐 HTTP API**:`POST /dsh-mcp-manager/api`(JSON `{op, args}` → `{ok, ...}`),供客户端与脚本调用
40
- - **📦 跨平台安装**:Windows / macOS / Linux 一条命令(npx / npm / `dsh plugin` / 脚本)
41
-
42
- ## 🚀 安装
43
-
44
- **前置**:DSH 已装好(`dsh web` 能正常运行),Node.js ≥ 18。
45
-
46
- ### 方式一 · npx 一条命令(推荐)
47
-
48
- ```sh
49
- npx -y @xxxyz/dsh-mcp-manager
50
- ```
51
-
52
- 所有参数照常透传:`npx -y @xxxyz/dsh-mcp-manager --dsh-home /path/.dsh --profile web --repair --port 3080`。
53
-
54
- ### 方式二 · npm 全局安装(适合经常使用)
55
-
56
- ```sh
57
- npm i -g @xxxyz/dsh-mcp-manager
58
- dsh-mcp-manager # 安装插件
59
- dsh-mcp-manager-uninstall # 卸载插件
60
- npm i -g @xxxyz/dsh-mcp-manager@latest # 升级
61
- ```
62
-
63
- ### 方式三 · dsh 命令安装(bundle 方式)
64
-
65
- ```sh
66
- dsh plugin --profile web add @xxxyz/dsh-mcp-manager
67
- # 或 GitHub 源(构建产物 lib/ 已入库,无需本地构建)
68
- dsh plugin --profile web add github:xxxyz/DeepSeekHarness-MCP-Manager
69
- ```
70
-
71
- ### 方式四 · 免 npm 账号:GitHub 直拉
72
-
73
- ```sh
74
- npx -y github:xxxyz/DeepSeekHarness-MCP-Manager
75
- ```
76
-
77
- <details>
78
- <summary><b>脚本安装</b>(源码方式:下载仓库后执行,幂等)</summary>
79
-
80
- **Windows(PowerShell)**:
81
-
82
- ```powershell
83
- .\dsh-mcp-manager\install.ps1 # 默认 ~/.dsh + web profile
84
- .\dsh-mcp-manager\install.ps1 -DshHome D:\path\.dsh -Profile web
85
- ```
86
-
87
- **macOS / Linux(bash)**(无执行权限先 `chmod +x dsh-mcp-manager/install.sh`):
88
-
89
- ```sh
90
- ./dsh-mcp-manager/install.sh # 默认 ~/.dsh + web profile
91
- ./dsh-mcp-manager/install.sh --dsh-home /path/.dsh --profile web
92
- ```
93
-
94
- **任何平台直接运行**:
95
-
96
- ```sh
97
- node dsh-mcp-manager/install.mjs [--dsh-home <path>] [--profile <name>] [--port <n>] [--repair] [--skip-patch]
98
- ```
99
-
100
- 安装脚本会:① 复制到 `local-packages/`(真源备份,DSH 升级不动它)② 复制到 `profiles/node_modules/`(普通复制而非软链接,保证 ESM 能解析 `@deepseek-ai/dsh-tools`)③ 幂等追加 loader 行(insert 块)。
101
-
102
- </details>
103
-
104
- 装完**硬刷新浏览器**(Cmd/Ctrl+Shift+R),打开 **设置 → MCP 管理** 即可看到管理页。若未出现,重启一次 DSH(host 半首次挂载需要)。
105
-
106
- <details>
107
- <summary><b>卸载</b></summary>
108
-
109
- ```sh
110
- dsh-mcp-manager-uninstall # 若用 npm -g 安装
111
- # 或:.\uninstall.ps1 | ./uninstall.sh | node uninstall.mjs [--dsh-home <path>] [--profile <name>]
112
- ```
113
-
114
- 然后重启 DSH。卸载删除部署副本、`local-packages` 真源,并清理 loader 行(补丁保持合法)。
115
-
116
- </details>
117
-
118
- <details>
119
- <summary><b>DSH 升级后:--repair</b></summary>
120
-
121
- DSH 升级(或 HMR 状态异常)后若 **设置里没有"MCP 管理"** 或 **`mcp_manager_*` 工具消失**,运行一次修复命令:重新部署 → 递增 loader 行 `config.version`(触发 HMR 重应用)→ 轮询 API 直到 `{ok:true}`(默认 30 秒)。
122
-
123
- ```sh
124
- node dsh-mcp-manager/install.mjs --repair --port 3080
125
- # PowerShell: .\install.ps1 -Repair -Port 3080 bash: ./install.sh --repair --port 3080
126
- ```
127
-
128
- 仍不恢复则重启一次 DSH(loader 启动时重新导入)。
129
-
130
- </details>
131
-
132
- <details>
133
- <summary><b>常见问题</b></summary>
134
-
135
- | 现象 | 原因与解决 |
136
- |---|---|
137
- | 装完设置里没有"MCP 管理" | 硬刷新(Cmd/Ctrl+Shift+R);仍没有就重启 DSH 一次。 |
138
- | 页面出现**两个 MCP 页签 / 工具重复** | 双挂载:同时用了 install.mjs 与 `dsh plugin add` 两种方式。卸载其中一种(`dsh-mcp-manager-uninstall` 或删掉对应的 loader 行 / `dsh.profile.bundles` 条目)。 |
139
- | DSH 升级后工具消失 | 跑一次 `--repair`(见上)。 |
140
- | `npx` / `npm view` 报 404 | 国内镜像(npmmirror)同步有延迟:加 `--registry=https://registry.npmjs.org` 或稍等再试。 |
141
- | 安装脚本报错 `EPERM` | DSH 正在运行占用了文件:先退出 DSH 再装。 |
142
- | 修改配置后未生效 | 所有修改走 HMR 热应用,等 1–2 秒自动刷新;页面会自动轮询。 |
143
-
144
- </details>
145
-
146
- ## 📖 使用说明
147
-
148
- 打开 **设置 → MCP 管理**:
149
-
150
- - **添加服务器**:填写 `serverName`(唯一,1–32 位 `[A-Za-z0-9_-]`)、传输方式及对应字段(`streamable-http` 填 URL / headers;`stdio` 填 command / args / env),选择级别(项目级 / 全局)。面板做格式与重名校验。
151
- - 每张卡片显示实时状态、连接目标与工具数;可 **启用 / 停用**、**重启**、**编辑**、**删除**。
152
- - **备份 / 恢复**:一键导出 JSON,或粘贴 JSON 导入(合并新增,已存在自动跳过)。
153
- - 页面底部显示正在编辑的补丁文件路径。
154
-
155
- ## ⚙️ 配置
156
-
157
- 插件自身在 loader 行中的配置:
158
-
159
- | 字段 | 说明 |
160
- |---|---|
161
- | `version` | loader 行 `config.version`。`--repair` 会将其递增以强制 HMR 重应用,无需手动修改。 |
162
-
163
- loader 行必须为 **`insert` 块**形式(DSH patch 方言中普通 `- id:` 行只是对已存在条目的覆盖,无法新增插件):
164
-
165
- ```yaml
166
- - insert:
167
- - id: dsh-mcp-manager
168
- name: dsh-mcp-manager
169
- config:
170
- version: 1
171
- ```
172
-
173
- ## 🏗️ 架构
174
-
175
- - **宿主端**(`src/index.ts` → `lib/index.js`,对象形态 Cordis 插件 `{name, inject, apply}`):`inject` 声明 `timer/fs/settings/sandboxPolicy/webServer/tools`,框架保证就绪并在依赖消失时自动重载——这是插件跨 DSH 升级存活的机制。注册 4 个模型工具(`ctx.tools.register(defineTool(...))`)与精确路由 `POST /dsh-mcp-manager/api`(`ctx.effect` 作用域化清理);对 `cordis.patch.yml` 做行级 CRUD(迷你 YAML 解析 + 按文件写锁)。
176
- - **浏览器端**(`lib/client.js`,ModuleLoader CJS bundle):注册 设置 → MCP 管理 页(`settings.section` 槽位,order 16),经同源 `fetch('/dsh-mcp-manager/api')` 与宿主通信,不直接访问文件系统。
177
- - **loader 行**:写入 profile 的 `cordis.patch.yml`,client-modules 服务扫描启用的条目并下发客户端 bundle。
178
- - **安装器**:`install.mjs`(跨平台核心)/ `install.ps1` / `install.sh` + 对应的 `uninstall.*`;npm 包 `@xxxyz/dsh-mcp-manager` 的 bin 直接执行安装器(`dsh-mcp-manager` / `dsh-mcp-manager-uninstall`)。
179
-
180
- ## 🛠️ 开发
181
-
182
- ```bash
183
- npm install
184
- npm run build # tsc -p tsconfig.json → lib/index.js(宿主端)
185
- ```
186
-
187
- - 宿主插件源码:`src/index.ts`;浏览器 bundle:`lib/client.js`(手写,无需构建)
188
- - 包本身纯 JS、零依赖、跨平台;构建只需 devDependencies(typescript、`@deepseek-ai/cordis`、`@deepseek-ai/dsh-tools`、`@types/node`)
189
- - 发布:`npm version patch && npm publish`(`prepublishOnly` 自动构建;scoped 包已配置 `publishConfig.access: public`)
190
-
191
- ## 许可证
192
-
193
- MIT