@eum-agent/integration-mcp 1.0.0 → 1.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/dist/index.js +1439 -220
- package/package.json +7 -5
- package/ui/ui.js +219 -144
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"en-US": "MCP Tool Integration",
|
|
5
5
|
"zh-CN": "MCP 工具接入"
|
|
6
6
|
},
|
|
7
|
-
"version": "1.
|
|
7
|
+
"version": "1.1.0",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"description": "Tools, resources and prompts from Model Context Protocol servers",
|
|
10
10
|
"license": "MIT",
|
|
@@ -19,12 +19,14 @@
|
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@modelcontextprotocol/sdk": "1.30.1",
|
|
22
|
-
"zod": "^4.4.3"
|
|
22
|
+
"zod": "^4.4.3",
|
|
23
|
+
"ajv": "8.20.0",
|
|
24
|
+
"ajv-formats": "3.0.1"
|
|
23
25
|
},
|
|
24
26
|
"devDependencies": {
|
|
25
27
|
"@eum-agent/container": "1.0.0",
|
|
26
28
|
"@eum-agent/kernel": "1.0.0",
|
|
27
|
-
"@eum-agent/plugin": "1.
|
|
29
|
+
"@eum-agent/plugin": "1.1.0",
|
|
28
30
|
"@eum-agent/runtime": "1.0.0",
|
|
29
31
|
"@types/react": "^19.2.18",
|
|
30
32
|
"@types/react-dom": "^19.2.5",
|
|
@@ -42,8 +44,8 @@
|
|
|
42
44
|
"dependencies": {},
|
|
43
45
|
"kind": "extension",
|
|
44
46
|
"foundationDependencies": {
|
|
45
|
-
"@eum-agent/infra-local": "1.0.
|
|
46
|
-
"@eum-agent/storage-sqlite": "1.
|
|
47
|
+
"@eum-agent/infra-local": "1.0.1",
|
|
48
|
+
"@eum-agent/storage-sqlite": "1.1.0"
|
|
47
49
|
}
|
|
48
50
|
},
|
|
49
51
|
"scripts": {
|
package/ui/ui.js
CHANGED
|
@@ -1,88 +1,5 @@
|
|
|
1
1
|
import { useCallback, useEffect, useId, useRef, useState, useSyncExternalStore } from "react";
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
//#region src/tool-names.ts
|
|
4
|
-
/** Canonical names shared by tool registration and browser presentation. */
|
|
5
|
-
var TOOL_NAMES = [
|
|
6
|
-
"mcp_server_list",
|
|
7
|
-
"mcp_server_create",
|
|
8
|
-
"mcp_server_update",
|
|
9
|
-
"mcp_server_set_selected"
|
|
10
|
-
];
|
|
11
|
-
//#endregion
|
|
12
|
-
//#region src/ui/metadata.ts
|
|
13
|
-
var CATALOGUES$1 = {
|
|
14
|
-
"en-US": {
|
|
15
|
-
section: "Built-in plugins",
|
|
16
|
-
servers: "MCP servers",
|
|
17
|
-
group: "MCP",
|
|
18
|
-
mcp_server_list: "Inspect MCP servers",
|
|
19
|
-
mcp_server_create: "Add MCP server",
|
|
20
|
-
mcp_server_update: "Edit MCP server",
|
|
21
|
-
mcp_server_set_selected: "Select MCP server"
|
|
22
|
-
},
|
|
23
|
-
"zh-CN": {
|
|
24
|
-
section: "内置插件",
|
|
25
|
-
servers: "MCP 服务器",
|
|
26
|
-
group: "MCP",
|
|
27
|
-
mcp_server_list: "查看 MCP 服务器",
|
|
28
|
-
mcp_server_create: "添加 MCP 服务器",
|
|
29
|
-
mcp_server_update: "修改 MCP 服务器",
|
|
30
|
-
mcp_server_set_selected: "选用 MCP 服务器"
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
var names = new Set(TOOL_NAMES);
|
|
34
|
-
/** Registers presentation facets with the same activation lifetime as the tools. */
|
|
35
|
-
function registerMetadata(ctx) {
|
|
36
|
-
ctx.i18n.register(CATALOGUES$1, "en-US");
|
|
37
|
-
ctx.i18n.contribute(Object.fromEntries(Object.entries(CATALOGUES$1).map(([language, catalogue]) => [language, Object.fromEntries([...names].map((tool) => [`transcript.actions.${tool}`, catalogue[tool] ?? tool]))])), "en-US");
|
|
38
|
-
ctx.slots.register("chat.tool.presentation", {
|
|
39
|
-
id: "tool-metadata",
|
|
40
|
-
describe: ({ call }) => {
|
|
41
|
-
if (!(names.has(call.name) || call.name === "mcp_resource_read" || /^mcp_([a-z0-9][a-z0-9-]{0,23})_(.+)$/.test(call.name))) return void 0;
|
|
42
|
-
const input = call.input !== null && typeof call.input === "object" ? call.input : {};
|
|
43
|
-
const summary = [
|
|
44
|
-
"path",
|
|
45
|
-
"url",
|
|
46
|
-
"query",
|
|
47
|
-
"command",
|
|
48
|
-
"skill",
|
|
49
|
-
"id",
|
|
50
|
-
"name",
|
|
51
|
-
"task",
|
|
52
|
-
"prompt"
|
|
53
|
-
].flatMap((key) => typeof input[key] === "string" ? [input[key]] : []).slice(0, 2).join(" · ").replace(/\s+/g, " ").slice(0, 240);
|
|
54
|
-
return {
|
|
55
|
-
label: names.has(call.name) ? ctx.i18n.t(call.name) : call.name,
|
|
56
|
-
icon: "hammer",
|
|
57
|
-
summary
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
ctx.slots.register("shell.tools.group", {
|
|
62
|
-
id: "tool-groups",
|
|
63
|
-
describe: (tool) => {
|
|
64
|
-
if (tool.plugin !== ctx.plugin) return void 0;
|
|
65
|
-
const slug = /^mcp_([a-z0-9][a-z0-9-]{0,23})_(.+)$/.exec(tool.name)?.[1];
|
|
66
|
-
if (slug && !names.has(tool.name) && tool.name !== "mcp_resource_read") return {
|
|
67
|
-
key: `mcp-server:${slug}`,
|
|
68
|
-
label: slug,
|
|
69
|
-
source: `${ctx.plugin} · ${slug}`,
|
|
70
|
-
sectionLabel: ctx.i18n.t("servers"),
|
|
71
|
-
sectionOrder: 3,
|
|
72
|
-
order: 0
|
|
73
|
-
};
|
|
74
|
-
return {
|
|
75
|
-
key: `plugin:${ctx.plugin}`,
|
|
76
|
-
label: ctx.i18n.t("group"),
|
|
77
|
-
source: ctx.plugin,
|
|
78
|
-
sectionLabel: ctx.i18n.t("section"),
|
|
79
|
-
sectionOrder: 1,
|
|
80
|
-
order: 9
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
//#endregion
|
|
86
3
|
//#region src/ui/shared.ts
|
|
87
4
|
/** Returns feature failures; the global dialog owns gateway connectivity and authentication. */
|
|
88
5
|
function failureText(_ctx, error) {
|
|
@@ -159,27 +76,39 @@ function agentNames(agents, ids) {
|
|
|
159
76
|
return name === void 0 ? [] : [name];
|
|
160
77
|
});
|
|
161
78
|
}
|
|
79
|
+
/** Reads a singleton collection member while retaining a business refusal as an error. */
|
|
80
|
+
function first(batch) {
|
|
81
|
+
const item = batch.results[0];
|
|
82
|
+
if (!item?.ok) throw new Error(item?.error.message ?? "Operation returned no member");
|
|
83
|
+
return item.value;
|
|
84
|
+
}
|
|
85
|
+
/** Preserves uncertain and failed cleanup receipts instead of treating admission as success. */
|
|
86
|
+
function committed(receipt) {
|
|
87
|
+
if (receipt.operationState === "admitted") throw new Error("Operation settlement is uncertain; retry the same intent");
|
|
88
|
+
if (receipt.operationState === "cleanup-pending") throw new Error(receipt.cleanup.map((item) => item.message).join("; "));
|
|
89
|
+
return receipt.value;
|
|
90
|
+
}
|
|
162
91
|
//#endregion
|
|
163
92
|
//#region src/ui/wire.ts
|
|
164
93
|
/** Local method names, as `ctx.invoke` takes them. */
|
|
165
94
|
var METHOD = {
|
|
166
95
|
commandParse: "commandParse",
|
|
167
96
|
listServers: "listServers",
|
|
168
|
-
|
|
97
|
+
getServers: "getServers",
|
|
169
98
|
saveServer: "saveServer",
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
99
|
+
removeServers: "removeServers",
|
|
100
|
+
setServersEnabled: "setServersEnabled",
|
|
101
|
+
retryServers: "retryServers",
|
|
102
|
+
testServers: "testServers",
|
|
174
103
|
authorize: "authorize",
|
|
175
104
|
cancelAuthorize: "cancelAuthorize",
|
|
176
|
-
|
|
177
|
-
|
|
105
|
+
signOutServers: "signOutServers",
|
|
106
|
+
agentServerSets: "agentServerSets",
|
|
178
107
|
setAgentServers: "setAgentServers",
|
|
179
108
|
prompts: "prompts",
|
|
180
109
|
getPrompt: "getPrompt",
|
|
181
110
|
resources: "resources",
|
|
182
|
-
|
|
111
|
+
readResources: "readResources"
|
|
183
112
|
};
|
|
184
113
|
/** Local frame names, as `ctx.on` takes them. */
|
|
185
114
|
var FRAME = {
|
|
@@ -341,19 +270,29 @@ function attachmentSource(ctx) {
|
|
|
341
270
|
group: entry.serverName
|
|
342
271
|
}));
|
|
343
272
|
},
|
|
344
|
-
async read(
|
|
345
|
-
const
|
|
346
|
-
|
|
273
|
+
async read(ids, session, limits) {
|
|
274
|
+
const maxTotalBytes = Math.min(4194304, limits.maxTotalBytes);
|
|
275
|
+
const count = ids.length;
|
|
276
|
+
if (count < 1 || count > 32) throw new Error("MCP resources require 1..32 members");
|
|
277
|
+
const maxBytes = Math.min(1048576, Math.floor(maxTotalBytes / count), Math.floor((8380416 - 65536 * count) / (6 * count)));
|
|
278
|
+
if (maxBytes < 1) throw new Error("MCP resource budget is too small");
|
|
279
|
+
return { results: (await ctx.invoke(METHOD.readResources, {
|
|
347
280
|
agentId: session.agentId,
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
281
|
+
items: ids.map((id) => ({
|
|
282
|
+
...parseItemId(id),
|
|
283
|
+
maxBytes
|
|
284
|
+
})),
|
|
285
|
+
maxTotalBytes
|
|
286
|
+
})).results.map((item) => ({
|
|
287
|
+
...item,
|
|
288
|
+
target: ids[item.index]
|
|
289
|
+
})) };
|
|
351
290
|
},
|
|
352
291
|
subscribe: subscribeFor(ctx)
|
|
353
292
|
};
|
|
354
293
|
}
|
|
355
294
|
/** Browser translations keyed by the product's supported language-region IDs. */
|
|
356
|
-
var CATALOGUES = {
|
|
295
|
+
var CATALOGUES$1 = {
|
|
357
296
|
"zh-CN": {
|
|
358
297
|
"mcp.title": "MCP",
|
|
359
298
|
"mcp.servers": "MCP 服务器",
|
|
@@ -365,6 +304,8 @@ var CATALOGUES = {
|
|
|
365
304
|
"mcp.emptyBody": "添加服务器后,可在智能体设置中选用它的工具、资源与提示词。",
|
|
366
305
|
"mcp.enable": "启用 {{name}}",
|
|
367
306
|
"mcp.turnOn": "启用",
|
|
307
|
+
"mcp.selectionOn": "选用",
|
|
308
|
+
"mcp.selectionOff": "不选用",
|
|
368
309
|
"mcp.turnOff": "停用",
|
|
369
310
|
"mcp.retry": "重试",
|
|
370
311
|
"mcp.agents": "智能体",
|
|
@@ -436,12 +377,12 @@ var CATALOGUES = {
|
|
|
436
377
|
"mcp.testing": "正在测试…",
|
|
437
378
|
"mcp.testOk": "连接成功:{{tools}} 个工具、{{resources}} 个资源、{{prompts}} 个提示词",
|
|
438
379
|
"mcp.testSaveFirst": "请先保存修改再测试。",
|
|
439
|
-
"mcp.oauth": "
|
|
380
|
+
"mcp.oauth": "账号登录",
|
|
440
381
|
"mcp.oauth.none": "未授权",
|
|
441
382
|
"mcp.oauth.authorized": "已授权",
|
|
442
383
|
"mcp.oauth.expires": "已授权,{{time}} 到期",
|
|
443
384
|
"mcp.oauth.reauth": "需要重新授权:{{reason}}",
|
|
444
|
-
"mcp.authorize": "
|
|
385
|
+
"mcp.authorize": "浏览器登录",
|
|
445
386
|
"mcp.authorizePending": "等待授权完成",
|
|
446
387
|
"mcp.authorizeHint": "请在浏览器中完成授权,完成后此页面会自动更新。",
|
|
447
388
|
"mcp.authorizeOpen": "打开授权页面",
|
|
@@ -497,6 +438,8 @@ var CATALOGUES = {
|
|
|
497
438
|
"mcp.emptyBody": "Add a server, then choose it in an agent’s settings to use its tools, resources and prompts.",
|
|
498
439
|
"mcp.enable": "Enable {{name}}",
|
|
499
440
|
"mcp.turnOn": "Enable",
|
|
441
|
+
"mcp.selectionOn": "Use",
|
|
442
|
+
"mcp.selectionOff": "Do not use",
|
|
500
443
|
"mcp.turnOff": "Disable",
|
|
501
444
|
"mcp.retry": "Retry",
|
|
502
445
|
"mcp.agents": "Agents",
|
|
@@ -568,12 +511,12 @@ var CATALOGUES = {
|
|
|
568
511
|
"mcp.testing": "Testing…",
|
|
569
512
|
"mcp.testOk": "Connected: {{tools}} tools, {{resources}} resources, {{prompts}} prompts",
|
|
570
513
|
"mcp.testSaveFirst": "Save your changes before testing.",
|
|
571
|
-
"mcp.oauth": "
|
|
514
|
+
"mcp.oauth": "Account sign-in",
|
|
572
515
|
"mcp.oauth.none": "Not authorized",
|
|
573
516
|
"mcp.oauth.authorized": "Authorized",
|
|
574
517
|
"mcp.oauth.expires": "Authorized, expires {{time}}",
|
|
575
518
|
"mcp.oauth.reauth": "Needs authorization again: {{reason}}",
|
|
576
|
-
"mcp.authorize": "
|
|
519
|
+
"mcp.authorize": "Sign in with a browser",
|
|
577
520
|
"mcp.authorizePending": "Waiting for authorization",
|
|
578
521
|
"mcp.authorizeHint": "Complete authorization in the browser. This page updates automatically.",
|
|
579
522
|
"mcp.authorizeOpen": "Open authorization page",
|
|
@@ -624,6 +567,91 @@ function fill(text, values) {
|
|
|
624
567
|
return text.replace(/\{\{(\w+)\}\}/g, (whole, key) => key in values ? String(values[key]) : whole);
|
|
625
568
|
}
|
|
626
569
|
//#endregion
|
|
570
|
+
//#region src/tool-names.ts
|
|
571
|
+
/** Canonical names shared by tool registration and browser presentation. */
|
|
572
|
+
var TOOL_NAMES = [
|
|
573
|
+
"mcp_server_list",
|
|
574
|
+
"mcp_server_create",
|
|
575
|
+
"mcp_server_update",
|
|
576
|
+
"mcp_server_set_selected"
|
|
577
|
+
];
|
|
578
|
+
//#endregion
|
|
579
|
+
//#region src/ui/metadata.ts
|
|
580
|
+
var CATALOGUES = {
|
|
581
|
+
"en-US": {
|
|
582
|
+
section: "Built-in plugins",
|
|
583
|
+
servers: "MCP servers",
|
|
584
|
+
group: "MCP",
|
|
585
|
+
mcp_server_list: "Inspect MCP servers",
|
|
586
|
+
mcp_server_create: "Add MCP server",
|
|
587
|
+
mcp_server_update: "Edit MCP server",
|
|
588
|
+
mcp_server_set_selected: "Select MCP server",
|
|
589
|
+
mcp_resource_read: "Read MCP resources"
|
|
590
|
+
},
|
|
591
|
+
"zh-CN": {
|
|
592
|
+
section: "内置插件",
|
|
593
|
+
servers: "MCP 服务器",
|
|
594
|
+
group: "MCP",
|
|
595
|
+
mcp_server_list: "查看 MCP 服务器",
|
|
596
|
+
mcp_server_create: "添加 MCP 服务器",
|
|
597
|
+
mcp_server_update: "修改 MCP 服务器",
|
|
598
|
+
mcp_server_set_selected: "选用 MCP 服务器",
|
|
599
|
+
mcp_resource_read: "读取 MCP 资源"
|
|
600
|
+
}
|
|
601
|
+
};
|
|
602
|
+
var names = /* @__PURE__ */ new Set([...TOOL_NAMES, "mcp_resource_read"]);
|
|
603
|
+
/** Registers presentation facets with the same activation lifetime as the tools. */
|
|
604
|
+
function registerMetadata(ctx) {
|
|
605
|
+
ctx.i18n.register(CATALOGUES, "en-US");
|
|
606
|
+
ctx.i18n.contribute(Object.fromEntries(Object.entries(CATALOGUES).map(([language, catalogue]) => [language, Object.fromEntries([...names].map((tool) => [`transcript.actions.${tool}`, catalogue[tool] ?? tool]))])), "en-US");
|
|
607
|
+
ctx.slots.register("chat.tool.presentation", {
|
|
608
|
+
id: "tool-metadata",
|
|
609
|
+
describe: ({ call }) => {
|
|
610
|
+
if (!(names.has(call.name) || /^mcp_([a-z0-9][a-z0-9-]{0,23})_(.+)$/.test(call.name))) return void 0;
|
|
611
|
+
const input = call.input !== null && typeof call.input === "object" ? call.input : {};
|
|
612
|
+
const summary = [
|
|
613
|
+
"path",
|
|
614
|
+
"url",
|
|
615
|
+
"query",
|
|
616
|
+
"command",
|
|
617
|
+
"skill",
|
|
618
|
+
"id",
|
|
619
|
+
"name",
|
|
620
|
+
"task",
|
|
621
|
+
"prompt"
|
|
622
|
+
].flatMap((key) => typeof input[key] === "string" ? [input[key]] : []).slice(0, 2).join(" · ").replace(/\s+/g, " ").slice(0, 240);
|
|
623
|
+
return {
|
|
624
|
+
label: names.has(call.name) ? ctx.i18n.t(call.name) : call.name,
|
|
625
|
+
icon: "hammer",
|
|
626
|
+
summary
|
|
627
|
+
};
|
|
628
|
+
}
|
|
629
|
+
});
|
|
630
|
+
ctx.slots.register("shell.tools.group", {
|
|
631
|
+
id: "tool-groups",
|
|
632
|
+
describe: (tool) => {
|
|
633
|
+
if (tool.plugin !== ctx.plugin) return void 0;
|
|
634
|
+
const slug = /^mcp_([a-z0-9][a-z0-9-]{0,23})_(.+)$/.exec(tool.name)?.[1];
|
|
635
|
+
if (slug && !names.has(tool.name)) return {
|
|
636
|
+
key: `mcp-server:${slug}`,
|
|
637
|
+
label: slug,
|
|
638
|
+
source: `${ctx.plugin} · ${slug}`,
|
|
639
|
+
sectionLabel: ctx.i18n.t("servers"),
|
|
640
|
+
sectionOrder: 3,
|
|
641
|
+
order: 0
|
|
642
|
+
};
|
|
643
|
+
return {
|
|
644
|
+
key: `plugin:${ctx.plugin}`,
|
|
645
|
+
label: ctx.i18n.t("group"),
|
|
646
|
+
source: ctx.plugin,
|
|
647
|
+
sectionLabel: ctx.i18n.t("section"),
|
|
648
|
+
sectionOrder: 1,
|
|
649
|
+
order: 9
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
//#endregion
|
|
627
655
|
//#region src/command-text.ts
|
|
628
656
|
/** Shared command-paste input bounds for the owner RPC and browser editor. */
|
|
629
657
|
var COMMAND_TEXT_LIMIT = 65536;
|
|
@@ -878,12 +906,13 @@ function hasCredentialEdits(draft) {
|
|
|
878
906
|
}
|
|
879
907
|
//#endregion
|
|
880
908
|
//#region src/ui/editor.tsx
|
|
881
|
-
function ServerEditor({ ctx, detail, onSaved, registerGuard, children }) {
|
|
909
|
+
function ServerEditor({ ctx, detail, onSaved, onTested, registerGuard, children }) {
|
|
882
910
|
const t = ctx.i18n.t;
|
|
883
911
|
const creating = !detail;
|
|
884
912
|
const [draft, setDraft] = useState(() => draftFrom(detail));
|
|
885
913
|
const baseline = useRef(fingerprint(draft));
|
|
886
914
|
const editingRevision = useRef(0);
|
|
915
|
+
const saveIntent = useRef(void 0);
|
|
887
916
|
const [stored, setStored] = useState(/* @__PURE__ */ new Map());
|
|
888
917
|
const [credentialsLoading, setCredentialsLoading] = useState(!creating);
|
|
889
918
|
const [credentialsError, setCredentialsError] = useState(null);
|
|
@@ -950,6 +979,7 @@ function ServerEditor({ ctx, detail, onSaved, registerGuard, children }) {
|
|
|
950
979
|
const errorFor = (key) => showErrors && errors[key] ? t(errors[key]) : void 0;
|
|
951
980
|
const update = (patch) => {
|
|
952
981
|
editingRevision.current++;
|
|
982
|
+
saveIntent.current = void 0;
|
|
953
983
|
setDraft((current) => ({
|
|
954
984
|
...current,
|
|
955
985
|
...patch
|
|
@@ -1012,36 +1042,45 @@ function ServerEditor({ ctx, detail, onSaved, registerGuard, children }) {
|
|
|
1012
1042
|
config,
|
|
1013
1043
|
...needsAck ? { acknowledge: true } : {}
|
|
1014
1044
|
};
|
|
1015
|
-
|
|
1016
|
-
try {
|
|
1017
|
-
saved = await ctx.invoke(METHOD.saveServer, params);
|
|
1018
|
-
} catch (failure) {
|
|
1019
|
-
savingRef.current = false;
|
|
1020
|
-
if (!ctx.signal.aborted) {
|
|
1021
|
-
setError(failureText(ctx, failure));
|
|
1022
|
-
setSaving(false);
|
|
1023
|
-
}
|
|
1024
|
-
return;
|
|
1025
|
-
}
|
|
1045
|
+
const revision = editingRevision.current;
|
|
1026
1046
|
const plan = credentialPlan(draft, new Set(stored.keys()));
|
|
1047
|
+
const key = JSON.stringify({
|
|
1048
|
+
params,
|
|
1049
|
+
plan
|
|
1050
|
+
});
|
|
1051
|
+
if (saveIntent.current?.key !== key) saveIntent.current = {
|
|
1052
|
+
key,
|
|
1053
|
+
setId: ctx.uuid(),
|
|
1054
|
+
clearId: ctx.uuid()
|
|
1055
|
+
};
|
|
1056
|
+
const intent = saveIntent.current;
|
|
1027
1057
|
let notice;
|
|
1028
1058
|
try {
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
if (
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1059
|
+
const saved = intent.saved ?? await ctx.invoke(METHOD.saveServer, params);
|
|
1060
|
+
intent.saved = saved;
|
|
1061
|
+
if (ctx.signal.aborted || editingRevision.current !== revision) return;
|
|
1062
|
+
if (plan.set.length) committed(await ctx.credentials.set(saved.id, plan.set, intent.setId));
|
|
1063
|
+
if (plan.clear.length) committed(await ctx.credentials.clear([{
|
|
1064
|
+
scope: saved.id,
|
|
1065
|
+
mode: "names",
|
|
1066
|
+
names: plan.clear
|
|
1067
|
+
}], intent.clearId));
|
|
1068
|
+
if (ctx.signal.aborted || editingRevision.current !== revision) return;
|
|
1069
|
+
if (creating || plan.set.length || plan.clear.length) try {
|
|
1070
|
+
first(await ctx.invoke(METHOD.retryServers, { ids: [saved.id] }));
|
|
1071
|
+
} catch (failure) {
|
|
1072
|
+
notice = failureText(ctx, failure) ?? void 0;
|
|
1073
|
+
}
|
|
1074
|
+
if (ctx.signal.aborted || editingRevision.current !== revision) return;
|
|
1075
|
+
saveIntent.current = void 0;
|
|
1076
|
+
baseline.current = fingerprint(draft);
|
|
1077
|
+
onSaved(saved, notice);
|
|
1037
1078
|
} catch (failure) {
|
|
1038
|
-
|
|
1079
|
+
if (!ctx.signal.aborted && editingRevision.current === revision) setError(failureText(ctx, failure));
|
|
1080
|
+
} finally {
|
|
1081
|
+
savingRef.current = false;
|
|
1082
|
+
if (!ctx.signal.aborted) setSaving(false);
|
|
1039
1083
|
}
|
|
1040
|
-
savingRef.current = false;
|
|
1041
|
-
if (ctx.signal.aborted) return;
|
|
1042
|
-
setSaving(false);
|
|
1043
|
-
baseline.current = fingerprint(draft);
|
|
1044
|
-
onSaved(saved, notice);
|
|
1045
1084
|
}
|
|
1046
1085
|
async function runTest() {
|
|
1047
1086
|
if (!detail || testingRef.current || savingRef.current) return;
|
|
@@ -1049,7 +1088,7 @@ function ServerEditor({ ctx, detail, onSaved, registerGuard, children }) {
|
|
|
1049
1088
|
setTesting(true);
|
|
1050
1089
|
setTest(null);
|
|
1051
1090
|
try {
|
|
1052
|
-
const result = await ctx.invoke(METHOD.
|
|
1091
|
+
const result = first(await ctx.invoke(METHOD.testServers, { ids: [detail.id] }));
|
|
1053
1092
|
if (ctx.signal.aborted) return;
|
|
1054
1093
|
setTest(result.ok ? {
|
|
1055
1094
|
ok: true,
|
|
@@ -1062,6 +1101,7 @@ function ServerEditor({ ctx, detail, onSaved, registerGuard, children }) {
|
|
|
1062
1101
|
ok: false,
|
|
1063
1102
|
text: result.reason
|
|
1064
1103
|
});
|
|
1104
|
+
if (result.ok) await onTested?.();
|
|
1065
1105
|
} catch (failure) {
|
|
1066
1106
|
const text = failureText(ctx, failure);
|
|
1067
1107
|
if (!ctx.signal.aborted && text !== null) setTest({
|
|
@@ -1592,9 +1632,12 @@ function settingsFor(ctx) {
|
|
|
1592
1632
|
try {
|
|
1593
1633
|
do {
|
|
1594
1634
|
request.again = false;
|
|
1595
|
-
const next = await ctx.invoke(METHOD.
|
|
1635
|
+
const next = first(await ctx.invoke(METHOD.getServers, { ids: [id] }));
|
|
1596
1636
|
if (ctx.signal.aborted || openRef.current !== id) return;
|
|
1597
|
-
if (!request.again)
|
|
1637
|
+
if (!request.again) {
|
|
1638
|
+
setDetail(next);
|
|
1639
|
+
replaceRow(next);
|
|
1640
|
+
}
|
|
1598
1641
|
} while (request.again);
|
|
1599
1642
|
} catch (failure) {
|
|
1600
1643
|
if (!ctx.signal.aborted && openRef.current === id) {
|
|
@@ -1667,11 +1710,26 @@ function settingsFor(ctx) {
|
|
|
1667
1710
|
if (!ctx.signal.aborted) setPendingActions(new Set(activeActions.current));
|
|
1668
1711
|
}
|
|
1669
1712
|
}
|
|
1713
|
+
const enableIntents = useRef(/* @__PURE__ */ new Map());
|
|
1670
1714
|
async function setEnabled(server, enabled) {
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1715
|
+
let intent = enableIntents.current.get(server.id);
|
|
1716
|
+
if (!intent || intent.enabled !== enabled) {
|
|
1717
|
+
intent = {
|
|
1718
|
+
enabled,
|
|
1719
|
+
operationId: ctx.uuid()
|
|
1720
|
+
};
|
|
1721
|
+
enableIntents.current.set(server.id, intent);
|
|
1722
|
+
}
|
|
1723
|
+
await rowAction(server.id, async () => {
|
|
1724
|
+
committed(await ctx.invoke(METHOD.setServersEnabled, {
|
|
1725
|
+
operationId: intent.operationId,
|
|
1726
|
+
ids: [server.id],
|
|
1727
|
+
enabled
|
|
1728
|
+
}));
|
|
1729
|
+
const batch = await ctx.invoke(METHOD.getServers, { ids: [server.id] });
|
|
1730
|
+
enableIntents.current.delete(server.id);
|
|
1731
|
+
return first(batch);
|
|
1732
|
+
});
|
|
1675
1733
|
}
|
|
1676
1734
|
function show(id) {
|
|
1677
1735
|
setNotice(null);
|
|
@@ -1723,12 +1781,20 @@ function settingsFor(ctx) {
|
|
|
1723
1781
|
const [deleting, setDeleting] = useState(null);
|
|
1724
1782
|
const [removing, setRemoving] = useState(false);
|
|
1725
1783
|
const removingRef = useRef(false);
|
|
1784
|
+
const removeIntents = useRef(/* @__PURE__ */ new Map());
|
|
1726
1785
|
async function remove() {
|
|
1727
1786
|
if (!deleting || removingRef.current) return;
|
|
1728
1787
|
removingRef.current = true;
|
|
1729
1788
|
setRemoving(true);
|
|
1730
1789
|
try {
|
|
1731
|
-
const
|
|
1790
|
+
const operationId = removeIntents.current.get(deleting.id) ?? ctx.uuid();
|
|
1791
|
+
removeIntents.current.set(deleting.id, operationId);
|
|
1792
|
+
committed(await ctx.invoke(METHOD.removeServers, {
|
|
1793
|
+
operationId,
|
|
1794
|
+
ids: [deleting.id]
|
|
1795
|
+
}));
|
|
1796
|
+
const { servers: next } = await ctx.invoke(METHOD.listServers, {});
|
|
1797
|
+
removeIntents.current.delete(deleting.id);
|
|
1732
1798
|
if (ctx.signal.aborted) return;
|
|
1733
1799
|
setDeleting(null);
|
|
1734
1800
|
if (deleting.id === openRef.current) removed(next);
|
|
@@ -1952,6 +2018,7 @@ function settingsFor(ctx) {
|
|
|
1952
2018
|
ctx,
|
|
1953
2019
|
detail,
|
|
1954
2020
|
registerGuard,
|
|
2021
|
+
onTested: () => loadDetail(detail.id),
|
|
1955
2022
|
onSaved: (next, message) => {
|
|
1956
2023
|
setDetail(next);
|
|
1957
2024
|
setNotice(message ?? null);
|
|
@@ -2025,7 +2092,7 @@ function settingsFor(ctx) {
|
|
|
2025
2092
|
});
|
|
2026
2093
|
};
|
|
2027
2094
|
}
|
|
2028
|
-
function ServerDetailView({ ctx, detail, registerGuard, onSaved }) {
|
|
2095
|
+
function ServerDetailView({ ctx, detail, registerGuard, onSaved, onTested }) {
|
|
2029
2096
|
const oauth = detail.transport === "http" && "auth" in detail.config && detail.config.auth === "oauth";
|
|
2030
2097
|
return /* @__PURE__ */ jsx("div", {
|
|
2031
2098
|
className: "mcp-detail",
|
|
@@ -2033,6 +2100,7 @@ function ServerDetailView({ ctx, detail, registerGuard, onSaved }) {
|
|
|
2033
2100
|
ctx,
|
|
2034
2101
|
detail,
|
|
2035
2102
|
onSaved,
|
|
2103
|
+
onTested,
|
|
2036
2104
|
registerGuard,
|
|
2037
2105
|
children: oauth && /* @__PURE__ */ jsx(AuthorizationArea, {
|
|
2038
2106
|
ctx,
|
|
@@ -2124,12 +2192,18 @@ function AuthorizationArea({ ctx, detail }) {
|
|
|
2124
2192
|
if (!ctx.signal.aborted) setAction(null);
|
|
2125
2193
|
}
|
|
2126
2194
|
}
|
|
2195
|
+
const signOutIntent = useRef(null);
|
|
2127
2196
|
async function signOut() {
|
|
2128
2197
|
if (actionRef.current) return;
|
|
2198
|
+
signOutIntent.current ??= ctx.uuid();
|
|
2129
2199
|
actionRef.current = "signOut";
|
|
2130
2200
|
setAction("signOut");
|
|
2131
2201
|
try {
|
|
2132
|
-
await ctx.invoke(METHOD.
|
|
2202
|
+
committed(await ctx.invoke(METHOD.signOutServers, {
|
|
2203
|
+
operationId: signOutIntent.current,
|
|
2204
|
+
ids: [detail.id]
|
|
2205
|
+
}));
|
|
2206
|
+
signOutIntent.current = null;
|
|
2133
2207
|
} catch (failure) {
|
|
2134
2208
|
if (!ctx.signal.aborted) fail(failure);
|
|
2135
2209
|
} finally {
|
|
@@ -2167,11 +2241,12 @@ function AuthorizationArea({ ctx, detail }) {
|
|
|
2167
2241
|
loading: action === "cancel",
|
|
2168
2242
|
onClick: () => void cancel(),
|
|
2169
2243
|
children: t("mcp.authorizeCancel")
|
|
2170
|
-
}) : /* @__PURE__ */ jsxs(Fragment, { children: [(!authorized || needsAgain) && /* @__PURE__ */
|
|
2244
|
+
}) : /* @__PURE__ */ jsxs(Fragment, { children: [(!authorized || needsAgain) && /* @__PURE__ */ jsxs(ctx.ui.Button, {
|
|
2171
2245
|
disabled: action !== null,
|
|
2172
2246
|
loading: action === "authorize",
|
|
2247
|
+
variant: "primary",
|
|
2173
2248
|
onClick: () => void authorize(),
|
|
2174
|
-
children: t("mcp.authorize")
|
|
2249
|
+
children: [/* @__PURE__ */ jsx(ctx.ui.Icon, { name: "fingerprint-pattern" }), t("mcp.authorize")]
|
|
2175
2250
|
}), authorized && /* @__PURE__ */ jsx(ctx.ui.Button, {
|
|
2176
2251
|
disabled: action !== null,
|
|
2177
2252
|
loading: action === "signOut",
|
|
@@ -2433,7 +2508,7 @@ function CapabilityDetails({ ctx, kind, row }) {
|
|
|
2433
2508
|
});
|
|
2434
2509
|
}
|
|
2435
2510
|
/**
|
|
2436
|
-
* Which agents select this server, one
|
|
2511
|
+
* Which agents select this server, one choice per agent. A selection is a save:
|
|
2437
2512
|
* the agent's own selection is read, this server added or taken out, and the
|
|
2438
2513
|
* whole set written back through `setAgentServers`, whose `serversChanged`
|
|
2439
2514
|
* brings `server.agentIds` up to date. One write at a time, because each is
|
|
@@ -2452,7 +2527,7 @@ function Agents({ ctx, server, agents }) {
|
|
|
2452
2527
|
on
|
|
2453
2528
|
});
|
|
2454
2529
|
try {
|
|
2455
|
-
const { serverIds, revision, contentHash } = await ctx.invoke(METHOD.
|
|
2530
|
+
const { serverIds, revision, contentHash } = first(await ctx.invoke(METHOD.agentServerSets, { agentIds: [agentId] }));
|
|
2456
2531
|
const next = on ? [...serverIds.filter((id) => id !== server.id), server.id] : serverIds.filter((id) => id !== server.id);
|
|
2457
2532
|
await ctx.invoke(METHOD.setAgentServers, {
|
|
2458
2533
|
agentId,
|
|
@@ -2601,7 +2676,7 @@ button.mcp-risk-command { display: block; width: fit-content; max-width: 100%; h
|
|
|
2601
2676
|
.mcp-test-ok { color: var(--success); }
|
|
2602
2677
|
.mcp-oauth { display: flex; flex-direction: column; min-width: 0; gap: .5rem; }
|
|
2603
2678
|
.mcp-oauth-header { display: grid; grid-template-columns: 5rem minmax(0, 1fr) auto; align-items: center; gap: .75rem; min-height: var(--form-control-height); }
|
|
2604
|
-
.mcp-oauth-label { font-size:
|
|
2679
|
+
.mcp-oauth-label { font-size: var(--text-sm); font-weight: 400; color: var(--foreground); }
|
|
2605
2680
|
.mcp-oauth-status { display: inline-flex; align-items: center; gap: .375rem; min-width: 0; font-size: .75rem; color: var(--muted-foreground); }
|
|
2606
2681
|
.mcp-oauth-authorized { color: var(--success); }
|
|
2607
2682
|
.mcp-oauth-dot { display: inline-block; flex: none; width: .375rem; height: .375rem; border-radius: var(--radius-pill); background: currentColor; }
|
|
@@ -2666,7 +2741,7 @@ button.mcp-cap-open { display: flex; align-items: center; gap: .75rem; width: 10
|
|
|
2666
2741
|
`;
|
|
2667
2742
|
var register = (ctx) => {
|
|
2668
2743
|
registerMetadata(ctx);
|
|
2669
|
-
ctx.i18n.register(CATALOGUES, "en-US");
|
|
2744
|
+
ctx.i18n.register(CATALOGUES$1, "en-US");
|
|
2670
2745
|
ctx.styles.add(STYLES);
|
|
2671
2746
|
const title = () => ctx.i18n.t("mcp.title");
|
|
2672
2747
|
ctx.slots.register("shell.settings.category", {
|