@xenosystem/agent-interface-host 0.1.169 → 0.1.171
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/account/accountWorkforceOperationState.d.ts +5 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +41 -2
- package/dist/index.js.map +1 -1
- package/dist/pluginMcp/PluginMcpManagerService.d.ts +13 -3
- package/dist/pluginMcp/PluginMcpManagerService.d.ts.map +1 -1
- package/dist/pluginMcp/PluginMcpManagerService.js +192 -76
- package/dist/pluginMcp/PluginMcpManagerService.js.map +1 -1
- package/dist/sdk/SdkNativeAgentTurnExecutionAdapter.d.ts +2 -0
- package/dist/sdk/SdkNativeAgentTurnExecutionAdapter.d.ts.map +1 -1
- package/dist/sdk/SdkNativeAgentTurnExecutionAdapter.js +2 -0
- package/dist/sdk/SdkNativeAgentTurnExecutionAdapter.js.map +1 -1
- package/package.json +7 -7
|
@@ -50,8 +50,8 @@ export declare class PluginMcpManagerService {
|
|
|
50
50
|
private readonly mcpApprovalsPath;
|
|
51
51
|
private readonly sdkApprovalsPath;
|
|
52
52
|
private pluginHost;
|
|
53
|
-
private
|
|
54
|
-
private
|
|
53
|
+
private sharedMcpConnections;
|
|
54
|
+
private readonly folderMcp;
|
|
55
55
|
private pluginEvents;
|
|
56
56
|
private activePluginsHydrated;
|
|
57
57
|
/** A string is the legacy layout at that base (`~/.xeno`, or a test's temp folder). */
|
|
@@ -175,13 +175,13 @@ export declare class PluginMcpManagerService {
|
|
|
175
175
|
pluginTools: string[];
|
|
176
176
|
mcpTools: string[];
|
|
177
177
|
builtInMcpTools: string[];
|
|
178
|
+
awaitingApproval: string[];
|
|
178
179
|
errors: string[];
|
|
179
180
|
}>;
|
|
180
181
|
toSearchDocuments(): HubSearchDocument[];
|
|
181
182
|
private resolveEffectivePolicy;
|
|
182
183
|
private isPluginAllowed;
|
|
183
184
|
private isMcpServerAllowed;
|
|
184
|
-
private isMcpServerTrusted;
|
|
185
185
|
private assertMcpServerUsable;
|
|
186
186
|
private recordMcpCallAudit;
|
|
187
187
|
/**
|
|
@@ -214,6 +214,16 @@ export declare class PluginMcpManagerService {
|
|
|
214
214
|
private getPluginHost;
|
|
215
215
|
private hydratePersistedActivePlugins;
|
|
216
216
|
private getMcpManager;
|
|
217
|
+
private sharedConnectionSet;
|
|
218
|
+
private createMcpConnectionSet;
|
|
219
|
+
private folderConnectionSet;
|
|
220
|
+
private evictFolderConnections;
|
|
221
|
+
/** Connects one approved server unless it is live on this definition. Returns why it could not. */
|
|
222
|
+
private connectMcpServer;
|
|
223
|
+
/** A folder's server that is no longer approved or configured stops serving that folder's turns. */
|
|
224
|
+
private dropUnwantedFolderConnections;
|
|
225
|
+
/** A decision or an edit applies now, including to a turn already running. */
|
|
226
|
+
private disconnectMcpServerEverywhere;
|
|
217
227
|
private disposeMcpManager;
|
|
218
228
|
private withPlugin;
|
|
219
229
|
private upsertSdkMcpServer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PluginMcpManagerService.d.ts","sourceRoot":"","sources":["../../src/pluginMcp/PluginMcpManagerService.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAOV,cAAc,EAId,UAAU,EAGX,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,KAAK,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AAEzJ,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AAEtE,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,kCAAkC,EAClC,mBAAmB,EACnB,oBAAoB,EAMpB,wBAAwB,EAGxB,mBAAmB,EACnB,2BAA2B,EAE3B,kBAAkB,EAClB,mBAAmB,EAGnB,oBAAoB,EACpB,uBAAuB,EACvB,gBAAgB,EAChB,6BAA6B,EAC7B,yBAAyB,EACzB,oBAAoB,EACpB,8BAA8B,EAC9B,+BAA+B,EAC/B,wBAAwB,EACxB,iBAAiB,EACjB,sBAAsB,EACtB,uBAAuB,EACvB,gBAAgB,EAChB,sBAAsB,EACtB,8BAA8B,EAC9B,+BAA+B,EAC/B,qBAAqB,EACrB,2BAA2B,EAC3B,8BAA8B,EAC9B,qBAAqB,EACrB,uBAAuB,EACvB,+BAA+B,EAC/B,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,mBAAmB,EACnB,sBAAsB,EACvB,MAAM,qBAAqB,CAAA;AAG5B,KAAK,mBAAmB,GAAG;IACzB,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;CAClC,CAAA;
|
|
1
|
+
{"version":3,"file":"PluginMcpManagerService.d.ts","sourceRoot":"","sources":["../../src/pluginMcp/PluginMcpManagerService.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAOV,cAAc,EAId,UAAU,EAGX,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,KAAK,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AAEzJ,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AAEtE,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,kCAAkC,EAClC,mBAAmB,EACnB,oBAAoB,EAMpB,wBAAwB,EAGxB,mBAAmB,EACnB,2BAA2B,EAE3B,kBAAkB,EAClB,mBAAmB,EAGnB,oBAAoB,EACpB,uBAAuB,EACvB,gBAAgB,EAChB,6BAA6B,EAC7B,yBAAyB,EACzB,oBAAoB,EACpB,8BAA8B,EAC9B,+BAA+B,EAC/B,wBAAwB,EACxB,iBAAiB,EACjB,sBAAsB,EACtB,uBAAuB,EACvB,gBAAgB,EAChB,sBAAsB,EACtB,8BAA8B,EAC9B,+BAA+B,EAC/B,qBAAqB,EACrB,2BAA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AAC,gBAAgB;IAaxB,OAAO,CAAC,iBAAiB;IAkBzB,OAAO,CAAC,iBAAiB;CAQ1B;AAID,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,KAAK,sBAAsB,EAAE,CAAA;AAa/H;;;;GAIG;AACH,wBAAgB,0BAA0B,IAAI,uBAAuB,CAQpE;AAED;;;;GAIG;AACH,wBAAgB,gCAAgC,CAAC,QAAQ,EAAE,sBAAsB,GAAG,MAAM,GAAG,IAAI,CAEhG"}
|
|
@@ -5,7 +5,12 @@ import { dirname, join, resolve } from 'path';
|
|
|
5
5
|
import { choosePluginMcpStore, extensionsPluginMcpStore, legacyPluginMcpStore, pluginMcpStoreFor } from './storeLocation.js';
|
|
6
6
|
import { capabilityMcpServerConfig, CAPABILITY_MCP_SERVER_NAME } from './capabilityMcpRegistration.js';
|
|
7
7
|
import { createScopeAcl, estimateTokens, normalizeSearchText, stableDocumentId } from '../agentSearch/searchUtils.js';
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* A server is approved one at a time, and each of its tool calls still passes the turn's permission rules, so an approved server's
|
|
10
|
+
* tools are offered unless someone narrows this. It was `context` (prompts and resources only), which meant approving a server in
|
|
11
|
+
* the app gave a chat none of its tools.
|
|
12
|
+
*/
|
|
13
|
+
const DEFAULT_REGISTRY_POLICY = 'all';
|
|
9
14
|
const MAX_PLUGIN_EVENTS = 500;
|
|
10
15
|
const MAX_PREVIEW_BYTES = 8_000;
|
|
11
16
|
class PluginMcpDeniedError extends Error {
|
|
@@ -256,6 +261,32 @@ function sdkApprovalIdOf(sourcePath, approvalKey) {
|
|
|
256
261
|
function sdkApprovalId(record) {
|
|
257
262
|
return sdkApprovalIdOf(record.sourcePath, record.approvalKey);
|
|
258
263
|
}
|
|
264
|
+
/**
|
|
265
|
+
* A server from the SDK's configuration files runs for one folder, as it does in a terminal chat: its relative paths mean that
|
|
266
|
+
* folder and it takes that folder's definition of its name. Two folders can each define `docs` differently, and one connection
|
|
267
|
+
* cannot be both, so these get a connection set per folder. Hub and plugin servers are one definition, shared by every turn.
|
|
268
|
+
*/
|
|
269
|
+
function isFolderMcpServer(record) {
|
|
270
|
+
return record.source === 'sdk-config';
|
|
271
|
+
}
|
|
272
|
+
function folderMcpKey(cwd) {
|
|
273
|
+
const resolved = resolve(cwd);
|
|
274
|
+
return process.platform === 'win32' ? resolved.toLowerCase() : resolved;
|
|
275
|
+
}
|
|
276
|
+
/** How long a server that failed to connect is left alone, so it does not hold up every turn by its connection timeout. */
|
|
277
|
+
const MCP_CONNECT_RETRY_MS = 60_000;
|
|
278
|
+
/** Folders whose servers stay connected. The least recently used one past this is disconnected. */
|
|
279
|
+
const MAX_FOLDER_MCP_CONNECTIONS = 16;
|
|
280
|
+
function disposeConnectionSet(set) {
|
|
281
|
+
try {
|
|
282
|
+
set.unsubscribe();
|
|
283
|
+
}
|
|
284
|
+
catch { /* noop */ }
|
|
285
|
+
try {
|
|
286
|
+
set.manager.dispose();
|
|
287
|
+
}
|
|
288
|
+
catch { /* noop */ }
|
|
289
|
+
}
|
|
259
290
|
function sdkScopeCwd(scope, cwd) {
|
|
260
291
|
if (scope === 'user')
|
|
261
292
|
return undefined;
|
|
@@ -783,8 +814,8 @@ export class PluginMcpManagerService {
|
|
|
783
814
|
mcpApprovalsPath;
|
|
784
815
|
sdkApprovalsPath;
|
|
785
816
|
pluginHost = null;
|
|
786
|
-
|
|
787
|
-
|
|
817
|
+
sharedMcpConnections = null;
|
|
818
|
+
folderMcp = new Map();
|
|
788
819
|
pluginEvents = [];
|
|
789
820
|
activePluginsHydrated = false;
|
|
790
821
|
/** A string is the legacy layout at that base (`~/.xeno`, or a test's temp folder). */
|
|
@@ -831,11 +862,13 @@ export class PluginMcpManagerService {
|
|
|
831
862
|
...stringArray(plugin.registeredTools?.map(pluginToolName)),
|
|
832
863
|
]);
|
|
833
864
|
const configured = await this.listConfiguredMcpRecords(request);
|
|
834
|
-
const
|
|
835
|
-
const
|
|
836
|
-
const
|
|
837
|
-
const
|
|
838
|
-
const
|
|
865
|
+
const folderSet = request.cwd ? await this.folderMcp.get(folderMcpKey(request.cwd)) : undefined;
|
|
866
|
+
const managers = folderSet ? [folderSet.manager, manager] : [manager];
|
|
867
|
+
const runtimeStates = managers.flatMap((entry) => entry.listServers());
|
|
868
|
+
const mcpServers = this.mergeMcpServerSummaries(configured, runtimeStates, managers);
|
|
869
|
+
const mcpTools = managers.flatMap((entry) => entry.listTools()).map(summarizeMcpTool);
|
|
870
|
+
const mcpPrompts = managers.flatMap((entry) => entry.listPrompts()).map(summarizeMcpPrompt);
|
|
871
|
+
const mcpResources = managers.flatMap((entry) => entry.listResources()).map(summarizeMcpResource);
|
|
839
872
|
const activePluginCount = plugins.filter((plugin) => plugin.status === 'active').length;
|
|
840
873
|
return {
|
|
841
874
|
plugins,
|
|
@@ -992,8 +1025,7 @@ export class PluginMcpManagerService {
|
|
|
992
1025
|
if (existing && mcpConfigHash(existing) !== mcpConfigHash(next)) {
|
|
993
1026
|
next.approvalState = undefined;
|
|
994
1027
|
next.approvalConfigHash = undefined;
|
|
995
|
-
|
|
996
|
-
manager.removeServer(next.name);
|
|
1028
|
+
await this.disconnectMcpServerEverywhere(next.name);
|
|
997
1029
|
}
|
|
998
1030
|
file.servers = [
|
|
999
1031
|
...file.servers.filter((entry) => entry.name !== server.name),
|
|
@@ -1013,8 +1045,7 @@ export class PluginMcpManagerService {
|
|
|
1013
1045
|
return { success: false, error: 'MCP server name is required.' };
|
|
1014
1046
|
if (isPluginMcpServerName(name))
|
|
1015
1047
|
return { success: false, error: PLUGIN_MCP_NAME_RESERVED };
|
|
1016
|
-
|
|
1017
|
-
manager.removeServer(name);
|
|
1048
|
+
await this.disconnectMcpServerEverywhere(name);
|
|
1018
1049
|
if (request.scope) {
|
|
1019
1050
|
const sdk = await loadSdk();
|
|
1020
1051
|
const configPath = sdk.removeMcpServerConfig(request.scope, sdkScopeCwd(request.scope, request.cwd), name);
|
|
@@ -1054,10 +1085,8 @@ export class PluginMcpManagerService {
|
|
|
1054
1085
|
}
|
|
1055
1086
|
server.updatedAt = Date.now();
|
|
1056
1087
|
this.writeMcpFile(file);
|
|
1057
|
-
if (request.decision !== 'approved')
|
|
1058
|
-
|
|
1059
|
-
manager.removeServer(name);
|
|
1060
|
-
}
|
|
1088
|
+
if (request.decision !== 'approved')
|
|
1089
|
+
await this.disconnectMcpServerEverywhere(name);
|
|
1061
1090
|
this.appendMcpApproval({
|
|
1062
1091
|
type: 'mcp-approval.decision',
|
|
1063
1092
|
targetType: 'mcp',
|
|
@@ -1088,7 +1117,6 @@ export class PluginMcpManagerService {
|
|
|
1088
1117
|
const errors = [];
|
|
1089
1118
|
try {
|
|
1090
1119
|
this.disposeMcpManager();
|
|
1091
|
-
const manager = await this.getMcpManager();
|
|
1092
1120
|
const configured = await this.listConfiguredMcpRecords({ cwd: request.cwd, includeSdkConfigured: true });
|
|
1093
1121
|
const file = this.readMcpFile();
|
|
1094
1122
|
const effectivePolicy = this.resolveEffectivePolicy(normalizeCaller(request), file);
|
|
@@ -1106,13 +1134,12 @@ export class PluginMcpManagerService {
|
|
|
1106
1134
|
skipped.push(server.name);
|
|
1107
1135
|
continue;
|
|
1108
1136
|
}
|
|
1109
|
-
|
|
1110
|
-
|
|
1137
|
+
const set = isFolderMcpServer(server) && request.cwd ? await this.folderConnectionSet(request.cwd) : await this.sharedConnectionSet();
|
|
1138
|
+
const failure = await this.connectMcpServer(set, server, request.cwd, true);
|
|
1139
|
+
if (failure)
|
|
1140
|
+
errors.push({ name: server.name, error: failure });
|
|
1141
|
+
else
|
|
1111
1142
|
connected.push(server.name);
|
|
1112
|
-
}
|
|
1113
|
-
catch (err) {
|
|
1114
|
-
errors.push({ name: server.name, error: err instanceof Error ? err.message : String(err) });
|
|
1115
|
-
}
|
|
1116
1143
|
}
|
|
1117
1144
|
}
|
|
1118
1145
|
else {
|
|
@@ -1236,8 +1263,7 @@ export class PluginMcpManagerService {
|
|
|
1236
1263
|
if (existing && mcpConfigHash(existing) !== mcpConfigHash(next)) {
|
|
1237
1264
|
next.approvalState = undefined;
|
|
1238
1265
|
next.approvalConfigHash = undefined;
|
|
1239
|
-
|
|
1240
|
-
manager.removeServer(next.name);
|
|
1266
|
+
await this.disconnectMcpServerEverywhere(next.name);
|
|
1241
1267
|
}
|
|
1242
1268
|
existingByName.set(server.name, next);
|
|
1243
1269
|
}
|
|
@@ -1481,6 +1507,7 @@ export class PluginMcpManagerService {
|
|
|
1481
1507
|
const errors = [];
|
|
1482
1508
|
const pluginTools = [];
|
|
1483
1509
|
const mcpTools = [];
|
|
1510
|
+
const awaitingApproval = [];
|
|
1484
1511
|
const file = this.readMcpFile();
|
|
1485
1512
|
const effectivePolicy = this.resolveEffectivePolicy(normalizeCaller(options), file);
|
|
1486
1513
|
if (options.includePlugins !== false) {
|
|
@@ -1520,31 +1547,42 @@ export class PluginMcpManagerService {
|
|
|
1520
1547
|
}
|
|
1521
1548
|
try {
|
|
1522
1549
|
const sdk = await loadSdk();
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
if (
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1550
|
+
const configured = await this.listConfiguredMcpRecords({ cwd: options.cwd, includeSdkConfigured: true });
|
|
1551
|
+
const usable = configured.filter((server) => {
|
|
1552
|
+
if (excluded.has(server.name) || !this.isMcpServerAllowed(server.name, effectivePolicy))
|
|
1553
|
+
return false;
|
|
1554
|
+
const state = analyzeMcpTrust(server).state;
|
|
1555
|
+
if (state === 'review-required')
|
|
1556
|
+
awaitingApproval.push(server.name);
|
|
1557
|
+
return state === 'trusted';
|
|
1558
|
+
});
|
|
1559
|
+
const shared = await this.sharedConnectionSet();
|
|
1560
|
+
const folderServers = options.cwd ? usable.filter(isFolderMcpServer) : [];
|
|
1561
|
+
const folder = options.cwd && (folderServers.length > 0 || this.folderMcp.has(folderMcpKey(options.cwd)))
|
|
1562
|
+
? await this.folderConnectionSet(options.cwd)
|
|
1563
|
+
: undefined;
|
|
1564
|
+
if (folder)
|
|
1565
|
+
this.dropUnwantedFolderConnections(folder, folderServers);
|
|
1566
|
+
const folderNames = new Set(folderServers.map((server) => server.name));
|
|
1567
|
+
await Promise.all(usable.map(async (server) => {
|
|
1568
|
+
const failure = await this.connectMcpServer(folderNames.has(server.name) && folder ? folder : shared, server, options.cwd, false);
|
|
1569
|
+
if (failure)
|
|
1570
|
+
errors.push(`MCP ${server.name}: ${failure}`);
|
|
1571
|
+
}));
|
|
1572
|
+
const sharedNames = new Set(usable.map((server) => server.name).filter((name) => !folderNames.has(name)));
|
|
1573
|
+
const admit = (names) => (entry) => {
|
|
1574
|
+
const admitted = names.has(entry.server) && sdk.matchesMcpRegistryEntryPolicy(entry, effectivePolicy.mcpRegistryPolicy);
|
|
1541
1575
|
// A composer's own server (trusted AND marked built in): remember its tools by the name
|
|
1542
1576
|
// the registry gives them, so the turn can show them up front and trust them.
|
|
1543
1577
|
if (admitted && entry.kind === 'tool' && file.servers.some((server) => server.name === entry.server && server.builtIn === true)) {
|
|
1544
1578
|
builtInCandidates.push(sdk.getMcpToolName(entry.server, entry.name));
|
|
1545
1579
|
}
|
|
1546
1580
|
return admitted;
|
|
1547
|
-
}
|
|
1581
|
+
};
|
|
1582
|
+
const registry = toolRegistry;
|
|
1583
|
+
const registered = sdk.syncMcpToolsToRegistry(shared.manager, registry, [], admit(sharedNames));
|
|
1584
|
+
if (folder)
|
|
1585
|
+
registered.push(...sdk.syncMcpToolsToRegistry(folder.manager, registry, [], admit(folderNames)));
|
|
1548
1586
|
mcpTools.push(...registered);
|
|
1549
1587
|
}
|
|
1550
1588
|
catch (err) {
|
|
@@ -1553,7 +1591,7 @@ export class PluginMcpManagerService {
|
|
|
1553
1591
|
}
|
|
1554
1592
|
// Only names that really reached the registry (a collision can rename one).
|
|
1555
1593
|
const builtInMcpTools = builtInCandidates.filter((name) => mcpTools.includes(name));
|
|
1556
|
-
return { pluginTools, mcpTools, builtInMcpTools, errors };
|
|
1594
|
+
return { pluginTools, mcpTools, builtInMcpTools, awaitingApproval, errors };
|
|
1557
1595
|
}
|
|
1558
1596
|
toSearchDocuments() {
|
|
1559
1597
|
const documents = [];
|
|
@@ -1642,10 +1680,6 @@ export class PluginMcpManagerService {
|
|
|
1642
1680
|
isMcpServerAllowed(name, policy) {
|
|
1643
1681
|
return isAllowedByPolicyLists(name, policy.mcpServerAllowlist, policy.mcpServerDenylist);
|
|
1644
1682
|
}
|
|
1645
|
-
isMcpServerTrusted(name, file = this.readMcpFile()) {
|
|
1646
|
-
const server = file.servers.find((entry) => entry.name === name);
|
|
1647
|
-
return !!server && analyzeMcpTrust(server).state === 'trusted';
|
|
1648
|
-
}
|
|
1649
1683
|
assertMcpServerUsable(serverName, caller, accessKind) {
|
|
1650
1684
|
const name = normalizeSearchText(serverName);
|
|
1651
1685
|
if (!name) {
|
|
@@ -1840,8 +1874,13 @@ export class PluginMcpManagerService {
|
|
|
1840
1874
|
}
|
|
1841
1875
|
}
|
|
1842
1876
|
async getMcpManager() {
|
|
1843
|
-
|
|
1844
|
-
|
|
1877
|
+
return (await this.sharedConnectionSet()).manager;
|
|
1878
|
+
}
|
|
1879
|
+
sharedConnectionSet() {
|
|
1880
|
+
this.sharedMcpConnections ??= this.createMcpConnectionSet();
|
|
1881
|
+
return this.sharedMcpConnections;
|
|
1882
|
+
}
|
|
1883
|
+
async createMcpConnectionSet() {
|
|
1845
1884
|
// Built with the stored credentials (`@xenosystem/agent-sdk/mcp-auth`): an OAuth MCP server a person logged into with
|
|
1846
1885
|
// `xeno mcp login` or `mcpAuth.login` gets its token, refreshed when it expires. Before, only `bearerTokenEnv` was
|
|
1847
1886
|
// read, so such a server worked in the terminal and failed here. The subpath bundles its own copy of the MCPManager
|
|
@@ -1851,8 +1890,8 @@ export class PluginMcpManagerService {
|
|
|
1851
1890
|
import('@xenosystem/agent-sdk/mcp-auth'),
|
|
1852
1891
|
import('@xenosystem/agent-sdk'),
|
|
1853
1892
|
]);
|
|
1854
|
-
|
|
1855
|
-
|
|
1893
|
+
const manager = createMcpManagerWithCredentials({ managerClass: SdkMCPManager });
|
|
1894
|
+
const unsubscribe = manager.onServerStateChanged((event) => {
|
|
1856
1895
|
this.appendMcpApproval({
|
|
1857
1896
|
name: event.serverName,
|
|
1858
1897
|
approvalKey: event.state.config.approvalKey || event.serverName,
|
|
@@ -1862,19 +1901,91 @@ export class PluginMcpManagerService {
|
|
|
1862
1901
|
timestamp: new Date().toISOString(),
|
|
1863
1902
|
});
|
|
1864
1903
|
});
|
|
1865
|
-
return
|
|
1866
|
-
}
|
|
1867
|
-
|
|
1904
|
+
return { manager, unsubscribe, definitions: new Map(), connecting: new Map(), failures: new Map(), lastUsed: Date.now() };
|
|
1905
|
+
}
|
|
1906
|
+
async folderConnectionSet(cwd) {
|
|
1907
|
+
const key = folderMcpKey(cwd);
|
|
1908
|
+
let pending = this.folderMcp.get(key);
|
|
1909
|
+
if (!pending) {
|
|
1910
|
+
pending = this.createMcpConnectionSet();
|
|
1911
|
+
this.folderMcp.set(key, pending);
|
|
1912
|
+
}
|
|
1913
|
+
const set = await pending;
|
|
1914
|
+
set.lastUsed = Date.now();
|
|
1915
|
+
await this.evictFolderConnections(key);
|
|
1916
|
+
return set;
|
|
1917
|
+
}
|
|
1918
|
+
async evictFolderConnections(keep) {
|
|
1919
|
+
if (this.folderMcp.size <= MAX_FOLDER_MCP_CONNECTIONS)
|
|
1920
|
+
return;
|
|
1921
|
+
const entries = await Promise.all([...this.folderMcp.entries()].map(async ([key, pending]) => ({ key, set: await pending })));
|
|
1922
|
+
const oldest = entries.filter((entry) => entry.key !== keep).sort((left, right) => left.set.lastUsed - right.set.lastUsed)[0];
|
|
1923
|
+
if (!oldest)
|
|
1924
|
+
return;
|
|
1925
|
+
this.folderMcp.delete(oldest.key);
|
|
1926
|
+
disposeConnectionSet(oldest.set);
|
|
1927
|
+
}
|
|
1928
|
+
/** Connects one approved server unless it is live on this definition. Returns why it could not. */
|
|
1929
|
+
async connectMcpServer(set, server, cwd, force) {
|
|
1930
|
+
const name = server.name;
|
|
1931
|
+
const hash = mcpConfigHash(server);
|
|
1932
|
+
const pending = set.connecting.get(name);
|
|
1933
|
+
if (pending)
|
|
1934
|
+
await pending.catch(() => undefined);
|
|
1935
|
+
const live = set.manager.listServers().find((state) => state.config.name === name);
|
|
1936
|
+
const isLive = live?.status === 'ready' || live?.status === 'connecting';
|
|
1937
|
+
if (isLive && set.definitions.get(name) === hash)
|
|
1938
|
+
return undefined;
|
|
1939
|
+
const failed = set.failures.get(name);
|
|
1940
|
+
if (!force && failed?.hash === hash && Date.now() - failed.at < MCP_CONNECT_RETRY_MS)
|
|
1941
|
+
return failed.error;
|
|
1942
|
+
if (live)
|
|
1943
|
+
set.manager.removeServer(name);
|
|
1944
|
+
const config = mcpRecordToConfig(server);
|
|
1945
|
+
// The host's own working directory means nothing to a folder's server: `node ./server.js` is relative to the folder.
|
|
1946
|
+
const connection = set.manager.addServer(isFolderMcpServer(server) && cwd && config.cwd === undefined ? { ...config, cwd: resolve(cwd) } : config);
|
|
1947
|
+
set.connecting.set(name, connection);
|
|
1868
1948
|
try {
|
|
1869
|
-
|
|
1949
|
+
await connection;
|
|
1950
|
+
set.definitions.set(name, hash);
|
|
1951
|
+
set.failures.delete(name);
|
|
1952
|
+
return undefined;
|
|
1870
1953
|
}
|
|
1871
|
-
catch {
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1954
|
+
catch (err) {
|
|
1955
|
+
const error = err instanceof Error ? err.message : String(err);
|
|
1956
|
+
set.failures.set(name, { hash, at: Date.now(), error });
|
|
1957
|
+
return error;
|
|
1958
|
+
}
|
|
1959
|
+
finally {
|
|
1960
|
+
if (set.connecting.get(name) === connection)
|
|
1961
|
+
set.connecting.delete(name);
|
|
1875
1962
|
}
|
|
1876
|
-
|
|
1877
|
-
|
|
1963
|
+
}
|
|
1964
|
+
/** A folder's server that is no longer approved or configured stops serving that folder's turns. */
|
|
1965
|
+
dropUnwantedFolderConnections(set, wanted) {
|
|
1966
|
+
const names = new Set(wanted.map((server) => server.name));
|
|
1967
|
+
for (const state of set.manager.listServers()) {
|
|
1968
|
+
if (names.has(state.config.name))
|
|
1969
|
+
continue;
|
|
1970
|
+
set.manager.removeServer(state.config.name);
|
|
1971
|
+
set.definitions.delete(state.config.name);
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1974
|
+
/** A decision or an edit applies now, including to a turn already running. */
|
|
1975
|
+
async disconnectMcpServerEverywhere(name) {
|
|
1976
|
+
const sets = await Promise.all([this.sharedConnectionSet(), ...this.folderMcp.values()]);
|
|
1977
|
+
for (const set of sets) {
|
|
1978
|
+
set.manager.removeServer(name);
|
|
1979
|
+
set.definitions.delete(name);
|
|
1980
|
+
set.failures.delete(name);
|
|
1981
|
+
}
|
|
1982
|
+
}
|
|
1983
|
+
disposeMcpManager() {
|
|
1984
|
+
const sets = [this.sharedMcpConnections, ...this.folderMcp.values()];
|
|
1985
|
+
this.sharedMcpConnections = null;
|
|
1986
|
+
this.folderMcp.clear();
|
|
1987
|
+
for (const pending of sets)
|
|
1988
|
+
void pending?.then(disposeConnectionSet, () => undefined);
|
|
1878
1989
|
}
|
|
1879
1990
|
async withPlugin(inputName, handler) {
|
|
1880
1991
|
try {
|
|
@@ -1927,8 +2038,7 @@ export class PluginMcpManagerService {
|
|
|
1927
2038
|
});
|
|
1928
2039
|
// A changed definition must not keep a live connection made under the old one. Its approval is
|
|
1929
2040
|
// already void: the hash covers the definition.
|
|
1930
|
-
|
|
1931
|
-
manager.removeServer(name);
|
|
2041
|
+
await this.disconnectMcpServerEverywhere(name);
|
|
1932
2042
|
const server = (await this.listConfiguredMcpRecords({ cwd, includeSdkConfigured: true }))
|
|
1933
2043
|
.find((entry) => entry.name === name && entry.source === 'sdk-config' && resolve(entry.sourcePath) === resolve(configPath));
|
|
1934
2044
|
if (!server)
|
|
@@ -1961,10 +2071,8 @@ export class PluginMcpManagerService {
|
|
|
1961
2071
|
else
|
|
1962
2072
|
sdk.clearMcpServerApproval(request.cwd, server.approvalKey);
|
|
1963
2073
|
}
|
|
1964
|
-
if (request.decision !== 'approved')
|
|
1965
|
-
|
|
1966
|
-
manager.removeServer(name);
|
|
1967
|
-
}
|
|
2074
|
+
if (request.decision !== 'approved')
|
|
2075
|
+
await this.disconnectMcpServerEverywhere(name);
|
|
1968
2076
|
this.appendMcpApproval({
|
|
1969
2077
|
type: 'mcp-approval.decision',
|
|
1970
2078
|
targetType: 'mcp',
|
|
@@ -2086,8 +2194,11 @@ export class PluginMcpManagerService {
|
|
|
2086
2194
|
}))
|
|
2087
2195
|
: [];
|
|
2088
2196
|
return {
|
|
2089
|
-
version:
|
|
2090
|
-
|
|
2197
|
+
version: 2,
|
|
2198
|
+
// Version 1 wrote the old default on every save, so its `context` says nothing about what anyone chose.
|
|
2199
|
+
registryPolicy: value.version === 1 && value.registryPolicy === 'context'
|
|
2200
|
+
? DEFAULT_REGISTRY_POLICY
|
|
2201
|
+
: normalizeRegistryPolicy(value.registryPolicy),
|
|
2091
2202
|
scopedPolicies: Array.isArray(value.scopedPolicies)
|
|
2092
2203
|
? value.scopedPolicies
|
|
2093
2204
|
.filter((policy) => !!policy && typeof policy === 'object' && !!policy.scope)
|
|
@@ -2101,7 +2212,7 @@ export class PluginMcpManagerService {
|
|
|
2101
2212
|
}
|
|
2102
2213
|
writeMcpFile(file) {
|
|
2103
2214
|
safeWriteJson(this.mcpServersPath, {
|
|
2104
|
-
version:
|
|
2215
|
+
version: 2,
|
|
2105
2216
|
registryPolicy: normalizeRegistryPolicy(file.registryPolicy),
|
|
2106
2217
|
scopedPolicies: file.scopedPolicies
|
|
2107
2218
|
.map((policy) => normalizeScopedPolicy({ ...policy, scope: policy.scope }, policy))
|
|
@@ -2136,16 +2247,21 @@ export class PluginMcpManagerService {
|
|
|
2136
2247
|
return hubServers;
|
|
2137
2248
|
}
|
|
2138
2249
|
}
|
|
2139
|
-
mergeMcpServerSummaries(configured, runtimeStates,
|
|
2140
|
-
|
|
2250
|
+
mergeMcpServerSummaries(configured, runtimeStates, managers) {
|
|
2251
|
+
// The folder's own set is listed first, so its definition of a name wins over a shared one.
|
|
2252
|
+
const runtimeByName = new Map();
|
|
2253
|
+
for (const state of runtimeStates)
|
|
2254
|
+
if (!runtimeByName.has(state.config.name))
|
|
2255
|
+
runtimeByName.set(state.config.name, state);
|
|
2256
|
+
const managerOf = (name) => managers.find((entry) => entry.listServers().some((state) => state.config.name === name)) ?? managers[0];
|
|
2141
2257
|
const summaries = [];
|
|
2142
2258
|
for (const server of configured) {
|
|
2143
2259
|
const state = runtimeByName.get(server.name);
|
|
2144
|
-
summaries.push(this.mcpServerSummary(server, state,
|
|
2260
|
+
summaries.push(this.mcpServerSummary(server, state, managerOf(server.name)));
|
|
2145
2261
|
runtimeByName.delete(server.name);
|
|
2146
2262
|
}
|
|
2147
2263
|
for (const state of runtimeByName.values()) {
|
|
2148
|
-
summaries.push(this.mcpServerSummary(mcpRecordFromConfig(state.config, state.config.sourcePath || this.mcpServersPath, 'hub'), state,
|
|
2264
|
+
summaries.push(this.mcpServerSummary(mcpRecordFromConfig(state.config, state.config.sourcePath || this.mcpServersPath, 'hub'), state, managerOf(state.config.name)));
|
|
2149
2265
|
}
|
|
2150
2266
|
return summaries.sort((left, right) => left.name.localeCompare(right.name));
|
|
2151
2267
|
}
|