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