@lqrui/dsh-mcp 0.0.0-stage → 2.1.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/LICENSE +21 -0
- package/README.md +26 -2
- package/client.js +1075 -0
- package/cordis.patch.yml +7 -0
- package/icon.svg +13 -0
- package/index.js +6 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +51 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 lqrui
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
-
#
|
|
1
|
+
# MCP servers
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Open **MCP servers** in the left sidebar to manage the Host's MCP server fleet from one page: the servers configured for this profile and the servers installed plugins register, each with its live connection status.
|
|
4
|
+
|
|
5
|
+
## What the page does
|
|
6
|
+
|
|
7
|
+
- **List** every managed server with its status: connected (with the number of live tools), connecting, reconnecting (with the next retry time), waiting for credentials, disabled, or failed (with the Host's diagnostic text).
|
|
8
|
+
- **Add server** opens a modal dialog with a name (the `mcp__<name>__*` tool namespace), a transport, and its connection fields:
|
|
9
|
+
- *Streamable HTTP*: endpoint URL plus optional `Name: Value` request headers.
|
|
10
|
+
- *stdio*: command, one argument per line, and optional `KEY=VALUE` environment variables.
|
|
11
|
+
- **Edit** opens the same dialog for one entry. The manager rebuilds only that server; other servers keep running.
|
|
12
|
+
- **Enable / Disable** keeps the entry but unmounts or mounts its instance.
|
|
13
|
+
- **Restart** replaces the instance and resets its reconnect budget — use it after a server exhausted automatic reconnection.
|
|
14
|
+
- **Tools** opens a dialog that probes the entry without touching the live instance and lists every tool name it advertises, with the server identity, tool count, probe duration, and any truncation or cleanup warning.
|
|
15
|
+
- **Remove** deletes a server added in this profile. An entry that comes from the installed plugin composition cannot be deleted here; the page disables it instead, which leaves the composition untouched.
|
|
16
|
+
|
|
17
|
+
Both dialogs close on Cancel/Close or a backdrop click; Escape closes them too and focus returns to the control that opened them.
|
|
18
|
+
|
|
19
|
+
The page edits this profile's own settings layer, which overrides the composition for a server of the same name. A server a deployment or another bundle pins in the composition is listed but cannot be removed here; disable it instead, which leaves the composition untouched. Any credential such as an `Authorization` header is stored in the layer that defines the entry, so replace it there when it expires.
|
|
20
|
+
|
|
21
|
+
## Behaviour and limits
|
|
22
|
+
|
|
23
|
+
- Changes are written to the profile's settings document through the shared Settings form and apply immediately; the tools appear (or disappear) for every agent in this profile, not just the current session.
|
|
24
|
+
- A changed entry is disposed and remounted, so its tools disappear from the model's tool set until the new instance finishes its initial tool discovery.
|
|
25
|
+
- Server names must match `[A-Za-z0-9_-]{1,32}`; the name is the tool namespace and cannot be renamed in place — add a new server and remove the old one.
|
|
26
|
+
- The page manages the global plane only. Servers a deployment pins in the composition or an agent preset contributes are not listed, and a name collision with one of them is refused at the write.
|
|
27
|
+
- There is no OAuth sign-in flow: a server that answers with an authorization challenge shows as an ordinary connection failure.
|
package/client.js
ADDED
|
@@ -0,0 +1,1075 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP servers panel — browser half of @lqrui/dsh-mcp.
|
|
3
|
+
*
|
|
4
|
+
* Contributes one global sidebar entry ("MCP servers") and the main panel it
|
|
5
|
+
* opens. The page lists the Host mcp-manager fleet (live status over the
|
|
6
|
+
* `mcpManager/watch` Remote stream) beside the profile's configured entries
|
|
7
|
+
* (read and written through the shared Settings form of the `mcp-manager`
|
|
8
|
+
* entry). Adding, editing, enabling, disabling, removing, restarting, and
|
|
9
|
+
* probing all go through the existing Host services; this module owns no MCP
|
|
10
|
+
* transport and no settings file of its own.
|
|
11
|
+
*/
|
|
12
|
+
window.__ModuleLoader__.load({
|
|
13
|
+
id: '@lqrui/dsh-mcp',
|
|
14
|
+
factory(require) {
|
|
15
|
+
const React = require('react')
|
|
16
|
+
const h = React.createElement
|
|
17
|
+
|
|
18
|
+
/** Client locale namespace of this page. */
|
|
19
|
+
const NS = 'mcp.hub'
|
|
20
|
+
/** Shared id of the sidebar entry and the main panel it opens. */
|
|
21
|
+
const PANEL_ID = 'mcp-servers'
|
|
22
|
+
/** Settings namespace owned by the `mcp-manager` Loader entry. */
|
|
23
|
+
const SETTINGS_NAMESPACE = 'mcp-manager'
|
|
24
|
+
/** Same shape the Host accepts for `servers.<name>` keys. */
|
|
25
|
+
const NAME_PATTERN = /^[A-Za-z0-9_-]{1,32}$/
|
|
26
|
+
|
|
27
|
+
const en = {
|
|
28
|
+
panel: 'MCP servers',
|
|
29
|
+
title: 'MCP servers',
|
|
30
|
+
subtitle: 'Configured servers publish their tools to every agent as mcp__<name>__*. Changes apply immediately.',
|
|
31
|
+
refresh: 'Refresh',
|
|
32
|
+
add: 'Add server',
|
|
33
|
+
addTitle: 'Add an MCP server',
|
|
34
|
+
edit: 'Edit',
|
|
35
|
+
editTitle: 'Edit server',
|
|
36
|
+
name: 'Name',
|
|
37
|
+
nameHint: 'Letters, digits, hyphen, or underscore (max 32). Also the tool namespace.',
|
|
38
|
+
nameLockedHint: 'The name is fixed after creation; add a new server to use another tool namespace.',
|
|
39
|
+
transport: 'Transport',
|
|
40
|
+
transportHttp: 'Streamable HTTP',
|
|
41
|
+
transportStdio: 'stdio (local process)',
|
|
42
|
+
url: 'Endpoint URL',
|
|
43
|
+
urlHint: 'For example https://example.com/mcp',
|
|
44
|
+
headers: 'Request headers',
|
|
45
|
+
headersHint: 'One “Name: Value” per line. Leave empty when the server needs none.',
|
|
46
|
+
command: 'Command',
|
|
47
|
+
commandHint: 'Executable to spawn, for example npx.',
|
|
48
|
+
args: 'Arguments',
|
|
49
|
+
argsHint: 'One argument per line.',
|
|
50
|
+
env: 'Environment variables',
|
|
51
|
+
envHint: 'One KEY=VALUE per line.',
|
|
52
|
+
enabled: 'Enabled',
|
|
53
|
+
save: 'Save',
|
|
54
|
+
saved: 'Saved. The Host applies the change immediately.',
|
|
55
|
+
saving: 'Saving…',
|
|
56
|
+
cancel: 'Cancel',
|
|
57
|
+
restart: 'Restart',
|
|
58
|
+
restarting: 'Restarting…',
|
|
59
|
+
probe: 'Probe',
|
|
60
|
+
probing: 'Probing…',
|
|
61
|
+
disable: 'Disable',
|
|
62
|
+
enable: 'Enable',
|
|
63
|
+
remove: 'Remove',
|
|
64
|
+
restartOk: 'Restart requested.',
|
|
65
|
+
restartFailed: 'The Host refused the restart.',
|
|
66
|
+
probeOk: 'Probe succeeded',
|
|
67
|
+
probeFailed: 'Probe failed',
|
|
68
|
+
probeTools: 'tools',
|
|
69
|
+
probeTruncated: '(list truncated)',
|
|
70
|
+
probeCleanup: 'cleanup warning',
|
|
71
|
+
toolsButton: 'Tools',
|
|
72
|
+
toolsTitle: 'MCP tools',
|
|
73
|
+
toolsHint: 'Opening this list probes the server over a separate connection; the live instance is not touched.',
|
|
74
|
+
toolsConfig: 'Configuration',
|
|
75
|
+
toolsServer: 'MCP server',
|
|
76
|
+
toolsDuration: 'took',
|
|
77
|
+
toolsStage: 'stage',
|
|
78
|
+
toolsEmpty: 'The server advertised no tools.',
|
|
79
|
+
toolsRetry: 'Probe again',
|
|
80
|
+
toolsClose: 'Close',
|
|
81
|
+
toolsUnavailable: 'The MCP manager did not answer.',
|
|
82
|
+
saveFailed: 'The Host refused the change. Check the entry, then reload the page.',
|
|
83
|
+
saveConflict: 'The configuration changed in another surface. Review it and try again.',
|
|
84
|
+
saveTransport: 'Could not reach the Host configuration service.',
|
|
85
|
+
removed: 'Removed from the profile.',
|
|
86
|
+
removedInherited: 'This server comes from the installed plugin composition. It was disabled instead of removed.',
|
|
87
|
+
enabledNotice: 'Server enabled.',
|
|
88
|
+
disabledNotice: 'Server disabled.',
|
|
89
|
+
invalidName: 'Enter a name of 1–32 letters, digits, hyphens, or underscores.',
|
|
90
|
+
duplicateName: 'A server with this name already exists.',
|
|
91
|
+
urlRequired: 'This transport needs an endpoint URL.',
|
|
92
|
+
commandRequired: 'This transport needs a command.',
|
|
93
|
+
headersInvalid: 'A header line must contain “Name: Value”.',
|
|
94
|
+
envInvalid: 'An environment line must contain “KEY=VALUE”.',
|
|
95
|
+
settingsUnavailable: 'This deployment does not expose the mcp-manager settings entry, so servers cannot be edited here.',
|
|
96
|
+
settingsLoading: 'Loading configuration…',
|
|
97
|
+
runtimeLoading: 'Connecting to the Host…',
|
|
98
|
+
runtimeError: 'The Host status stream ended.',
|
|
99
|
+
listEmpty: 'No MCP servers yet. Add one, or install a plugin that registers its own server.',
|
|
100
|
+
sourceInherited: 'Composition',
|
|
101
|
+
sourceCustom: 'Profile',
|
|
102
|
+
sourcePlugin: 'Plugin',
|
|
103
|
+
statusConnected: 'Connected',
|
|
104
|
+
statusConnecting: 'Connecting',
|
|
105
|
+
statusReconnecting: 'Reconnecting',
|
|
106
|
+
statusDisabled: 'Disabled',
|
|
107
|
+
statusWaitingCredentials: 'Waiting for credentials',
|
|
108
|
+
statusFailed: 'Failed',
|
|
109
|
+
statusClosed: 'Closed',
|
|
110
|
+
statusUnknown: 'Unknown',
|
|
111
|
+
attempt: 'attempt',
|
|
112
|
+
retryAt: 'retry',
|
|
113
|
+
tools: 'tools',
|
|
114
|
+
reasonGaveUp: 'gave up reconnecting',
|
|
115
|
+
reasonReconnectDisabled: 'reconnect disabled',
|
|
116
|
+
reasonUnclosed: 'previous connection not closed',
|
|
117
|
+
reasonLoad: 'failed to load',
|
|
118
|
+
reasonCleanup: 'cleanup failed',
|
|
119
|
+
noToolsLabel: '—',
|
|
120
|
+
editorNote: 'Saved through the profile settings; the manager rebuilds only the edited server.',
|
|
121
|
+
close: 'Close editor',
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const zh = {
|
|
125
|
+
panel: 'MCP 服务器',
|
|
126
|
+
title: 'MCP 服务器',
|
|
127
|
+
subtitle: '这里配置的服务器会把工具以 mcp__<名称>__* 的形式提供给所有智能体,改动立即生效。',
|
|
128
|
+
refresh: '刷新',
|
|
129
|
+
add: '添加服务器',
|
|
130
|
+
addTitle: '添加 MCP 服务器',
|
|
131
|
+
edit: '编辑',
|
|
132
|
+
editTitle: '编辑服务器',
|
|
133
|
+
name: '名称',
|
|
134
|
+
nameHint: '字母、数字、连字符或下划线(最多 32 个字符),同时作为工具命名空间。',
|
|
135
|
+
nameLockedHint: '创建后名称不可修改;如需其他工具命名空间,请新增一个服务器。',
|
|
136
|
+
transport: '传输方式',
|
|
137
|
+
transportHttp: 'Streamable HTTP',
|
|
138
|
+
transportStdio: 'stdio(本地进程)',
|
|
139
|
+
url: '服务地址',
|
|
140
|
+
urlHint: '例如 https://example.com/mcp',
|
|
141
|
+
headers: '请求头',
|
|
142
|
+
headersHint: '每行一个“名称: 值”。不需要时留空。',
|
|
143
|
+
command: '启动命令',
|
|
144
|
+
commandHint: '要启动的可执行文件,例如 npx。',
|
|
145
|
+
args: '参数',
|
|
146
|
+
argsHint: '每行一个参数。',
|
|
147
|
+
env: '环境变量',
|
|
148
|
+
envHint: '每行一个 KEY=VALUE。',
|
|
149
|
+
enabled: '启用',
|
|
150
|
+
save: '保存',
|
|
151
|
+
saved: '已保存,宿主已立即应用该改动。',
|
|
152
|
+
saving: '保存中…',
|
|
153
|
+
cancel: '取消',
|
|
154
|
+
restart: '重启',
|
|
155
|
+
restarting: '重启中…',
|
|
156
|
+
probe: '探测',
|
|
157
|
+
probing: '探测中…',
|
|
158
|
+
disable: '停用',
|
|
159
|
+
enable: '启用',
|
|
160
|
+
remove: '删除',
|
|
161
|
+
restartOk: '已请求重启。',
|
|
162
|
+
restartFailed: '宿主拒绝了这次重启。',
|
|
163
|
+
probeOk: '探测成功',
|
|
164
|
+
probeFailed: '探测失败',
|
|
165
|
+
probeTools: '个工具',
|
|
166
|
+
probeTruncated: '(列表已截断)',
|
|
167
|
+
probeCleanup: '清理告警',
|
|
168
|
+
toolsButton: '工具',
|
|
169
|
+
toolsTitle: 'MCP 工具',
|
|
170
|
+
toolsHint: '打开此列表会单独连接服务器探测一次,不会影响正在运行的实例。',
|
|
171
|
+
toolsConfig: '配置',
|
|
172
|
+
toolsServer: 'MCP 服务器',
|
|
173
|
+
toolsDuration: '耗时',
|
|
174
|
+
toolsStage: '阶段',
|
|
175
|
+
toolsEmpty: '该服务器没有提供工具。',
|
|
176
|
+
toolsRetry: '重新探测',
|
|
177
|
+
toolsClose: '关闭',
|
|
178
|
+
toolsUnavailable: 'MCP 管理器没有响应。',
|
|
179
|
+
saveFailed: '宿主没有接受这次修改。请检查条目后刷新页面重试。',
|
|
180
|
+
saveConflict: '配置已在其他界面被改动,请核对后重试。',
|
|
181
|
+
saveTransport: '无法连接宿主配置服务。',
|
|
182
|
+
removed: '已从配置中删除。',
|
|
183
|
+
removedInherited: '该服务器来自已安装插件的组合层,已改为停用而不是删除。',
|
|
184
|
+
enabledNotice: '已启用该服务器。',
|
|
185
|
+
disabledNotice: '已停用该服务器。',
|
|
186
|
+
invalidName: '请输入 1–32 位的字母、数字、连字符或下划线。',
|
|
187
|
+
duplicateName: '已存在同名服务器。',
|
|
188
|
+
urlRequired: '该传输方式需要填写服务地址。',
|
|
189
|
+
commandRequired: '该传输方式需要填写启动命令。',
|
|
190
|
+
headersInvalid: '请求头每行必须是“名称: 值”。',
|
|
191
|
+
envInvalid: '环境变量每行必须是“KEY=VALUE”。',
|
|
192
|
+
settingsUnavailable: '当前部署没有暴露 mcp-manager 设置项,无法在此编辑服务器。',
|
|
193
|
+
settingsLoading: '正在加载配置…',
|
|
194
|
+
runtimeLoading: '正在连接宿主…',
|
|
195
|
+
runtimeError: '宿主状态流已结束。',
|
|
196
|
+
listEmpty: '还没有 MCP 服务器。可以添加一个,或安装自带服务器注册的插件。',
|
|
197
|
+
sourceInherited: '组合配置',
|
|
198
|
+
sourceCustom: '个人配置',
|
|
199
|
+
sourcePlugin: '插件注册',
|
|
200
|
+
statusConnected: '已连接',
|
|
201
|
+
statusConnecting: '连接中',
|
|
202
|
+
statusReconnecting: '重连中',
|
|
203
|
+
statusDisabled: '已停用',
|
|
204
|
+
statusWaitingCredentials: '等待凭据',
|
|
205
|
+
statusFailed: '失败',
|
|
206
|
+
statusClosed: '已关闭',
|
|
207
|
+
statusUnknown: '未知',
|
|
208
|
+
attempt: '第',
|
|
209
|
+
retryAt: '下次重试',
|
|
210
|
+
tools: '个工具',
|
|
211
|
+
reasonGaveUp: '重连次数已用尽',
|
|
212
|
+
reasonReconnectDisabled: '已关闭自动重连',
|
|
213
|
+
reasonUnclosed: '上一个连接未完全关闭',
|
|
214
|
+
reasonLoad: '加载失败',
|
|
215
|
+
reasonCleanup: '清理失败',
|
|
216
|
+
noToolsLabel: '—',
|
|
217
|
+
editorNote: '通过 profile 设置保存,管理器只重建被修改的这个服务器。',
|
|
218
|
+
close: '关闭编辑',
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// ── small token-based style helpers ───────────────────────────────────────
|
|
222
|
+
|
|
223
|
+
const color = {
|
|
224
|
+
primary: 'var(--dsw-alias-label-primary)',
|
|
225
|
+
secondary: 'var(--dsw-alias-label-secondary)',
|
|
226
|
+
border: 'var(--dsw-alias-border-l1)',
|
|
227
|
+
borderStrong: 'var(--dsw-alias-border-l2)',
|
|
228
|
+
layer1: 'var(--dsw-alias-bg-layer-1)',
|
|
229
|
+
layer2: 'var(--dsw-alias-bg-layer-2)',
|
|
230
|
+
brand: 'var(--dsw-alias-brand-primary)',
|
|
231
|
+
success: 'var(--dsw-alias-state-success-primary)',
|
|
232
|
+
warn: 'var(--dsw-alias-state-warn-primary)',
|
|
233
|
+
error: 'var(--dsw-alias-state-error-primary)',
|
|
234
|
+
idle: 'var(--dsw-alias-state-idle-primary)',
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
const button = (kind) => ({
|
|
238
|
+
appearance: 'none',
|
|
239
|
+
font: 'inherit',
|
|
240
|
+
fontSize: '13px',
|
|
241
|
+
lineHeight: '20px',
|
|
242
|
+
height: '32px',
|
|
243
|
+
padding: '0 12px',
|
|
244
|
+
borderRadius: '16px',
|
|
245
|
+
cursor: 'pointer',
|
|
246
|
+
border: kind === 'primary' ? `1px solid ${color.brand}` : `1px solid ${color.border}`,
|
|
247
|
+
background: 'transparent',
|
|
248
|
+
color: kind === 'primary' ? color.brand : color.primary,
|
|
249
|
+
opacity: 1,
|
|
250
|
+
})
|
|
251
|
+
|
|
252
|
+
/** Page-local interaction states on top of the inline, token-based styles. */
|
|
253
|
+
const PAGE_CLASS = 'dsh-mcp-page'
|
|
254
|
+
const pageStyles = [
|
|
255
|
+
`.${PAGE_CLASS} button:disabled { opacity: .55; cursor: default; }`,
|
|
256
|
+
`.${PAGE_CLASS} button:not(:disabled):hover { filter: brightness(.96); }`,
|
|
257
|
+
`.${PAGE_CLASS} button:focus-visible, .${PAGE_CLASS} input:focus-visible,`
|
|
258
|
+
+ ` .${PAGE_CLASS} select:focus-visible, .${PAGE_CLASS} textarea:focus-visible`
|
|
259
|
+
+ ' { outline: 2px solid var(--dsw-alias-brand-primary); outline-offset: 1px; }',
|
|
260
|
+
].join('\n')
|
|
261
|
+
|
|
262
|
+
const iconButton = {
|
|
263
|
+
appearance: 'none',
|
|
264
|
+
font: 'inherit',
|
|
265
|
+
fontSize: '12px',
|
|
266
|
+
lineHeight: '20px',
|
|
267
|
+
height: '28px',
|
|
268
|
+
padding: '0 10px',
|
|
269
|
+
borderRadius: '14px',
|
|
270
|
+
cursor: 'pointer',
|
|
271
|
+
border: `1px solid ${color.border}`,
|
|
272
|
+
background: 'transparent',
|
|
273
|
+
color: color.primary,
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
const field = {
|
|
277
|
+
width: '100%',
|
|
278
|
+
boxSizing: 'border-box',
|
|
279
|
+
font: 'inherit',
|
|
280
|
+
fontSize: '14px',
|
|
281
|
+
lineHeight: '20px',
|
|
282
|
+
padding: '8px 10px',
|
|
283
|
+
borderRadius: '8px',
|
|
284
|
+
border: `1px solid ${color.borderStrong}`,
|
|
285
|
+
background: color.layer2,
|
|
286
|
+
color: color.primary,
|
|
287
|
+
outline: 'none',
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
const fieldLabel = { display: 'grid', gap: '6px', fontSize: '13px', color: color.primary }
|
|
291
|
+
const hintStyle = { margin: 0, fontSize: '12px', lineHeight: '18px', color: color.secondary }
|
|
292
|
+
|
|
293
|
+
const statusTone = (status) => {
|
|
294
|
+
if (status === undefined) return color.idle
|
|
295
|
+
switch (status.state) {
|
|
296
|
+
case 'connected': return color.success
|
|
297
|
+
case 'connecting':
|
|
298
|
+
case 'reconnecting': return color.warn
|
|
299
|
+
case 'waiting-credentials':
|
|
300
|
+
case 'disabled':
|
|
301
|
+
case 'closed': return color.idle
|
|
302
|
+
case 'failed': return color.error
|
|
303
|
+
default: return color.idle
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/** One-line status text for a runtime status union value. */
|
|
308
|
+
const statusText = (status, t) => {
|
|
309
|
+
if (status === undefined) return t('statusUnknown')
|
|
310
|
+
switch (status.state) {
|
|
311
|
+
case 'pending': return t('statusConnecting')
|
|
312
|
+
case 'connected': return `${t('statusConnected')} · ${String(status.toolCount)} ${t('tools')}`
|
|
313
|
+
case 'connecting': return `${t('statusConnecting')} (${String(status.attempt)})`
|
|
314
|
+
case 'reconnecting':
|
|
315
|
+
return `${t('statusReconnecting')} (${String(status.attempt)}/${String(status.maxAttempts)}, ${t('retryAt')} ${new Date(status.nextRetryAtMs).toLocaleTimeString()})`
|
|
316
|
+
case 'waiting-credentials': return t('statusWaitingCredentials')
|
|
317
|
+
case 'disabled': return t('statusDisabled')
|
|
318
|
+
case 'closed': return t('statusClosed')
|
|
319
|
+
case 'failed': {
|
|
320
|
+
if (status.reason === 'load') return `${t('statusFailed')}: ${t('reasonLoad')}`
|
|
321
|
+
if (status.reason === 'cleanup') return `${t('statusFailed')}: ${t('reasonCleanup')}`
|
|
322
|
+
if (status.reason === 'gave-up') return `${t('statusFailed')}: ${t('reasonGaveUp')}`
|
|
323
|
+
if (status.reason === 'reconnect-disabled') return `${t('statusFailed')}: ${t('reasonReconnectDisabled')}`
|
|
324
|
+
return `${t('statusFailed')}: ${t('reasonUnclosed')}`
|
|
325
|
+
}
|
|
326
|
+
default: return t('statusUnknown')
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/** Diagnostic text carried by a status value, when it has one. */
|
|
331
|
+
const statusDetail = (status) => {
|
|
332
|
+
if (status === undefined) return undefined
|
|
333
|
+
if (status.state === 'failed') return status.lastError ?? (status.result?.cleanupError)
|
|
334
|
+
if (status.state === 'reconnecting') return status.lastError
|
|
335
|
+
if (status.state === 'waiting-credentials') return status.lastError
|
|
336
|
+
if (status.state === 'closed') return status.result?.cleanupError
|
|
337
|
+
return undefined
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// ── stores ────────────────────────────────────────────────────────────────
|
|
341
|
+
|
|
342
|
+
function createStore(initial) {
|
|
343
|
+
let state = initial
|
|
344
|
+
const listeners = new Set()
|
|
345
|
+
return {
|
|
346
|
+
get: () => state,
|
|
347
|
+
set(next) {
|
|
348
|
+
state = { ...state, ...next }
|
|
349
|
+
for (const listener of [...listeners]) listener()
|
|
350
|
+
},
|
|
351
|
+
subscribe(listener) {
|
|
352
|
+
listeners.add(listener)
|
|
353
|
+
return () => { listeners.delete(listener) }
|
|
354
|
+
},
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
const useStore = (store) => {
|
|
359
|
+
const [state, setState] = React.useState(store.get())
|
|
360
|
+
React.useEffect(() => {
|
|
361
|
+
setState(store.get())
|
|
362
|
+
return store.subscribe(() => { setState(store.get()) })
|
|
363
|
+
}, [store])
|
|
364
|
+
return state
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
const messageOf = (error) => {
|
|
368
|
+
if (error === undefined || error === null) return ''
|
|
369
|
+
if (typeof error === 'string') return error
|
|
370
|
+
return error.message ?? String(error)
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/** Parse “Name: Value” lines into a header object; returns null on a malformed line. */
|
|
374
|
+
const parseHeaders = (text) => {
|
|
375
|
+
const out = {}
|
|
376
|
+
for (const raw of text.split('\n')) {
|
|
377
|
+
const line = raw.trim()
|
|
378
|
+
if (line === '') continue
|
|
379
|
+
const index = line.indexOf(':')
|
|
380
|
+
if (index <= 0) return null
|
|
381
|
+
const key = line.slice(0, index).trim()
|
|
382
|
+
const value = line.slice(index + 1).trim()
|
|
383
|
+
if (key === '') return null
|
|
384
|
+
out[key] = value
|
|
385
|
+
}
|
|
386
|
+
return out
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/** Parse KEY=VALUE lines into an env object; returns null on a malformed line. */
|
|
390
|
+
const parseEnv = (text) => {
|
|
391
|
+
const out = {}
|
|
392
|
+
for (const raw of text.split('\n')) {
|
|
393
|
+
const line = raw.trim()
|
|
394
|
+
if (line === '') continue
|
|
395
|
+
const index = line.indexOf('=')
|
|
396
|
+
if (index <= 0) return null
|
|
397
|
+
out[line.slice(0, index).trim()] = line.slice(index + 1)
|
|
398
|
+
}
|
|
399
|
+
return out
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
const headerLines = (headers) => Object.entries(headers ?? {}).map(([key, value]) => `${key}: ${value}`).join('\n')
|
|
403
|
+
|
|
404
|
+
/** Build a validated manager entry from the editor fields, or an error key. */
|
|
405
|
+
const buildEntry = (fields, existing) => {
|
|
406
|
+
if (!NAME_PATTERN.test(fields.name)) return { error: 'invalidName' }
|
|
407
|
+
const transport = fields.transport === 'stdio' ? 'stdio' : 'streamable-http'
|
|
408
|
+
const entry = { transport, enabled: fields.enabled }
|
|
409
|
+
if (existing !== undefined) {
|
|
410
|
+
for (const key of ['cwd', 'toolCallTimeoutMs', 'startupTimeoutMs', 'closeTimeoutMs', 'reconnect']) {
|
|
411
|
+
if (existing[key] !== undefined) entry[key] = existing[key]
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
if (transport === 'streamable-http') {
|
|
415
|
+
const url = fields.url.trim()
|
|
416
|
+
if (url === '') return { error: 'urlRequired' }
|
|
417
|
+
entry.url = url
|
|
418
|
+
const headers = parseHeaders(fields.headers)
|
|
419
|
+
if (headers === null) return { error: 'headersInvalid' }
|
|
420
|
+
if (Object.keys(headers).length > 0) entry.headers = headers
|
|
421
|
+
return { entry }
|
|
422
|
+
}
|
|
423
|
+
const command = fields.command.trim()
|
|
424
|
+
if (command === '') return { error: 'commandRequired' }
|
|
425
|
+
entry.command = command
|
|
426
|
+
const args = fields.args.split('\n').map(line => line.trim()).filter(line => line !== '')
|
|
427
|
+
if (args.length > 0) entry.args = args
|
|
428
|
+
const env = parseEnv(fields.env)
|
|
429
|
+
if (env === null) return { error: 'envInvalid' }
|
|
430
|
+
if (Object.keys(env).length > 0) entry.env = env
|
|
431
|
+
return { entry }
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
// ── sidebar icon ──────────────────────────────────────────────────────────
|
|
435
|
+
|
|
436
|
+
function McpServersIcon(props) {
|
|
437
|
+
const size = typeof props?.size === 'number' ? props.size : 20
|
|
438
|
+
const ink = 'currentColor'
|
|
439
|
+
const spoke = { stroke: ink, strokeWidth: 2.4, strokeLinecap: 'round', fill: 'none' }
|
|
440
|
+
const node = (cx, cy, r) => h('circle', { cx, cy, r, fill: ink })
|
|
441
|
+
return h('svg', {
|
|
442
|
+
width: size,
|
|
443
|
+
height: size,
|
|
444
|
+
viewBox: '0 0 36 36',
|
|
445
|
+
'aria-hidden': true,
|
|
446
|
+
style: { display: 'block', overflow: 'visible' },
|
|
447
|
+
},
|
|
448
|
+
h('path', { d: 'M18 10.5v5', ...spoke }),
|
|
449
|
+
h('path', { d: 'M18 20.5v5', ...spoke }),
|
|
450
|
+
h('path', { d: 'M10.5 18h5', ...spoke }),
|
|
451
|
+
h('path', { d: 'M20.5 18h5', ...spoke }),
|
|
452
|
+
node(18, 18, 4.2),
|
|
453
|
+
node(18, 7.5, 2.4),
|
|
454
|
+
node(18, 28.5, 2.4),
|
|
455
|
+
node(7.5, 18, 2.4),
|
|
456
|
+
node(28.5, 18, 2.4))
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
// ── modal shell ───────────────────────────────────────────────────────────
|
|
460
|
+
|
|
461
|
+
const overlayStyle = {
|
|
462
|
+
position: 'fixed',
|
|
463
|
+
inset: 0,
|
|
464
|
+
zIndex: 1000,
|
|
465
|
+
display: 'flex',
|
|
466
|
+
alignItems: 'center',
|
|
467
|
+
justifyContent: 'center',
|
|
468
|
+
padding: '24px',
|
|
469
|
+
background: 'rgba(8, 10, 12, 0.45)',
|
|
470
|
+
pointerEvents: 'auto',
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
const dialogStyle = {
|
|
474
|
+
display: 'flex',
|
|
475
|
+
flexDirection: 'column',
|
|
476
|
+
gap: '14px',
|
|
477
|
+
width: 'min(560px, 100%)',
|
|
478
|
+
maxHeight: 'calc(100vh - 48px)',
|
|
479
|
+
overflowY: 'auto',
|
|
480
|
+
boxSizing: 'border-box',
|
|
481
|
+
padding: '20px',
|
|
482
|
+
borderRadius: '16px',
|
|
483
|
+
border: `1px solid ${color.borderStrong}`,
|
|
484
|
+
background: color.layer1,
|
|
485
|
+
boxShadow: '0 18px 48px rgba(0, 0, 0, 0.28)',
|
|
486
|
+
outline: 'none',
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
const dialogHeaderStyle = { display: 'flex', alignItems: 'baseline', gap: '10px', justifyContent: 'space-between' }
|
|
490
|
+
const dialogTitleStyle = { margin: 0, fontSize: '16px', lineHeight: '24px', fontWeight: 500, color: color.primary }
|
|
491
|
+
const dialogFooterStyle = { display: 'flex', alignItems: 'center', gap: '8px', flexWrap: 'wrap' }
|
|
492
|
+
const toolChipStyle = {
|
|
493
|
+
fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Consolas, monospace',
|
|
494
|
+
fontSize: '12px',
|
|
495
|
+
lineHeight: '18px',
|
|
496
|
+
padding: '2px 8px',
|
|
497
|
+
borderRadius: '9px',
|
|
498
|
+
border: `1px solid ${color.border}`,
|
|
499
|
+
background: color.layer2,
|
|
500
|
+
color: color.primary,
|
|
501
|
+
overflowWrap: 'anywhere',
|
|
502
|
+
}
|
|
503
|
+
const FOCUSABLE = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* Modal surface over the frame-wide overlay: backdrop click, Escape, initial
|
|
507
|
+
* focus, Tab cycling, and focus restoration on unmount.
|
|
508
|
+
* @param {{ title: string, busy: boolean, onClose: () => void, children: unknown }} props dialog props.
|
|
509
|
+
*/
|
|
510
|
+
function Modal(props) {
|
|
511
|
+
const { title, busy, onClose, children } = props
|
|
512
|
+
const panelRef = React.useRef(null)
|
|
513
|
+
const restoreRef = React.useRef(null)
|
|
514
|
+
|
|
515
|
+
React.useEffect(() => {
|
|
516
|
+
restoreRef.current = typeof document === 'undefined' ? null : document.activeElement
|
|
517
|
+
const panel = panelRef.current
|
|
518
|
+
if (panel !== null) {
|
|
519
|
+
const first = panel.querySelector(FOCUSABLE)
|
|
520
|
+
if (first !== null && typeof first.focus === 'function') first.focus()
|
|
521
|
+
else if (typeof panel.focus === 'function') panel.focus()
|
|
522
|
+
}
|
|
523
|
+
return () => {
|
|
524
|
+
const prior = restoreRef.current
|
|
525
|
+
if (prior !== null && prior !== undefined && typeof prior.focus === 'function') prior.focus()
|
|
526
|
+
}
|
|
527
|
+
}, [])
|
|
528
|
+
|
|
529
|
+
const onKeyDown = (event) => {
|
|
530
|
+
if (event.key === 'Escape') {
|
|
531
|
+
event.stopPropagation()
|
|
532
|
+
if (busy !== true) onClose()
|
|
533
|
+
return
|
|
534
|
+
}
|
|
535
|
+
if (event.key !== 'Tab') return
|
|
536
|
+
const panel = panelRef.current
|
|
537
|
+
if (panel === null) return
|
|
538
|
+
const items = [...panel.querySelectorAll(FOCUSABLE)]
|
|
539
|
+
if (items.length === 0) { event.preventDefault(); panel.focus(); return }
|
|
540
|
+
const first = items[0]
|
|
541
|
+
const last = items[items.length - 1]
|
|
542
|
+
const active = typeof document === 'undefined' ? null : document.activeElement
|
|
543
|
+
if (event.shiftKey && (active === first || active === panel)) { event.preventDefault(); last.focus() }
|
|
544
|
+
else if (!event.shiftKey && active === last) { event.preventDefault(); first.focus() }
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
return h('div', {
|
|
548
|
+
style: overlayStyle,
|
|
549
|
+
onMouseDown: (event) => { if (event.target === event.currentTarget && busy !== true) onClose() },
|
|
550
|
+
onKeyDown,
|
|
551
|
+
},
|
|
552
|
+
h('div', {
|
|
553
|
+
ref: panelRef,
|
|
554
|
+
role: 'dialog',
|
|
555
|
+
'aria-modal': 'true',
|
|
556
|
+
'aria-label': title,
|
|
557
|
+
tabIndex: -1,
|
|
558
|
+
style: dialogStyle,
|
|
559
|
+
onMouseDown: (event) => { event.stopPropagation() },
|
|
560
|
+
}, children))
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
// ── add/edit dialog ───────────────────────────────────────────────────────
|
|
564
|
+
|
|
565
|
+
function EditorDialog(props) {
|
|
566
|
+
const { t, view, ui, mode, initialName, existing, taken = [], onClose } = props
|
|
567
|
+
const [name, setName] = React.useState(initialName)
|
|
568
|
+
const [transport, setTransport] = React.useState(existing?.transport === 'stdio' ? 'stdio' : 'streamable-http')
|
|
569
|
+
const [url, setUrl] = React.useState(existing?.url ?? '')
|
|
570
|
+
const [headers, setHeaders] = React.useState(headerLines(existing?.headers))
|
|
571
|
+
const [command, setCommand] = React.useState(existing?.command ?? '')
|
|
572
|
+
const [args, setArgs] = React.useState((existing?.args ?? []).join('\n'))
|
|
573
|
+
const [env, setEnv] = React.useState(Object.entries(existing?.env ?? {}).map(([key, value]) => `${key}=${value}`).join('\n'))
|
|
574
|
+
const [enabled, setEnabled] = React.useState(existing?.enabled !== false)
|
|
575
|
+
const [error, setError] = React.useState(null)
|
|
576
|
+
const [busy, setBusy] = React.useState(false)
|
|
577
|
+
|
|
578
|
+
const submit = async () => {
|
|
579
|
+
if (busy) return
|
|
580
|
+
const built = buildEntry({ name, transport, url, headers, command, args, env, enabled }, existing)
|
|
581
|
+
if (built.error !== undefined) { setError({ key: built.error }); return }
|
|
582
|
+
if (mode === 'create' && taken.includes(name)) { setError({ key: 'duplicateName' }); return }
|
|
583
|
+
setError(null)
|
|
584
|
+
setBusy(true)
|
|
585
|
+
try {
|
|
586
|
+
const outcome = await view.saveServer(name, built.entry)
|
|
587
|
+
if (outcome?.ok === true) {
|
|
588
|
+
ui.set({ editor: null, notice: { kind: 'info', text: t('saved') } })
|
|
589
|
+
return
|
|
590
|
+
}
|
|
591
|
+
setError({ text: outcome?.notice ?? t('saveFailed') })
|
|
592
|
+
} catch (caught) {
|
|
593
|
+
setError({ text: `${t('saveTransport')} ${messageOf(caught)}` })
|
|
594
|
+
} finally {
|
|
595
|
+
setBusy(false)
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
const label = (text, control, hint) => h('label', { style: fieldLabel }, h('span', null, text), control, hint !== undefined ? h('span', { style: hintStyle }, hint) : null)
|
|
600
|
+
const title = mode === 'create' ? t('addTitle') : t('editTitle')
|
|
601
|
+
const errorText = error === null ? null : error.text ?? t(error.key)
|
|
602
|
+
|
|
603
|
+
return h(Modal, { title, busy, onClose: () => { if (!busy) onClose() } },
|
|
604
|
+
h('div', { style: dialogHeaderStyle },
|
|
605
|
+
h('h2', { style: dialogTitleStyle }, title)),
|
|
606
|
+
h('div', { style: { display: 'grid', gap: '14px' } },
|
|
607
|
+
label(t('name'),
|
|
608
|
+
h('input', {
|
|
609
|
+
style: field, value: name, disabled: mode === 'edit' || busy,
|
|
610
|
+
spellCheck: false, autoComplete: 'off',
|
|
611
|
+
onChange: (event) => { setName(event.target.value) },
|
|
612
|
+
}),
|
|
613
|
+
mode === 'edit' ? t('nameLockedHint') : t('nameHint')),
|
|
614
|
+
label(t('transport'),
|
|
615
|
+
h('select', {
|
|
616
|
+
style: field, value: transport, disabled: busy,
|
|
617
|
+
onChange: (event) => { setTransport(event.target.value) },
|
|
618
|
+
},
|
|
619
|
+
h('option', { value: 'streamable-http' }, t('transportHttp')),
|
|
620
|
+
h('option', { value: 'stdio' }, t('transportStdio')))),
|
|
621
|
+
transport === 'streamable-http'
|
|
622
|
+
? label(t('url'), h('input', {
|
|
623
|
+
style: field, value: url, disabled: busy, spellCheck: false, autoComplete: 'off',
|
|
624
|
+
placeholder: 'http://host:port/path',
|
|
625
|
+
onChange: (event) => { setUrl(event.target.value) },
|
|
626
|
+
}), t('urlHint'))
|
|
627
|
+
: null,
|
|
628
|
+
transport === 'streamable-http'
|
|
629
|
+
? label(t('headers'), h('textarea', {
|
|
630
|
+
style: { ...field, minHeight: '76px', resize: 'vertical', fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Consolas, monospace' },
|
|
631
|
+
value: headers, disabled: busy, spellCheck: false,
|
|
632
|
+
onChange: (event) => { setHeaders(event.target.value) },
|
|
633
|
+
}), t('headersHint'))
|
|
634
|
+
: null,
|
|
635
|
+
transport === 'stdio'
|
|
636
|
+
? label(t('command'), h('input', {
|
|
637
|
+
style: field, value: command, disabled: busy, spellCheck: false, autoComplete: 'off',
|
|
638
|
+
onChange: (event) => { setCommand(event.target.value) },
|
|
639
|
+
}), t('commandHint'))
|
|
640
|
+
: null,
|
|
641
|
+
transport === 'stdio'
|
|
642
|
+
? label(t('args'), h('textarea', {
|
|
643
|
+
style: { ...field, minHeight: '60px', resize: 'vertical', fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Consolas, monospace' },
|
|
644
|
+
value: args, disabled: busy, spellCheck: false,
|
|
645
|
+
onChange: (event) => { setArgs(event.target.value) },
|
|
646
|
+
}), t('argsHint'))
|
|
647
|
+
: null,
|
|
648
|
+
transport === 'stdio'
|
|
649
|
+
? label(t('env'), h('textarea', {
|
|
650
|
+
style: { ...field, minHeight: '60px', resize: 'vertical', fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Consolas, monospace' },
|
|
651
|
+
value: env, disabled: busy, spellCheck: false,
|
|
652
|
+
onChange: (event) => { setEnv(event.target.value) },
|
|
653
|
+
}), t('envHint'))
|
|
654
|
+
: null,
|
|
655
|
+
h('label', { style: { display: 'flex', alignItems: 'center', gap: '8px', fontSize: '13px', color: color.primary } },
|
|
656
|
+
h('input', { type: 'checkbox', checked: enabled, disabled: busy, onChange: (event) => { setEnabled(event.target.checked) } }),
|
|
657
|
+
t('enabled')),
|
|
658
|
+
errorText !== null ? h('p', { role: 'alert', style: { margin: 0, color: color.error, fontSize: '13px' } }, errorText) : null,
|
|
659
|
+
h('div', { style: dialogFooterStyle },
|
|
660
|
+
h('button', { type: 'button', style: button('primary'), disabled: busy, onClick: () => { void submit() } }, busy ? t('saving') : t('save')),
|
|
661
|
+
h('button', { type: 'button', style: button('ghost'), disabled: busy, onClick: onClose }, t('cancel')),
|
|
662
|
+
h('span', { style: { ...hintStyle, marginLeft: 'auto', maxWidth: '46ch', minWidth: '200px', flex: '1 1 200px' } }, t('editorNote')))))
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
// ── tools dialog ──────────────────────────────────────────────────────────
|
|
666
|
+
|
|
667
|
+
/** One-line transport descriptor for the configured entry, when it has one. */
|
|
668
|
+
const transportSummary = (entry) => {
|
|
669
|
+
if (entry === undefined || entry === null) return null
|
|
670
|
+
if (entry.transport === 'stdio') return `stdio · ${entry.command ?? ''}`
|
|
671
|
+
return entry.url ?? ''
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
const versionLabel = (info) => {
|
|
675
|
+
if (info === undefined || info === null) return ''
|
|
676
|
+
const version = typeof info.version === 'string' && info.version !== '' ? ` ${info.version}` : ''
|
|
677
|
+
return `${String(info.name ?? '')}${version}`
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* Tool list for one server: probes it over a separate connection so the
|
|
682
|
+
* live instance keeps running, then lists the advertised tool names.
|
|
683
|
+
* @param {{ t: Function, view: object, name: string, entry: object | undefined, onClose: () => void }} props dialog props.
|
|
684
|
+
*/
|
|
685
|
+
function ToolsDialog(props) {
|
|
686
|
+
const { t, view, name, entry, onClose } = props
|
|
687
|
+
const [attempt, setAttempt] = React.useState(0)
|
|
688
|
+
const [state, setState] = React.useState({ status: 'loading', value: undefined, error: undefined })
|
|
689
|
+
|
|
690
|
+
React.useEffect(() => {
|
|
691
|
+
let active = true
|
|
692
|
+
setState({ status: 'loading', value: undefined, error: undefined })
|
|
693
|
+
void (async () => {
|
|
694
|
+
try {
|
|
695
|
+
const outcome = await view.probe(name)
|
|
696
|
+
if (!active) return
|
|
697
|
+
if (outcome === undefined || outcome.ok !== true) {
|
|
698
|
+
setState({ status: 'error', value: undefined, error: messageOf(outcome?.error ?? t('toolsUnavailable')) })
|
|
699
|
+
return
|
|
700
|
+
}
|
|
701
|
+
setState({ status: 'ready', value: outcome.value, error: undefined })
|
|
702
|
+
} catch (caught) {
|
|
703
|
+
if (active) setState({ status: 'error', value: undefined, error: messageOf(caught) })
|
|
704
|
+
}
|
|
705
|
+
})()
|
|
706
|
+
return () => { active = false }
|
|
707
|
+
}, [name, view, attempt])
|
|
708
|
+
|
|
709
|
+
const title = t('toolsTitle')
|
|
710
|
+
const summary = transportSummary(entry)
|
|
711
|
+
const value = state.value
|
|
712
|
+
|
|
713
|
+
const body = (() => {
|
|
714
|
+
if (state.status === 'loading') return h('p', { style: hintStyle }, t('toolsLoading'))
|
|
715
|
+
if (state.status === 'error') {
|
|
716
|
+
return h('p', { role: 'alert', style: { ...hintStyle, color: color.error } }, `${t('probeFailed')} · ${state.error}`)
|
|
717
|
+
}
|
|
718
|
+
if (value === undefined || value.ok !== true) {
|
|
719
|
+
const stage = value?.stage === undefined ? '' : ` · ${t('toolsStage')} ${String(value.stage)}`
|
|
720
|
+
return h('p', { role: 'alert', style: { ...hintStyle, color: color.error } }, `${t('probeFailed')}${stage} · ${messageOf(value?.message)}`)
|
|
721
|
+
}
|
|
722
|
+
const toolNames = Array.isArray(value.toolNames) ? value.toolNames : []
|
|
723
|
+
return h('div', { style: { display: 'grid', gap: '10px' } },
|
|
724
|
+
h('div', {
|
|
725
|
+
style: { display: 'flex', alignItems: 'center', gap: '8px', flexWrap: 'wrap', fontSize: '13px', color: color.secondary },
|
|
726
|
+
},
|
|
727
|
+
value.serverInfo !== undefined
|
|
728
|
+
? h('span', null, `${t('toolsServer')}: ${versionLabel(value.serverInfo)}`)
|
|
729
|
+
: null,
|
|
730
|
+
h('span', null, `${String(toolNames.length)} ${t('probeTools')}`),
|
|
731
|
+
h('span', null, `${t('toolsDuration')} ${String(value.durationMs)}ms`),
|
|
732
|
+
value.truncated === true ? h('span', null, t('probeTruncated')) : null,
|
|
733
|
+
value.cleanupError !== undefined
|
|
734
|
+
? h('span', { style: { color: color.warn } }, `${t('probeCleanup')} · ${String(value.cleanupError)}`)
|
|
735
|
+
: null),
|
|
736
|
+
toolNames.length === 0
|
|
737
|
+
? h('p', { style: hintStyle }, t('toolsEmpty'))
|
|
738
|
+
: h('ul', {
|
|
739
|
+
style: { listStyle: 'none', margin: 0, padding: 0, display: 'flex', flexWrap: 'wrap', gap: '6px' },
|
|
740
|
+
}, toolNames.map((tool) => h('li', { key: tool, style: toolChipStyle }, tool))))
|
|
741
|
+
})()
|
|
742
|
+
|
|
743
|
+
return h(Modal, { title, onClose },
|
|
744
|
+
h('div', { style: dialogHeaderStyle },
|
|
745
|
+
h('h2', { style: dialogTitleStyle }, title),
|
|
746
|
+
h('span', { style: { ...toolChipStyle, fontFamily: 'inherit' } }, name)),
|
|
747
|
+
summary !== null && summary !== ''
|
|
748
|
+
? h('p', { style: { ...hintStyle, margin: 0 } }, `${t('toolsConfig')}: ${summary}`)
|
|
749
|
+
: null,
|
|
750
|
+
h('p', { style: { ...hintStyle, margin: 0 } }, t('toolsHint')),
|
|
751
|
+
body,
|
|
752
|
+
h('div', { style: dialogFooterStyle },
|
|
753
|
+
h('button', {
|
|
754
|
+
type: 'button', style: button('primary'), disabled: state.status === 'loading',
|
|
755
|
+
onClick: () => { setAttempt(attempt + 1) },
|
|
756
|
+
}, state.status === 'loading' ? t('probing') : t('toolsRetry')),
|
|
757
|
+
h('button', { type: 'button', style: button('ghost'), onClick: onClose }, t('toolsClose'))))
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
/** Overlay-slot component: renders whichever dialog the page opened. */
|
|
761
|
+
function McpDialogs(props) {
|
|
762
|
+
const { t, view, ui } = props
|
|
763
|
+
const state = useStore(ui)
|
|
764
|
+
if (state.editor !== null) {
|
|
765
|
+
return h(EditorDialog, {
|
|
766
|
+
key: `editor:${state.editor.mode}:${state.editor.name}`,
|
|
767
|
+
t,
|
|
768
|
+
view,
|
|
769
|
+
ui,
|
|
770
|
+
mode: state.editor.mode,
|
|
771
|
+
initialName: state.editor.name,
|
|
772
|
+
existing: state.editor.existing,
|
|
773
|
+
taken: state.editor.taken,
|
|
774
|
+
onClose: () => { ui.set({ editor: null }) },
|
|
775
|
+
})
|
|
776
|
+
}
|
|
777
|
+
if (state.tools !== null) {
|
|
778
|
+
return h(ToolsDialog, {
|
|
779
|
+
key: `tools:${state.tools.name}`,
|
|
780
|
+
t,
|
|
781
|
+
view,
|
|
782
|
+
name: state.tools.name,
|
|
783
|
+
entry: state.tools.entry,
|
|
784
|
+
onClose: () => { ui.set({ tools: null }) },
|
|
785
|
+
})
|
|
786
|
+
}
|
|
787
|
+
return null
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
// ── main page ─────────────────────────────────────────────────────────────
|
|
791
|
+
|
|
792
|
+
function McpServersPage(props) {
|
|
793
|
+
const { t, view, ui } = props
|
|
794
|
+
const runtime = useStore(view.runtime)
|
|
795
|
+
const settings = useStore(view.formStore)
|
|
796
|
+
const uiState = useStore(ui)
|
|
797
|
+
const notice = uiState.notice
|
|
798
|
+
const [busy, setBusy] = React.useState(null)
|
|
799
|
+
|
|
800
|
+
const settingsValue = settings.status === 'ready' && settings.value !== null && typeof settings.value === 'object'
|
|
801
|
+
? settings.value : undefined
|
|
802
|
+
const configured = settingsValue?.servers !== undefined && settingsValue.servers !== null && typeof settingsValue.servers === 'object'
|
|
803
|
+
? settingsValue.servers : {}
|
|
804
|
+
const base = settings.base !== null && typeof settings.base === 'object' && settings.base.servers !== null && typeof settings.base.servers === 'object'
|
|
805
|
+
? settings.base.servers : {}
|
|
806
|
+
const user = settings.user !== null && typeof settings.user === 'object' && settings.user.servers !== null && typeof settings.user.servers === 'object'
|
|
807
|
+
? settings.user.servers : {}
|
|
808
|
+
|
|
809
|
+
const runtimeByName = new Map()
|
|
810
|
+
for (const item of runtime.servers ?? []) runtimeByName.set(item.name, item)
|
|
811
|
+
|
|
812
|
+
const names = [...new Set([...Object.keys(configured), ...runtimeByName.keys()])]
|
|
813
|
+
const rows = names.map((name) => {
|
|
814
|
+
const entry = configured[name]
|
|
815
|
+
const live = runtimeByName.get(name)
|
|
816
|
+
const registered = live !== undefined && live.configured === false && entry === undefined
|
|
817
|
+
const source = user[name] !== undefined ? 'custom' : base[name] !== undefined ? 'inherited' : registered ? 'plugin' : 'custom'
|
|
818
|
+
return { name, entry, status: live?.status, configured: entry !== undefined, registered, source }
|
|
819
|
+
})
|
|
820
|
+
|
|
821
|
+
const formReady = settings.status === 'ready'
|
|
822
|
+
const writable = settings.writable === true
|
|
823
|
+
|
|
824
|
+
const run = async (key, action) => {
|
|
825
|
+
setBusy(key)
|
|
826
|
+
ui.set({ notice: null })
|
|
827
|
+
try {
|
|
828
|
+
const outcome = await action()
|
|
829
|
+
if (outcome?.notice !== undefined) ui.set({ notice: { kind: outcome.kind ?? 'info', text: outcome.notice } })
|
|
830
|
+
return outcome
|
|
831
|
+
} catch (error) {
|
|
832
|
+
ui.set({ notice: { kind: 'error', text: messageOf(error) } })
|
|
833
|
+
return undefined
|
|
834
|
+
} finally {
|
|
835
|
+
setBusy(null)
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
const restart = async (name) => {
|
|
839
|
+
const outcome = await run(`restart:${name}`, () => view.restart(name))
|
|
840
|
+
if (outcome === undefined) return
|
|
841
|
+
if (outcome.ok === true) ui.set({ notice: { kind: 'info', text: `${name}: ${t('restartOk')}` } })
|
|
842
|
+
else ui.set({ notice: { kind: 'error', text: `${name}: ${t('restartFailed')} · ${messageOf(outcome.error)}` } })
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
const toggle = async (row) => {
|
|
846
|
+
const next = row.entry?.enabled === false
|
|
847
|
+
const entry = { ...row.entry, enabled: next }
|
|
848
|
+
const outcome = await run(`toggle:${row.name}`, () => view.saveServer(row.name, entry))
|
|
849
|
+
if (outcome?.ok === true) ui.set({ notice: { kind: 'info', text: next ? t('enabledNotice') : t('disabledNotice') } })
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
const remove = async (row) => {
|
|
853
|
+
if (row.source === 'inherited') {
|
|
854
|
+
const outcome = await run(`remove:${row.name}`, () => view.saveServer(row.name, { ...row.entry, enabled: false }))
|
|
855
|
+
if (outcome?.ok === true) ui.set({ notice: { kind: 'info', text: t('removedInherited') } })
|
|
856
|
+
return
|
|
857
|
+
}
|
|
858
|
+
const outcome = await run(`remove:${row.name}`, () => view.removeServer(row.name))
|
|
859
|
+
if (outcome?.ok === true) ui.set({ notice: { kind: 'info', text: t('removed') } })
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
const openEditor = (row) => {
|
|
863
|
+
ui.set({
|
|
864
|
+
notice: null,
|
|
865
|
+
tools: null,
|
|
866
|
+
editor: row === undefined
|
|
867
|
+
? { mode: 'create', name: '', existing: undefined, taken: Object.keys(configured) }
|
|
868
|
+
: { mode: 'edit', name: row.name, existing: row.entry, taken: [] },
|
|
869
|
+
})
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
const openTools = (row) => {
|
|
873
|
+
ui.set({ notice: null, editor: null, tools: { name: row.name, entry: row.entry } })
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
const renderRow = (row) => {
|
|
877
|
+
const shownStatus = row.status ?? (row.configured ? { state: 'pending' } : undefined)
|
|
878
|
+
const tone = statusTone(shownStatus)
|
|
879
|
+
const detail = statusDetail(shownStatus)
|
|
880
|
+
const canEdit = row.configured && writable && formReady
|
|
881
|
+
const sourceLabel = row.source === 'inherited' ? t('sourceInherited') : row.source === 'plugin' ? t('sourcePlugin') : t('sourceCustom')
|
|
882
|
+
const rowBusy = busy !== null && (busy.endsWith(`:${row.name}`) || busy === 'save')
|
|
883
|
+
return h('li', {
|
|
884
|
+
key: row.name,
|
|
885
|
+
style: {
|
|
886
|
+
display: 'grid', gap: '10px', padding: '14px 16px', borderRadius: '12px',
|
|
887
|
+
border: `1px solid ${color.border}`, background: color.layer1,
|
|
888
|
+
},
|
|
889
|
+
},
|
|
890
|
+
h('div', { style: { display: 'flex', alignItems: 'center', gap: '10px', flexWrap: 'wrap' } },
|
|
891
|
+
h('span', {
|
|
892
|
+
style: {
|
|
893
|
+
fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Consolas, monospace',
|
|
894
|
+
fontSize: '14px', fontWeight: 600, color: color.primary, overflowWrap: 'anywhere',
|
|
895
|
+
},
|
|
896
|
+
}, row.name),
|
|
897
|
+
h('span', {
|
|
898
|
+
style: {
|
|
899
|
+
fontSize: '11px', lineHeight: '18px', padding: '0 8px', borderRadius: '9px',
|
|
900
|
+
color: color.secondary, border: `1px solid ${color.border}`,
|
|
901
|
+
},
|
|
902
|
+
}, sourceLabel),
|
|
903
|
+
h('span', { style: { display: 'inline-flex', alignItems: 'center', gap: '6px', marginLeft: 'auto', fontSize: '13px', color: tone } },
|
|
904
|
+
h('span', { style: { width: '7px', height: '7px', borderRadius: '50%', background: tone, display: 'inline-block' } }),
|
|
905
|
+
statusText(shownStatus, t)),
|
|
906
|
+
row.entry !== undefined
|
|
907
|
+
? h('span', { style: { fontSize: '12px', color: color.secondary, overflowWrap: 'anywhere' } },
|
|
908
|
+
row.entry.transport === 'stdio'
|
|
909
|
+
? `stdio · ${row.entry.command ?? ''}`
|
|
910
|
+
: row.entry.url ?? '')
|
|
911
|
+
: null),
|
|
912
|
+
detail !== undefined && detail !== ''
|
|
913
|
+
? h('p', { style: { ...hintStyle, overflowWrap: 'anywhere' } }, detail)
|
|
914
|
+
: null,
|
|
915
|
+
h('div', { style: { display: 'flex', alignItems: 'center', gap: '8px', flexWrap: 'wrap' } },
|
|
916
|
+
canEdit
|
|
917
|
+
? h('button', { type: 'button', style: iconButton, disabled: rowBusy || busy !== null, onClick: () => openEditor(row) }, t('edit'))
|
|
918
|
+
: null,
|
|
919
|
+
canEdit
|
|
920
|
+
? h('button', { type: 'button', style: iconButton, disabled: rowBusy || busy !== null, onClick: () => { void toggle(row) } }, row.entry?.enabled === false ? t('enable') : t('disable'))
|
|
921
|
+
: null,
|
|
922
|
+
row.configured
|
|
923
|
+
? h('button', { type: 'button', style: iconButton, disabled: rowBusy || busy !== null, onClick: () => { void restart(row.name) } },
|
|
924
|
+
busy === `restart:${row.name}` ? t('restarting') : t('restart'))
|
|
925
|
+
: null,
|
|
926
|
+
row.configured || row.registered
|
|
927
|
+
? h('button', { type: 'button', style: iconButton, disabled: rowBusy || busy !== null, onClick: () => { openTools(row) } }, t('toolsButton'))
|
|
928
|
+
: null,
|
|
929
|
+
canEdit
|
|
930
|
+
? h('button', {
|
|
931
|
+
type: 'button',
|
|
932
|
+
style: { ...iconButton, color: color.error, borderColor: color.border },
|
|
933
|
+
disabled: rowBusy || busy !== null,
|
|
934
|
+
onClick: () => { void remove(row) },
|
|
935
|
+
}, t('remove'))
|
|
936
|
+
: null))
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
const notice_view = notice === null ? null : h('div', {
|
|
940
|
+
role: notice.kind === 'error' ? 'alert' : 'status',
|
|
941
|
+
style: {
|
|
942
|
+
marginTop: '16px', padding: '10px 12px', borderRadius: '8px', fontSize: '13px',
|
|
943
|
+
color: notice.kind === 'error' ? color.error : color.primary,
|
|
944
|
+
border: `1px solid ${notice.kind === 'error' ? color.error : color.border}`,
|
|
945
|
+
background: color.layer2, overflowWrap: 'anywhere',
|
|
946
|
+
},
|
|
947
|
+
}, notice.text)
|
|
948
|
+
|
|
949
|
+
return h('section', {
|
|
950
|
+
className: PAGE_CLASS,
|
|
951
|
+
'aria-label': t('title'),
|
|
952
|
+
style: {
|
|
953
|
+
display: 'flex', width: '100%', height: '100%', minWidth: 0, minHeight: 0, overflow: 'auto',
|
|
954
|
+
color: color.primary, background: 'var(--dsw-alias-bg-base)',
|
|
955
|
+
fontSize: '14px', lineHeight: 1.6, scrollbarGutter: 'stable',
|
|
956
|
+
},
|
|
957
|
+
},
|
|
958
|
+
h('style', { key: 'dsh-mcp-style' }, pageStyles),
|
|
959
|
+
h('div', { style: { maxWidth: '960px', width: '100%', margin: '0 auto', padding: '28px clamp(20px, 4vw, 48px) 48px', boxSizing: 'border-box' } },
|
|
960
|
+
h('header', { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: '16px', flexWrap: 'wrap' } },
|
|
961
|
+
h('div', { style: { minWidth: 0 } },
|
|
962
|
+
h('h1', { style: { margin: 0, fontSize: '20px', lineHeight: '28px', fontWeight: 500 } }, t('title')),
|
|
963
|
+
h('p', { style: { margin: '4px 0 0', ...hintStyle } }, t('subtitle'))),
|
|
964
|
+
h('div', { style: { display: 'flex', gap: '8px', flex: 'none' } },
|
|
965
|
+
h('button', { type: 'button', style: button('primary'), disabled: !formReady || !writable || busy !== null, onClick: () => openEditor(undefined) }, t('add')))),
|
|
966
|
+
notice_view,
|
|
967
|
+
settings.status === 'loading'
|
|
968
|
+
? h('p', { style: { marginTop: '24px', ...hintStyle } }, t('settingsLoading'))
|
|
969
|
+
: null,
|
|
970
|
+
settings.status === 'unavailable'
|
|
971
|
+
? h('p', { style: { marginTop: '24px', ...hintStyle } }, t('settingsUnavailable'))
|
|
972
|
+
: null,
|
|
973
|
+
runtime.status === 'loading'
|
|
974
|
+
? h('p', { style: { marginTop: '24px', ...hintStyle } }, t('runtimeLoading'))
|
|
975
|
+
: null,
|
|
976
|
+
runtime.error !== null && runtime.error !== undefined
|
|
977
|
+
? h('p', { style: { marginTop: '16px', fontSize: '13px', color: color.error } }, `${t('runtimeError')} ${messageOf(runtime.error)}`)
|
|
978
|
+
: null,
|
|
979
|
+
settings.status === 'ready' && rows.length === 0
|
|
980
|
+
? h('p', { style: { marginTop: '24px', ...hintStyle } }, t('listEmpty'))
|
|
981
|
+
: null,
|
|
982
|
+
h('ul', { style: { listStyle: 'none', margin: '20px 0 0', padding: 0, display: 'grid', gap: '12px' } }, rows.map(renderRow))))
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
// ── plugin ────────────────────────────────────────────────────────────────
|
|
986
|
+
|
|
987
|
+
/** Required Client services: slot registry, locale, Remote namespaces, access gate, shared settings forms. */
|
|
988
|
+
const inject = ['slots', 'locale', 'remote', 'remote.mcpManager', 'remoteAccess', 'configForms']
|
|
989
|
+
|
|
990
|
+
/**
|
|
991
|
+
* Register the MCP servers panel once the Peer may watch the fleet, and
|
|
992
|
+
* follow the live server list and the settings entry while it stays allowed.
|
|
993
|
+
* @param ctx browser plugin context.
|
|
994
|
+
*/
|
|
995
|
+
function apply(ctx) {
|
|
996
|
+
ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'dsh-mcp: dictionaries')
|
|
997
|
+
const t = ctx.locale.bind(NS)
|
|
998
|
+
|
|
999
|
+
const runtime = createStore({ status: 'loading', servers: [], error: null })
|
|
1000
|
+
const form = ctx.configForms.get(SETTINGS_NAMESPACE)
|
|
1001
|
+
const formStore = createStore(form.getSnapshot())
|
|
1002
|
+
ctx.effect(() => form.subscribe(() => { formStore.set(form.getSnapshot()) }), 'dsh-mcp: settings form')
|
|
1003
|
+
|
|
1004
|
+
/** Dialog and page-notice state shared by the panel and the overlay slot. */
|
|
1005
|
+
const ui = createStore({ editor: null, tools: null, notice: null })
|
|
1006
|
+
|
|
1007
|
+
const view = {
|
|
1008
|
+
runtime,
|
|
1009
|
+
formStore,
|
|
1010
|
+
/** Save one server entry through the settings write queue. */
|
|
1011
|
+
async saveServer(name, entry) {
|
|
1012
|
+
try {
|
|
1013
|
+
const ok = await form.mutate([{ op: 'set', path: ['servers', name], value: entry }])
|
|
1014
|
+
return { ok, notice: ok ? undefined : t('saveFailed') }
|
|
1015
|
+
} catch (error) {
|
|
1016
|
+
return { ok: false, notice: `${t('saveTransport')} ${messageOf(error)}` }
|
|
1017
|
+
}
|
|
1018
|
+
},
|
|
1019
|
+
/** Remove one profile-layer server entry. */
|
|
1020
|
+
async removeServer(name) {
|
|
1021
|
+
try {
|
|
1022
|
+
const ok = await form.mutate([{ op: 'unset', path: ['servers', name] }])
|
|
1023
|
+
return { ok, notice: ok ? undefined : t('saveFailed') }
|
|
1024
|
+
} catch (error) {
|
|
1025
|
+
return { ok: false, notice: `${t('saveTransport')} ${messageOf(error)}` }
|
|
1026
|
+
}
|
|
1027
|
+
},
|
|
1028
|
+
restart(name) {
|
|
1029
|
+
return ctx.remote.mcpManager.restart(name)
|
|
1030
|
+
},
|
|
1031
|
+
probe(name) {
|
|
1032
|
+
return ctx.remote.mcpManager.probe(name)
|
|
1033
|
+
},
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
ctx.remoteAccess.whenAccess('mcpManager/watch', function* () {
|
|
1037
|
+
const handle = ctx.remote.mcpManager.watch()
|
|
1038
|
+
runtime.set({ status: 'loading', servers: [], error: null })
|
|
1039
|
+
void (async () => {
|
|
1040
|
+
try {
|
|
1041
|
+
for await (const servers of handle) {
|
|
1042
|
+
runtime.set({ status: 'ready', servers: Array.isArray(servers) ? servers : [], error: null })
|
|
1043
|
+
}
|
|
1044
|
+
} catch (error) {
|
|
1045
|
+
runtime.set({ status: 'error', servers: runtime.get().servers, error })
|
|
1046
|
+
}
|
|
1047
|
+
})()
|
|
1048
|
+
yield () => { handle.dispose() }
|
|
1049
|
+
yield ctx.slots.inject('main', () => ctx.slots.register({
|
|
1050
|
+
name: 'main',
|
|
1051
|
+
key: PANEL_ID,
|
|
1052
|
+
locale: NS,
|
|
1053
|
+
inject: () => ({ view, ui }),
|
|
1054
|
+
}, McpServersPage))
|
|
1055
|
+
yield ctx.slots.inject('sidebar.panellist', () => ctx.slots.register({
|
|
1056
|
+
name: 'sidebar.panellist',
|
|
1057
|
+
id: PANEL_ID,
|
|
1058
|
+
order: 20,
|
|
1059
|
+
locale: NS,
|
|
1060
|
+
label: () => t('panel'),
|
|
1061
|
+
}, McpServersIcon))
|
|
1062
|
+
yield ctx.slots.inject('shell.overlay', () => ctx.slots.register({
|
|
1063
|
+
name: 'shell.overlay',
|
|
1064
|
+
id: `${PANEL_ID}-dialogs`,
|
|
1065
|
+
order: 10,
|
|
1066
|
+
locale: NS,
|
|
1067
|
+
inject: () => ({ view, ui }),
|
|
1068
|
+
}, McpDialogs))
|
|
1069
|
+
yield () => { ui.set({ editor: null, tools: null }) }
|
|
1070
|
+
})
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
return { inject, apply }
|
|
1074
|
+
},
|
|
1075
|
+
})
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# @lqrui/dsh-mcp — generated by scripts/build.mjs from dsh-mcp/cordis.patch.yml.
|
|
2
|
+
# This machine's deployment values (proxy, model pin, credentials, internal endpoints)
|
|
3
|
+
# are not shipped. Set them in your own profile patch layer, or through the plugin's
|
|
4
|
+
# configuration, after installing this bundle.
|
|
5
|
+
- insert:
|
|
6
|
+
- id: dsh-mcp
|
|
7
|
+
name: "@lqrui/dsh-mcp"
|
package/icon.svg
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="36" height="36" viewBox="0 0 36 36">
|
|
2
|
+
<g fill="none" stroke="#2f6fd0" stroke-width="2.4" stroke-linecap="round">
|
|
3
|
+
<path d="M18 12.5v4.2"/>
|
|
4
|
+
<path d="M18 19.3v4.2"/>
|
|
5
|
+
<path d="M12.5 18h4.2"/>
|
|
6
|
+
<path d="M19.3 18h4.2"/>
|
|
7
|
+
</g>
|
|
8
|
+
<circle cx="18" cy="18" r="4" fill="#1aa38a"/>
|
|
9
|
+
<circle cx="18" cy="9.4" r="2.4" fill="#2f6fd0"/>
|
|
10
|
+
<circle cx="18" cy="26.6" r="2.4" fill="#2f6fd0"/>
|
|
11
|
+
<circle cx="9.4" cy="18" r="2.4" fill="#2f6fd0"/>
|
|
12
|
+
<circle cx="26.6" cy="18" r="2.4" fill="#2f6fd0"/>
|
|
13
|
+
</svg>
|
package/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host half of the MCP servers bundle. It exists so the package holds a Loader
|
|
3
|
+
* row: the browser half (exported as `./client`) owns the sidebar page and
|
|
4
|
+
* drives the shipped mcp-manager services, so no Host-side code is needed.
|
|
5
|
+
*/
|
|
6
|
+
export function apply() {}
|
package/locale/en.json
ADDED
package/locale/zh.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,53 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lqrui/dsh-mcp",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "2.1.0",
|
|
4
|
+
"description": "Manage MCP servers from a left-sidebar page: add and edit through a modal dialog, enable, disable, restart, and inspect each server's tool list.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./index.js",
|
|
8
|
+
"./client": "./client.js",
|
|
9
|
+
"./locale/*.json": "./locale/*.json",
|
|
10
|
+
"./icon": "./icon.svg"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"index.js",
|
|
14
|
+
"client.js",
|
|
15
|
+
"cordis.patch.yml",
|
|
16
|
+
"locale/*.json",
|
|
17
|
+
"icon.svg",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
20
|
+
"dsh": {
|
|
21
|
+
"bundle": {
|
|
22
|
+
"patch": "./cordis.patch.yml"
|
|
23
|
+
},
|
|
24
|
+
"client": {
|
|
25
|
+
"platform": "web",
|
|
26
|
+
"immediately": true,
|
|
27
|
+
"inject": [
|
|
28
|
+
"@deepseek-ai/dsh-client-locale",
|
|
29
|
+
"@deepseek-ai/dsh-api-remotes",
|
|
30
|
+
"@deepseek-ai/dsh-api-remote-access",
|
|
31
|
+
"@deepseek-ai/dsh-client-ui-settings"
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"author": "lqrui",
|
|
40
|
+
"keywords": [
|
|
41
|
+
"dsh",
|
|
42
|
+
"dsh-plugin",
|
|
43
|
+
"deepseek-harness",
|
|
44
|
+
"mcp",
|
|
45
|
+
"model-context-protocol",
|
|
46
|
+
"servers",
|
|
47
|
+
"tools",
|
|
48
|
+
"sidebar"
|
|
49
|
+
],
|
|
50
|
+
"engines": {
|
|
51
|
+
"dsh": "^0.2.2-rc.5"
|
|
52
|
+
}
|
|
53
|
+
}
|