@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.cjs
CHANGED
|
@@ -535,10 +535,9 @@ var ProgressTokenSchema = z.union([z.string(), z.number().int()]);
|
|
|
535
535
|
var CursorSchema = z.string();
|
|
536
536
|
var TaskCreationParamsSchema = z.looseObject({
|
|
537
537
|
/**
|
|
538
|
-
*
|
|
539
|
-
* If null, the task has unlimited lifetime until manually cleaned up.
|
|
538
|
+
* Requested duration in milliseconds to retain task from creation.
|
|
540
539
|
*/
|
|
541
|
-
ttl: z.
|
|
540
|
+
ttl: z.number().optional(),
|
|
542
541
|
/**
|
|
543
542
|
* Time in milliseconds to wait between task status requests.
|
|
544
543
|
*/
|
|
@@ -838,7 +837,11 @@ var ClientCapabilitiesSchema = z.object({
|
|
|
838
837
|
/**
|
|
839
838
|
* Present if the client supports task creation.
|
|
840
839
|
*/
|
|
841
|
-
tasks: ClientTasksCapabilitySchema.optional()
|
|
840
|
+
tasks: ClientTasksCapabilitySchema.optional(),
|
|
841
|
+
/**
|
|
842
|
+
* Extensions that the client supports. Keys are extension identifiers (vendor-prefix/extension-name).
|
|
843
|
+
*/
|
|
844
|
+
extensions: z.record(z.string(), AssertObjectSchema).optional()
|
|
842
845
|
});
|
|
843
846
|
var InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
844
847
|
/**
|
|
@@ -899,7 +902,11 @@ var ServerCapabilitiesSchema = z.object({
|
|
|
899
902
|
/**
|
|
900
903
|
* Present if the server supports task creation.
|
|
901
904
|
*/
|
|
902
|
-
tasks: ServerTasksCapabilitySchema.optional()
|
|
905
|
+
tasks: ServerTasksCapabilitySchema.optional(),
|
|
906
|
+
/**
|
|
907
|
+
* Extensions that the server supports. Keys are extension identifiers (vendor-prefix/extension-name).
|
|
908
|
+
*/
|
|
909
|
+
extensions: z.record(z.string(), AssertObjectSchema).optional()
|
|
903
910
|
});
|
|
904
911
|
var InitializeResultSchema = ResultSchema.extend({
|
|
905
912
|
/**
|
|
@@ -1092,6 +1099,12 @@ var ResourceSchema = z.object({
|
|
|
1092
1099
|
* The MIME type of this resource, if known.
|
|
1093
1100
|
*/
|
|
1094
1101
|
mimeType: z.optional(z.string()),
|
|
1102
|
+
/**
|
|
1103
|
+
* The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known.
|
|
1104
|
+
*
|
|
1105
|
+
* This can be used by Hosts to display file sizes and estimate context window usage.
|
|
1106
|
+
*/
|
|
1107
|
+
size: z.optional(z.number()),
|
|
1095
1108
|
/**
|
|
1096
1109
|
* Optional annotations for the client.
|
|
1097
1110
|
*/
|
|
@@ -2333,15 +2346,17 @@ var Response2 = class _Response {
|
|
|
2333
2346
|
this.#init = init;
|
|
2334
2347
|
}
|
|
2335
2348
|
if (typeof body === "string" || typeof body?.getReader !== "undefined" || body instanceof Blob || body instanceof Uint8Array) {
|
|
2336
|
-
|
|
2337
|
-
this[cacheKey] = [init?.status || 200, body, headers];
|
|
2349
|
+
;
|
|
2350
|
+
this[cacheKey] = [init?.status || 200, body, headers || init?.headers];
|
|
2338
2351
|
}
|
|
2339
2352
|
}
|
|
2340
2353
|
get headers() {
|
|
2341
2354
|
const cache = this[cacheKey];
|
|
2342
2355
|
if (cache) {
|
|
2343
2356
|
if (!(cache[2] instanceof Headers)) {
|
|
2344
|
-
cache[2] = new Headers(
|
|
2357
|
+
cache[2] = new Headers(
|
|
2358
|
+
cache[2] || { "content-type": "text/plain; charset=UTF-8" }
|
|
2359
|
+
);
|
|
2345
2360
|
}
|
|
2346
2361
|
return cache[2];
|
|
2347
2362
|
}
|
|
@@ -2375,6 +2390,8 @@ if (typeof global.crypto === "undefined") {
|
|
|
2375
2390
|
global.crypto = import_crypto.default;
|
|
2376
2391
|
}
|
|
2377
2392
|
var outgoingEnded = Symbol("outgoingEnded");
|
|
2393
|
+
var incomingDraining = Symbol("incomingDraining");
|
|
2394
|
+
var MAX_DRAIN_BYTES = 64 * 1024 * 1024;
|
|
2378
2395
|
|
|
2379
2396
|
// __mcpc__cli_latest/node_modules/@jsr/std__cli/parse_args.js
|
|
2380
2397
|
var FLAG_REGEXP = /^(?:-(?:(?<doubleDash>-)(?<negated>no-)?)?)(?<key>.+?)(?:=(?<value>.*))?$/s;
|
|
@@ -5478,7 +5495,7 @@ function getDefaultAgents() {
|
|
|
5478
5495
|
}
|
|
5479
5496
|
|
|
5480
5497
|
// __mcpc__cli_latest/node_modules/@mcpc/cli/src/config/loader.js
|
|
5481
|
-
var CLI_VERSION = "0.1.
|
|
5498
|
+
var CLI_VERSION = "0.1.54";
|
|
5482
5499
|
function extractServerName(command, commandArgs) {
|
|
5483
5500
|
for (const arg of commandArgs) {
|
|
5484
5501
|
if (!arg.startsWith("-")) {
|
|
@@ -5901,7 +5918,7 @@ function applyModeOverride(config, mode) {
|
|
|
5901
5918
|
agent.options.mode = mode;
|
|
5902
5919
|
if (mode === "ai_acp" && !agent.options.acpSettings) {
|
|
5903
5920
|
agent.options.acpSettings = {
|
|
5904
|
-
command: "claude-
|
|
5921
|
+
command: "claude-agent-acp",
|
|
5905
5922
|
args: [],
|
|
5906
5923
|
session: {}
|
|
5907
5924
|
};
|
|
@@ -6261,6 +6278,10 @@ var Protocol = class {
|
|
|
6261
6278
|
this._progressHandlers.clear();
|
|
6262
6279
|
this._taskProgressTokens.clear();
|
|
6263
6280
|
this._pendingDebouncedNotifications.clear();
|
|
6281
|
+
for (const info of this._timeoutInfo.values()) {
|
|
6282
|
+
clearTimeout(info.timeoutId);
|
|
6283
|
+
}
|
|
6284
|
+
this._timeoutInfo.clear();
|
|
6264
6285
|
for (const controller of this._requestHandlerAbortControllers.values()) {
|
|
6265
6286
|
controller.abort();
|
|
6266
6287
|
}
|
|
@@ -6391,7 +6412,9 @@ var Protocol = class {
|
|
|
6391
6412
|
await capturedTransport?.send(errorResponse);
|
|
6392
6413
|
}
|
|
6393
6414
|
}).catch((error) => this._onerror(new Error(`Failed to send response: ${error}`))).finally(() => {
|
|
6394
|
-
this._requestHandlerAbortControllers.
|
|
6415
|
+
if (this._requestHandlerAbortControllers.get(request.id) === abortController) {
|
|
6416
|
+
this._requestHandlerAbortControllers.delete(request.id);
|
|
6417
|
+
}
|
|
6395
6418
|
});
|
|
6396
6419
|
}
|
|
6397
6420
|
_onprogress(notification) {
|
|
@@ -8485,7 +8508,7 @@ var StdioClientTransport = class {
|
|
|
8485
8508
|
},
|
|
8486
8509
|
stdio: ["pipe", "pipe", this._serverParams.stderr ?? "inherit"],
|
|
8487
8510
|
shell: false,
|
|
8488
|
-
windowsHide: import_node_process6.default.platform === "win32"
|
|
8511
|
+
windowsHide: import_node_process6.default.platform === "win32",
|
|
8489
8512
|
cwd: this._serverParams.cwd
|
|
8490
8513
|
});
|
|
8491
8514
|
this._process.on("error", (error) => {
|
|
@@ -8592,9 +8615,6 @@ var StdioClientTransport = class {
|
|
|
8592
8615
|
});
|
|
8593
8616
|
}
|
|
8594
8617
|
};
|
|
8595
|
-
function isElectron() {
|
|
8596
|
-
return "type" in import_node_process6.default;
|
|
8597
|
-
}
|
|
8598
8618
|
|
|
8599
8619
|
// __mcpc__cli_latest/node_modules/eventsource-parser/dist/index.js
|
|
8600
8620
|
var ParseError = class extends Error {
|
|
@@ -9339,12 +9359,12 @@ var AUTHORIZATION_CODE_RESPONSE_TYPE = "code";
|
|
|
9339
9359
|
var AUTHORIZATION_CODE_CHALLENGE_METHOD = "S256";
|
|
9340
9360
|
function selectClientAuthMethod(clientInformation, supportedMethods) {
|
|
9341
9361
|
const hasClientSecret = clientInformation.client_secret !== void 0;
|
|
9342
|
-
if (supportedMethods.length === 0) {
|
|
9343
|
-
return hasClientSecret ? "client_secret_post" : "none";
|
|
9344
|
-
}
|
|
9345
|
-
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)) {
|
|
9362
|
+
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))) {
|
|
9346
9363
|
return clientInformation.token_endpoint_auth_method;
|
|
9347
9364
|
}
|
|
9365
|
+
if (supportedMethods.length === 0) {
|
|
9366
|
+
return hasClientSecret ? "client_secret_basic" : "none";
|
|
9367
|
+
}
|
|
9348
9368
|
if (hasClientSecret && supportedMethods.includes("client_secret_basic")) {
|
|
9349
9369
|
return "client_secret_basic";
|
|
9350
9370
|
}
|
|
@@ -9455,6 +9475,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
|
|
|
9455
9475
|
});
|
|
9456
9476
|
}
|
|
9457
9477
|
const resource = await selectResourceURL(serverUrl, provider, resourceMetadata);
|
|
9478
|
+
const resolvedScope = scope || resourceMetadata?.scopes_supported?.join(" ") || provider.clientMetadata.scope;
|
|
9458
9479
|
let clientInformation = await Promise.resolve(provider.clientInformation());
|
|
9459
9480
|
if (!clientInformation) {
|
|
9460
9481
|
if (authorizationCode !== void 0) {
|
|
@@ -9478,6 +9499,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
|
|
|
9478
9499
|
const fullInformation = await registerClient(authorizationServerUrl, {
|
|
9479
9500
|
metadata,
|
|
9480
9501
|
clientMetadata: provider.clientMetadata,
|
|
9502
|
+
scope: resolvedScope,
|
|
9481
9503
|
fetchFn
|
|
9482
9504
|
});
|
|
9483
9505
|
await provider.saveClientInformation(fullInformation);
|
|
@@ -9521,7 +9543,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
|
|
|
9521
9543
|
clientInformation,
|
|
9522
9544
|
state,
|
|
9523
9545
|
redirectUrl: provider.redirectUrl,
|
|
9524
|
-
scope:
|
|
9546
|
+
scope: resolvedScope,
|
|
9525
9547
|
resource
|
|
9526
9548
|
});
|
|
9527
9549
|
await provider.saveCodeVerifier(codeVerifier);
|
|
@@ -9839,7 +9861,7 @@ async function fetchToken(provider, authorizationServerUrl, { metadata, resource
|
|
|
9839
9861
|
fetchFn
|
|
9840
9862
|
});
|
|
9841
9863
|
}
|
|
9842
|
-
async function registerClient(authorizationServerUrl, { metadata, clientMetadata, fetchFn }) {
|
|
9864
|
+
async function registerClient(authorizationServerUrl, { metadata, clientMetadata, scope, fetchFn }) {
|
|
9843
9865
|
let registrationUrl;
|
|
9844
9866
|
if (metadata) {
|
|
9845
9867
|
if (!metadata.registration_endpoint) {
|
|
@@ -9854,7 +9876,10 @@ async function registerClient(authorizationServerUrl, { metadata, clientMetadata
|
|
|
9854
9876
|
headers: {
|
|
9855
9877
|
"Content-Type": "application/json"
|
|
9856
9878
|
},
|
|
9857
|
-
body: JSON.stringify(
|
|
9879
|
+
body: JSON.stringify({
|
|
9880
|
+
...clientMetadata,
|
|
9881
|
+
...scope !== void 0 ? { scope } : {}
|
|
9882
|
+
})
|
|
9858
9883
|
});
|
|
9859
9884
|
if (!response.ok) {
|
|
9860
9885
|
throw await parseErrorResponse(response);
|
|
@@ -10949,7 +10974,7 @@ var SystemPrompts = {
|
|
|
10949
10974
|
</rules>
|
|
10950
10975
|
|
|
10951
10976
|
<format>
|
|
10952
|
-
Get tool
|
|
10977
|
+
Get tool definitions: \`{ "tool": "man", "args": { "tools": ["tool1", "tool2"] } }\`
|
|
10953
10978
|
Execute a tool: \`{ "tool": "tool_name", "args": { /* parameters */ } }\`
|
|
10954
10979
|
</format>`,
|
|
10955
10980
|
/**
|
|
@@ -11074,7 +11099,7 @@ function createArgsDefFactory(_name, _allToolNames, _depGroups, _predefinedSteps
|
|
|
11074
11099
|
*
|
|
11075
11100
|
* Only two fields:
|
|
11076
11101
|
* - `tool`: which tool to execute (enum includes "man" + all tool names)
|
|
11077
|
-
* - `args`: object with parameters. For "man": { tools: ["a", "b"] }. For others: tool parameters.
|
|
11102
|
+
* - `args`: object with parameters. For "man": { tools: ["a", "b"] } to fetch tool definitions (including input/output schemas). For others: tool parameters.
|
|
11078
11103
|
*/
|
|
11079
11104
|
forAgentic: function(allToolNames) {
|
|
11080
11105
|
const toolEnum = [
|
|
@@ -13026,11 +13051,12 @@ var ToolManager = class {
|
|
|
13026
13051
|
/**
|
|
13027
13052
|
* Register a tool in the registry
|
|
13028
13053
|
*/
|
|
13029
|
-
registerTool(name, description,
|
|
13054
|
+
registerTool(name, description, inputSchema, callback, options = {}) {
|
|
13030
13055
|
this.toolRegistry.set(name, {
|
|
13031
13056
|
callback,
|
|
13032
13057
|
description,
|
|
13033
|
-
|
|
13058
|
+
inputSchema,
|
|
13059
|
+
outputSchema: options.outputSchema
|
|
13034
13060
|
});
|
|
13035
13061
|
if (options.hidden) {
|
|
13036
13062
|
this.toolConfigs.set(name, {
|
|
@@ -13043,13 +13069,16 @@ var ToolManager = class {
|
|
|
13043
13069
|
/**
|
|
13044
13070
|
* Explicitly mark a tool as public (exposed to MCP clients)
|
|
13045
13071
|
*/
|
|
13046
|
-
addPublicTool(name, description,
|
|
13072
|
+
addPublicTool(name, description, inputSchema, outputSchema) {
|
|
13047
13073
|
const existingTool = this.publicTools.find((t) => t.name === name);
|
|
13048
13074
|
if (!existingTool) {
|
|
13049
13075
|
this.publicTools.push({
|
|
13050
13076
|
name,
|
|
13051
13077
|
description,
|
|
13052
|
-
inputSchema
|
|
13078
|
+
inputSchema,
|
|
13079
|
+
...outputSchema ? {
|
|
13080
|
+
outputSchema
|
|
13081
|
+
} : {}
|
|
13053
13082
|
});
|
|
13054
13083
|
}
|
|
13055
13084
|
this.toolConfigs.set(name, {
|
|
@@ -13175,10 +13204,13 @@ var ToolManager = class {
|
|
|
13175
13204
|
getHiddenToolSchema(name) {
|
|
13176
13205
|
const tool2 = this.toolRegistry.get(name);
|
|
13177
13206
|
const config = this.toolConfigs.get(name);
|
|
13178
|
-
if (tool2 && config?.visibility?.hidden && tool2.
|
|
13207
|
+
if (tool2 && config?.visibility?.hidden && tool2.inputSchema) {
|
|
13179
13208
|
return {
|
|
13180
13209
|
description: tool2.description,
|
|
13181
|
-
|
|
13210
|
+
inputSchema: tool2.inputSchema,
|
|
13211
|
+
...tool2.outputSchema ? {
|
|
13212
|
+
outputSchema: tool2.outputSchema
|
|
13213
|
+
} : {}
|
|
13182
13214
|
};
|
|
13183
13215
|
}
|
|
13184
13216
|
return void 0;
|
|
@@ -13214,10 +13246,13 @@ var ToolManager = class {
|
|
|
13214
13246
|
composedTools[name] = {
|
|
13215
13247
|
name,
|
|
13216
13248
|
description: tool2.description,
|
|
13217
|
-
inputSchema: jsonSchema(tool2.
|
|
13249
|
+
inputSchema: jsonSchema(tool2.inputSchema || {
|
|
13218
13250
|
type: "object",
|
|
13219
13251
|
properties: {}
|
|
13220
13252
|
}),
|
|
13253
|
+
...tool2.outputSchema ? {
|
|
13254
|
+
outputSchema: jsonSchema(tool2.outputSchema)
|
|
13255
|
+
} : {},
|
|
13221
13256
|
execute: tool2.callback
|
|
13222
13257
|
};
|
|
13223
13258
|
}
|
|
@@ -13234,10 +13269,13 @@ var ToolManager = class {
|
|
|
13234
13269
|
return {
|
|
13235
13270
|
name,
|
|
13236
13271
|
description: tool2.description,
|
|
13237
|
-
inputSchema: tool2.
|
|
13272
|
+
inputSchema: tool2.inputSchema ?? {
|
|
13238
13273
|
type: "object",
|
|
13239
13274
|
properties: {}
|
|
13240
13275
|
},
|
|
13276
|
+
...tool2.outputSchema ? {
|
|
13277
|
+
outputSchema: tool2.outputSchema
|
|
13278
|
+
} : {},
|
|
13241
13279
|
execute: tool2.callback
|
|
13242
13280
|
};
|
|
13243
13281
|
}
|
|
@@ -13251,10 +13289,13 @@ var ToolManager = class {
|
|
|
13251
13289
|
composedTools.push({
|
|
13252
13290
|
name,
|
|
13253
13291
|
description: tool2.description,
|
|
13254
|
-
inputSchema: tool2.
|
|
13292
|
+
inputSchema: tool2.inputSchema ?? {
|
|
13255
13293
|
type: "object",
|
|
13256
13294
|
properties: {}
|
|
13257
13295
|
},
|
|
13296
|
+
...tool2.outputSchema ? {
|
|
13297
|
+
outputSchema: tool2.outputSchema
|
|
13298
|
+
} : {},
|
|
13258
13299
|
execute: tool2.callback
|
|
13259
13300
|
});
|
|
13260
13301
|
}
|
|
@@ -13307,7 +13348,10 @@ async function processToolsWithPlugins(server, _externalTools, mode) {
|
|
|
13307
13348
|
const tempTool = {
|
|
13308
13349
|
name: toolId,
|
|
13309
13350
|
description: toolData.description,
|
|
13310
|
-
inputSchema: toolData.
|
|
13351
|
+
inputSchema: toolData.inputSchema || defaultSchema,
|
|
13352
|
+
...toolData.outputSchema ? {
|
|
13353
|
+
outputSchema: toolData.outputSchema
|
|
13354
|
+
} : {},
|
|
13311
13355
|
execute: toolData.callback
|
|
13312
13356
|
};
|
|
13313
13357
|
const processedTool = await pluginManager.applyTransformToolHooks(tempTool, {
|
|
@@ -13319,7 +13363,9 @@ async function processToolsWithPlugins(server, _externalTools, mode) {
|
|
|
13319
13363
|
},
|
|
13320
13364
|
transformationIndex: 0
|
|
13321
13365
|
});
|
|
13322
|
-
toolManager.registerTool(toolId, processedTool.description || toolData.description, processedTool.inputSchema, processedTool.execute
|
|
13366
|
+
toolManager.registerTool(toolId, processedTool.description || toolData.description, processedTool.inputSchema, processedTool.execute, {
|
|
13367
|
+
outputSchema: processedTool.outputSchema
|
|
13368
|
+
});
|
|
13323
13369
|
}
|
|
13324
13370
|
}
|
|
13325
13371
|
function buildDependencyGroups(toolNameToDetailList, hiddenToolNames, publicToolNames, server) {
|
|
@@ -13365,6 +13411,7 @@ var ComposableMCPServer = class extends Server {
|
|
|
13365
13411
|
toolManager;
|
|
13366
13412
|
logger = createLogger("mcpc.compose");
|
|
13367
13413
|
fileLoaders = /* @__PURE__ */ new Map();
|
|
13414
|
+
pluginsDisposed = false;
|
|
13368
13415
|
// Legacy property for backward compatibility
|
|
13369
13416
|
get toolNameMapping() {
|
|
13370
13417
|
return this.toolManager.getToolNameMapping();
|
|
@@ -13493,9 +13540,13 @@ var ComposableMCPServer = class extends Server {
|
|
|
13493
13540
|
}
|
|
13494
13541
|
tool(name, description, paramsSchema, cb, options = {}) {
|
|
13495
13542
|
const jsonSchemaObj = extractJsonSchema(paramsSchema);
|
|
13496
|
-
|
|
13543
|
+
const outputSchemaObj = options.outputSchema ? extractJsonSchema(options.outputSchema) : void 0;
|
|
13544
|
+
this.toolManager.registerTool(name, description, jsonSchemaObj, cb, {
|
|
13545
|
+
...options,
|
|
13546
|
+
outputSchema: outputSchemaObj
|
|
13547
|
+
});
|
|
13497
13548
|
if (!options.internal) {
|
|
13498
|
-
this.toolManager.addPublicTool(name, description, jsonSchemaObj);
|
|
13549
|
+
this.toolManager.addPublicTool(name, description, jsonSchemaObj, outputSchemaObj);
|
|
13499
13550
|
}
|
|
13500
13551
|
if (options.plugins) {
|
|
13501
13552
|
for (const plugin of options.plugins) {
|
|
@@ -13752,9 +13803,12 @@ var ComposableMCPServer = class extends Server {
|
|
|
13752
13803
|
return {
|
|
13753
13804
|
name,
|
|
13754
13805
|
description: tool2?.description || "",
|
|
13755
|
-
inputSchema: tool2?.
|
|
13806
|
+
inputSchema: tool2?.inputSchema || {
|
|
13756
13807
|
type: "object"
|
|
13757
|
-
}
|
|
13808
|
+
},
|
|
13809
|
+
...tool2?.outputSchema ? {
|
|
13810
|
+
outputSchema: tool2.outputSchema
|
|
13811
|
+
} : {}
|
|
13758
13812
|
};
|
|
13759
13813
|
});
|
|
13760
13814
|
}
|
|
@@ -13779,9 +13833,12 @@ var ComposableMCPServer = class extends Server {
|
|
|
13779
13833
|
return Array.from(registry.entries()).map(([name, tool2]) => ({
|
|
13780
13834
|
name,
|
|
13781
13835
|
description: tool2?.description || "",
|
|
13782
|
-
inputSchema: tool2?.
|
|
13836
|
+
inputSchema: tool2?.inputSchema || {
|
|
13783
13837
|
type: "object"
|
|
13784
|
-
}
|
|
13838
|
+
},
|
|
13839
|
+
...tool2?.outputSchema ? {
|
|
13840
|
+
outputSchema: tool2.outputSchema
|
|
13841
|
+
} : {}
|
|
13785
13842
|
}));
|
|
13786
13843
|
}
|
|
13787
13844
|
/**
|
|
@@ -13840,11 +13897,21 @@ var ComposableMCPServer = class extends Server {
|
|
|
13840
13897
|
async disposePlugins() {
|
|
13841
13898
|
await this.pluginManager.dispose();
|
|
13842
13899
|
}
|
|
13900
|
+
/**
|
|
13901
|
+
* Dispose plugins only once to avoid duplicated cleanup in chained handlers.
|
|
13902
|
+
*/
|
|
13903
|
+
async disposePluginsOnce() {
|
|
13904
|
+
if (this.pluginsDisposed) {
|
|
13905
|
+
return;
|
|
13906
|
+
}
|
|
13907
|
+
this.pluginsDisposed = true;
|
|
13908
|
+
await this.disposePlugins();
|
|
13909
|
+
}
|
|
13843
13910
|
/**
|
|
13844
13911
|
* Close the server and ensure all plugins are disposed
|
|
13845
13912
|
*/
|
|
13846
13913
|
async close() {
|
|
13847
|
-
await this.
|
|
13914
|
+
await this.disposePluginsOnce();
|
|
13848
13915
|
await super.close();
|
|
13849
13916
|
}
|
|
13850
13917
|
async compose(name, description, depsConfig = {
|
|
@@ -13913,7 +13980,9 @@ var ComposableMCPServer = class extends Server {
|
|
|
13913
13980
|
});
|
|
13914
13981
|
});
|
|
13915
13982
|
Object.entries(tools).forEach(([toolId, tool2]) => {
|
|
13916
|
-
this.toolManager.registerTool(toolId, tool2.description || "", tool2.inputSchema, tool2.execute
|
|
13983
|
+
this.toolManager.registerTool(toolId, tool2.description || "", tool2.inputSchema, tool2.execute, {
|
|
13984
|
+
outputSchema: tool2.outputSchema
|
|
13985
|
+
});
|
|
13917
13986
|
});
|
|
13918
13987
|
const registeredTools = this.toolManager.getRegisteredToolsAsComposed();
|
|
13919
13988
|
const allTools = {
|
|
@@ -13949,16 +14018,20 @@ var ComposableMCPServer = class extends Server {
|
|
|
13949
14018
|
server: this,
|
|
13950
14019
|
toolNames: Object.keys(allTools)
|
|
13951
14020
|
});
|
|
14021
|
+
const previousOnClose = this.onclose;
|
|
13952
14022
|
this.onclose = async () => {
|
|
13953
14023
|
await cleanupClients();
|
|
13954
|
-
await this.
|
|
14024
|
+
await this.disposePluginsOnce();
|
|
13955
14025
|
await this.logger.info(`[${name}] Event: closed - cleaned up dependent clients and plugins`);
|
|
14026
|
+
previousOnClose?.();
|
|
13956
14027
|
};
|
|
14028
|
+
const previousOnError = this.onerror;
|
|
13957
14029
|
this.onerror = async (error) => {
|
|
13958
14030
|
await this.logger.error(`[${name}] Event: error - ${error?.stack ?? String(error)}`);
|
|
13959
14031
|
await cleanupClients();
|
|
13960
|
-
await this.
|
|
14032
|
+
await this.disposePluginsOnce();
|
|
13961
14033
|
await this.logger.info(`[${name}] Action: cleaned up dependent clients and plugins`);
|
|
14034
|
+
previousOnError?.(error);
|
|
13962
14035
|
};
|
|
13963
14036
|
const toolNameToDetailList = Object.entries(allTools);
|
|
13964
14037
|
const publicToolNames = this.getPublicToolNames();
|
|
@@ -13970,7 +14043,8 @@ var ComposableMCPServer = class extends Server {
|
|
|
13970
14043
|
return;
|
|
13971
14044
|
}
|
|
13972
14045
|
this.tool(toolId, tool2.description || "", jsonSchema(tool2.inputSchema), tool2.execute, {
|
|
13973
|
-
internal: false
|
|
14046
|
+
internal: false,
|
|
14047
|
+
outputSchema: tool2.outputSchema
|
|
13974
14048
|
});
|
|
13975
14049
|
});
|
|
13976
14050
|
await this.pluginManager.triggerComposeEnd({
|