@mcpc-tech/cli 0.1.52 → 0.1.54
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/app.cjs +193 -56
- package/app.mjs +194 -57
- package/bin/mcpc.cjs +120 -46
- package/bin/mcpc.mjs +120 -46
- package/bin.cjs +120 -46
- package/bin.mjs +120 -46
- package/index.cjs +193 -56
- package/index.mjs +194 -57
- package/package.json +2 -2
- package/server.cjs +193 -56
- package/server.mjs +194 -57
package/bin/mcpc.mjs
CHANGED
|
@@ -544,10 +544,9 @@ var ProgressTokenSchema = z.union([z.string(), z.number().int()]);
|
|
|
544
544
|
var CursorSchema = z.string();
|
|
545
545
|
var TaskCreationParamsSchema = z.looseObject({
|
|
546
546
|
/**
|
|
547
|
-
*
|
|
548
|
-
* If null, the task has unlimited lifetime until manually cleaned up.
|
|
547
|
+
* Requested duration in milliseconds to retain task from creation.
|
|
549
548
|
*/
|
|
550
|
-
ttl: z.
|
|
549
|
+
ttl: z.number().optional(),
|
|
551
550
|
/**
|
|
552
551
|
* Time in milliseconds to wait between task status requests.
|
|
553
552
|
*/
|
|
@@ -847,7 +846,11 @@ var ClientCapabilitiesSchema = z.object({
|
|
|
847
846
|
/**
|
|
848
847
|
* Present if the client supports task creation.
|
|
849
848
|
*/
|
|
850
|
-
tasks: ClientTasksCapabilitySchema.optional()
|
|
849
|
+
tasks: ClientTasksCapabilitySchema.optional(),
|
|
850
|
+
/**
|
|
851
|
+
* Extensions that the client supports. Keys are extension identifiers (vendor-prefix/extension-name).
|
|
852
|
+
*/
|
|
853
|
+
extensions: z.record(z.string(), AssertObjectSchema).optional()
|
|
851
854
|
});
|
|
852
855
|
var InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
853
856
|
/**
|
|
@@ -908,7 +911,11 @@ var ServerCapabilitiesSchema = z.object({
|
|
|
908
911
|
/**
|
|
909
912
|
* Present if the server supports task creation.
|
|
910
913
|
*/
|
|
911
|
-
tasks: ServerTasksCapabilitySchema.optional()
|
|
914
|
+
tasks: ServerTasksCapabilitySchema.optional(),
|
|
915
|
+
/**
|
|
916
|
+
* Extensions that the server supports. Keys are extension identifiers (vendor-prefix/extension-name).
|
|
917
|
+
*/
|
|
918
|
+
extensions: z.record(z.string(), AssertObjectSchema).optional()
|
|
912
919
|
});
|
|
913
920
|
var InitializeResultSchema = ResultSchema.extend({
|
|
914
921
|
/**
|
|
@@ -1101,6 +1108,12 @@ var ResourceSchema = z.object({
|
|
|
1101
1108
|
* The MIME type of this resource, if known.
|
|
1102
1109
|
*/
|
|
1103
1110
|
mimeType: z.optional(z.string()),
|
|
1111
|
+
/**
|
|
1112
|
+
* The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known.
|
|
1113
|
+
*
|
|
1114
|
+
* This can be used by Hosts to display file sizes and estimate context window usage.
|
|
1115
|
+
*/
|
|
1116
|
+
size: z.optional(z.number()),
|
|
1104
1117
|
/**
|
|
1105
1118
|
* Optional annotations for the client.
|
|
1106
1119
|
*/
|
|
@@ -2342,15 +2355,17 @@ var Response2 = class _Response {
|
|
|
2342
2355
|
this.#init = init;
|
|
2343
2356
|
}
|
|
2344
2357
|
if (typeof body === "string" || typeof body?.getReader !== "undefined" || body instanceof Blob || body instanceof Uint8Array) {
|
|
2345
|
-
|
|
2346
|
-
this[cacheKey] = [init?.status || 200, body, headers];
|
|
2358
|
+
;
|
|
2359
|
+
this[cacheKey] = [init?.status || 200, body, headers || init?.headers];
|
|
2347
2360
|
}
|
|
2348
2361
|
}
|
|
2349
2362
|
get headers() {
|
|
2350
2363
|
const cache = this[cacheKey];
|
|
2351
2364
|
if (cache) {
|
|
2352
2365
|
if (!(cache[2] instanceof Headers)) {
|
|
2353
|
-
cache[2] = new Headers(
|
|
2366
|
+
cache[2] = new Headers(
|
|
2367
|
+
cache[2] || { "content-type": "text/plain; charset=UTF-8" }
|
|
2368
|
+
);
|
|
2354
2369
|
}
|
|
2355
2370
|
return cache[2];
|
|
2356
2371
|
}
|
|
@@ -2384,6 +2399,8 @@ if (typeof global.crypto === "undefined") {
|
|
|
2384
2399
|
global.crypto = crypto2;
|
|
2385
2400
|
}
|
|
2386
2401
|
var outgoingEnded = Symbol("outgoingEnded");
|
|
2402
|
+
var incomingDraining = Symbol("incomingDraining");
|
|
2403
|
+
var MAX_DRAIN_BYTES = 64 * 1024 * 1024;
|
|
2387
2404
|
|
|
2388
2405
|
// __mcpc__cli_latest/node_modules/@jsr/std__cli/parse_args.js
|
|
2389
2406
|
var FLAG_REGEXP = /^(?:-(?:(?<doubleDash>-)(?<negated>no-)?)?)(?<key>.+?)(?:=(?<value>.*))?$/s;
|
|
@@ -5487,7 +5504,7 @@ function getDefaultAgents() {
|
|
|
5487
5504
|
}
|
|
5488
5505
|
|
|
5489
5506
|
// __mcpc__cli_latest/node_modules/@mcpc/cli/src/config/loader.js
|
|
5490
|
-
var CLI_VERSION = "0.1.
|
|
5507
|
+
var CLI_VERSION = "0.1.54";
|
|
5491
5508
|
function extractServerName(command, commandArgs) {
|
|
5492
5509
|
for (const arg of commandArgs) {
|
|
5493
5510
|
if (!arg.startsWith("-")) {
|
|
@@ -5910,7 +5927,7 @@ function applyModeOverride(config, mode) {
|
|
|
5910
5927
|
agent.options.mode = mode;
|
|
5911
5928
|
if (mode === "ai_acp" && !agent.options.acpSettings) {
|
|
5912
5929
|
agent.options.acpSettings = {
|
|
5913
|
-
command: "claude-
|
|
5930
|
+
command: "claude-agent-acp",
|
|
5914
5931
|
args: [],
|
|
5915
5932
|
session: {}
|
|
5916
5933
|
};
|
|
@@ -6270,6 +6287,10 @@ var Protocol = class {
|
|
|
6270
6287
|
this._progressHandlers.clear();
|
|
6271
6288
|
this._taskProgressTokens.clear();
|
|
6272
6289
|
this._pendingDebouncedNotifications.clear();
|
|
6290
|
+
for (const info of this._timeoutInfo.values()) {
|
|
6291
|
+
clearTimeout(info.timeoutId);
|
|
6292
|
+
}
|
|
6293
|
+
this._timeoutInfo.clear();
|
|
6273
6294
|
for (const controller of this._requestHandlerAbortControllers.values()) {
|
|
6274
6295
|
controller.abort();
|
|
6275
6296
|
}
|
|
@@ -6400,7 +6421,9 @@ var Protocol = class {
|
|
|
6400
6421
|
await capturedTransport?.send(errorResponse);
|
|
6401
6422
|
}
|
|
6402
6423
|
}).catch((error) => this._onerror(new Error(`Failed to send response: ${error}`))).finally(() => {
|
|
6403
|
-
this._requestHandlerAbortControllers.
|
|
6424
|
+
if (this._requestHandlerAbortControllers.get(request.id) === abortController) {
|
|
6425
|
+
this._requestHandlerAbortControllers.delete(request.id);
|
|
6426
|
+
}
|
|
6404
6427
|
});
|
|
6405
6428
|
}
|
|
6406
6429
|
_onprogress(notification) {
|
|
@@ -8494,7 +8517,7 @@ var StdioClientTransport = class {
|
|
|
8494
8517
|
},
|
|
8495
8518
|
stdio: ["pipe", "pipe", this._serverParams.stderr ?? "inherit"],
|
|
8496
8519
|
shell: false,
|
|
8497
|
-
windowsHide: process7.platform === "win32"
|
|
8520
|
+
windowsHide: process7.platform === "win32",
|
|
8498
8521
|
cwd: this._serverParams.cwd
|
|
8499
8522
|
});
|
|
8500
8523
|
this._process.on("error", (error) => {
|
|
@@ -8601,9 +8624,6 @@ var StdioClientTransport = class {
|
|
|
8601
8624
|
});
|
|
8602
8625
|
}
|
|
8603
8626
|
};
|
|
8604
|
-
function isElectron() {
|
|
8605
|
-
return "type" in process7;
|
|
8606
|
-
}
|
|
8607
8627
|
|
|
8608
8628
|
// __mcpc__cli_latest/node_modules/eventsource-parser/dist/index.js
|
|
8609
8629
|
var ParseError = class extends Error {
|
|
@@ -9348,12 +9368,12 @@ var AUTHORIZATION_CODE_RESPONSE_TYPE = "code";
|
|
|
9348
9368
|
var AUTHORIZATION_CODE_CHALLENGE_METHOD = "S256";
|
|
9349
9369
|
function selectClientAuthMethod(clientInformation, supportedMethods) {
|
|
9350
9370
|
const hasClientSecret = clientInformation.client_secret !== void 0;
|
|
9351
|
-
if (supportedMethods.length === 0) {
|
|
9352
|
-
return hasClientSecret ? "client_secret_post" : "none";
|
|
9353
|
-
}
|
|
9354
|
-
if ("token_endpoint_auth_method" in clientInformation && clientInformation.token_endpoint_auth_method && isClientAuthMethod(clientInformation.token_endpoint_auth_method) && supportedMethods.includes(clientInformation.token_endpoint_auth_method)) {
|
|
9371
|
+
if ("token_endpoint_auth_method" in clientInformation && clientInformation.token_endpoint_auth_method && isClientAuthMethod(clientInformation.token_endpoint_auth_method) && (supportedMethods.length === 0 || supportedMethods.includes(clientInformation.token_endpoint_auth_method))) {
|
|
9355
9372
|
return clientInformation.token_endpoint_auth_method;
|
|
9356
9373
|
}
|
|
9374
|
+
if (supportedMethods.length === 0) {
|
|
9375
|
+
return hasClientSecret ? "client_secret_basic" : "none";
|
|
9376
|
+
}
|
|
9357
9377
|
if (hasClientSecret && supportedMethods.includes("client_secret_basic")) {
|
|
9358
9378
|
return "client_secret_basic";
|
|
9359
9379
|
}
|
|
@@ -9464,6 +9484,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
|
|
|
9464
9484
|
});
|
|
9465
9485
|
}
|
|
9466
9486
|
const resource = await selectResourceURL(serverUrl, provider, resourceMetadata);
|
|
9487
|
+
const resolvedScope = scope || resourceMetadata?.scopes_supported?.join(" ") || provider.clientMetadata.scope;
|
|
9467
9488
|
let clientInformation = await Promise.resolve(provider.clientInformation());
|
|
9468
9489
|
if (!clientInformation) {
|
|
9469
9490
|
if (authorizationCode !== void 0) {
|
|
@@ -9487,6 +9508,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
|
|
|
9487
9508
|
const fullInformation = await registerClient(authorizationServerUrl, {
|
|
9488
9509
|
metadata,
|
|
9489
9510
|
clientMetadata: provider.clientMetadata,
|
|
9511
|
+
scope: resolvedScope,
|
|
9490
9512
|
fetchFn
|
|
9491
9513
|
});
|
|
9492
9514
|
await provider.saveClientInformation(fullInformation);
|
|
@@ -9530,7 +9552,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
|
|
|
9530
9552
|
clientInformation,
|
|
9531
9553
|
state,
|
|
9532
9554
|
redirectUrl: provider.redirectUrl,
|
|
9533
|
-
scope:
|
|
9555
|
+
scope: resolvedScope,
|
|
9534
9556
|
resource
|
|
9535
9557
|
});
|
|
9536
9558
|
await provider.saveCodeVerifier(codeVerifier);
|
|
@@ -9848,7 +9870,7 @@ async function fetchToken(provider, authorizationServerUrl, { metadata, resource
|
|
|
9848
9870
|
fetchFn
|
|
9849
9871
|
});
|
|
9850
9872
|
}
|
|
9851
|
-
async function registerClient(authorizationServerUrl, { metadata, clientMetadata, fetchFn }) {
|
|
9873
|
+
async function registerClient(authorizationServerUrl, { metadata, clientMetadata, scope, fetchFn }) {
|
|
9852
9874
|
let registrationUrl;
|
|
9853
9875
|
if (metadata) {
|
|
9854
9876
|
if (!metadata.registration_endpoint) {
|
|
@@ -9863,7 +9885,10 @@ async function registerClient(authorizationServerUrl, { metadata, clientMetadata
|
|
|
9863
9885
|
headers: {
|
|
9864
9886
|
"Content-Type": "application/json"
|
|
9865
9887
|
},
|
|
9866
|
-
body: JSON.stringify(
|
|
9888
|
+
body: JSON.stringify({
|
|
9889
|
+
...clientMetadata,
|
|
9890
|
+
...scope !== void 0 ? { scope } : {}
|
|
9891
|
+
})
|
|
9867
9892
|
});
|
|
9868
9893
|
if (!response.ok) {
|
|
9869
9894
|
throw await parseErrorResponse(response);
|
|
@@ -10958,7 +10983,7 @@ var SystemPrompts = {
|
|
|
10958
10983
|
</rules>
|
|
10959
10984
|
|
|
10960
10985
|
<format>
|
|
10961
|
-
Get tool
|
|
10986
|
+
Get tool definitions: \`{ "tool": "man", "args": { "tools": ["tool1", "tool2"] } }\`
|
|
10962
10987
|
Execute a tool: \`{ "tool": "tool_name", "args": { /* parameters */ } }\`
|
|
10963
10988
|
</format>`,
|
|
10964
10989
|
/**
|
|
@@ -11083,7 +11108,7 @@ function createArgsDefFactory(_name, _allToolNames, _depGroups, _predefinedSteps
|
|
|
11083
11108
|
*
|
|
11084
11109
|
* Only two fields:
|
|
11085
11110
|
* - `tool`: which tool to execute (enum includes "man" + all tool names)
|
|
11086
|
-
* - `args`: object with parameters. For "man": { tools: ["a", "b"] }. For others: tool parameters.
|
|
11111
|
+
* - `args`: object with parameters. For "man": { tools: ["a", "b"] } to fetch tool definitions (including input/output schemas). For others: tool parameters.
|
|
11087
11112
|
*/
|
|
11088
11113
|
forAgentic: function(allToolNames) {
|
|
11089
11114
|
const toolEnum = [
|
|
@@ -13034,11 +13059,12 @@ var ToolManager = class {
|
|
|
13034
13059
|
/**
|
|
13035
13060
|
* Register a tool in the registry
|
|
13036
13061
|
*/
|
|
13037
|
-
registerTool(name, description,
|
|
13062
|
+
registerTool(name, description, inputSchema, callback, options = {}) {
|
|
13038
13063
|
this.toolRegistry.set(name, {
|
|
13039
13064
|
callback,
|
|
13040
13065
|
description,
|
|
13041
|
-
|
|
13066
|
+
inputSchema,
|
|
13067
|
+
outputSchema: options.outputSchema
|
|
13042
13068
|
});
|
|
13043
13069
|
if (options.hidden) {
|
|
13044
13070
|
this.toolConfigs.set(name, {
|
|
@@ -13051,13 +13077,16 @@ var ToolManager = class {
|
|
|
13051
13077
|
/**
|
|
13052
13078
|
* Explicitly mark a tool as public (exposed to MCP clients)
|
|
13053
13079
|
*/
|
|
13054
|
-
addPublicTool(name, description,
|
|
13080
|
+
addPublicTool(name, description, inputSchema, outputSchema) {
|
|
13055
13081
|
const existingTool = this.publicTools.find((t) => t.name === name);
|
|
13056
13082
|
if (!existingTool) {
|
|
13057
13083
|
this.publicTools.push({
|
|
13058
13084
|
name,
|
|
13059
13085
|
description,
|
|
13060
|
-
inputSchema
|
|
13086
|
+
inputSchema,
|
|
13087
|
+
...outputSchema ? {
|
|
13088
|
+
outputSchema
|
|
13089
|
+
} : {}
|
|
13061
13090
|
});
|
|
13062
13091
|
}
|
|
13063
13092
|
this.toolConfigs.set(name, {
|
|
@@ -13183,10 +13212,13 @@ var ToolManager = class {
|
|
|
13183
13212
|
getHiddenToolSchema(name) {
|
|
13184
13213
|
const tool2 = this.toolRegistry.get(name);
|
|
13185
13214
|
const config = this.toolConfigs.get(name);
|
|
13186
|
-
if (tool2 && config?.visibility?.hidden && tool2.
|
|
13215
|
+
if (tool2 && config?.visibility?.hidden && tool2.inputSchema) {
|
|
13187
13216
|
return {
|
|
13188
13217
|
description: tool2.description,
|
|
13189
|
-
|
|
13218
|
+
inputSchema: tool2.inputSchema,
|
|
13219
|
+
...tool2.outputSchema ? {
|
|
13220
|
+
outputSchema: tool2.outputSchema
|
|
13221
|
+
} : {}
|
|
13190
13222
|
};
|
|
13191
13223
|
}
|
|
13192
13224
|
return void 0;
|
|
@@ -13222,10 +13254,13 @@ var ToolManager = class {
|
|
|
13222
13254
|
composedTools[name] = {
|
|
13223
13255
|
name,
|
|
13224
13256
|
description: tool2.description,
|
|
13225
|
-
inputSchema: jsonSchema(tool2.
|
|
13257
|
+
inputSchema: jsonSchema(tool2.inputSchema || {
|
|
13226
13258
|
type: "object",
|
|
13227
13259
|
properties: {}
|
|
13228
13260
|
}),
|
|
13261
|
+
...tool2.outputSchema ? {
|
|
13262
|
+
outputSchema: jsonSchema(tool2.outputSchema)
|
|
13263
|
+
} : {},
|
|
13229
13264
|
execute: tool2.callback
|
|
13230
13265
|
};
|
|
13231
13266
|
}
|
|
@@ -13242,10 +13277,13 @@ var ToolManager = class {
|
|
|
13242
13277
|
return {
|
|
13243
13278
|
name,
|
|
13244
13279
|
description: tool2.description,
|
|
13245
|
-
inputSchema: tool2.
|
|
13280
|
+
inputSchema: tool2.inputSchema ?? {
|
|
13246
13281
|
type: "object",
|
|
13247
13282
|
properties: {}
|
|
13248
13283
|
},
|
|
13284
|
+
...tool2.outputSchema ? {
|
|
13285
|
+
outputSchema: tool2.outputSchema
|
|
13286
|
+
} : {},
|
|
13249
13287
|
execute: tool2.callback
|
|
13250
13288
|
};
|
|
13251
13289
|
}
|
|
@@ -13259,10 +13297,13 @@ var ToolManager = class {
|
|
|
13259
13297
|
composedTools.push({
|
|
13260
13298
|
name,
|
|
13261
13299
|
description: tool2.description,
|
|
13262
|
-
inputSchema: tool2.
|
|
13300
|
+
inputSchema: tool2.inputSchema ?? {
|
|
13263
13301
|
type: "object",
|
|
13264
13302
|
properties: {}
|
|
13265
13303
|
},
|
|
13304
|
+
...tool2.outputSchema ? {
|
|
13305
|
+
outputSchema: tool2.outputSchema
|
|
13306
|
+
} : {},
|
|
13266
13307
|
execute: tool2.callback
|
|
13267
13308
|
});
|
|
13268
13309
|
}
|
|
@@ -13315,7 +13356,10 @@ async function processToolsWithPlugins(server, _externalTools, mode) {
|
|
|
13315
13356
|
const tempTool = {
|
|
13316
13357
|
name: toolId,
|
|
13317
13358
|
description: toolData.description,
|
|
13318
|
-
inputSchema: toolData.
|
|
13359
|
+
inputSchema: toolData.inputSchema || defaultSchema,
|
|
13360
|
+
...toolData.outputSchema ? {
|
|
13361
|
+
outputSchema: toolData.outputSchema
|
|
13362
|
+
} : {},
|
|
13319
13363
|
execute: toolData.callback
|
|
13320
13364
|
};
|
|
13321
13365
|
const processedTool = await pluginManager.applyTransformToolHooks(tempTool, {
|
|
@@ -13327,7 +13371,9 @@ async function processToolsWithPlugins(server, _externalTools, mode) {
|
|
|
13327
13371
|
},
|
|
13328
13372
|
transformationIndex: 0
|
|
13329
13373
|
});
|
|
13330
|
-
toolManager.registerTool(toolId, processedTool.description || toolData.description, processedTool.inputSchema, processedTool.execute
|
|
13374
|
+
toolManager.registerTool(toolId, processedTool.description || toolData.description, processedTool.inputSchema, processedTool.execute, {
|
|
13375
|
+
outputSchema: processedTool.outputSchema
|
|
13376
|
+
});
|
|
13331
13377
|
}
|
|
13332
13378
|
}
|
|
13333
13379
|
function buildDependencyGroups(toolNameToDetailList, hiddenToolNames, publicToolNames, server) {
|
|
@@ -13373,6 +13419,7 @@ var ComposableMCPServer = class extends Server {
|
|
|
13373
13419
|
toolManager;
|
|
13374
13420
|
logger = createLogger("mcpc.compose");
|
|
13375
13421
|
fileLoaders = /* @__PURE__ */ new Map();
|
|
13422
|
+
pluginsDisposed = false;
|
|
13376
13423
|
// Legacy property for backward compatibility
|
|
13377
13424
|
get toolNameMapping() {
|
|
13378
13425
|
return this.toolManager.getToolNameMapping();
|
|
@@ -13501,9 +13548,13 @@ var ComposableMCPServer = class extends Server {
|
|
|
13501
13548
|
}
|
|
13502
13549
|
tool(name, description, paramsSchema, cb, options = {}) {
|
|
13503
13550
|
const jsonSchemaObj = extractJsonSchema(paramsSchema);
|
|
13504
|
-
|
|
13551
|
+
const outputSchemaObj = options.outputSchema ? extractJsonSchema(options.outputSchema) : void 0;
|
|
13552
|
+
this.toolManager.registerTool(name, description, jsonSchemaObj, cb, {
|
|
13553
|
+
...options,
|
|
13554
|
+
outputSchema: outputSchemaObj
|
|
13555
|
+
});
|
|
13505
13556
|
if (!options.internal) {
|
|
13506
|
-
this.toolManager.addPublicTool(name, description, jsonSchemaObj);
|
|
13557
|
+
this.toolManager.addPublicTool(name, description, jsonSchemaObj, outputSchemaObj);
|
|
13507
13558
|
}
|
|
13508
13559
|
if (options.plugins) {
|
|
13509
13560
|
for (const plugin of options.plugins) {
|
|
@@ -13760,9 +13811,12 @@ var ComposableMCPServer = class extends Server {
|
|
|
13760
13811
|
return {
|
|
13761
13812
|
name,
|
|
13762
13813
|
description: tool2?.description || "",
|
|
13763
|
-
inputSchema: tool2?.
|
|
13814
|
+
inputSchema: tool2?.inputSchema || {
|
|
13764
13815
|
type: "object"
|
|
13765
|
-
}
|
|
13816
|
+
},
|
|
13817
|
+
...tool2?.outputSchema ? {
|
|
13818
|
+
outputSchema: tool2.outputSchema
|
|
13819
|
+
} : {}
|
|
13766
13820
|
};
|
|
13767
13821
|
});
|
|
13768
13822
|
}
|
|
@@ -13787,9 +13841,12 @@ var ComposableMCPServer = class extends Server {
|
|
|
13787
13841
|
return Array.from(registry.entries()).map(([name, tool2]) => ({
|
|
13788
13842
|
name,
|
|
13789
13843
|
description: tool2?.description || "",
|
|
13790
|
-
inputSchema: tool2?.
|
|
13844
|
+
inputSchema: tool2?.inputSchema || {
|
|
13791
13845
|
type: "object"
|
|
13792
|
-
}
|
|
13846
|
+
},
|
|
13847
|
+
...tool2?.outputSchema ? {
|
|
13848
|
+
outputSchema: tool2.outputSchema
|
|
13849
|
+
} : {}
|
|
13793
13850
|
}));
|
|
13794
13851
|
}
|
|
13795
13852
|
/**
|
|
@@ -13848,11 +13905,21 @@ var ComposableMCPServer = class extends Server {
|
|
|
13848
13905
|
async disposePlugins() {
|
|
13849
13906
|
await this.pluginManager.dispose();
|
|
13850
13907
|
}
|
|
13908
|
+
/**
|
|
13909
|
+
* Dispose plugins only once to avoid duplicated cleanup in chained handlers.
|
|
13910
|
+
*/
|
|
13911
|
+
async disposePluginsOnce() {
|
|
13912
|
+
if (this.pluginsDisposed) {
|
|
13913
|
+
return;
|
|
13914
|
+
}
|
|
13915
|
+
this.pluginsDisposed = true;
|
|
13916
|
+
await this.disposePlugins();
|
|
13917
|
+
}
|
|
13851
13918
|
/**
|
|
13852
13919
|
* Close the server and ensure all plugins are disposed
|
|
13853
13920
|
*/
|
|
13854
13921
|
async close() {
|
|
13855
|
-
await this.
|
|
13922
|
+
await this.disposePluginsOnce();
|
|
13856
13923
|
await super.close();
|
|
13857
13924
|
}
|
|
13858
13925
|
async compose(name, description, depsConfig = {
|
|
@@ -13921,7 +13988,9 @@ var ComposableMCPServer = class extends Server {
|
|
|
13921
13988
|
});
|
|
13922
13989
|
});
|
|
13923
13990
|
Object.entries(tools).forEach(([toolId, tool2]) => {
|
|
13924
|
-
this.toolManager.registerTool(toolId, tool2.description || "", tool2.inputSchema, tool2.execute
|
|
13991
|
+
this.toolManager.registerTool(toolId, tool2.description || "", tool2.inputSchema, tool2.execute, {
|
|
13992
|
+
outputSchema: tool2.outputSchema
|
|
13993
|
+
});
|
|
13925
13994
|
});
|
|
13926
13995
|
const registeredTools = this.toolManager.getRegisteredToolsAsComposed();
|
|
13927
13996
|
const allTools = {
|
|
@@ -13957,16 +14026,20 @@ var ComposableMCPServer = class extends Server {
|
|
|
13957
14026
|
server: this,
|
|
13958
14027
|
toolNames: Object.keys(allTools)
|
|
13959
14028
|
});
|
|
14029
|
+
const previousOnClose = this.onclose;
|
|
13960
14030
|
this.onclose = async () => {
|
|
13961
14031
|
await cleanupClients();
|
|
13962
|
-
await this.
|
|
14032
|
+
await this.disposePluginsOnce();
|
|
13963
14033
|
await this.logger.info(`[${name}] Event: closed - cleaned up dependent clients and plugins`);
|
|
14034
|
+
previousOnClose?.();
|
|
13964
14035
|
};
|
|
14036
|
+
const previousOnError = this.onerror;
|
|
13965
14037
|
this.onerror = async (error) => {
|
|
13966
14038
|
await this.logger.error(`[${name}] Event: error - ${error?.stack ?? String(error)}`);
|
|
13967
14039
|
await cleanupClients();
|
|
13968
|
-
await this.
|
|
14040
|
+
await this.disposePluginsOnce();
|
|
13969
14041
|
await this.logger.info(`[${name}] Action: cleaned up dependent clients and plugins`);
|
|
14042
|
+
previousOnError?.(error);
|
|
13970
14043
|
};
|
|
13971
14044
|
const toolNameToDetailList = Object.entries(allTools);
|
|
13972
14045
|
const publicToolNames = this.getPublicToolNames();
|
|
@@ -13978,7 +14051,8 @@ var ComposableMCPServer = class extends Server {
|
|
|
13978
14051
|
return;
|
|
13979
14052
|
}
|
|
13980
14053
|
this.tool(toolId, tool2.description || "", jsonSchema(tool2.inputSchema), tool2.execute, {
|
|
13981
|
-
internal: false
|
|
14054
|
+
internal: false,
|
|
14055
|
+
outputSchema: tool2.outputSchema
|
|
13982
14056
|
});
|
|
13983
14057
|
});
|
|
13984
14058
|
await this.pluginManager.triggerComposeEnd({
|