@mcpc-tech/core 0.2.10 → 0.2.11
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/index.mjs +57 -13
- package/package.json +1 -1
- package/types/src/compose.d.ts +3 -0
- package/types/src/compose.d.ts.map +1 -1
package/index.mjs
CHANGED
|
@@ -92,7 +92,7 @@ var init_json = __esm({
|
|
|
92
92
|
|
|
93
93
|
// __mcpc__core_latest/node_modules/@mcpc/core/src/utils/common/provider.js
|
|
94
94
|
function sanitizePropertyKey(name) {
|
|
95
|
-
return name.replace(/[
|
|
95
|
+
return name.replace(/[@.,/\\:;!?#$%^&*()[\]{}]/g, "_").substring(0, 64);
|
|
96
96
|
}
|
|
97
97
|
var createGoogleCompatibleJSONSchema;
|
|
98
98
|
var init_provider = __esm({
|
|
@@ -284,12 +284,21 @@ var init_logging_plugin = __esm({
|
|
|
284
284
|
const { stats } = context2;
|
|
285
285
|
const server = context2.server;
|
|
286
286
|
const publicTools = Array.from(new Set(server.getPublicToolNames().map(String)));
|
|
287
|
+
const internalTools = Array.from(new Set(server.getInternalToolNames().map(String)));
|
|
287
288
|
const hiddenTools = Array.from(new Set(server.getHiddenToolNames().map(String)));
|
|
289
|
+
const normalInternal = internalTools.filter((name) => !hiddenTools.includes(name));
|
|
288
290
|
if (publicTools.length > 0) {
|
|
289
291
|
await logger2.info(` \u251C\u2500 Public: ${publicTools.join(", ")}`);
|
|
290
292
|
}
|
|
291
|
-
if (
|
|
292
|
-
|
|
293
|
+
if (internalTools.length > 0) {
|
|
294
|
+
const parts = [];
|
|
295
|
+
if (normalInternal.length > 0) {
|
|
296
|
+
parts.push(normalInternal.join(", "));
|
|
297
|
+
}
|
|
298
|
+
if (hiddenTools.length > 0) {
|
|
299
|
+
parts.push(`(${hiddenTools.join(", ")})`);
|
|
300
|
+
}
|
|
301
|
+
await logger2.info(` \u251C\u2500 Internal: ${parts.join(", ")}`);
|
|
293
302
|
}
|
|
294
303
|
await logger2.info(` \u2514\u2500 Total: ${stats.totalTools} tools`);
|
|
295
304
|
}
|
|
@@ -3581,6 +3590,25 @@ var ToolManager = class {
|
|
|
3581
3590
|
getToolRegistry() {
|
|
3582
3591
|
return this.toolRegistry;
|
|
3583
3592
|
}
|
|
3593
|
+
/**
|
|
3594
|
+
* Get all registered tools as ComposedTool objects
|
|
3595
|
+
* This includes tools registered via server.tool() in setup hooks
|
|
3596
|
+
*/
|
|
3597
|
+
getRegisteredToolsAsComposed() {
|
|
3598
|
+
const composedTools = {};
|
|
3599
|
+
for (const [name, tool] of this.toolRegistry.entries()) {
|
|
3600
|
+
composedTools[name] = {
|
|
3601
|
+
name,
|
|
3602
|
+
description: tool.description,
|
|
3603
|
+
inputSchema: tool.schema || {
|
|
3604
|
+
type: "object",
|
|
3605
|
+
properties: {}
|
|
3606
|
+
},
|
|
3607
|
+
execute: tool.callback
|
|
3608
|
+
};
|
|
3609
|
+
}
|
|
3610
|
+
return composedTools;
|
|
3611
|
+
}
|
|
3584
3612
|
};
|
|
3585
3613
|
|
|
3586
3614
|
// __mcpc__core_latest/node_modules/@mcpc/core/src/compose.js
|
|
@@ -3743,6 +3771,14 @@ var ComposableMCPServer = class extends Server {
|
|
|
3743
3771
|
getHiddenToolNames() {
|
|
3744
3772
|
return this.toolManager.getHiddenToolNames();
|
|
3745
3773
|
}
|
|
3774
|
+
/**
|
|
3775
|
+
* Get all internal tool names (tools that are not public)
|
|
3776
|
+
*/
|
|
3777
|
+
getInternalToolNames() {
|
|
3778
|
+
const allToolNames = Array.from(this.toolManager.getToolRegistry().keys());
|
|
3779
|
+
const publicToolNames = this.getPublicToolNames();
|
|
3780
|
+
return allToolNames.filter((name) => !publicToolNames.includes(name));
|
|
3781
|
+
}
|
|
3746
3782
|
/**
|
|
3747
3783
|
* Get hidden tool schema by name (for internal access)
|
|
3748
3784
|
*/
|
|
@@ -3845,7 +3881,6 @@ var ComposableMCPServer = class extends Server {
|
|
|
3845
3881
|
availableToolNames.add(toolNameWithScope);
|
|
3846
3882
|
availableToolNames.add(toolId);
|
|
3847
3883
|
availableToolNames.add(`${mcpName}.${ALL_TOOLS_PLACEHOLDER2}`);
|
|
3848
|
-
availableToolNames.add(mcpName);
|
|
3849
3884
|
this.toolManager.setToolNameMapping(toolNameWithScope, toolId);
|
|
3850
3885
|
const internalName = toolNameWithScope.includes(".") ? toolNameWithScope.split(".").slice(1).join(".") : toolNameWithScope;
|
|
3851
3886
|
if (!this.toolNameMapping.has(internalName)) {
|
|
@@ -3876,14 +3911,23 @@ var ComposableMCPServer = class extends Server {
|
|
|
3876
3911
|
await this.logger.warning(` Available tools: ${Array.from(availableToolNames).sort().join(", ")}`);
|
|
3877
3912
|
}
|
|
3878
3913
|
Object.entries(tools).forEach(([toolId, tool]) => {
|
|
3879
|
-
this.toolManager.registerTool(toolId, tool.description || "
|
|
3914
|
+
this.toolManager.registerTool(toolId, tool.description || "", tool.inputSchema, tool.execute);
|
|
3880
3915
|
});
|
|
3881
|
-
|
|
3882
|
-
|
|
3916
|
+
const registeredTools = this.toolManager.getRegisteredToolsAsComposed();
|
|
3917
|
+
const allTools = {
|
|
3918
|
+
...tools
|
|
3919
|
+
};
|
|
3920
|
+
for (const [toolName, tool] of Object.entries(registeredTools)) {
|
|
3921
|
+
if (!allTools[toolName]) {
|
|
3922
|
+
allTools[toolName] = tool;
|
|
3923
|
+
}
|
|
3924
|
+
}
|
|
3925
|
+
await this.processToolsWithPlugins(allTools, options.mode ?? "agentic");
|
|
3926
|
+
await this.pluginManager.triggerFinalizeComposition(allTools, {
|
|
3883
3927
|
serverName: name ?? "anonymous",
|
|
3884
3928
|
mode: options.mode ?? "agentic",
|
|
3885
3929
|
server: this,
|
|
3886
|
-
toolNames: Object.keys(
|
|
3930
|
+
toolNames: Object.keys(allTools)
|
|
3887
3931
|
});
|
|
3888
3932
|
this.onclose = async () => {
|
|
3889
3933
|
await cleanupClients();
|
|
@@ -3896,16 +3940,16 @@ var ComposableMCPServer = class extends Server {
|
|
|
3896
3940
|
await this.disposePlugins();
|
|
3897
3941
|
await this.logger.info(`[${name}] Action: cleaned up dependent clients and plugins`);
|
|
3898
3942
|
};
|
|
3899
|
-
const toolNameToDetailList = Object.entries(
|
|
3943
|
+
const toolNameToDetailList = Object.entries(allTools);
|
|
3900
3944
|
const publicToolNames = this.getPublicToolNames();
|
|
3901
3945
|
const hiddenToolNames = this.getHiddenToolNames();
|
|
3902
3946
|
const contextToolNames = toolNameToDetailList.map(([name2]) => name2).filter((n) => !hiddenToolNames.includes(n));
|
|
3903
3947
|
publicToolNames.forEach((toolId) => {
|
|
3904
|
-
const tool =
|
|
3948
|
+
const tool = allTools[toolId];
|
|
3905
3949
|
if (!tool) {
|
|
3906
|
-
throw new Error(`Public tool ${toolId} not found in registry, available: ${Object.keys(
|
|
3950
|
+
throw new Error(`Public tool ${toolId} not found in registry, available: ${Object.keys(allTools).join(", ")}`);
|
|
3907
3951
|
}
|
|
3908
|
-
this.tool(toolId, tool.description || "
|
|
3952
|
+
this.tool(toolId, tool.description || "", jsonSchema(tool.inputSchema), tool.execute, {
|
|
3909
3953
|
internal: false
|
|
3910
3954
|
});
|
|
3911
3955
|
});
|
|
@@ -3930,7 +3974,7 @@ var ComposableMCPServer = class extends Server {
|
|
|
3930
3974
|
description = processToolTags({
|
|
3931
3975
|
...desTags,
|
|
3932
3976
|
description,
|
|
3933
|
-
tools,
|
|
3977
|
+
tools: allTools,
|
|
3934
3978
|
toolOverrides: /* @__PURE__ */ new Map(),
|
|
3935
3979
|
toolNameMapping: toolNameToIdMapping
|
|
3936
3980
|
});
|
package/package.json
CHANGED
package/types/src/compose.d.ts
CHANGED
|
@@ -39,6 +39,9 @@ export declare class ComposableMCPServer extends Server {
|
|
|
39
39
|
/**
|
|
40
40
|
* Get all hidden tool names
|
|
41
41
|
*/ getHiddenToolNames(): string[];
|
|
42
|
+
/**
|
|
43
|
+
* Get all internal tool names (tools that are not public)
|
|
44
|
+
*/ getInternalToolNames(): string[];
|
|
42
45
|
/**
|
|
43
46
|
* Get hidden tool schema by name (for internal access)
|
|
44
47
|
*/ getHiddenToolSchema(name: string): {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compose.d.ts","sources":["../../src/compose.ts"],"names":[],"mappings":"AAAA,SAGE,KAAK,cAAc,EAGnB,KAAK,IAAI,6CAC6C;AACxD,SAAwC,KAAK,MAAM,4BAA4B;AAC/E,cAAc,iBAAiB,6BAA6B;AAC5D,SACE,MAAM,EACN,KAAK,aAAa,oDAC2C;AAC/D,YAAY,aAAyB;AAGrC,cAAc,iBAAiB,kCAAkC;AACjE,cAAc,UAAU,EAAE,YAAY,qBAAqB;AAQ3D,cAA4B,UAAU,EAAE,UAAU,4BAA4B;AAU9E,OAAO,cAAM,4BAA4B;EACvC,QAAQ,mBAA6B;EACrC,QAAQ,iBAAyB;EACjC,QAAQ,YAAsC;EAG9C,IAAI,mBAAmB,IAAI,MAAM,EAAE,MAAM;EAIzC,YAAY,aAAa,cAAc,EAAE,SAAS,aAAa;EAiB/D;;GAEC,GACD,AAAM,sBAAsB,QAAQ,IAAI;UAqB1B;UAwDN;EAIR,KAAK,GACH,MAAM,MAAM,EACZ,aAAa,MAAM,EACnB,cAAc,OAAO,KAAK,UAAU,EACpC,KAAK,MAAM,GAAG,QAAQ,OAAO,KAAK,OAAO,EACzC;IAAW,WAAW,OAAO;IAAE,UAAU;GAAmB;EAqE9D;;GAEC,GACD,gBAAgB,MAAM,MAAM,GAAG,eAAe,SAAS;EAIvD;;GAEC,GACD,eAAe,QAAQ,MAAM,GAAG,aAAa,SAAS;EAItD;;GAEC,GACD,AAAM,SAAS,MAAM,MAAM,EAAE,MAAM,OAAO,GAAG,QAAQ,OAAO;EAyB5D;;GAEC,GACD,sBAAsB,MAAM;EAI5B;;GAEC,GACD,kBAAkB;EAIlB;;GAEC,GACD,sBAAsB,MAAM;EAI5B;;GAEC,GACD,oBACE,MAAM,MAAM;IACT,aAAa,MAAM;IAAE,QAAQ;MAA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