dsh-mcp-servers 1.0.260817
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 +74 -0
- package/client/client.js +1133 -0
- package/cordis.patch.yml +3 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +473 -0
- package/dist/sanitize.d.ts +1 -0
- package/dist/sanitize.js +39 -0
- package/package.json +69 -0
package/client/client.js
ADDED
|
@@ -0,0 +1,1133 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: "dsh-mcp-servers",
|
|
3
|
+
factory: (require) => {
|
|
4
|
+
var module = { exports: {} };
|
|
5
|
+
var exports = module.exports;
|
|
6
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
|
+
let react = require("react");
|
|
8
|
+
let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
9
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
|
+
//#region src/client/index.tsx
|
|
11
|
+
/**
|
|
12
|
+
* dsh-mcp-servers client: "MCP Servers" settings section. Each card shows a
|
|
13
|
+
* read-only summary (status dot | id | endpoint | transport icon); Edit
|
|
14
|
+
* switches to fields, and Save persists that card. Tokens match the Harness
|
|
15
|
+
* settings conventions; primitives are host-injected externals.
|
|
16
|
+
*/
|
|
17
|
+
const name = "dsh-mcp-servers";
|
|
18
|
+
const inject = ["slots"];
|
|
19
|
+
const EMPTY = {
|
|
20
|
+
id: "",
|
|
21
|
+
enabled: true,
|
|
22
|
+
type: "stdio",
|
|
23
|
+
args: [],
|
|
24
|
+
env: {}
|
|
25
|
+
};
|
|
26
|
+
const card = {
|
|
27
|
+
background: "var(--dsw-alias-bg-layer-1)",
|
|
28
|
+
border: "1px solid var(--dsw-alias-border-l2)",
|
|
29
|
+
borderRadius: 12,
|
|
30
|
+
padding: "12px 14px",
|
|
31
|
+
display: "flex",
|
|
32
|
+
flexDirection: "column",
|
|
33
|
+
gap: 8,
|
|
34
|
+
minWidth: 0
|
|
35
|
+
};
|
|
36
|
+
const fieldStyle = {
|
|
37
|
+
boxSizing: "border-box",
|
|
38
|
+
width: "100%",
|
|
39
|
+
padding: "6px 8px",
|
|
40
|
+
font: "inherit",
|
|
41
|
+
borderRadius: 6,
|
|
42
|
+
border: "1px solid var(--dsw-alias-border-l1)",
|
|
43
|
+
background: "var(--dsw-alias-bg-layer-2)",
|
|
44
|
+
color: "var(--dsw-alias-label-primary)"
|
|
45
|
+
};
|
|
46
|
+
const labelStyle = {
|
|
47
|
+
marginBottom: 2,
|
|
48
|
+
fontSize: 12,
|
|
49
|
+
color: "var(--dsw-alias-label-tertiary)"
|
|
50
|
+
};
|
|
51
|
+
const muted = {
|
|
52
|
+
opacity: .7,
|
|
53
|
+
fontSize: 13
|
|
54
|
+
};
|
|
55
|
+
const ellipsis = {
|
|
56
|
+
overflow: "hidden",
|
|
57
|
+
textOverflow: "ellipsis",
|
|
58
|
+
whiteSpace: "nowrap"
|
|
59
|
+
};
|
|
60
|
+
function Field({ label, children }) {
|
|
61
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
62
|
+
style: { margin: "2px 0" },
|
|
63
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
64
|
+
style: labelStyle,
|
|
65
|
+
children: label
|
|
66
|
+
}), children]
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function StatusDot({ status }) {
|
|
70
|
+
const ok = status?.ok === true;
|
|
71
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
72
|
+
title: ok ? "connected" : status ? status.error ?? "not connected" : "not saved yet",
|
|
73
|
+
style: { display: "inline-flex" },
|
|
74
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.StateDot, { state: ok ? "done" : "error" })
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
function TransportIcon({ type }) {
|
|
78
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
79
|
+
title: type === "stdio" ? "stdio (local process)" : type === "sse" ? "sse (legacy event stream)" : "http (streamable)",
|
|
80
|
+
style: { display: "inline-flex" },
|
|
81
|
+
children: type === "stdio" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCodeOutline16, {}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconGlobeOutline14, {})
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/** Eye / eye-off for censoring secret values (no such icon in primitives). */
|
|
85
|
+
const eyeStyle = {
|
|
86
|
+
width: 14,
|
|
87
|
+
height: 14
|
|
88
|
+
};
|
|
89
|
+
function EyeIcon() {
|
|
90
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
91
|
+
viewBox: "0 0 24 24",
|
|
92
|
+
fill: "none",
|
|
93
|
+
stroke: "currentColor",
|
|
94
|
+
strokeWidth: "2",
|
|
95
|
+
strokeLinecap: "round",
|
|
96
|
+
strokeLinejoin: "round",
|
|
97
|
+
style: eyeStyle,
|
|
98
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
|
|
99
|
+
cx: "12",
|
|
100
|
+
cy: "12",
|
|
101
|
+
r: "3"
|
|
102
|
+
})]
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function EyeOffIcon() {
|
|
106
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
107
|
+
viewBox: "0 0 24 24",
|
|
108
|
+
fill: "none",
|
|
109
|
+
stroke: "currentColor",
|
|
110
|
+
strokeWidth: "2",
|
|
111
|
+
strokeLinecap: "round",
|
|
112
|
+
strokeLinejoin: "round",
|
|
113
|
+
style: eyeStyle,
|
|
114
|
+
children: [
|
|
115
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49" }),
|
|
116
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M14.084 14.158a3 3 0 0 1-4.242-4.242" }),
|
|
117
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143" }),
|
|
118
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "m2 2 20 20" })
|
|
119
|
+
]
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
const iconBtn = {
|
|
123
|
+
background: "transparent",
|
|
124
|
+
border: "none",
|
|
125
|
+
cursor: "pointer",
|
|
126
|
+
padding: 4,
|
|
127
|
+
display: "inline-flex",
|
|
128
|
+
alignItems: "center",
|
|
129
|
+
color: "var(--dsw-alias-label-secondary)"
|
|
130
|
+
};
|
|
131
|
+
function PlusIcon() {
|
|
132
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
133
|
+
viewBox: "0 0 24 24",
|
|
134
|
+
fill: "none",
|
|
135
|
+
stroke: "currentColor",
|
|
136
|
+
strokeWidth: "2",
|
|
137
|
+
strokeLinecap: "round",
|
|
138
|
+
style: eyeStyle,
|
|
139
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M12 5v14" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M5 12h14" })]
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
function TrashIcon() {
|
|
143
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
144
|
+
viewBox: "0 0 24 24",
|
|
145
|
+
fill: "none",
|
|
146
|
+
stroke: "currentColor",
|
|
147
|
+
strokeWidth: "2",
|
|
148
|
+
strokeLinecap: "round",
|
|
149
|
+
strokeLinejoin: "round",
|
|
150
|
+
style: eyeStyle,
|
|
151
|
+
children: [
|
|
152
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M3 6h18" }),
|
|
153
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" }),
|
|
154
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" })
|
|
155
|
+
]
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
function ClipboardIcon() {
|
|
159
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
160
|
+
viewBox: "0 0 24 24",
|
|
161
|
+
fill: "none",
|
|
162
|
+
stroke: "currentColor",
|
|
163
|
+
strokeWidth: "2",
|
|
164
|
+
strokeLinecap: "round",
|
|
165
|
+
strokeLinejoin: "round",
|
|
166
|
+
style: eyeStyle,
|
|
167
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
|
|
168
|
+
x: "8",
|
|
169
|
+
y: "2",
|
|
170
|
+
width: "8",
|
|
171
|
+
height: "4",
|
|
172
|
+
rx: "1"
|
|
173
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2" })]
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
function Switch({ checked, onChange }) {
|
|
177
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
178
|
+
type: "button",
|
|
179
|
+
role: "switch",
|
|
180
|
+
"aria-checked": checked,
|
|
181
|
+
"aria-label": "enabled",
|
|
182
|
+
onClick: () => onChange(!checked),
|
|
183
|
+
style: {
|
|
184
|
+
width: 44,
|
|
185
|
+
height: 26,
|
|
186
|
+
borderRadius: 13,
|
|
187
|
+
padding: 0,
|
|
188
|
+
cursor: "pointer",
|
|
189
|
+
flexShrink: 0,
|
|
190
|
+
boxSizing: "border-box",
|
|
191
|
+
border: "1px solid var(--dsw-alias-border-l1, #d9dde3)",
|
|
192
|
+
background: checked ? "var(--dsw-alias-state-success-primary, #16a34a)" : "var(--dsw-alias-bg-layer-2, #f7f8fa)",
|
|
193
|
+
position: "relative"
|
|
194
|
+
},
|
|
195
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { style: {
|
|
196
|
+
position: "absolute",
|
|
197
|
+
top: 2,
|
|
198
|
+
left: checked ? 20 : 2,
|
|
199
|
+
width: 20,
|
|
200
|
+
height: 20,
|
|
201
|
+
borderRadius: 10,
|
|
202
|
+
background: "var(--dsw-alias-bg-layer-1, #fff)",
|
|
203
|
+
transition: "left 0.15s ease"
|
|
204
|
+
} })
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
function TypeTabs({ type, onChange }) {
|
|
208
|
+
const tab = (value, label) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
209
|
+
type: "button",
|
|
210
|
+
onClick: () => onChange(value),
|
|
211
|
+
style: {
|
|
212
|
+
border: "none",
|
|
213
|
+
background: "none",
|
|
214
|
+
font: "inherit",
|
|
215
|
+
fontSize: 12,
|
|
216
|
+
cursor: "pointer",
|
|
217
|
+
padding: "6px 12px",
|
|
218
|
+
whiteSpace: "nowrap",
|
|
219
|
+
color: type === value ? "var(--dsw-alias-brand-primary)" : "var(--dsw-alias-label-secondary)",
|
|
220
|
+
borderBottom: type === value ? "2px solid var(--dsw-alias-brand-primary)" : "2px solid transparent",
|
|
221
|
+
fontWeight: type === value ? 600 : 400
|
|
222
|
+
},
|
|
223
|
+
children: label
|
|
224
|
+
});
|
|
225
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
226
|
+
style: {
|
|
227
|
+
display: "flex",
|
|
228
|
+
gap: 2,
|
|
229
|
+
borderBottom: "1px solid var(--dsw-alias-border-l2)"
|
|
230
|
+
},
|
|
231
|
+
children: [
|
|
232
|
+
tab("stdio", "stdio"),
|
|
233
|
+
tab("http", "http"),
|
|
234
|
+
tab("sse", "sse")
|
|
235
|
+
]
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
function CountBadge({ n, label }) {
|
|
239
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
240
|
+
style: {
|
|
241
|
+
fontSize: 11,
|
|
242
|
+
lineHeight: "16px",
|
|
243
|
+
borderRadius: 4,
|
|
244
|
+
padding: "1px 6px",
|
|
245
|
+
border: "1px solid var(--dsw-alias-border-l3, #d9dde3)",
|
|
246
|
+
color: "var(--dsw-alias-label-secondary, #6b7280)",
|
|
247
|
+
whiteSpace: "nowrap"
|
|
248
|
+
},
|
|
249
|
+
children: [
|
|
250
|
+
n,
|
|
251
|
+
" ",
|
|
252
|
+
label
|
|
253
|
+
]
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
function SectionTabs({ tab, onChange }) {
|
|
257
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
258
|
+
style: {
|
|
259
|
+
display: "flex",
|
|
260
|
+
gap: 2,
|
|
261
|
+
borderBottom: "1px solid var(--dsw-alias-border-l2, #e5e7eb)",
|
|
262
|
+
alignItems: "flex-end"
|
|
263
|
+
},
|
|
264
|
+
children: [
|
|
265
|
+
["all", "All"],
|
|
266
|
+
["local", "Local"],
|
|
267
|
+
["remote", "Remote"],
|
|
268
|
+
["backup", "Backup & Restore"]
|
|
269
|
+
].map(([value, label]) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
270
|
+
type: "button",
|
|
271
|
+
onClick: () => onChange(value),
|
|
272
|
+
style: {
|
|
273
|
+
border: "none",
|
|
274
|
+
background: "none",
|
|
275
|
+
font: "inherit",
|
|
276
|
+
fontSize: 13,
|
|
277
|
+
cursor: "pointer",
|
|
278
|
+
padding: "7px 12px",
|
|
279
|
+
whiteSpace: "nowrap",
|
|
280
|
+
color: tab === value ? "var(--dsw-alias-brand-primary, #4f6ef7)" : "var(--dsw-alias-label-secondary, #6b7280)",
|
|
281
|
+
borderBottom: tab === value ? "2px solid var(--dsw-alias-brand-primary, #4f6ef7)" : "2px solid transparent",
|
|
282
|
+
fontWeight: tab === value ? 600 : 400
|
|
283
|
+
},
|
|
284
|
+
children: label
|
|
285
|
+
}, value))
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
function EnvRow({ row, onChange, onRemove }) {
|
|
289
|
+
const [show, setShow] = (0, react.useState)(false);
|
|
290
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
291
|
+
style: {
|
|
292
|
+
display: "flex",
|
|
293
|
+
gap: 6,
|
|
294
|
+
alignItems: "center",
|
|
295
|
+
margin: "4px 0"
|
|
296
|
+
},
|
|
297
|
+
children: [
|
|
298
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
299
|
+
value: row.key,
|
|
300
|
+
placeholder: "key",
|
|
301
|
+
onChange: (e) => onChange({
|
|
302
|
+
...row,
|
|
303
|
+
key: e.target.value
|
|
304
|
+
}),
|
|
305
|
+
style: {
|
|
306
|
+
...fieldStyle,
|
|
307
|
+
width: 130,
|
|
308
|
+
padding: "3px 6px"
|
|
309
|
+
}
|
|
310
|
+
}),
|
|
311
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
312
|
+
value: row.value,
|
|
313
|
+
type: show ? "text" : "password",
|
|
314
|
+
placeholder: "value",
|
|
315
|
+
onChange: (e) => onChange({
|
|
316
|
+
...row,
|
|
317
|
+
value: e.target.value
|
|
318
|
+
}),
|
|
319
|
+
style: {
|
|
320
|
+
...fieldStyle,
|
|
321
|
+
flex: 1,
|
|
322
|
+
padding: "3px 6px"
|
|
323
|
+
}
|
|
324
|
+
}),
|
|
325
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
326
|
+
type: "button",
|
|
327
|
+
title: show ? "hide value" : "show value",
|
|
328
|
+
style: iconBtn,
|
|
329
|
+
onClick: () => setShow(!show),
|
|
330
|
+
children: show ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EyeOffIcon, {}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EyeIcon, {})
|
|
331
|
+
}),
|
|
332
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
333
|
+
type: "button",
|
|
334
|
+
title: "delete variable",
|
|
335
|
+
style: {
|
|
336
|
+
...iconBtn,
|
|
337
|
+
color: "var(--dsw-alias-state-error-primary)"
|
|
338
|
+
},
|
|
339
|
+
onClick: onRemove,
|
|
340
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TrashIcon, {})
|
|
341
|
+
})
|
|
342
|
+
]
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
function mapToRows(map) {
|
|
346
|
+
return Object.entries(map ?? {}).map(([k, v]) => ({
|
|
347
|
+
key: k,
|
|
348
|
+
value: v
|
|
349
|
+
}));
|
|
350
|
+
}
|
|
351
|
+
function rowsToMap(rows) {
|
|
352
|
+
const out = {};
|
|
353
|
+
for (const r of rows) if (r.key.trim() !== "") out[r.key.trim()] = r.value;
|
|
354
|
+
return out;
|
|
355
|
+
}
|
|
356
|
+
/** Shared KEY=VALUE row editor (env vars for stdio, headers for http). */
|
|
357
|
+
function KeyValueEditor({ label, addLabel, map, onMapChange }) {
|
|
358
|
+
const [rows, setRows] = (0, react.useState)(() => mapToRows(map));
|
|
359
|
+
const update = (next) => {
|
|
360
|
+
setRows(next);
|
|
361
|
+
onMapChange(rowsToMap(next));
|
|
362
|
+
};
|
|
363
|
+
const paste = async () => {
|
|
364
|
+
try {
|
|
365
|
+
const text = await navigator.clipboard.readText();
|
|
366
|
+
const merged = new Map(rows.map((r) => [r.key, r.value]));
|
|
367
|
+
for (const line of text.split(/\r?\n/)) {
|
|
368
|
+
const i = line.indexOf("=");
|
|
369
|
+
if (i <= 0) continue;
|
|
370
|
+
merged.set(line.slice(0, i).trim(), line.slice(i + 1).trim());
|
|
371
|
+
}
|
|
372
|
+
update([...merged].map(([key, value]) => ({
|
|
373
|
+
key,
|
|
374
|
+
value
|
|
375
|
+
})));
|
|
376
|
+
} catch {}
|
|
377
|
+
};
|
|
378
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
379
|
+
style: { marginTop: 2 },
|
|
380
|
+
children: [
|
|
381
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
382
|
+
style: {
|
|
383
|
+
display: "flex",
|
|
384
|
+
alignItems: "center"
|
|
385
|
+
},
|
|
386
|
+
children: [
|
|
387
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
388
|
+
style: labelStyle,
|
|
389
|
+
children: label
|
|
390
|
+
}),
|
|
391
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { style: { flex: 1 } }),
|
|
392
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
393
|
+
variant: "outline",
|
|
394
|
+
size: "sm",
|
|
395
|
+
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ClipboardIcon, {}),
|
|
396
|
+
onClick: () => void paste(),
|
|
397
|
+
children: "Paste .env"
|
|
398
|
+
})
|
|
399
|
+
]
|
|
400
|
+
}),
|
|
401
|
+
rows.map((row, ri) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EnvRow, {
|
|
402
|
+
row,
|
|
403
|
+
onChange: (next) => update(rows.map((r, j) => j === ri ? next : r)),
|
|
404
|
+
onRemove: () => update(rows.filter((_, j) => j !== ri))
|
|
405
|
+
}, ri)),
|
|
406
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
407
|
+
variant: "outline",
|
|
408
|
+
size: "sm",
|
|
409
|
+
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PlusIcon, {}),
|
|
410
|
+
onClick: () => update([...rows, {
|
|
411
|
+
key: "",
|
|
412
|
+
value: ""
|
|
413
|
+
}]),
|
|
414
|
+
children: addLabel
|
|
415
|
+
})
|
|
416
|
+
]
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
function ServerCard({ server, status, index, onSave, onRemove }) {
|
|
420
|
+
const isNew = !server.id;
|
|
421
|
+
const [editing, setEditing] = (0, react.useState)(isNew);
|
|
422
|
+
const [draft, setDraft] = (0, react.useState)(server);
|
|
423
|
+
const [testing, setTesting] = (0, react.useState)(false);
|
|
424
|
+
const [testResult, setTestResult] = (0, react.useState)(null);
|
|
425
|
+
const test = async () => {
|
|
426
|
+
setTesting(true);
|
|
427
|
+
setTestResult(null);
|
|
428
|
+
try {
|
|
429
|
+
const res = await fetch("/mcp-servers/test", {
|
|
430
|
+
method: "POST",
|
|
431
|
+
headers: { "content-type": "application/json" },
|
|
432
|
+
body: JSON.stringify({ server: draft })
|
|
433
|
+
});
|
|
434
|
+
const text = await res.text();
|
|
435
|
+
if (!res.ok) throw new Error("HTTP " + res.status);
|
|
436
|
+
let d = {};
|
|
437
|
+
try {
|
|
438
|
+
d = JSON.parse(text);
|
|
439
|
+
} catch {
|
|
440
|
+
throw new Error("empty or invalid response from server");
|
|
441
|
+
}
|
|
442
|
+
setTestResult({
|
|
443
|
+
ok: d.ok === true,
|
|
444
|
+
error: d.error,
|
|
445
|
+
tools: d.tools
|
|
446
|
+
});
|
|
447
|
+
} catch (e) {
|
|
448
|
+
setTestResult({
|
|
449
|
+
ok: false,
|
|
450
|
+
error: String(e instanceof Error ? e.message : e)
|
|
451
|
+
});
|
|
452
|
+
} finally {
|
|
453
|
+
setTesting(false);
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
const set = (patch) => setDraft({
|
|
457
|
+
...draft,
|
|
458
|
+
...patch
|
|
459
|
+
});
|
|
460
|
+
const startEdit = () => {
|
|
461
|
+
setDraft(server);
|
|
462
|
+
setEditing(true);
|
|
463
|
+
};
|
|
464
|
+
const cancel = () => {
|
|
465
|
+
setDraft(server);
|
|
466
|
+
setEditing(false);
|
|
467
|
+
};
|
|
468
|
+
if (!editing) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
469
|
+
className: "dshmcp-card",
|
|
470
|
+
style: {
|
|
471
|
+
...card,
|
|
472
|
+
animationDelay: `${Math.min(index ?? 0, 6) * 40}ms`
|
|
473
|
+
},
|
|
474
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
475
|
+
style: {
|
|
476
|
+
display: "flex",
|
|
477
|
+
alignItems: "center",
|
|
478
|
+
gap: 10
|
|
479
|
+
},
|
|
480
|
+
children: [
|
|
481
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatusDot, { status }),
|
|
482
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
483
|
+
style: {
|
|
484
|
+
flex: "0 1 auto",
|
|
485
|
+
fontWeight: 500,
|
|
486
|
+
fontSize: 13,
|
|
487
|
+
color: "var(--dsw-alias-label-primary)",
|
|
488
|
+
...ellipsis
|
|
489
|
+
},
|
|
490
|
+
children: server.id || "(new server)"
|
|
491
|
+
}),
|
|
492
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TransportIcon, { type: server.type }),
|
|
493
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { style: { flex: 1 } }),
|
|
494
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
495
|
+
variant: "outline",
|
|
496
|
+
size: "sm",
|
|
497
|
+
onClick: startEdit,
|
|
498
|
+
children: "Edit"
|
|
499
|
+
})
|
|
500
|
+
]
|
|
501
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
502
|
+
style: {
|
|
503
|
+
fontSize: 12,
|
|
504
|
+
color: "var(--dsw-alias-label-tertiary)",
|
|
505
|
+
...ellipsis
|
|
506
|
+
},
|
|
507
|
+
children: server.type === "stdio" ? [server.command, ...server.args ?? []].filter(Boolean).join(" ") : server.url || "—"
|
|
508
|
+
})]
|
|
509
|
+
});
|
|
510
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
511
|
+
className: "dshmcp-card",
|
|
512
|
+
style: {
|
|
513
|
+
...card,
|
|
514
|
+
animationDelay: `${Math.min(index ?? 0, 6) * 40}ms`
|
|
515
|
+
},
|
|
516
|
+
children: [
|
|
517
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
518
|
+
style: {
|
|
519
|
+
display: "flex",
|
|
520
|
+
alignItems: "center",
|
|
521
|
+
gap: 10
|
|
522
|
+
},
|
|
523
|
+
children: [
|
|
524
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatusDot, { status }),
|
|
525
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
526
|
+
value: draft.id,
|
|
527
|
+
placeholder: "server id",
|
|
528
|
+
onChange: (e) => set({ id: e.target.value }),
|
|
529
|
+
style: {
|
|
530
|
+
...fieldStyle,
|
|
531
|
+
width: 200
|
|
532
|
+
}
|
|
533
|
+
}),
|
|
534
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TransportIcon, { type: draft.type }),
|
|
535
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { style: { flex: 1 } }),
|
|
536
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Switch, {
|
|
537
|
+
checked: draft.enabled,
|
|
538
|
+
onChange: (v) => set({ enabled: v })
|
|
539
|
+
})
|
|
540
|
+
]
|
|
541
|
+
}),
|
|
542
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TypeTabs, {
|
|
543
|
+
type: draft.type,
|
|
544
|
+
onChange: (t) => set(t !== "stdio" ? {
|
|
545
|
+
type: t,
|
|
546
|
+
command: "",
|
|
547
|
+
args: [],
|
|
548
|
+
env: {}
|
|
549
|
+
} : {
|
|
550
|
+
type: t,
|
|
551
|
+
url: "",
|
|
552
|
+
headers: {}
|
|
553
|
+
})
|
|
554
|
+
}),
|
|
555
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
556
|
+
className: "dshmcp-edit",
|
|
557
|
+
style: {
|
|
558
|
+
display: "flex",
|
|
559
|
+
flexDirection: "column"
|
|
560
|
+
},
|
|
561
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
562
|
+
label: draft.type === "stdio" ? "command" : "url",
|
|
563
|
+
children: draft.type === "stdio" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
|
|
564
|
+
value: [draft.command ?? "", ...draft.args ?? []].join("\n"),
|
|
565
|
+
rows: 4,
|
|
566
|
+
placeholder: "npx\n-y\n@some/mcp-server",
|
|
567
|
+
onChange: (e) => {
|
|
568
|
+
const lines = e.target.value.split(/\r?\n/);
|
|
569
|
+
set({
|
|
570
|
+
command: lines[0] ?? "",
|
|
571
|
+
args: lines.slice(1).map((s) => s.trim()).filter(Boolean)
|
|
572
|
+
});
|
|
573
|
+
},
|
|
574
|
+
style: fieldStyle
|
|
575
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
576
|
+
value: draft.url ?? "",
|
|
577
|
+
placeholder: "https://example.com/mcp",
|
|
578
|
+
onChange: (e) => set({ url: e.target.value }),
|
|
579
|
+
style: fieldStyle
|
|
580
|
+
})
|
|
581
|
+
}), draft.type === "stdio" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(KeyValueEditor, {
|
|
582
|
+
label: "Environment Variables",
|
|
583
|
+
addLabel: "Add environment variable",
|
|
584
|
+
map: draft.env ?? {},
|
|
585
|
+
onMapChange: (m) => set({ env: m })
|
|
586
|
+
}, "env") : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(KeyValueEditor, {
|
|
587
|
+
label: "Headers",
|
|
588
|
+
addLabel: "Add header",
|
|
589
|
+
map: draft.headers ?? {},
|
|
590
|
+
onMapChange: (m) => set({ headers: m })
|
|
591
|
+
}, "headers")]
|
|
592
|
+
}),
|
|
593
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
594
|
+
style: {
|
|
595
|
+
display: "flex",
|
|
596
|
+
justifyContent: "flex-end",
|
|
597
|
+
gap: 8,
|
|
598
|
+
marginTop: 4,
|
|
599
|
+
alignItems: "center"
|
|
600
|
+
},
|
|
601
|
+
children: [
|
|
602
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
603
|
+
variant: "outline",
|
|
604
|
+
size: "sm",
|
|
605
|
+
disabled: testing,
|
|
606
|
+
onClick: () => void test(),
|
|
607
|
+
children: testing ? "Testing…" : "Test"
|
|
608
|
+
}),
|
|
609
|
+
testResult !== null ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
610
|
+
style: {
|
|
611
|
+
fontSize: 12,
|
|
612
|
+
color: testResult.ok ? "var(--dsw-alias-state-success-primary, #16a34a)" : "var(--dsw-alias-state-error-primary, #dc2626)"
|
|
613
|
+
},
|
|
614
|
+
children: testResult.ok ? `OK · ${testResult.tools} tools` : testResult.error ?? "failed"
|
|
615
|
+
}) : null,
|
|
616
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { style: { flex: 1 } }),
|
|
617
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
618
|
+
variant: "outline",
|
|
619
|
+
size: "sm",
|
|
620
|
+
onClick: onRemove,
|
|
621
|
+
style: { color: "var(--dsw-alias-state-error-primary)" },
|
|
622
|
+
children: "Delete"
|
|
623
|
+
}),
|
|
624
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
625
|
+
variant: "outline",
|
|
626
|
+
size: "sm",
|
|
627
|
+
onClick: () => {
|
|
628
|
+
if (isNew) onRemove();
|
|
629
|
+
else cancel();
|
|
630
|
+
},
|
|
631
|
+
children: "Cancel"
|
|
632
|
+
}),
|
|
633
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
634
|
+
variant: "primary",
|
|
635
|
+
size: "sm",
|
|
636
|
+
onClick: () => {
|
|
637
|
+
onSave(draft);
|
|
638
|
+
setEditing(false);
|
|
639
|
+
},
|
|
640
|
+
style: {
|
|
641
|
+
height: 28,
|
|
642
|
+
minHeight: 28,
|
|
643
|
+
boxSizing: "border-box",
|
|
644
|
+
display: "inline-flex",
|
|
645
|
+
alignItems: "center"
|
|
646
|
+
},
|
|
647
|
+
children: "Save"
|
|
648
|
+
})
|
|
649
|
+
]
|
|
650
|
+
})
|
|
651
|
+
]
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
function McpServersSection() {
|
|
655
|
+
const [servers, setServers] = (0, react.useState)(null);
|
|
656
|
+
const [cardKeys, setCardKeys] = (0, react.useState)([]);
|
|
657
|
+
const [status, setStatus] = (0, react.useState)({});
|
|
658
|
+
const [webdavUrl, setWebdavUrl] = (0, react.useState)("");
|
|
659
|
+
const [webdavUser, setWebdavUser] = (0, react.useState)("");
|
|
660
|
+
const [webdavPass, setWebdavPass] = (0, react.useState)("");
|
|
661
|
+
const [webdavDaily, setWebdavDaily] = (0, react.useState)(false);
|
|
662
|
+
const [error, setError] = (0, react.useState)("");
|
|
663
|
+
const [notice, setNotice] = (0, react.useState)("");
|
|
664
|
+
const [busy, setBusy] = (0, react.useState)(false);
|
|
665
|
+
const [tab, setTab] = (0, react.useState)("all");
|
|
666
|
+
const [preview, setPreview] = (0, react.useState)(false);
|
|
667
|
+
const restoreRef = (0, react.useRef)(null);
|
|
668
|
+
const keyRef = (0, react.useRef)(0);
|
|
669
|
+
const newKey = () => `new-${++keyRef.current}`;
|
|
670
|
+
const load = (alive = true) => {
|
|
671
|
+
return fetch("/mcp-servers/config", { cache: "no-store" }).then((r) => {
|
|
672
|
+
if (!r.ok) throw new Error("HTTP " + r.status);
|
|
673
|
+
return r.json();
|
|
674
|
+
}).then((d) => {
|
|
675
|
+
if (!alive) return;
|
|
676
|
+
const list = Array.isArray(d?.servers) ? d.servers : [];
|
|
677
|
+
setServers(list);
|
|
678
|
+
setCardKeys(list.map((s) => s.id || newKey()));
|
|
679
|
+
setStatus(d?.status ?? {});
|
|
680
|
+
if (typeof d?.webdavUrl === "string") setWebdavUrl(d.webdavUrl);
|
|
681
|
+
if (typeof d?.webdavUser === "string") setWebdavUser(d.webdavUser);
|
|
682
|
+
if (typeof d?.webdavDaily === "boolean") setWebdavDaily(d.webdavDaily);
|
|
683
|
+
});
|
|
684
|
+
};
|
|
685
|
+
(0, react.useEffect)(() => {
|
|
686
|
+
let alive = true;
|
|
687
|
+
load(alive).catch((e) => {
|
|
688
|
+
if (alive) setError(String(e));
|
|
689
|
+
});
|
|
690
|
+
return () => {
|
|
691
|
+
alive = false;
|
|
692
|
+
};
|
|
693
|
+
}, []);
|
|
694
|
+
(0, react.useEffect)(() => {
|
|
695
|
+
const id = setInterval(() => {
|
|
696
|
+
refreshStatus().catch(() => {});
|
|
697
|
+
}, 5e3);
|
|
698
|
+
return () => clearInterval(id);
|
|
699
|
+
}, []);
|
|
700
|
+
const refreshStatus = async () => {
|
|
701
|
+
const res = await fetch("/mcp-servers/config", { cache: "no-store" });
|
|
702
|
+
if (!res.ok) throw new Error("HTTP " + res.status);
|
|
703
|
+
const d = await res.json();
|
|
704
|
+
setStatus(d?.status ?? {});
|
|
705
|
+
};
|
|
706
|
+
const persist = async (list) => {
|
|
707
|
+
setBusy(true);
|
|
708
|
+
setNotice("");
|
|
709
|
+
setError("");
|
|
710
|
+
try {
|
|
711
|
+
const body = {
|
|
712
|
+
servers: list,
|
|
713
|
+
webdavUrl,
|
|
714
|
+
webdavUser,
|
|
715
|
+
webdavDaily
|
|
716
|
+
};
|
|
717
|
+
if (webdavPass !== "") body.webdavPass = webdavPass;
|
|
718
|
+
const res = await fetch("/mcp-servers/config", {
|
|
719
|
+
method: "POST",
|
|
720
|
+
headers: { "content-type": "application/json" },
|
|
721
|
+
body: JSON.stringify(body)
|
|
722
|
+
});
|
|
723
|
+
if (!res.ok) throw new Error("HTTP " + res.status + ": " + await res.text());
|
|
724
|
+
setNotice("Saved");
|
|
725
|
+
await refreshStatus();
|
|
726
|
+
} catch (e) {
|
|
727
|
+
setError(String(e));
|
|
728
|
+
} finally {
|
|
729
|
+
setBusy(false);
|
|
730
|
+
}
|
|
731
|
+
};
|
|
732
|
+
if (servers === null) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
733
|
+
style: {
|
|
734
|
+
padding: 8,
|
|
735
|
+
...muted
|
|
736
|
+
},
|
|
737
|
+
children: "Loading…"
|
|
738
|
+
});
|
|
739
|
+
const saveOne = (i, next) => {
|
|
740
|
+
const copy = servers.slice();
|
|
741
|
+
copy[i] = next;
|
|
742
|
+
setServers(copy);
|
|
743
|
+
persist(copy);
|
|
744
|
+
};
|
|
745
|
+
const addServer = () => {
|
|
746
|
+
setServers([{ ...EMPTY }, ...servers]);
|
|
747
|
+
setCardKeys([newKey(), ...cardKeys]);
|
|
748
|
+
};
|
|
749
|
+
const removeOne = (i) => {
|
|
750
|
+
const copy = servers.filter((_, j) => j !== i);
|
|
751
|
+
setServers(copy);
|
|
752
|
+
setCardKeys(cardKeys.filter((_, j) => j !== i));
|
|
753
|
+
persist(copy);
|
|
754
|
+
};
|
|
755
|
+
const backup = () => {
|
|
756
|
+
const blob = new Blob([JSON.stringify({
|
|
757
|
+
version: 1,
|
|
758
|
+
servers
|
|
759
|
+
}, null, 2)], { type: "application/json" });
|
|
760
|
+
const url = URL.createObjectURL(blob);
|
|
761
|
+
const a = document.createElement("a");
|
|
762
|
+
a.href = url;
|
|
763
|
+
a.download = "mcp-servers-backup.json";
|
|
764
|
+
a.click();
|
|
765
|
+
URL.revokeObjectURL(url);
|
|
766
|
+
};
|
|
767
|
+
const onRestoreFile = async (e) => {
|
|
768
|
+
const file = e.target.files?.[0];
|
|
769
|
+
e.target.value = "";
|
|
770
|
+
if (!file) return;
|
|
771
|
+
setBusy(true);
|
|
772
|
+
setNotice("");
|
|
773
|
+
setError("");
|
|
774
|
+
try {
|
|
775
|
+
const parsed = JSON.parse(await file.text());
|
|
776
|
+
if (!Array.isArray(parsed.servers)) throw new Error("backup has no servers list");
|
|
777
|
+
setServers(parsed.servers);
|
|
778
|
+
setCardKeys(parsed.servers.map((s) => s.id || newKey()));
|
|
779
|
+
await persist(parsed.servers);
|
|
780
|
+
setNotice("Backup restored.");
|
|
781
|
+
} catch (err) {
|
|
782
|
+
setError(String(err instanceof Error ? err.message : err));
|
|
783
|
+
} finally {
|
|
784
|
+
setBusy(false);
|
|
785
|
+
}
|
|
786
|
+
};
|
|
787
|
+
const webdav = async (direction) => {
|
|
788
|
+
setBusy(true);
|
|
789
|
+
setNotice("");
|
|
790
|
+
setError("");
|
|
791
|
+
try {
|
|
792
|
+
const body = {
|
|
793
|
+
url: webdavUrl,
|
|
794
|
+
username: webdavUser,
|
|
795
|
+
password: webdavPass,
|
|
796
|
+
direction: direction === "push" ? "upload" : "download"
|
|
797
|
+
};
|
|
798
|
+
if (direction === "push") body.body = JSON.stringify({
|
|
799
|
+
version: 1,
|
|
800
|
+
servers
|
|
801
|
+
});
|
|
802
|
+
const res = await fetch("/mcp-servers/webdav", {
|
|
803
|
+
method: "POST",
|
|
804
|
+
headers: { "content-type": "application/json" },
|
|
805
|
+
body: JSON.stringify(body)
|
|
806
|
+
});
|
|
807
|
+
if (!res.ok) throw new Error("HTTP " + res.status + ": " + await res.text());
|
|
808
|
+
const d = await res.json();
|
|
809
|
+
if (direction === "pull") {
|
|
810
|
+
const parsed = JSON.parse(d.body ?? "");
|
|
811
|
+
if (!Array.isArray(parsed.servers)) throw new Error("backup has no servers list");
|
|
812
|
+
setServers(parsed.servers);
|
|
813
|
+
setCardKeys(parsed.servers.map((s) => s.id || newKey()));
|
|
814
|
+
await persist(parsed.servers);
|
|
815
|
+
}
|
|
816
|
+
setNotice(direction === "push" ? "Backup pushed to WebDAV." : "Backup pulled from WebDAV.");
|
|
817
|
+
} catch (err) {
|
|
818
|
+
setError(String(err instanceof Error ? err.message : err));
|
|
819
|
+
} finally {
|
|
820
|
+
setBusy(false);
|
|
821
|
+
}
|
|
822
|
+
};
|
|
823
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
824
|
+
className: "dshmcp-section",
|
|
825
|
+
style: {
|
|
826
|
+
height: "100%",
|
|
827
|
+
display: "flex",
|
|
828
|
+
flexDirection: "column",
|
|
829
|
+
minWidth: 0
|
|
830
|
+
},
|
|
831
|
+
children: [
|
|
832
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("style", { children: `
|
|
833
|
+
@keyframes dshmcp-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
|
|
834
|
+
.dshmcp-section { animation: dshmcp-in 0.3s ease both; }
|
|
835
|
+
.dshmcp-card {
|
|
836
|
+
animation: dshmcp-in 0.28s cubic-bezier(0.2, 0.7, 0.3, 1) both;
|
|
837
|
+
transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
|
|
838
|
+
}
|
|
839
|
+
.dshmcp-card:hover {
|
|
840
|
+
border-color: var(--dsw-alias-border-l1);
|
|
841
|
+
transform: translateY(-1px);
|
|
842
|
+
box-shadow: 0 2px 10px rgb(0 0 0 / 0.06);
|
|
843
|
+
}
|
|
844
|
+
.dshmcp-edit { animation: dshmcp-in 0.22s ease both; }
|
|
845
|
+
` }),
|
|
846
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
847
|
+
style: {
|
|
848
|
+
display: "flex",
|
|
849
|
+
alignItems: "center",
|
|
850
|
+
gap: 8,
|
|
851
|
+
padding: "4px 4px 8px"
|
|
852
|
+
},
|
|
853
|
+
children: [
|
|
854
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
|
|
855
|
+
style: {
|
|
856
|
+
margin: 0,
|
|
857
|
+
fontSize: 16,
|
|
858
|
+
lineHeight: "24px",
|
|
859
|
+
fontWeight: 500,
|
|
860
|
+
color: "var(--dsw-alias-label-primary)"
|
|
861
|
+
},
|
|
862
|
+
children: "MCP Servers"
|
|
863
|
+
}),
|
|
864
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CountBadge, {
|
|
865
|
+
n: servers.filter((s) => s.type === "stdio").length,
|
|
866
|
+
label: "Local"
|
|
867
|
+
}),
|
|
868
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CountBadge, {
|
|
869
|
+
n: servers.filter((s) => s.type === "http").length,
|
|
870
|
+
label: "HTTP"
|
|
871
|
+
}),
|
|
872
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CountBadge, {
|
|
873
|
+
n: servers.filter((s) => s.type === "sse").length,
|
|
874
|
+
label: "SSE"
|
|
875
|
+
}),
|
|
876
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { style: { flex: 1 } }),
|
|
877
|
+
notice ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
878
|
+
style: {
|
|
879
|
+
fontSize: 12,
|
|
880
|
+
color: "var(--dsw-alias-state-success-primary)"
|
|
881
|
+
},
|
|
882
|
+
children: notice
|
|
883
|
+
}) : null,
|
|
884
|
+
error ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
885
|
+
style: {
|
|
886
|
+
fontSize: 12,
|
|
887
|
+
color: "var(--dsw-alias-state-error-primary)"
|
|
888
|
+
},
|
|
889
|
+
children: error
|
|
890
|
+
}) : null,
|
|
891
|
+
tab !== "backup" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
892
|
+
variant: "outline",
|
|
893
|
+
size: "sm",
|
|
894
|
+
disabled: busy,
|
|
895
|
+
onClick: addServer,
|
|
896
|
+
children: "Add server"
|
|
897
|
+
}) : null
|
|
898
|
+
]
|
|
899
|
+
}),
|
|
900
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SectionTabs, {
|
|
901
|
+
tab,
|
|
902
|
+
onChange: setTab
|
|
903
|
+
}),
|
|
904
|
+
tab === "backup" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
905
|
+
style: {
|
|
906
|
+
flex: 1,
|
|
907
|
+
overflowY: "auto",
|
|
908
|
+
overflowX: "hidden",
|
|
909
|
+
padding: "12px 4px 24px",
|
|
910
|
+
display: "flex",
|
|
911
|
+
flexDirection: "column",
|
|
912
|
+
gap: 12,
|
|
913
|
+
maxWidth: 720
|
|
914
|
+
},
|
|
915
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
916
|
+
className: "dshmcp-card",
|
|
917
|
+
style: card,
|
|
918
|
+
children: [
|
|
919
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
920
|
+
style: {
|
|
921
|
+
fontWeight: 500,
|
|
922
|
+
fontSize: 13,
|
|
923
|
+
color: "var(--dsw-alias-label-primary)"
|
|
924
|
+
},
|
|
925
|
+
children: "Local file"
|
|
926
|
+
}),
|
|
927
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
928
|
+
style: {
|
|
929
|
+
fontSize: 12,
|
|
930
|
+
lineHeight: "18px",
|
|
931
|
+
color: "var(--dsw-alias-label-tertiary, #8b93a1)"
|
|
932
|
+
},
|
|
933
|
+
children: "Export the current MCP server configuration — every server, its endpoint, environment variables and headers — to a JSON file, or import one back. Use it to back up your setup, share it with a teammate, or move it to another machine."
|
|
934
|
+
}),
|
|
935
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
936
|
+
style: {
|
|
937
|
+
display: "flex",
|
|
938
|
+
alignItems: "center",
|
|
939
|
+
gap: 8,
|
|
940
|
+
marginTop: 2
|
|
941
|
+
},
|
|
942
|
+
children: [
|
|
943
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
944
|
+
variant: "outline",
|
|
945
|
+
size: "sm",
|
|
946
|
+
disabled: busy,
|
|
947
|
+
onClick: backup,
|
|
948
|
+
children: "Export backup"
|
|
949
|
+
}),
|
|
950
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
951
|
+
variant: "outline",
|
|
952
|
+
size: "sm",
|
|
953
|
+
disabled: busy,
|
|
954
|
+
onClick: () => restoreRef.current?.click(),
|
|
955
|
+
children: "Import"
|
|
956
|
+
}),
|
|
957
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
958
|
+
variant: "outline",
|
|
959
|
+
size: "sm",
|
|
960
|
+
disabled: busy,
|
|
961
|
+
onClick: () => setPreview(!preview),
|
|
962
|
+
children: preview ? "Hide preview" : "Preview"
|
|
963
|
+
}),
|
|
964
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
965
|
+
ref: restoreRef,
|
|
966
|
+
type: "file",
|
|
967
|
+
accept: "application/json,.json",
|
|
968
|
+
style: { display: "none" },
|
|
969
|
+
onChange: onRestoreFile
|
|
970
|
+
})
|
|
971
|
+
]
|
|
972
|
+
}),
|
|
973
|
+
preview ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
|
|
974
|
+
style: {
|
|
975
|
+
margin: 0,
|
|
976
|
+
fontSize: 11,
|
|
977
|
+
lineHeight: "16px",
|
|
978
|
+
padding: 8,
|
|
979
|
+
borderRadius: 6,
|
|
980
|
+
overflow: "auto",
|
|
981
|
+
maxHeight: 240,
|
|
982
|
+
background: "var(--dsw-alias-bg-layer-2, #f7f8fa)",
|
|
983
|
+
border: "1px solid var(--dsw-alias-border-l1, #d9dde3)",
|
|
984
|
+
color: "var(--dsw-alias-label-primary, #1f2328)"
|
|
985
|
+
},
|
|
986
|
+
children: JSON.stringify({
|
|
987
|
+
version: 1,
|
|
988
|
+
servers
|
|
989
|
+
}, null, 2)
|
|
990
|
+
}) : null
|
|
991
|
+
]
|
|
992
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
993
|
+
className: "dshmcp-card",
|
|
994
|
+
style: card,
|
|
995
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
996
|
+
style: {
|
|
997
|
+
fontWeight: 500,
|
|
998
|
+
fontSize: 13,
|
|
999
|
+
color: "var(--dsw-alias-label-primary)"
|
|
1000
|
+
},
|
|
1001
|
+
children: "WebDAV"
|
|
1002
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1003
|
+
style: {
|
|
1004
|
+
display: "flex",
|
|
1005
|
+
flexDirection: "column",
|
|
1006
|
+
gap: 8
|
|
1007
|
+
},
|
|
1008
|
+
children: [
|
|
1009
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1010
|
+
value: webdavUrl,
|
|
1011
|
+
placeholder: "https://webdav…/mcp-backup.json",
|
|
1012
|
+
onChange: (e) => setWebdavUrl(e.target.value),
|
|
1013
|
+
style: fieldStyle
|
|
1014
|
+
}),
|
|
1015
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1016
|
+
value: webdavUser,
|
|
1017
|
+
placeholder: "user",
|
|
1018
|
+
onChange: (e) => setWebdavUser(e.target.value),
|
|
1019
|
+
style: fieldStyle
|
|
1020
|
+
}),
|
|
1021
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1022
|
+
value: webdavPass,
|
|
1023
|
+
type: "password",
|
|
1024
|
+
placeholder: "password",
|
|
1025
|
+
onChange: (e) => setWebdavPass(e.target.value),
|
|
1026
|
+
style: fieldStyle
|
|
1027
|
+
}),
|
|
1028
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1029
|
+
style: {
|
|
1030
|
+
display: "flex",
|
|
1031
|
+
alignItems: "center",
|
|
1032
|
+
gap: 8
|
|
1033
|
+
},
|
|
1034
|
+
children: [
|
|
1035
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
1036
|
+
variant: "outline",
|
|
1037
|
+
size: "sm",
|
|
1038
|
+
disabled: busy,
|
|
1039
|
+
onClick: () => void webdav("push"),
|
|
1040
|
+
children: "Push"
|
|
1041
|
+
}),
|
|
1042
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
1043
|
+
variant: "outline",
|
|
1044
|
+
size: "sm",
|
|
1045
|
+
disabled: busy,
|
|
1046
|
+
onClick: () => void webdav("pull"),
|
|
1047
|
+
children: "Pull"
|
|
1048
|
+
}),
|
|
1049
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { style: { flex: 1 } }),
|
|
1050
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1051
|
+
style: {
|
|
1052
|
+
fontSize: 12,
|
|
1053
|
+
color: "var(--dsw-alias-label-secondary, #6b7280)"
|
|
1054
|
+
},
|
|
1055
|
+
children: "Back up daily at 12:00 PM"
|
|
1056
|
+
}),
|
|
1057
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Switch, {
|
|
1058
|
+
checked: webdavDaily,
|
|
1059
|
+
onChange: (v) => {
|
|
1060
|
+
setWebdavDaily(v);
|
|
1061
|
+
persist(servers);
|
|
1062
|
+
}
|
|
1063
|
+
})
|
|
1064
|
+
]
|
|
1065
|
+
})
|
|
1066
|
+
]
|
|
1067
|
+
})]
|
|
1068
|
+
})]
|
|
1069
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1070
|
+
style: {
|
|
1071
|
+
flex: 1,
|
|
1072
|
+
overflowY: "auto",
|
|
1073
|
+
overflowX: "hidden",
|
|
1074
|
+
padding: "12px 4px 24px",
|
|
1075
|
+
display: "grid",
|
|
1076
|
+
gridTemplateColumns: "repeat(auto-fill, minmax(340px, 1fr))",
|
|
1077
|
+
gap: 12,
|
|
1078
|
+
alignContent: "start"
|
|
1079
|
+
},
|
|
1080
|
+
children: servers.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1081
|
+
style: {
|
|
1082
|
+
...card,
|
|
1083
|
+
...muted
|
|
1084
|
+
},
|
|
1085
|
+
children: "No MCP servers configured. Add one to expose its tools."
|
|
1086
|
+
}) : servers.map((s, i) => ({
|
|
1087
|
+
s,
|
|
1088
|
+
i
|
|
1089
|
+
})).filter(({ s }) => tab === "local" ? s.type === "stdio" : tab === "remote" ? s.type !== "stdio" : true).map(({ s, i }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ServerCard, {
|
|
1090
|
+
server: s,
|
|
1091
|
+
status: status[s.id],
|
|
1092
|
+
index: i,
|
|
1093
|
+
onSave: (next) => saveOne(i, next),
|
|
1094
|
+
onRemove: () => removeOne(i)
|
|
1095
|
+
}, cardKeys[i] ?? s.id))
|
|
1096
|
+
})
|
|
1097
|
+
]
|
|
1098
|
+
});
|
|
1099
|
+
}
|
|
1100
|
+
/** Shows a render crash instead of letting it blank the whole settings panel. */
|
|
1101
|
+
var SectionBoundary = class extends react.Component {
|
|
1102
|
+
state = { error: null };
|
|
1103
|
+
static getDerivedStateFromError(error) {
|
|
1104
|
+
return { error };
|
|
1105
|
+
}
|
|
1106
|
+
render() {
|
|
1107
|
+
if (this.state.error !== null) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1108
|
+
style: {
|
|
1109
|
+
padding: 12,
|
|
1110
|
+
fontSize: 12,
|
|
1111
|
+
color: "var(--dsw-alias-state-error-primary)",
|
|
1112
|
+
whiteSpace: "pre-wrap"
|
|
1113
|
+
},
|
|
1114
|
+
children: ["MCP Servers crashed: ", String(this.state.error.stack ?? this.state.error)]
|
|
1115
|
+
});
|
|
1116
|
+
return this.props.children;
|
|
1117
|
+
}
|
|
1118
|
+
};
|
|
1119
|
+
function apply(ctx) {
|
|
1120
|
+
ctx.slots.inject("settings.section", () => ctx.slots.register({
|
|
1121
|
+
name: "settings.section",
|
|
1122
|
+
id: "mcp-servers",
|
|
1123
|
+
order: 50,
|
|
1124
|
+
label: () => "MCP Servers"
|
|
1125
|
+
}, () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SectionBoundary, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(McpServersSection, {}) })));
|
|
1126
|
+
}
|
|
1127
|
+
//#endregion
|
|
1128
|
+
exports.apply = apply;
|
|
1129
|
+
exports.inject = inject;
|
|
1130
|
+
exports.name = name;
|
|
1131
|
+
return module.exports;
|
|
1132
|
+
}
|
|
1133
|
+
});
|