dsh-remote-mcp-manager 0.4.1 → 0.5.0

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.en.md ADDED
@@ -0,0 +1,109 @@
1
+ # dsh-remote-mcp-manager
2
+
3
+ A DSH plugin for managing remote and local MCP servers, from both the settings panel and the phone's native UI.
4
+
5
+ ![Downloads](https://img.shields.io/github/downloads/lwy521/dsh-remote-mcp-manager/total?logo=github)
6
+
7
+ [中文](README.md) | English
8
+
9
+ ## Features
10
+
11
+ ### Native mobile panel (new in v0.4.0)
12
+ - Registers an **MCP Manager** native panel via `ctx.dshGo.panel()`, shown in the session tab bar and under "All features"
13
+ - Read-only overview: lists every configured MCP server with its connection status and tool count
14
+ - Results are cached for 60 seconds to keep the UI responsive
15
+ - Panel title follows the system language
16
+
17
+ ### Dedicated settings page (since v0.3.0)
18
+ - **MCP Manager**: a top-level page in the settings sidebar
19
+ - **Single-card layout**: the server list and the editor form share one card and switch in place, so nothing scrolls out of view
20
+ - **Edit in place**: clicking "Edit" turns the card into a form
21
+ - **Unsaved-changes guard**: leaving a dirty form opens a modal offering "Save" or "Discard"
22
+ - **Themed modal**: matches the card styling in both light and dark themes
23
+
24
+ ### Configuration
25
+ - **Remote HTTP MCP**: add a Streamable HTTP MCP server (URL, token, path, timeout)
26
+ - **Local process MCP**: launch a stdio MCP server (command, arguments, environment, working directory)
27
+ - **Connection test**: remote HTTP servers can be tested live (MCP initialization + `tools/list`)
28
+ - **CRUD**: add, edit, and delete configured servers
29
+ - **Persistence**: configuration is written to `cordis.patch.yml` and hot-reloaded
30
+
31
+ ## Installation
32
+
33
+ ```bash
34
+ dsh plugin add dsh-remote-mcp-manager
35
+ ```
36
+
37
+ ## Usage
38
+
39
+ ### Managing servers
40
+ Open the **MCP Manager** page from the settings sidebar in the DSH Web UI. Existing servers are listed there; click **Edit** to switch that card into its form, where you can test the connection or delete the entry.
41
+
42
+ ### Adding a remote HTTP server
43
+ - **Server name**: unique identifier, letters, digits, underscore and hyphen only, 1–32 characters
44
+ - **URL**: MCP server endpoint
45
+ - **API key / token**: optional authentication
46
+ - **Path**: optional URL path
47
+ - **Timeout**: optional, defaults to 60000 ms
48
+
49
+ ### Adding a local process server
50
+ - **Server name**: same rules as above
51
+ - **Command**: executable path (for example `node`, `python`, `npx`)
52
+ - **Arguments**: one per line
53
+ - **Environment**: one `KEY=VALUE` per line
54
+ - **Working directory**: optional
55
+
56
+ ## Transport types
57
+
58
+ | Type | Protocol | Description |
59
+ |------|----------|-------------|
60
+ | Remote HTTP | `streamable-http` | Connects to a remote MCP server |
61
+ | Local process | `stdio` | Spawns a local MCP subprocess |
62
+
63
+ ## Changelog
64
+
65
+ ### v0.4.1
66
+ - **Fix: incomplete npm package** — the `files` field omitted `cordis.patch.yml`, `icon.png` and `icon@2x.png`, so the plugin failed to load when installed from npm
67
+ - **Added: `publishConfig`** — pins publishing to the official registry and declares public access
68
+
69
+ ### v0.4.0
70
+ - **Added: native mobile panel** — registers a `mcp-manager` panel showing each server's connection status and tool count
71
+ - **Added: localization** — ships `locale/zh.json` and `locale/en.json`; titles follow the system language
72
+ - **Added: plugin icons** — `icon.png` and `icon@2x.png`
73
+ - **Changed: unified plugin identifier** — renamed from `remote-mcp-manager` to `dsh-remote-mcp-manager` to match the package name
74
+ - **Fix: `cordis.patch.yml` was not tracked** — this file is required for the plugin to load and had been excluded by `.gitignore`, so a fresh clone could not load the plugin
75
+ - **Improved: server name validation** — enforces `[A-Za-z0-9_-]{1,32}` and rejects duplicates
76
+ - **Improved: explicit client injections** — client modules are now declared explicitly, avoiding load-order problems
77
+
78
+ > **Upgrade note**: the plugin identifier changed. When upgrading from v0.3.x, remove the old
79
+ > `remote-mcp-manager` in the plugin manager, then install `dsh-remote-mcp-manager`.
80
+ > Back up any MCP configuration previously written to `cordis.patch.yml`.
81
+
82
+ ### v0.3.1
83
+ - **Fix: token lost after update** — front end and back end now serialize the token field consistently
84
+ - **Fix: connection test hanging** — HTTP requests use a 15-second timeout (`AbortController`)
85
+ - **Fix: save button not working** — added the save callback, guarded against saving on first load, surfaced error messages
86
+ - **Fix: stronger form validation** — server name format check, duplicate detection, rejects non-ASCII names
87
+ - **Fix: stdio options dropped** — `toolCallTimeoutMs` and `failOnStartupError` are read and written correctly
88
+ - **Fix: patch file recovery** — a file with only a begin marker and no end marker is repaired instead of failing silently
89
+ - **Security** — CSRF same-origin check, 2 MB request body limit, no duplicate header writes on error
90
+ - **UX** — save failures and form errors are shown, empty loads ignored, path joining fixed
91
+
92
+ ### v0.3.0
93
+ - Top-level settings page: promoted from a card inside the "Plugins" page to its own settings page
94
+ - Merged card: the list and the create/edit form share one card, switched by a `mode` state
95
+ - Edit in place: clicking "Edit" turns the card into the form
96
+ - Unsaved-changes guard: a custom modal asks whether to save before leaving
97
+ - Sidebar label: renamed to "MCP Manager"
98
+
99
+ ### v0.2.0
100
+ - Added stdio transport support (local process MCP)
101
+ - Replaced the native select with a custom dropdown
102
+ - Configurable timeout
103
+ - Session ID passthrough (`MCP-Session-Id`)
104
+
105
+ ## License
106
+ ![License](https://img.shields.io/badge/License-GPLv3-blue.svg)
107
+
108
+ ## Version
109
+ ![Version](https://img.shields.io/github/v/release/lwy521/dsh-remote-mcp-manager?logo=github)
package/README.md CHANGED
@@ -1,14 +1,28 @@
1
- # dsh-remote-mcp-manager
1
+ 中文 | [English](README.en.md)
2
2
 
3
- DSH 插件:在设置面板与手机原生界面上管理远程 / 本地 MCP 服务器。
3
+ # dsh-remote-mcp-manager
4
+
5
+ DSH 插件:设置面板与手机原生界面上管理远程MCP 服务器
6
+
7
+ ![下载量](https://img.shields.io/github/downloads/lwy521/dsh-remote-mcp-manager/total?logo=github)
8
+ ![许可证](https://img.shields.io/badge/License-GPLv3-blue.svg)
9
+ ![版本号](https://img.shields.io/github/v/release/lwy521/dsh-remote-mcp-manager?logo=github)
10
+ <a href="https://github.com/ccch1mneyyy/dsh-go/stargazers"><img alt="GitHub Star 数" src="https://img.shields.io/github/stars/lwy521/dsh-remote-mcp-manager?style=flat-square&logo=github&label=Star&color=4B67B4&labelColor=2B3245"></a>
11
+
12
+ <p align="center">
13
+ <sub>有问题可以先看<a href="README.md">使用指南</a>遇到问题欢迎来</sub><br>
14
+ <sub>
15
+ <a href="https://qm.qq.com/q/n8IIExyQb6">QQ 群:1098700583</a></sub><br></p>
4
16
 
5
17
  ## 功能
6
18
 
7
- ### 手机端原生面板(v0.4.0 新增)
8
- - 通过 `ctx.dshGo.panel()` 注册 **MCP 管理** 原生面板,出现在会话标签页与「全部功能」
9
- - 只读信息面板:列出所有已配置的 MCP Server,显示连通状态与工具数量
10
- - 结果缓存 60 秒,避免频繁探测拖慢界面
11
- - 中英文标题跟随系统语言
19
+ ### 设置页对象表单(v0.5.0)
20
+ - 每个 MCP 服务 = 一个可展开的对象槽位,标题直接显示服务名(`mcp-gateway`、`Firecrawl`…)
21
+ - 点开就是完整表单:服务名 / 启用服务 / 自动测速 / 地址 / 协议(左右滑动选 streamable-http、sse、stdio)/ 密钥 / 描述 / 超时
22
+ - **删除这个服务**:打开后该槽位被清空、服务停止挂载
23
+ - 最后一行是 **添加服务**,只有一个字段「填写新配置服务名」;填了就自动追加一个完整槽位,填满继续增长,**不限条数**
24
+ - 服务名留空只填地址时,插件会向该地址握手取 `serverInfo.name` 自动补名
25
+ - 整页可编辑,改完离开即保存,不再有「由配置文件固定」的只读状态
12
26
 
13
27
  ### 设置侧边栏一级页面(v0.3.0)
14
28
  - **MCP管理**:设置侧边栏新增「MCP管理」一级页面
@@ -100,6 +114,6 @@ dsh plugin add dsh-remote-mcp-manager
100
114
  - 超时时间配置
101
115
  - 会话 ID 透传支持(MCP-Session-Id)
102
116
 
103
- ## 许可证
117
+ ## 更新日志
104
118
 
105
- MIT
119
+ - **v0.5.0** — 设置页改成对象槽位表单(服务名作标题、点开即完整字段、删除开关、添加服务不限条数);移除只读原生面板
package/lib/client.js CHANGED
@@ -465,17 +465,23 @@ window.__ModuleLoader__.load({
465
465
  var T = function (zhText, enText) { return ZH ? zhText : enText; };
466
466
 
467
467
  // ── exports ──
468
- var inject = [];
468
+ var inject = ["slots"];
469
469
  function apply(ctx) {
470
- var slots = ctx.get("slots");
471
- if (slots !== undefined) {
470
+ var wire = function (slots) {
472
471
  slots.inject("settings.section", function () {
473
472
  return slots.register(
474
473
  { name: "settings.section", id: "remote-mcp-manager", order: 150, label: T("MCP管理", "MCP Manager") },
475
474
  function () { return React.createElement(SettingsCard, {}); }
476
475
  );
477
476
  });
477
+ };
478
+ var own = ctx && ctx.slots;
479
+ if (own && typeof own.register === "function" && typeof own.inject === "function") {
480
+ wire(own);
481
+ return;
478
482
  }
483
+ var shared = ctx.get("slots");
484
+ if (shared !== undefined && typeof shared.register === "function" && typeof shared.inject === "function") wire(shared);
479
485
  }
480
486
  exports.apply = apply;
481
487
  exports.inject = inject;
package/lib/index.js CHANGED
@@ -1,29 +1,313 @@
1
1
  // dsh-remote-mcp-manager —— 一个包同时提供手机原生面板和 Web 设置页。
2
2
  // 配置持久化在 profile 的 cordis.patch.yml(managed 标记块,insert mcp-client),
3
- // 保存后 HMR 自动重载,工具随之注册;手机端面板读同一份配置并显示状态。
3
+ // 保存后 HMR 自动重载,工具随之注册;
4
+ // 手机端面板直接编辑同一份配置:改字段 → 保存 → 写回 → 重载,全程不跳网页。
4
5
  import fs from 'node:fs'
5
6
  import path from 'node:path'
6
7
  import os from 'node:os'
7
8
  import * as yaml from 'js-yaml'
9
+ import z from '@deepseek-ai/schemastery'
10
+ import * as McpClient from '@deepseek-ai/dsh-mcp-client'
8
11
 
9
12
  export const name = 'dsh-remote-mcp-manager'
10
13
  export const inject = []
11
14
 
15
+ // 插件配置(App 原生设置页按这份 schema 生成表单)
16
+
17
+ // 服务清单用 dict(键值表)暴露给 App:array 只要有一条元素 App 就把整页判成
18
+ // “由配置文件固定”而只读;dict 有元素照样能增删,是唯一能做真表单的类型。
19
+ // 键 = 服务名,值 = “地址[|令牌][|off]”,off/0/false/停用 表示不启用。
20
+
21
+ // 每个服务 = 一个对象字段:App 会把它展开成一整组字段(名字/地址/协议/密钥/开关…)
22
+ const ServiceObj = z.object({
23
+ name: z.string().default('').description('服务名'),
24
+ on: z.boolean().default(true).description('启用服务'),
25
+ autoProbe: z.boolean().default(true).description('自动测速'),
26
+ url: z.string().max(2048).default('').description('地址'),
27
+ protocol: z.union([
28
+ z.const('streamable-http'),
29
+ z.const('sse'),
30
+ z.const('stdio'),
31
+ ]).default('streamable-http').description('协议'),
32
+ token: z.string().max(4096).default('').description('密钥'),
33
+ desc: z.string().max(2000).default('').description('描述'),
34
+ timeoutMs: z.number().min(1000).max(60000).step(500).default(15000).description('超时(毫秒)'),
35
+ remove: z.boolean().default(false).description('删除这个服务'),
36
+ })
37
+
38
+ // 槽位标题:加载时读出该槽位当前的服务名,直接拿名字当标题(改完名字重载一次即更新)
39
+ function slotTitlesFromPatch() {
40
+ try {
41
+ const home = process.env.DSH_HOME || path.join(os.homedir(), '.dsh')
42
+ const file = path.join(home, 'profiles', 'web', 'cordis.patch.yml')
43
+ const text = fs.readFileSync(file, 'utf8')
44
+ const at = text.indexOf('- id: dsh-remote-mcp-manager')
45
+ if (at < 0) return {}
46
+ const nxt = text.indexOf('\n- ', at + 1)
47
+ const end = nxt < 0 ? text.length : nxt
48
+ const arr = yaml.load(text.slice(at, end))
49
+ const parsed = (Array.isArray(arr) ? arr[0] : arr) || {}
50
+ const cfg = parsed.config || {}
51
+ const out = { names: {}, maxKey: 0 }
52
+ for (let i = 1; i <= 64; i++) {
53
+ const o = cfg['server' + i]
54
+ if (o === undefined || o === null) continue
55
+ out.maxKey = i
56
+ const nm = o && typeof o === 'object' ? String(o.name || '').trim() : ''
57
+ if (nm) out.names[i] = nm
58
+ }
59
+ return out
60
+ } catch { return { names: {}, maxKey: 0 } }
61
+ }
62
+
63
+ // 槽位数量按现有服务自动增长:已用到的最大槽位 + 1 个空位(至少 4 个),填满会继续长
64
+ const slotInfo = slotTitlesFromPatch()
65
+ const slotTitles = slotInfo.names
66
+ const SLOT_INDEXES = Object.keys(slotTitles).map(Number).sort(function (a, b) { return a - b })
67
+ const MAX_SLOT = Math.max(0, slotInfo.maxKey, ...SLOT_INDEXES)
68
+
69
+ const slotFields = {}
70
+ for (const i of SLOT_INDEXES) {
71
+ slotFields['server' + i] = ServiceObj.default({}).volatile().description(slotTitles[i])
72
+ }
73
+ // 新增位:只显示一个名字字段,填了就会追加一个完整服务槽位
74
+ slotFields.newServer = z.object({
75
+ name: z.string().max(32).default('').description('填写新配置服务名'),
76
+ }).default({}).volatile().description('添加服务')
77
+
78
+ export const Config = z.object({
79
+ ...slotFields,
80
+ })
81
+
12
82
  // 文案:中文优先,英文界面回退
13
83
  const L = {
14
84
  title: ['MCP 管理', 'MCP Manager'],
15
- summary: [(en, n, t) => `服务状态: 已启用 ${n}/${t} 服务`, (en, n, t) => `Status: ${n}/${t} enabled`],
16
- empty: ['服务状态: 还没有配置服务', 'Status: no servers configured'],
17
- hint: ['提示: 编辑请到网页【设置 → MCP管理】', 'Tip: edit in Web UI → Settings → MCP Manager'],
85
+ summary: [(en, n, t) => `共 ${t} 个服务 · 启用 ${n}`, (en, n, t) => `${t} servers · ${n} on`],
86
+ empty: ['还没有配置服务,点下面的「新增服务」', 'No servers yet — tap Add server'],
87
+ more: (n) => [`还有 ${n} 条未显示,请到网页版编辑`, `${n} more hidden — edit in Web UI`],
88
+ saveAll: ['保存全部', 'Save all'],
89
+ editTitle: ['编辑 MCP 服务', 'Edit MCP server'],
90
+ editHint: ['改完点「保存全部」写入并重载;名称只允许字母、数字、下划线、短横', 'Save all to write and reload; name allows letters, digits, _ -'],
91
+ noSelection: ['没有选中条目,回列表点一条', 'Nothing selected — pick one in the list'],
92
+ notFound: ['没找到这一条', 'Row not found'],
93
+ listHint: ['编辑请到:设置 → MCP管理(原生表单);这里只显示状态', 'Edit in Settings → MCP Manager; status only'],
94
+ hint: ['改完点「保存全部」写入并自动生效;一屏最多 6 条', 'Edit, then Save all — applies on save; up to 6 per screen'],
18
95
  probing: ['测式中', 'Probing'],
19
96
  ok: (ms) => `正常·${ms}ms`,
20
97
  bad: (ms) => `异常·${ms}ms`,
98
+ fEnabled: ['启用', 'On'],
99
+ fTransport: ['传输', 'Transport'],
100
+ fName: ['名称', 'Name'],
101
+ fUrl: ['地址', 'URL'],
102
+ fToken: ['Token', 'Token'],
103
+ fTokenHint: ['留空表示不带鉴权', 'Empty for no auth'],
104
+ test: ['测试连接', 'Test'],
105
+ del: ['删除', 'Delete'],
106
+ add: ['新增服务', 'Add server'],
107
+ goSettings: ['去设置编辑', 'Edit in Settings'],
108
+ reload: ['重新载入', 'Reload'],
109
+ stdio: ['stdio 型服务请到网页版编辑', 'stdio servers: edit in Web UI'],
110
+ savedToast: ['已保存并生效', 'Saved and applied'],
111
+ addedToast: ['已新增一条,填好再保存', 'Added — fill it in and save'],
112
+ deletedToast: ['已删除', 'Deleted'],
113
+ badName: ['名称只能字母数字下划线短横', 'Name: letters, digits, _ - only'],
114
+ dupName: ['名称重复了', 'Duplicate name'],
115
+ noInput: ['没读到输入,点一下输入框再保存', 'No input read — tap a field and retry'],
116
+ optTransport: ['streamable-http', 'sse'],
21
117
  }
22
118
  const zh = (caps) => !caps || !caps.locale || String(caps.locale).startsWith('zh')
23
- const pick = (caps, pair) => zh(caps) ? pair[0] : pair[1]
119
+ const pick = (caps, pair) => Array.isArray(pair) ? (zh(caps) ? pair[0] : pair[1]) : pair
120
+
121
+
122
+ // 发布版:不再内置任何服务与凭据。
123
+ // 服务由用户在 设置 → MCP管理 里自行添加(每个服务一个对象槽位)。
124
+ const DEFAULT_SERVERS = []
125
+
126
+ // —— 独立存储:完整服务清单(真源)——
127
+ function storePath() {
128
+ const home = process.env.DSH_HOME || path.join(os.homedir(), '.dsh')
129
+ return path.join(home, 'dsh-go', 'mcp-manager.servers.json')
130
+ }
24
131
 
25
- const MANAGED_BEGIN = '# === dsh-remote-mcp-manager managed ===\n'
26
- const MANAGED_END = '# === dsh-remote-mcp-manager end ===\n'
132
+ function normServer(x) {
133
+ const s = x && typeof x === 'object' ? x : {}
134
+ const name = String(s.serverName || '').trim()
135
+ if (!/^[A-Za-z0-9_-]{1,32}$/.test(name)) return null
136
+ return {
137
+ serverName: name,
138
+ enabled: s.enabled !== false,
139
+ transport: s.transport === 'stdio' ? 'stdio' : 'streamable-http',
140
+ url: String(s.url || '').slice(0, 2048),
141
+ token: String(s.token || '').slice(0, 4096),
142
+ command: String(s.command || '').slice(0, 2048),
143
+ }
144
+ }
145
+
146
+ function loadStore(logger) {
147
+ const p = storePath()
148
+ try {
149
+ const raw = fs.readFileSync(p, 'utf8')
150
+ const data = JSON.parse(raw)
151
+ const list = Array.isArray(data) ? data : (Array.isArray(data?.servers) ? data.servers : [])
152
+ return list.map(normServer).filter(Boolean)
153
+ } catch (err) {
154
+ if (err?.code !== 'ENOENT') logger?.warn?.('[mcp-manager] 读取服务清单失败: ' + (err.message || err))
155
+ return null
156
+ }
157
+ }
158
+
159
+ function saveStore(servers, logger) {
160
+ const p = storePath()
161
+ try {
162
+ fs.mkdirSync(path.dirname(p), { recursive: true })
163
+ const body = JSON.stringify({ version: 1, servers }, null, 2) + '\n'
164
+ const tmp = p + '.tmp-' + process.pid
165
+ fs.writeFileSync(tmp, body, 'utf8')
166
+ fs.renameSync(tmp, p)
167
+ return true
168
+ } catch (err) {
169
+ logger?.warn?.('[mcp-manager] 写入服务清单失败: ' + (err.message || err))
170
+ return false
171
+ }
172
+ }
173
+
174
+ // 「地址[|令牌][|off]」→ 服务项
175
+ function parseDictValue(name, raw) {
176
+ const text = String(raw == null ? '' : raw).trim()
177
+ const parts = text.split(/[||]/).map((x) => x.trim())
178
+ const url = parts[0] || ''
179
+ let token = ''
180
+ let enabled = true
181
+ for (let i = 1; i < parts.length; i++) {
182
+ const v = parts[i]
183
+ if (!v) continue
184
+ if (/^(off|0|false|no|停用|禁用)$/i.test(v)) enabled = false
185
+ else if (!token) token = v
186
+ }
187
+ return normServer({ serverName: name, enabled, transport: 'streamable-http', url, token })
188
+ }
189
+
190
+ // 服务项 → 「地址[|令牌][|off]」
191
+ function dictValueOf(s) {
192
+ const bits = [String(s.url || '')]
193
+ if (s.token) bits.push(String(s.token))
194
+ if (s.enabled === false) bits.push('off')
195
+ return bits.join(' | ')
196
+ }
197
+
198
+ // 读 App 设置页的对象槽位(name 为空的槽位 = 未使用,相当于「添加服务」)
199
+ function dictFromConfig(cfgVal, config) {
200
+ const out = []
201
+ for (const i of SLOT_INDEXES) {
202
+ const o = cfgVal(config?.['server' + i], {}) || {}
203
+ if (o.remove === true) continue
204
+ const name = String(o.name || '').trim()
205
+ if (!name) continue
206
+ const item = normServer({
207
+ serverName: name,
208
+ enabled: o.on !== false,
209
+ transport: o.protocol || 'streamable-http',
210
+ url: o.url || '',
211
+ token: o.token || '',
212
+ })
213
+ if (item) {
214
+ item.autoProbe = o.autoProbe !== false
215
+ item.desc = o.desc || ''
216
+ item.timeoutMs = Number(o.timeoutMs) || 15000
217
+ out.push(item)
218
+ }
219
+ }
220
+ return out
221
+ }
222
+
223
+ // 把清单写回 profile patch 的对象槽位
224
+ function syncDictToPatch(patchFile, servers, logger) {
225
+ try {
226
+ const text = fs.readFileSync(patchFile, 'utf8')
227
+ const at = text.indexOf('- id: dsh-remote-mcp-manager')
228
+ if (at < 0) return false
229
+ const nxt = text.indexOf('\n- ', at + 1)
230
+ const end = nxt < 0 ? text.length : nxt
231
+ const arr = yaml.load(text.slice(at, end))
232
+ const parsed = (Array.isArray(arr) ? arr[0] : arr) || {}
233
+ const cfg = { ...(parsed.config || {}) }
234
+ for (const k of Object.keys(cfg)) if (/^server\d+$/.test(k)) delete cfg[k]
235
+ for (let i = 1; i <= servers.length; i++) {
236
+ const s = servers[i - 1]
237
+ if (!s) continue
238
+ cfg['server' + i] = {
239
+ name: s.serverName,
240
+ on: s.enabled !== false,
241
+ autoProbe: s.autoProbe !== false,
242
+ url: s.url || '',
243
+ protocol: s.transport || 'streamable-http',
244
+ token: s.token || '',
245
+ desc: s.desc || '',
246
+ timeoutMs: Number(s.timeoutMs) || 15000,
247
+ }
248
+ }
249
+ const dumped = yaml.dump([{ id: parsed.id, name: parsed.name, config: cfg }], { lineWidth: 1000, noRefs: true })
250
+ const tmp = patchFile + '.tmp-' + process.pid
251
+ fs.writeFileSync(tmp, text.slice(0, at) + dumped + text.slice(end), 'utf8')
252
+ fs.renameSync(tmp, patchFile)
253
+ return true
254
+ } catch (err) {
255
+ logger?.warn?.('[mcp-manager] 同步设置页字段失败: ' + (err.message || err))
256
+ return false
257
+ }
258
+ }
259
+
260
+ // 向服务地址握手,取服务端自报的名字(serverInfo.name)
261
+ async function probeServerName(url, token, timeoutMs = 8000) {
262
+ if (!url) return ''
263
+ const controller = new AbortController()
264
+ const timer = setTimeout(() => controller.abort(), timeoutMs)
265
+ const headers = { 'Content-Type': 'application/json', Accept: 'application/json, text/event-stream' }
266
+ const t = String(token || '').trim()
267
+ if (t) headers.Authorization = t.startsWith('Bearer ') ? t : `Bearer ${t}`
268
+ try {
269
+ const res = await fetch(url, {
270
+ method: 'POST', headers,
271
+ body: JSON.stringify({
272
+ jsonrpc: '2.0', id: 1, method: 'initialize',
273
+ params: { protocolVersion: '2025-06-18', capabilities: {}, clientInfo: { name: 'dsh-remote-mcp-manager', version: '2' } },
274
+ }),
275
+ signal: controller.signal,
276
+ })
277
+ if (!res.ok) return ''
278
+ const text = await res.text()
279
+ const m = text.match(/"serverInfo"\s*:\s*\{[^}]*?"name"\s*:\s*"([^"]{1,60})"/)
280
+ return m ? m[1].trim() : ''
281
+ } catch { return '' } finally { clearTimeout(timer) }
282
+ }
283
+
284
+ // 把探测到的真名写回 patch 的指定槽位
285
+ function writeSlotName(patchFile, slot, realName, logger) {
286
+ try {
287
+ const text = fs.readFileSync(patchFile, 'utf8')
288
+ const at = text.indexOf('- id: dsh-remote-mcp-manager')
289
+ if (at < 0) return false
290
+ const nxt = text.indexOf('\n- ', at + 1)
291
+ const end = nxt < 0 ? text.length : nxt
292
+ const arr = yaml.load(text.slice(at, end))
293
+ const parsed = (Array.isArray(arr) ? arr[0] : arr) || {}
294
+ const cfg = { ...(parsed.config || {}) }
295
+ const key = 'server' + slot
296
+ const cur = cfg[key] && typeof cfg[key] === 'object' ? { ...cfg[key] } : {}
297
+ if (String(cur.name || '').trim()) return false
298
+ cur.name = realName
299
+ cfg[key] = cur
300
+ const dumped = yaml.dump([{ id: parsed.id, name: parsed.name, config: cfg }], { lineWidth: 1000, noRefs: true })
301
+ const tmp = patchFile + '.tmp-' + process.pid
302
+ fs.writeFileSync(tmp, text.slice(0, at) + dumped + text.slice(end), 'utf8')
303
+ fs.renameSync(tmp, patchFile)
304
+ logger?.info?.('[mcp-manager] 槽位 ' + slot + ' 自动取到服务名: ' + realName)
305
+ return true
306
+ } catch (err) {
307
+ logger?.warn?.('[mcp-manager] 写回服务名失败: ' + (err.message || err))
308
+ return false
309
+ }
310
+ }
27
311
 
28
312
  // —— 定位 profile 的 cordis.patch.yml ——
29
313
  function profileDirs() {
@@ -46,11 +330,11 @@ function findPatchFile(ctx) {
46
330
  if (fs.existsSync(p)) return p
47
331
  } catch { /* 忽略 */ }
48
332
  }
49
- // 2) 扫描 profiles,找含有本插件 managed 块的那个
333
+ // 2) 扫描 profiles,找写了本插件配置条目的那个
50
334
  for (const dir of profileDirs()) {
51
335
  const p = path.join(dir, 'cordis.patch.yml')
52
336
  try {
53
- if (fs.readFileSync(p, 'utf8').includes(MANAGED_BEGIN)) return p
337
+ if (fs.readFileSync(p, 'utf8').includes('- id: dsh-remote-mcp-manager')) return p
54
338
  } catch { /* 忽略 */ }
55
339
  }
56
340
  // 3) 默认 web profile
@@ -58,103 +342,6 @@ function findPatchFile(ctx) {
58
342
  return path.join(home, 'profiles', 'web', 'cordis.patch.yml')
59
343
  }
60
344
 
61
- // —— 读配置 ——
62
- function readServers(patchFile, logger) {
63
- try {
64
- const text = fs.readFileSync(patchFile, 'utf8')
65
- const start = text.indexOf(MANAGED_BEGIN)
66
- if (start === -1) return []
67
- const end = text.indexOf(MANAGED_END, start)
68
- if (end === -1) return []
69
- const data = yaml.load(text.slice(start + MANAGED_BEGIN.length, end))
70
- if (!Array.isArray(data)) return []
71
- const out = []
72
- for (const patch of data) {
73
- if (!patch || !Array.isArray(patch.insert)) continue
74
- for (const entry of patch.insert) {
75
- const cfg = entry?.config
76
- if (!cfg || !cfg.serverName) continue
77
- const s = {
78
- id: entry.id || ('remote-mcp-' + cfg.serverName),
79
- serverName: cfg.serverName,
80
- transport: cfg.transport || 'streamable-http',
81
- enabled: cfg.enabled !== false,
82
- }
83
- if (cfg.transport === 'stdio') {
84
- s.command = cfg.command || ''
85
- s.args = Array.isArray(cfg.args) ? cfg.args : []
86
- s.env = cfg.env && typeof cfg.env === 'object' ? cfg.env : {}
87
- s.cwd = cfg.cwd || ''
88
- } else {
89
- s.url = cfg.url || ''
90
- const auth = cfg.headers && cfg.headers.Authorization
91
- s.token = auth ? String(auth).replace(/^Bearer\s+/i, '') : ''
92
- }
93
- out.push(s)
94
- }
95
- }
96
- return out
97
- } catch (err) {
98
- logger?.warn?.('[mcp-manager] 读取配置失败: ' + (err.message || err))
99
- return []
100
- }
101
- }
102
-
103
- // —— 写配置(原子替换)——
104
- function writeServers(patchFile, servers, logger) {
105
- const entries = servers.map((s) => {
106
- const cfg = {
107
- serverName: s.serverName,
108
- transport: s.transport || 'streamable-http',
109
- }
110
- if (s.transport === 'stdio') {
111
- cfg.command = s.command || ''
112
- if (Array.isArray(s.args) && s.args.length) cfg.args = s.args
113
- if (s.env && Object.keys(s.env).length) cfg.env = s.env
114
- if (s.cwd) cfg.cwd = s.cwd
115
- } else {
116
- let u = s.url || ''
117
- // mcp-client 0.2.2 没有 path 字段,路径拼进 url 才有效
118
- if (u && s.path) {
119
- const pp = String(s.path).replace(/^\/+/, '').replace(/\/+$/, '')
120
- if (pp) u = u.replace(/\/+$/, '') + '/' + pp
121
- }
122
- cfg.url = u
123
- const token = String(s.token || '').trim()
124
- if (token) cfg.headers = { Authorization: token.startsWith('Bearer ') ? token : `Bearer ${token}` }
125
- }
126
- return {
127
- id: 'remote-mcp-' + String(s.serverName).replace(/[^a-zA-Z0-9_-]/g, '_'),
128
- name: '@deepseek-ai/dsh-mcp-client',
129
- config: cfg,
130
- }
131
- })
132
- const block = entries.length
133
- ? MANAGED_BEGIN + entries.map(e => yaml.dump([{ insert: [e] }], { lineWidth: 120, noRefs: true }).trim()).join('\n') + '\n' + MANAGED_END
134
- : MANAGED_BEGIN + MANAGED_END
135
-
136
- let text
137
- try { text = fs.readFileSync(patchFile, 'utf8') } catch { text = '' }
138
-
139
- const start = text.indexOf(MANAGED_BEGIN)
140
- const end = text.indexOf(MANAGED_END)
141
- if (start !== -1 && end !== -1 && start < end) {
142
- text = text.slice(0, start) + block + text.slice(end + MANAGED_END.length)
143
- } else if (start !== -1) {
144
- logger?.warn?.('[mcp-manager] managed 块只有开头没有结尾,已修复')
145
- text = text.slice(0, start).replace(/\n+$/, '') + '\n\n' + block
146
- } else {
147
- const trimmed = text.endsWith('\n') ? text : text + '\n'
148
- text = trimmed + '\n' + block
149
- }
150
-
151
- // 先写临时文件再 rename,避免 HMR 读到半截
152
- const tmp = patchFile + '.tmp-' + process.pid
153
- fs.writeFileSync(tmp, text, 'utf8')
154
- fs.renameSync(tmp, patchFile)
155
- return true
156
- }
157
-
158
345
  // —— 测试连接(服务端代理,避免浏览器 CORS)——
159
346
  function parseToolCount(text) {
160
347
  const tryJson = (s) => { try { return JSON.parse(s) } catch { return null } }
@@ -184,7 +371,7 @@ async function testServer(server, timeoutMs = 15000) {
184
371
  headers,
185
372
  body: JSON.stringify({
186
373
  jsonrpc: '2.0', id: 1, method: 'initialize',
187
- params: { protocolVersion: '2025-06-18', capabilities: {}, clientInfo: { name: 'dsh-remote-mcp-manager', version: '1' } },
374
+ params: { protocolVersion: '2025-06-18', capabilities: {}, clientInfo: { name: 'dsh-remote-mcp-manager', version: '2' } },
188
375
  }),
189
376
  signal: controller.signal,
190
377
  })
@@ -216,9 +403,166 @@ async function testServer(server, timeoutMs = 15000) {
216
403
  }
217
404
  }
218
405
 
219
- export function apply(ctx) {
406
+ // —— 展平表单回传值(宽容几种形状,键名去掉 data./values./form. 前缀)——
407
+ function flattenValue(value) {
408
+ const flat = {}
409
+ const walk = (v, prefix, depth) => {
410
+ if (depth > 6 || v == null) return
411
+ if (Array.isArray(v)) {
412
+ v.forEach((item, i) => walk(item, prefix ? `${prefix}.${i}` : String(i), depth + 1))
413
+ return
414
+ }
415
+ if (typeof v === 'object') {
416
+ for (const [k, val] of Object.entries(v)) walk(val, prefix ? `${prefix}.${k}` : k, depth + 1)
417
+ return
418
+ }
419
+ if (prefix) flat[prefix] = v
420
+ }
421
+ walk(value, '', 0)
422
+ const out = {}
423
+ for (const [k, v] of Object.entries(flat)) {
424
+ const key = String(k).replace(/^data\./, '').replace(/^(values?|fields?|form)\./, '')
425
+ out[key] = v
426
+ }
427
+ return out
428
+ }
429
+
430
+ function asBool(v, fallback) {
431
+ if (typeof v === 'boolean') return v
432
+ if (typeof v === 'string') {
433
+ if (/^(false|0|off|no)$/i.test(v)) return false
434
+ if (/^(true|1|on|yes)$/i.test(v)) return true
435
+ }
436
+ return fallback
437
+ }
438
+
439
+ export function apply(ctx, config) {
220
440
  const patchFile = findPatchFile(ctx)
221
441
  const logger = ctx.logger
442
+ // volatile 字段在运行时是 Ref,用 .get() 取值
443
+ const cfgVal = (v, fb) => {
444
+ try {
445
+ const x = v && typeof v.get === 'function' ? v.get() : v
446
+ return x === undefined || x === null ? fb : x
447
+ } catch { return fb }
448
+ }
449
+ const autoProbe = cfgVal(config?.autoProbe, true) !== false
450
+ const probeTimeoutMs = Math.max(1000, Math.min(30000, Number(cfgVal(config?.probeTimeoutMs, 8000)) || 8000))
451
+
452
+ // 服务来源:App 设置页的 dict 字段是真源(谁在 App 里改就以它为准);
453
+ // 独立 JSON 是同步副本 + 超出表单能力时的补充。
454
+ const fromDict = dictFromConfig(cfgVal, config)
455
+ const stored = loadStore(logger)
456
+ let cfgServers
457
+ if (fromDict.length) {
458
+ cfgServers = fromDict
459
+ saveStore(cfgServers, logger)
460
+ } else if (Array.isArray(stored) && stored.length) {
461
+ cfgServers = stored
462
+ syncDictToPatch(patchFile, cfgServers, logger)
463
+ } else {
464
+ cfgServers = DEFAULT_SERVERS.map(normServer).filter(Boolean)
465
+ saveStore(cfgServers, logger)
466
+ syncDictToPatch(patchFile, cfgServers, logger)
467
+ }
468
+ // 新增位:填了名字就追加一个完整服务槽位(其余字段全默认)
469
+ const newName = String((cfgVal(config?.newServer, {}) || {}).name || '').trim()
470
+ if (newName && /^[A-Za-z0-9_-]{1,32}$/.test(newName)) {
471
+ setImmediate(() => {
472
+ try {
473
+ const text = fs.readFileSync(patchFile, 'utf8')
474
+ const at = text.indexOf('- id: dsh-remote-mcp-manager')
475
+ if (at < 0) return
476
+ const nxt = text.indexOf('\n- ', at + 1)
477
+ const end = nxt < 0 ? text.length : nxt
478
+ const arr = yaml.load(text.slice(at, end))
479
+ const parsed = (Array.isArray(arr) ? arr[0] : arr) || {}
480
+ const cfg = { ...(parsed.config || {}) }
481
+ const taken = Object.keys(cfg).some(function (k) {
482
+ return /^server\d+$/.test(k) && cfg[k] && String(cfg[k].name || '').trim() === newName
483
+ })
484
+ if (!taken) {
485
+ let slot = 1
486
+ while (cfg['server' + slot] !== undefined) slot++
487
+ cfg['server' + slot] = {
488
+ name: newName, on: true, autoProbe: true, url: '',
489
+ protocol: 'streamable-http', token: '', desc: '', timeoutMs: 15000, remove: false,
490
+ }
491
+ }
492
+ cfg.newServer = { name: '' }
493
+ const dumped = yaml.dump([{ id: parsed.id, name: parsed.name, config: cfg }], { lineWidth: 1000, noRefs: true })
494
+ const tmp = patchFile + '.tmp-' + process.pid
495
+ fs.writeFileSync(tmp, text.slice(0, at) + dumped + text.slice(end), 'utf8')
496
+ fs.renameSync(tmp, patchFile)
497
+ logger?.info?.('[mcp-manager] 新增服务槽位: ' + newName)
498
+ } catch (err) {
499
+ logger?.warn?.('[mcp-manager] 新增槽位失败: ' + (err.message || err))
500
+ }
501
+ })
502
+ }
503
+
504
+ // 名字空、地址有的槽位:向服务端要真名并写回(写回会触发一次重载,之后就稳定)
505
+ ;(async () => {
506
+ try {
507
+ for (const i of SLOT_INDEXES) {
508
+ const o = cfgVal(config?.['server' + i], {}) || {}
509
+ if (String(o.name || '').trim()) continue
510
+ if (!String(o.url || '').trim()) continue
511
+ const real = await probeServerName(o.url, o.token, probeTimeoutMs)
512
+ if (real) writeSlotName(patchFile, i, real, logger)
513
+ }
514
+ } catch { /* 探测失败不影响启动 */ }
515
+ })()
516
+
517
+ // 打开「删除这个服务」的槽位:清空该槽位并重载
518
+ const pendingRemove = []
519
+ for (const i of SLOT_INDEXES) {
520
+ const o = cfgVal(config?.['server' + i], {}) || {}
521
+ if (o.remove === true) pendingRemove.push(i)
522
+ }
523
+ if (pendingRemove.length) {
524
+ setImmediate(() => {
525
+ try {
526
+ const text = fs.readFileSync(patchFile, 'utf8')
527
+ const at = text.indexOf('- id: dsh-remote-mcp-manager')
528
+ if (at < 0) return
529
+ const nxt = text.indexOf('\n- ', at + 1)
530
+ const end = nxt < 0 ? text.length : nxt
531
+ const arr = yaml.load(text.slice(at, end))
532
+ const parsed = (Array.isArray(arr) ? arr[0] : arr) || {}
533
+ const cfg = { ...(parsed.config || {}) }
534
+ for (const i of pendingRemove) {
535
+ cfg['server' + i] = {
536
+ name: '', on: true, autoProbe: true, url: '',
537
+ protocol: 'streamable-http', token: '', desc: '', timeoutMs: 15000, remove: false,
538
+ }
539
+ }
540
+ const dumped = yaml.dump([{ id: parsed.id, name: parsed.name, config: cfg }], { lineWidth: 1000, noRefs: true })
541
+ const tmp = patchFile + '.tmp-' + process.pid
542
+ fs.writeFileSync(tmp, text.slice(0, at) + dumped + text.slice(end), 'utf8')
543
+ fs.renameSync(tmp, patchFile)
544
+ logger?.info?.('[mcp-manager] 已删除槽位: ' + pendingRemove.join(','))
545
+ } catch (err) {
546
+ logger?.warn?.('[mcp-manager] 删除槽位失败: ' + (err.message || err))
547
+ }
548
+ })
549
+ }
550
+
551
+ if (cfgServers.length) {
552
+ for (const item of cfgServers) {
553
+ if (!item || !item.serverName || item.enabled === false) continue
554
+ const token = String(item.token || '').trim()
555
+ const headers = token ? { Authorization: token.startsWith('Bearer ') ? token : `Bearer ${token}` } : {}
556
+ const cfg = item.transport === 'stdio'
557
+ ? { transport: 'stdio', serverName: item.serverName, command: item.command || '', args: [], env: {}, cwd: '' }
558
+ : { transport: 'streamable-http', serverName: item.serverName, url: item.url || '', headers }
559
+ try { ctx.plugin(McpClient, cfg) } catch (err) {
560
+ logger?.warn?.('[mcp-manager] 挂载 ' + item.serverName + ' 失败: ' + (err?.message || err))
561
+ }
562
+ }
563
+ }
564
+
565
+ // 编辑统一在 设置 → MCP管理(App 按对象槽位展开成完整表单)+ 插件自带网页设置页
222
566
 
223
567
  // —— Web 端:设置页路由 ——
224
568
  ctx.inject(['webServer'], (ctx) => {
@@ -237,53 +581,38 @@ export function apply(ctx) {
237
581
 
238
582
  if (method === 'GET') {
239
583
  res.writeHead(200, { 'content-type': 'application/json' })
240
- res.end(JSON.stringify({ servers: readServers(patchFile, logger) }))
584
+ res.end(JSON.stringify({ servers: cfgServers, readonly: false }))
241
585
  return
242
586
  }
243
587
 
244
588
  if (method === 'POST') {
245
- // 同源校验:跨站请求必带 Origin,比对 host 防止 CSRF
246
- const origin = req.headers.origin
247
- if (origin) {
248
- try { if (new URL(origin).host !== req.headers.host) { res.writeHead(403); res.end('forbidden'); return } }
249
- catch { res.writeHead(403); res.end('forbidden'); return }
250
- }
251
- const action = url.searchParams.get('action') || 'save'
252
- if (action === 'test') {
253
- const body = await readBody(req)
254
- let server = null
255
- try { server = JSON.parse(body || '{}') } catch { /* 忽略 */ }
256
- const r = await testServer(server)
257
- res.writeHead(r.ok ? 200 : 502, { 'content-type': 'application/json' })
258
- res.end(JSON.stringify(r))
259
- return
260
- }
589
+ // 网页设置页保存:写回 profile patch 里本插件条目的 config.servers
261
590
  const body = await readBody(req)
262
- let data
263
- try { data = JSON.parse(body || '{}') } catch {
264
- res.writeHead(400); res.end('invalid JSON'); return
591
+ let data = {}
592
+ try { data = JSON.parse(body || '{}') } catch { data = {} }
593
+ const servers = Array.isArray(data.servers) ? data.servers : null
594
+ if (!servers) {
595
+ res.writeHead(400, { 'content-type': 'application/json' })
596
+ res.end(JSON.stringify({ ok: false, error: 'servers 必须是数组' }))
597
+ return
265
598
  }
266
- const servers = Array.isArray(data.servers) ? data.servers : []
267
- const names = []
268
- for (const s of servers) {
269
- if (!s || typeof s.serverName !== 'string' || !s.serverName) {
270
- res.writeHead(400); res.end('invalid serverName'); return
271
- }
272
- if (!/^[A-Za-z0-9_-]{1,32}$/.test(s.serverName)) {
273
- res.writeHead(400); res.end('serverName 需匹配 [A-Za-z0-9_-]{1,32}'); return
274
- }
275
- if (names.includes(s.serverName)) {
276
- res.writeHead(400); res.end('serverName 重复'); return
277
- }
278
- names.push(s.serverName)
599
+ const badName = servers.find((x) => !x || !/^[A-Za-z0-9_-]{1,32}$/.test(String(x.serverName || '')))
600
+ if (badName) {
601
+ res.writeHead(400, { 'content-type': 'application/json' })
602
+ res.end(JSON.stringify({ ok: false, error: '服务名只能字母数字下划线短横' }))
603
+ return
279
604
  }
280
605
  try {
281
- writeServers(patchFile, servers, logger)
606
+ const clean = servers.map(normServer).filter(Boolean)
607
+ if (!saveStore(clean, logger)) throw Error('写独立 JSON 失败')
608
+ syncDictToPatch(patchFile, clean, logger)
282
609
  } catch (err) {
283
- res.writeHead(500); res.end('写入失败: ' + (err.message || err)); return
610
+ res.writeHead(500, { 'content-type': 'application/json' })
611
+ res.end(JSON.stringify({ ok: false, error: '写入失败: ' + (err.message || err) }))
612
+ return
284
613
  }
285
614
  res.writeHead(200, { 'content-type': 'application/json' })
286
- res.end(JSON.stringify({ ok: true }))
615
+ res.end(JSON.stringify({ ok: true, note: '已写入服务清单,重启引擎后生效' }))
287
616
  return
288
617
  }
289
618
 
@@ -296,66 +625,7 @@ export function apply(ctx) {
296
625
  })
297
626
  })
298
627
 
299
- // —— 手机端:只读信息面板 ——
300
- ctx.inject(['dshGo'], (ctx) => {
301
- const toolCache = new Map()
302
- const TOOL_TTL = 60_000
303
-
304
- const probe = async (s) => {
305
- const hit = toolCache.get(s.serverName)
306
- if (hit && Date.now() - hit.at < TOOL_TTL) return hit
307
- let r = { tools: -1, ms: 0, ok: false }
308
- try { r = await testServer(s, 8000) } catch { r = { tools: -1, ms: 0, ok: false } }
309
- const out = { tools: r.tools ?? -1, ms: r.ms ?? 0, ok: !!r.ok, at: Date.now() }
310
- toolCache.set(s.serverName, out)
311
- return out
312
- }
313
-
314
- ctx.dshGo.panel('mcp-manager', {
315
- view: (scope, caps) => ({
316
- v: 2,
317
- type: 'stack',
318
- title: pick(caps, L.title),
319
- children: [
320
- { type: 'callout', tone: 'info', text: { $: 'data.summary' } },
321
- { type: 'list', items: { $: 'data.items' } },
322
- { type: 'text', text: { $: 'data.hint' }, tone: 'muted' },
323
- ],
324
- }),
325
- data: (scope, emit, caps) => {
326
- const render = () => {
327
- const servers = readServers(patchFile, logger)
328
- const enabled = servers.length
329
- const items = servers.map(s => {
330
- const c = toolCache.get(s.serverName)
331
- let trailing
332
- if (!c) trailing = pick(caps, L.probing)
333
- else if (c.ok) trailing = L.ok(c.ms)
334
- else trailing = L.bad(c.ms)
335
- return {
336
- title: s.serverName,
337
- trailing,
338
- tone: c && c.ok ? 'good' : 'bad',
339
- }
340
- })
341
- emit({
342
- summary: servers.length
343
- ? pick(caps, L.summary)(zh(caps), enabled, servers.length)
344
- : pick(caps, L.empty),
345
- hint: pick(caps, L.hint),
346
- items,
347
- })
348
- }
349
- render()
350
- // 只在面板打开时测一轮,避免后台持续发请求
351
- void (async () => {
352
- for (const s of readServers(patchFile, logger)) await probe(s)
353
- render()
354
- })()
355
- return () => {}
356
- },
357
- })
358
- })
628
+ // 手机端不再注册面板:编辑统一在 App 设置页(原生 schema 表单)
359
629
  }
360
630
 
361
631
  function readBody(req) {
package/package.json CHANGED
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "name": "dsh-remote-mcp-manager",
3
- "version": "0.4.1",
4
- "icon": "icon.png",
5
- "description": "DSH 多端 MCP 管理器:手机原生面板 + Web 设置页,配置写在 cordis.patch.yml,保存后由 HMR 自动应用。",
3
+ "version": "0.5.0",
4
+ "description": "DSH 的 MCP 服务管理器:在 App 设置页直接增删改 MCP 服务,点开即完整表单,保存自动生效;附网页版管理页。",
6
5
  "license": "MIT",
7
6
  "keywords": [
8
7
  "dsh",
@@ -27,15 +26,11 @@
27
26
  "files": [
28
27
  "lib",
29
28
  "locale",
29
+ "README.md",
30
30
  "cordis.patch.yml",
31
31
  "icon.png",
32
- "icon@2x.png",
33
- "README.md"
32
+ "icon@2x.png"
34
33
  ],
35
- "publishConfig": {
36
- "registry": "https://registry.npmjs.org/",
37
- "access": "public"
38
- },
39
34
  "dsh": {
40
35
  "bundle": {
41
36
  "patch": "./cordis.patch.yml"
@@ -43,6 +38,8 @@
43
38
  "client": {
44
39
  "inject": [
45
40
  "@deepseek-ai/dsh-client-connection",
41
+ "@deepseek-ai/dsh-client-runtime",
42
+ "@deepseek-ai/dsh-client-ui-slots",
46
43
  "@deepseek-ai/dsh-client-locale",
47
44
  "@deepseek-ai/dsh-client-ui-settings",
48
45
  "@deepseek-ai/dsh-client-ui-sidebar-right"
@@ -62,22 +59,6 @@
62
59
  "title": {
63
60
  "zh": "MCP 管理",
64
61
  "en": "MCP Manager"
65
- },
66
- "contributes": {
67
- "panels": [
68
- {
69
- "id": "mcp-manager",
70
- "title": {
71
- "zh": "MCP 管理",
72
- "en": "MCP Manager"
73
- },
74
- "icon": "plugin",
75
- "placement": [
76
- "session.tab",
77
- "features"
78
- ]
79
- }
80
- ]
81
62
  }
82
63
  },
83
64
  "repository": {
@@ -87,4 +68,4 @@
87
68
  "dependencies": {
88
69
  "js-yaml": "^5.5.0"
89
70
  }
90
- }
71
+ }