@eum-agent/integration-mcp 1.0.0 → 1.0.1
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 +206 -136
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.0.
|
|
7
|
+
"version": "1.0.1",
|
|
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.0.
|
|
29
|
+
"@eum-agent/plugin": "1.0.1",
|
|
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.0.
|
|
47
|
+
"@eum-agent/infra-local": "1.0.1",
|
|
48
|
+
"@eum-agent/storage-sqlite": "1.0.1"
|
|
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 服务器",
|
|
@@ -624,6 +563,91 @@ function fill(text, values) {
|
|
|
624
563
|
return text.replace(/\{\{(\w+)\}\}/g, (whole, key) => key in values ? String(values[key]) : whole);
|
|
625
564
|
}
|
|
626
565
|
//#endregion
|
|
566
|
+
//#region src/tool-names.ts
|
|
567
|
+
/** Canonical names shared by tool registration and browser presentation. */
|
|
568
|
+
var TOOL_NAMES = [
|
|
569
|
+
"mcp_server_list",
|
|
570
|
+
"mcp_server_create",
|
|
571
|
+
"mcp_server_update",
|
|
572
|
+
"mcp_server_set_selected"
|
|
573
|
+
];
|
|
574
|
+
//#endregion
|
|
575
|
+
//#region src/ui/metadata.ts
|
|
576
|
+
var CATALOGUES = {
|
|
577
|
+
"en-US": {
|
|
578
|
+
section: "Built-in plugins",
|
|
579
|
+
servers: "MCP servers",
|
|
580
|
+
group: "MCP",
|
|
581
|
+
mcp_server_list: "Inspect MCP servers",
|
|
582
|
+
mcp_server_create: "Add MCP server",
|
|
583
|
+
mcp_server_update: "Edit MCP server",
|
|
584
|
+
mcp_server_set_selected: "Select MCP server",
|
|
585
|
+
mcp_resource_read: "Read MCP resources"
|
|
586
|
+
},
|
|
587
|
+
"zh-CN": {
|
|
588
|
+
section: "内置插件",
|
|
589
|
+
servers: "MCP 服务器",
|
|
590
|
+
group: "MCP",
|
|
591
|
+
mcp_server_list: "查看 MCP 服务器",
|
|
592
|
+
mcp_server_create: "添加 MCP 服务器",
|
|
593
|
+
mcp_server_update: "修改 MCP 服务器",
|
|
594
|
+
mcp_server_set_selected: "选用 MCP 服务器",
|
|
595
|
+
mcp_resource_read: "读取 MCP 资源"
|
|
596
|
+
}
|
|
597
|
+
};
|
|
598
|
+
var names = /* @__PURE__ */ new Set([...TOOL_NAMES, "mcp_resource_read"]);
|
|
599
|
+
/** Registers presentation facets with the same activation lifetime as the tools. */
|
|
600
|
+
function registerMetadata(ctx) {
|
|
601
|
+
ctx.i18n.register(CATALOGUES, "en-US");
|
|
602
|
+
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");
|
|
603
|
+
ctx.slots.register("chat.tool.presentation", {
|
|
604
|
+
id: "tool-metadata",
|
|
605
|
+
describe: ({ call }) => {
|
|
606
|
+
if (!(names.has(call.name) || /^mcp_([a-z0-9][a-z0-9-]{0,23})_(.+)$/.test(call.name))) return void 0;
|
|
607
|
+
const input = call.input !== null && typeof call.input === "object" ? call.input : {};
|
|
608
|
+
const summary = [
|
|
609
|
+
"path",
|
|
610
|
+
"url",
|
|
611
|
+
"query",
|
|
612
|
+
"command",
|
|
613
|
+
"skill",
|
|
614
|
+
"id",
|
|
615
|
+
"name",
|
|
616
|
+
"task",
|
|
617
|
+
"prompt"
|
|
618
|
+
].flatMap((key) => typeof input[key] === "string" ? [input[key]] : []).slice(0, 2).join(" · ").replace(/\s+/g, " ").slice(0, 240);
|
|
619
|
+
return {
|
|
620
|
+
label: names.has(call.name) ? ctx.i18n.t(call.name) : call.name,
|
|
621
|
+
icon: "hammer",
|
|
622
|
+
summary
|
|
623
|
+
};
|
|
624
|
+
}
|
|
625
|
+
});
|
|
626
|
+
ctx.slots.register("shell.tools.group", {
|
|
627
|
+
id: "tool-groups",
|
|
628
|
+
describe: (tool) => {
|
|
629
|
+
if (tool.plugin !== ctx.plugin) return void 0;
|
|
630
|
+
const slug = /^mcp_([a-z0-9][a-z0-9-]{0,23})_(.+)$/.exec(tool.name)?.[1];
|
|
631
|
+
if (slug && !names.has(tool.name)) return {
|
|
632
|
+
key: `mcp-server:${slug}`,
|
|
633
|
+
label: slug,
|
|
634
|
+
source: `${ctx.plugin} · ${slug}`,
|
|
635
|
+
sectionLabel: ctx.i18n.t("servers"),
|
|
636
|
+
sectionOrder: 3,
|
|
637
|
+
order: 0
|
|
638
|
+
};
|
|
639
|
+
return {
|
|
640
|
+
key: `plugin:${ctx.plugin}`,
|
|
641
|
+
label: ctx.i18n.t("group"),
|
|
642
|
+
source: ctx.plugin,
|
|
643
|
+
sectionLabel: ctx.i18n.t("section"),
|
|
644
|
+
sectionOrder: 1,
|
|
645
|
+
order: 9
|
|
646
|
+
};
|
|
647
|
+
}
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
//#endregion
|
|
627
651
|
//#region src/command-text.ts
|
|
628
652
|
/** Shared command-paste input bounds for the owner RPC and browser editor. */
|
|
629
653
|
var COMMAND_TEXT_LIMIT = 65536;
|
|
@@ -878,12 +902,13 @@ function hasCredentialEdits(draft) {
|
|
|
878
902
|
}
|
|
879
903
|
//#endregion
|
|
880
904
|
//#region src/ui/editor.tsx
|
|
881
|
-
function ServerEditor({ ctx, detail, onSaved, registerGuard, children }) {
|
|
905
|
+
function ServerEditor({ ctx, detail, onSaved, onTested, registerGuard, children }) {
|
|
882
906
|
const t = ctx.i18n.t;
|
|
883
907
|
const creating = !detail;
|
|
884
908
|
const [draft, setDraft] = useState(() => draftFrom(detail));
|
|
885
909
|
const baseline = useRef(fingerprint(draft));
|
|
886
910
|
const editingRevision = useRef(0);
|
|
911
|
+
const saveIntent = useRef(void 0);
|
|
887
912
|
const [stored, setStored] = useState(/* @__PURE__ */ new Map());
|
|
888
913
|
const [credentialsLoading, setCredentialsLoading] = useState(!creating);
|
|
889
914
|
const [credentialsError, setCredentialsError] = useState(null);
|
|
@@ -950,6 +975,7 @@ function ServerEditor({ ctx, detail, onSaved, registerGuard, children }) {
|
|
|
950
975
|
const errorFor = (key) => showErrors && errors[key] ? t(errors[key]) : void 0;
|
|
951
976
|
const update = (patch) => {
|
|
952
977
|
editingRevision.current++;
|
|
978
|
+
saveIntent.current = void 0;
|
|
953
979
|
setDraft((current) => ({
|
|
954
980
|
...current,
|
|
955
981
|
...patch
|
|
@@ -1012,36 +1038,45 @@ function ServerEditor({ ctx, detail, onSaved, registerGuard, children }) {
|
|
|
1012
1038
|
config,
|
|
1013
1039
|
...needsAck ? { acknowledge: true } : {}
|
|
1014
1040
|
};
|
|
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
|
-
}
|
|
1041
|
+
const revision = editingRevision.current;
|
|
1026
1042
|
const plan = credentialPlan(draft, new Set(stored.keys()));
|
|
1043
|
+
const key = JSON.stringify({
|
|
1044
|
+
params,
|
|
1045
|
+
plan
|
|
1046
|
+
});
|
|
1047
|
+
if (saveIntent.current?.key !== key) saveIntent.current = {
|
|
1048
|
+
key,
|
|
1049
|
+
setId: ctx.uuid(),
|
|
1050
|
+
clearId: ctx.uuid()
|
|
1051
|
+
};
|
|
1052
|
+
const intent = saveIntent.current;
|
|
1027
1053
|
let notice;
|
|
1028
1054
|
try {
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
if (
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1055
|
+
const saved = intent.saved ?? await ctx.invoke(METHOD.saveServer, params);
|
|
1056
|
+
intent.saved = saved;
|
|
1057
|
+
if (ctx.signal.aborted || editingRevision.current !== revision) return;
|
|
1058
|
+
if (plan.set.length) committed(await ctx.credentials.set(saved.id, plan.set, intent.setId));
|
|
1059
|
+
if (plan.clear.length) committed(await ctx.credentials.clear([{
|
|
1060
|
+
scope: saved.id,
|
|
1061
|
+
mode: "names",
|
|
1062
|
+
names: plan.clear
|
|
1063
|
+
}], intent.clearId));
|
|
1064
|
+
if (ctx.signal.aborted || editingRevision.current !== revision) return;
|
|
1065
|
+
if (creating || plan.set.length || plan.clear.length) try {
|
|
1066
|
+
first(await ctx.invoke(METHOD.retryServers, { ids: [saved.id] }));
|
|
1067
|
+
} catch (failure) {
|
|
1068
|
+
notice = failureText(ctx, failure) ?? void 0;
|
|
1069
|
+
}
|
|
1070
|
+
if (ctx.signal.aborted || editingRevision.current !== revision) return;
|
|
1071
|
+
saveIntent.current = void 0;
|
|
1072
|
+
baseline.current = fingerprint(draft);
|
|
1073
|
+
onSaved(saved, notice);
|
|
1037
1074
|
} catch (failure) {
|
|
1038
|
-
|
|
1075
|
+
if (!ctx.signal.aborted && editingRevision.current === revision) setError(failureText(ctx, failure));
|
|
1076
|
+
} finally {
|
|
1077
|
+
savingRef.current = false;
|
|
1078
|
+
if (!ctx.signal.aborted) setSaving(false);
|
|
1039
1079
|
}
|
|
1040
|
-
savingRef.current = false;
|
|
1041
|
-
if (ctx.signal.aborted) return;
|
|
1042
|
-
setSaving(false);
|
|
1043
|
-
baseline.current = fingerprint(draft);
|
|
1044
|
-
onSaved(saved, notice);
|
|
1045
1080
|
}
|
|
1046
1081
|
async function runTest() {
|
|
1047
1082
|
if (!detail || testingRef.current || savingRef.current) return;
|
|
@@ -1049,7 +1084,7 @@ function ServerEditor({ ctx, detail, onSaved, registerGuard, children }) {
|
|
|
1049
1084
|
setTesting(true);
|
|
1050
1085
|
setTest(null);
|
|
1051
1086
|
try {
|
|
1052
|
-
const result = await ctx.invoke(METHOD.
|
|
1087
|
+
const result = first(await ctx.invoke(METHOD.testServers, { ids: [detail.id] }));
|
|
1053
1088
|
if (ctx.signal.aborted) return;
|
|
1054
1089
|
setTest(result.ok ? {
|
|
1055
1090
|
ok: true,
|
|
@@ -1062,6 +1097,7 @@ function ServerEditor({ ctx, detail, onSaved, registerGuard, children }) {
|
|
|
1062
1097
|
ok: false,
|
|
1063
1098
|
text: result.reason
|
|
1064
1099
|
});
|
|
1100
|
+
if (result.ok) await onTested?.();
|
|
1065
1101
|
} catch (failure) {
|
|
1066
1102
|
const text = failureText(ctx, failure);
|
|
1067
1103
|
if (!ctx.signal.aborted && text !== null) setTest({
|
|
@@ -1592,9 +1628,12 @@ function settingsFor(ctx) {
|
|
|
1592
1628
|
try {
|
|
1593
1629
|
do {
|
|
1594
1630
|
request.again = false;
|
|
1595
|
-
const next = await ctx.invoke(METHOD.
|
|
1631
|
+
const next = first(await ctx.invoke(METHOD.getServers, { ids: [id] }));
|
|
1596
1632
|
if (ctx.signal.aborted || openRef.current !== id) return;
|
|
1597
|
-
if (!request.again)
|
|
1633
|
+
if (!request.again) {
|
|
1634
|
+
setDetail(next);
|
|
1635
|
+
replaceRow(next);
|
|
1636
|
+
}
|
|
1598
1637
|
} while (request.again);
|
|
1599
1638
|
} catch (failure) {
|
|
1600
1639
|
if (!ctx.signal.aborted && openRef.current === id) {
|
|
@@ -1667,11 +1706,26 @@ function settingsFor(ctx) {
|
|
|
1667
1706
|
if (!ctx.signal.aborted) setPendingActions(new Set(activeActions.current));
|
|
1668
1707
|
}
|
|
1669
1708
|
}
|
|
1709
|
+
const enableIntents = useRef(/* @__PURE__ */ new Map());
|
|
1670
1710
|
async function setEnabled(server, enabled) {
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1711
|
+
let intent = enableIntents.current.get(server.id);
|
|
1712
|
+
if (!intent || intent.enabled !== enabled) {
|
|
1713
|
+
intent = {
|
|
1714
|
+
enabled,
|
|
1715
|
+
operationId: ctx.uuid()
|
|
1716
|
+
};
|
|
1717
|
+
enableIntents.current.set(server.id, intent);
|
|
1718
|
+
}
|
|
1719
|
+
await rowAction(server.id, async () => {
|
|
1720
|
+
committed(await ctx.invoke(METHOD.setServersEnabled, {
|
|
1721
|
+
operationId: intent.operationId,
|
|
1722
|
+
ids: [server.id],
|
|
1723
|
+
enabled
|
|
1724
|
+
}));
|
|
1725
|
+
const batch = await ctx.invoke(METHOD.getServers, { ids: [server.id] });
|
|
1726
|
+
enableIntents.current.delete(server.id);
|
|
1727
|
+
return first(batch);
|
|
1728
|
+
});
|
|
1675
1729
|
}
|
|
1676
1730
|
function show(id) {
|
|
1677
1731
|
setNotice(null);
|
|
@@ -1723,12 +1777,20 @@ function settingsFor(ctx) {
|
|
|
1723
1777
|
const [deleting, setDeleting] = useState(null);
|
|
1724
1778
|
const [removing, setRemoving] = useState(false);
|
|
1725
1779
|
const removingRef = useRef(false);
|
|
1780
|
+
const removeIntents = useRef(/* @__PURE__ */ new Map());
|
|
1726
1781
|
async function remove() {
|
|
1727
1782
|
if (!deleting || removingRef.current) return;
|
|
1728
1783
|
removingRef.current = true;
|
|
1729
1784
|
setRemoving(true);
|
|
1730
1785
|
try {
|
|
1731
|
-
const
|
|
1786
|
+
const operationId = removeIntents.current.get(deleting.id) ?? ctx.uuid();
|
|
1787
|
+
removeIntents.current.set(deleting.id, operationId);
|
|
1788
|
+
committed(await ctx.invoke(METHOD.removeServers, {
|
|
1789
|
+
operationId,
|
|
1790
|
+
ids: [deleting.id]
|
|
1791
|
+
}));
|
|
1792
|
+
const { servers: next } = await ctx.invoke(METHOD.listServers, {});
|
|
1793
|
+
removeIntents.current.delete(deleting.id);
|
|
1732
1794
|
if (ctx.signal.aborted) return;
|
|
1733
1795
|
setDeleting(null);
|
|
1734
1796
|
if (deleting.id === openRef.current) removed(next);
|
|
@@ -1952,6 +2014,7 @@ function settingsFor(ctx) {
|
|
|
1952
2014
|
ctx,
|
|
1953
2015
|
detail,
|
|
1954
2016
|
registerGuard,
|
|
2017
|
+
onTested: () => loadDetail(detail.id),
|
|
1955
2018
|
onSaved: (next, message) => {
|
|
1956
2019
|
setDetail(next);
|
|
1957
2020
|
setNotice(message ?? null);
|
|
@@ -2025,7 +2088,7 @@ function settingsFor(ctx) {
|
|
|
2025
2088
|
});
|
|
2026
2089
|
};
|
|
2027
2090
|
}
|
|
2028
|
-
function ServerDetailView({ ctx, detail, registerGuard, onSaved }) {
|
|
2091
|
+
function ServerDetailView({ ctx, detail, registerGuard, onSaved, onTested }) {
|
|
2029
2092
|
const oauth = detail.transport === "http" && "auth" in detail.config && detail.config.auth === "oauth";
|
|
2030
2093
|
return /* @__PURE__ */ jsx("div", {
|
|
2031
2094
|
className: "mcp-detail",
|
|
@@ -2033,6 +2096,7 @@ function ServerDetailView({ ctx, detail, registerGuard, onSaved }) {
|
|
|
2033
2096
|
ctx,
|
|
2034
2097
|
detail,
|
|
2035
2098
|
onSaved,
|
|
2099
|
+
onTested,
|
|
2036
2100
|
registerGuard,
|
|
2037
2101
|
children: oauth && /* @__PURE__ */ jsx(AuthorizationArea, {
|
|
2038
2102
|
ctx,
|
|
@@ -2124,12 +2188,18 @@ function AuthorizationArea({ ctx, detail }) {
|
|
|
2124
2188
|
if (!ctx.signal.aborted) setAction(null);
|
|
2125
2189
|
}
|
|
2126
2190
|
}
|
|
2191
|
+
const signOutIntent = useRef(null);
|
|
2127
2192
|
async function signOut() {
|
|
2128
2193
|
if (actionRef.current) return;
|
|
2194
|
+
signOutIntent.current ??= ctx.uuid();
|
|
2129
2195
|
actionRef.current = "signOut";
|
|
2130
2196
|
setAction("signOut");
|
|
2131
2197
|
try {
|
|
2132
|
-
await ctx.invoke(METHOD.
|
|
2198
|
+
committed(await ctx.invoke(METHOD.signOutServers, {
|
|
2199
|
+
operationId: signOutIntent.current,
|
|
2200
|
+
ids: [detail.id]
|
|
2201
|
+
}));
|
|
2202
|
+
signOutIntent.current = null;
|
|
2133
2203
|
} catch (failure) {
|
|
2134
2204
|
if (!ctx.signal.aborted) fail(failure);
|
|
2135
2205
|
} finally {
|
|
@@ -2452,7 +2522,7 @@ function Agents({ ctx, server, agents }) {
|
|
|
2452
2522
|
on
|
|
2453
2523
|
});
|
|
2454
2524
|
try {
|
|
2455
|
-
const { serverIds, revision, contentHash } = await ctx.invoke(METHOD.
|
|
2525
|
+
const { serverIds, revision, contentHash } = first(await ctx.invoke(METHOD.agentServerSets, { agentIds: [agentId] }));
|
|
2456
2526
|
const next = on ? [...serverIds.filter((id) => id !== server.id), server.id] : serverIds.filter((id) => id !== server.id);
|
|
2457
2527
|
await ctx.invoke(METHOD.setAgentServers, {
|
|
2458
2528
|
agentId,
|
|
@@ -2666,7 +2736,7 @@ button.mcp-cap-open { display: flex; align-items: center; gap: .75rem; width: 10
|
|
|
2666
2736
|
`;
|
|
2667
2737
|
var register = (ctx) => {
|
|
2668
2738
|
registerMetadata(ctx);
|
|
2669
|
-
ctx.i18n.register(CATALOGUES, "en-US");
|
|
2739
|
+
ctx.i18n.register(CATALOGUES$1, "en-US");
|
|
2670
2740
|
ctx.styles.add(STYLES);
|
|
2671
2741
|
const title = () => ctx.i18n.t("mcp.title");
|
|
2672
2742
|
ctx.slots.register("shell.settings.category", {
|