@mcpc-tech/cli 0.1.9 → 0.1.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.
Files changed (2) hide show
  1. package/bin/mcpc.mjs +476 -451
  2. package/package.json +1 -1
package/bin/mcpc.mjs CHANGED
@@ -25,7 +25,7 @@ function jsonSchema(schema, options = {}) {
25
25
  };
26
26
  }
27
27
  function isWrappedSchema(value) {
28
- return typeof value === "object" && value !== null && schemaSymbol in value && value[schemaSymbol] === true;
28
+ return typeof value === "object" && value !== null && (schemaSymbol in value && value[schemaSymbol] === true || vercelSchemaSymbol in value && value[vercelSchemaSymbol] === true);
29
29
  }
30
30
  function extractJsonSchema(schema) {
31
31
  if (isWrappedSchema(schema)) {
@@ -33,10 +33,11 @@ function extractJsonSchema(schema) {
33
33
  }
34
34
  return schema;
35
35
  }
36
- var schemaSymbol, validatorSymbol;
36
+ var schemaSymbol, vercelSchemaSymbol, validatorSymbol;
37
37
  var init_schema = __esm({
38
38
  "__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/schema.js"() {
39
39
  schemaSymbol = Symbol.for("mcpc.schema");
40
+ vercelSchemaSymbol = Symbol.for("vercel.ai.schema");
40
41
  validatorSymbol = Symbol.for("mcpc.validator");
41
42
  }
42
43
  });
@@ -59,7 +60,7 @@ var init_json = __esm({
59
60
 
60
61
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/provider.js
61
62
  function sanitizePropertyKey(name) {
62
- return name.replace(/[^a-zA-Z0-9_-]/g, "_").substring(0, 64);
63
+ return name.replace(/[@.,/\\:;!?#$%^&*()[\]{}]/g, "_").substring(0, 64);
63
64
  }
64
65
  var createGoogleCompatibleJSONSchema;
65
66
  var init_provider = __esm({
@@ -251,12 +252,21 @@ var init_logging_plugin = __esm({
251
252
  const { stats } = context2;
252
253
  const server2 = context2.server;
253
254
  const publicTools = Array.from(new Set(server2.getPublicToolNames().map(String)));
255
+ const internalTools = Array.from(new Set(server2.getInternalToolNames().map(String)));
254
256
  const hiddenTools = Array.from(new Set(server2.getHiddenToolNames().map(String)));
257
+ const normalInternal = internalTools.filter((name) => !hiddenTools.includes(name));
255
258
  if (publicTools.length > 0) {
256
259
  await logger2.info(` \u251C\u2500 Public: ${publicTools.join(", ")}`);
257
260
  }
258
- if (hiddenTools.length > 0) {
259
- await logger2.info(` \u251C\u2500 Hidden: ${hiddenTools.join(", ")}`);
261
+ if (internalTools.length > 0) {
262
+ const parts = [];
263
+ if (normalInternal.length > 0) {
264
+ parts.push(normalInternal.join(", "));
265
+ }
266
+ if (hiddenTools.length > 0) {
267
+ parts.push(`(${hiddenTools.join(", ")})`);
268
+ }
269
+ await logger2.info(` \u251C\u2500 Internal: ${parts.join(", ")}`);
260
270
  }
261
271
  await logger2.info(` \u2514\u2500 Total: ${stats.totalTools} tools`);
262
272
  }
@@ -296,218 +306,6 @@ var init_built_in = __esm({
296
306
  }
297
307
  });
298
308
 
299
- // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/plugin-utils.js
300
- var plugin_utils_exports = {};
301
- __export(plugin_utils_exports, {
302
- checkCircularDependencies: () => checkCircularDependencies,
303
- clearPluginCache: () => clearPluginCache,
304
- getPluginsWithHook: () => getPluginsWithHook,
305
- isValidPlugin: () => isValidPlugin,
306
- loadPlugin: () => loadPlugin,
307
- shouldApplyPlugin: () => shouldApplyPlugin,
308
- sortPluginsByOrder: () => sortPluginsByOrder,
309
- validatePlugins: () => validatePlugins
310
- });
311
- function shouldApplyPlugin(plugin, mode) {
312
- if (!plugin.apply) return true;
313
- if (typeof plugin.apply === "string") {
314
- return mode.includes(plugin.apply);
315
- }
316
- if (typeof plugin.apply === "function") {
317
- try {
318
- return plugin.apply(mode);
319
- } catch (error) {
320
- console.warn(`Plugin "${plugin.name}" apply function failed: ${error}. Defaulting to true.`);
321
- return true;
322
- }
323
- }
324
- return true;
325
- }
326
- function sortPluginsByOrder(plugins) {
327
- const pluginMap = /* @__PURE__ */ new Map();
328
- for (const plugin of plugins) {
329
- pluginMap.set(plugin.name, plugin);
330
- }
331
- const visited = /* @__PURE__ */ new Set();
332
- const sorted = [];
333
- function visit(plugin) {
334
- if (visited.has(plugin.name)) return;
335
- visited.add(plugin.name);
336
- if (plugin.dependencies) {
337
- for (const depName of plugin.dependencies) {
338
- const dep = pluginMap.get(depName);
339
- if (dep) {
340
- visit(dep);
341
- } else {
342
- console.warn(`Plugin "${plugin.name}" depends on "${depName}" which is not loaded`);
343
- }
344
- }
345
- }
346
- sorted.push(plugin);
347
- }
348
- const prePlugins = plugins.filter((p2) => p2.enforce === "pre");
349
- const normalPlugins = plugins.filter((p2) => !p2.enforce);
350
- const postPlugins = plugins.filter((p2) => p2.enforce === "post");
351
- [
352
- ...prePlugins,
353
- ...normalPlugins,
354
- ...postPlugins
355
- ].forEach(visit);
356
- return sorted;
357
- }
358
- function getPluginsWithHook(plugins, hookName) {
359
- return plugins.filter((p2) => typeof p2[hookName] === "function");
360
- }
361
- function isValidPlugin(plugin) {
362
- if (!plugin || typeof plugin !== "object") return false;
363
- const p2 = plugin;
364
- if (!p2.name || typeof p2.name !== "string" || p2.name.trim() === "") {
365
- return false;
366
- }
367
- const hasHook = typeof p2.configureServer === "function" || typeof p2.composeStart === "function" || typeof p2.transformTool === "function" || typeof p2.finalizeComposition === "function" || typeof p2.composeEnd === "function" || typeof p2.transformInput === "function" || typeof p2.transformOutput === "function" || typeof p2.dispose === "function";
368
- if (!hasHook) return false;
369
- if (p2.enforce && p2.enforce !== "pre" && p2.enforce !== "post") {
370
- return false;
371
- }
372
- if (p2.apply && typeof p2.apply !== "string" && typeof p2.apply !== "function") {
373
- return false;
374
- }
375
- if (p2.dependencies && !Array.isArray(p2.dependencies)) {
376
- return false;
377
- }
378
- return true;
379
- }
380
- function parseQueryParams(params) {
381
- const typedParams = {};
382
- for (const [key, value] of Object.entries(params)) {
383
- const numValue = Number(value);
384
- if (!isNaN(numValue) && value.trim() !== "") {
385
- typedParams[key] = numValue;
386
- continue;
387
- }
388
- if (value === "true") {
389
- typedParams[key] = true;
390
- continue;
391
- }
392
- if (value === "false") {
393
- typedParams[key] = false;
394
- continue;
395
- }
396
- if (value.includes(",")) {
397
- typedParams[key] = value.split(",").map((v) => v.trim());
398
- continue;
399
- }
400
- typedParams[key] = value;
401
- }
402
- return typedParams;
403
- }
404
- async function loadPlugin(pluginPath, options = {
405
- cache: true
406
- }) {
407
- if (options.cache && pluginCache.has(pluginPath)) {
408
- return pluginCache.get(pluginPath);
409
- }
410
- try {
411
- const [rawPath, queryString] = pluginPath.split("?", 2);
412
- const searchParams = new URLSearchParams(queryString || "");
413
- const params = Object.fromEntries(searchParams.entries());
414
- const importPath = rawPath;
415
- const pluginModule = await import(importPath);
416
- const pluginFactory = pluginModule.createPlugin;
417
- const defaultPlugin = pluginModule.default;
418
- let plugin;
419
- if (Object.keys(params).length > 0) {
420
- if (typeof pluginFactory !== "function") {
421
- throw new Error(`Plugin "${rawPath}" has parameters but no createPlugin export function`);
422
- }
423
- const typedParams = parseQueryParams(params);
424
- plugin = pluginFactory(typedParams);
425
- } else {
426
- if (defaultPlugin) {
427
- plugin = defaultPlugin;
428
- } else if (typeof pluginFactory === "function") {
429
- plugin = pluginFactory();
430
- } else {
431
- throw new Error(`Plugin "${rawPath}" has no default export or createPlugin function`);
432
- }
433
- }
434
- if (!isValidPlugin(plugin)) {
435
- throw new Error(`Invalid plugin format in "${rawPath}": must have a unique name and at least one lifecycle hook`);
436
- }
437
- if (options.cache) {
438
- pluginCache.set(pluginPath, plugin);
439
- }
440
- return plugin;
441
- } catch (error) {
442
- const errorMsg = error instanceof Error ? error.message : String(error);
443
- throw new Error(`Failed to load plugin from "${pluginPath}": ${errorMsg}`);
444
- }
445
- }
446
- function clearPluginCache() {
447
- pluginCache.clear();
448
- }
449
- function checkCircularDependencies(plugins) {
450
- const errors = [];
451
- const pluginMap = /* @__PURE__ */ new Map();
452
- for (const plugin of plugins) {
453
- pluginMap.set(plugin.name, plugin);
454
- }
455
- function checkCircular(pluginName, visited, path) {
456
- if (visited.has(pluginName)) {
457
- const cycle = [
458
- ...path,
459
- pluginName
460
- ].join(" -> ");
461
- errors.push(`Circular dependency detected: ${cycle}`);
462
- return;
463
- }
464
- const plugin = pluginMap.get(pluginName);
465
- if (!plugin || !plugin.dependencies) return;
466
- visited.add(pluginName);
467
- path.push(pluginName);
468
- for (const dep of plugin.dependencies) {
469
- checkCircular(dep, new Set(visited), [
470
- ...path
471
- ]);
472
- }
473
- }
474
- for (const plugin of plugins) {
475
- checkCircular(plugin.name, /* @__PURE__ */ new Set(), []);
476
- }
477
- return errors;
478
- }
479
- function validatePlugins(plugins) {
480
- const errors = [];
481
- const names = /* @__PURE__ */ new Map();
482
- for (const plugin of plugins) {
483
- const count = names.get(plugin.name) || 0;
484
- names.set(plugin.name, count + 1);
485
- }
486
- for (const [name, count] of names.entries()) {
487
- if (count > 1) {
488
- errors.push(`Duplicate plugin name: "${name}" (${count} instances)`);
489
- }
490
- }
491
- const circularErrors = checkCircularDependencies(plugins);
492
- errors.push(...circularErrors);
493
- for (const plugin of plugins) {
494
- if (!isValidPlugin(plugin)) {
495
- const name = plugin.name || "unknown";
496
- errors.push(`Invalid plugin: "${name}"`);
497
- }
498
- }
499
- return {
500
- valid: errors.length === 0,
501
- errors
502
- };
503
- }
504
- var pluginCache;
505
- var init_plugin_utils = __esm({
506
- "__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/plugin-utils.js"() {
507
- pluginCache = /* @__PURE__ */ new Map();
508
- }
509
- });
510
-
511
309
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/schema.js
512
310
  import traverse from "json-schema-traverse";
513
311
  function updateRefPaths(schema, wrapperPath) {
@@ -827,6 +625,7 @@ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
827
625
  import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
828
626
  import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
829
627
  import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
628
+ import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js";
830
629
 
831
630
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/registory.js
832
631
  function connectToSmitheryServer(smitheryConfig) {
@@ -862,54 +661,75 @@ var mcpClientPool = /* @__PURE__ */ new Map();
862
661
  var mcpClientConnecting = /* @__PURE__ */ new Map();
863
662
  var shortHash = (s) => createHash("sha256").update(s).digest("hex").slice(0, 8);
864
663
  function defSignature(def) {
865
- return JSON.stringify(def);
866
- }
867
- async function getOrCreateMcpClient(defKey, def) {
868
- const pooled = mcpClientPool.get(defKey);
869
- if (pooled) {
870
- pooled.refCount += 1;
871
- return pooled.client;
664
+ const defCopy = {
665
+ ...def
666
+ };
667
+ if (defCopy.transportType === "memory" || defCopy.transport) {
668
+ return `memory:${Date.now()}:${Math.random()}`;
872
669
  }
873
- const existingConnecting = mcpClientConnecting.get(defKey);
874
- if (existingConnecting) {
875
- const client = await existingConnecting;
876
- const entry = mcpClientPool.get(defKey);
877
- if (entry) entry.refCount += 1;
878
- return client;
670
+ return JSON.stringify(defCopy);
671
+ }
672
+ function createTransport(def) {
673
+ const defAny = def;
674
+ const explicitType = defAny.transportType || defAny.type;
675
+ if (explicitType === "memory") {
676
+ if (!defAny.server) {
677
+ throw new Error("In-memory transport requires a 'server' field with a Server instance");
678
+ }
679
+ const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
680
+ defAny.server.connect(serverTransport).catch((err) => {
681
+ console.error("Error connecting in-memory server:", err);
682
+ });
683
+ return clientTransport;
879
684
  }
880
- let transport2;
881
- if (typeof def.transportType === "string" && def.transportType === "sse") {
685
+ if (explicitType === "sse") {
882
686
  const options = {};
883
- if (def.headers) {
687
+ if (defAny.headers) {
884
688
  options.requestInit = {
885
- headers: def.headers
689
+ headers: defAny.headers
886
690
  };
887
691
  options.eventSourceInit = {
888
- headers: def.headers
692
+ headers: defAny.headers
889
693
  };
890
694
  }
891
- transport2 = new SSEClientTransport(new URL(def.url), options);
892
- } else if ("url" in def && typeof def.url === "string") {
695
+ return new SSEClientTransport(new URL(defAny.url), options);
696
+ }
697
+ if (defAny.url && typeof defAny.url === "string") {
893
698
  const options = {};
894
- if (def.headers) {
699
+ if (defAny.headers) {
895
700
  options.requestInit = {
896
- headers: def.headers
701
+ headers: defAny.headers
897
702
  };
898
703
  }
899
- transport2 = new StreamableHTTPClientTransport(new URL(def.url), options);
900
- } else if (typeof def.transportType === "string" && def.transportType === "stdio" || "command" in def) {
901
- transport2 = new StdioClientTransport({
902
- command: def.command,
903
- args: def.args,
704
+ return new StreamableHTTPClientTransport(new URL(defAny.url), options);
705
+ }
706
+ if (explicitType === "stdio" || defAny.command) {
707
+ return new StdioClientTransport({
708
+ command: defAny.command,
709
+ args: defAny.args,
904
710
  env: {
905
711
  ...process3.env,
906
- ...def.env ?? {}
712
+ ...defAny.env ?? {}
907
713
  },
908
714
  cwd: cwd()
909
715
  });
910
- } else {
911
- throw new Error(`Unsupported transport type: ${JSON.stringify(def)}`);
912
716
  }
717
+ throw new Error(`Unsupported transport configuration: ${JSON.stringify(def)}`);
718
+ }
719
+ async function getOrCreateMcpClient(defKey, def) {
720
+ const pooled = mcpClientPool.get(defKey);
721
+ if (pooled) {
722
+ pooled.refCount += 1;
723
+ return pooled.client;
724
+ }
725
+ const existingConnecting = mcpClientConnecting.get(defKey);
726
+ if (existingConnecting) {
727
+ const client = await existingConnecting;
728
+ const entry = mcpClientPool.get(defKey);
729
+ if (entry) entry.refCount += 1;
730
+ return client;
731
+ }
732
+ const transport2 = createTransport(def);
913
733
  const connecting = (async () => {
914
734
  const client = new Client({
915
735
  name: `mcp_${shortHash(defSignature(def))}`,
@@ -1028,160 +848,166 @@ var SystemPrompts = {
1028
848
  /**
1029
849
  * Base system prompt for autonomous MCP execution
1030
850
  */
1031
- AUTONOMOUS_EXECUTION: `Autonomous AI Agent \`{toolName}\` that answers user questions through iterative self-invocation and collecting feedback.
851
+ AUTONOMOUS_EXECUTION: `Agentic tool \`{toolName}\` that executes complex tasks by iteratively calling actions, gathering results, and deciding next steps until completion. Use this tool when the task matches the manual below.
852
+
853
+ You must follow the <manual/>, obey the <execution_rules/>, and use the <call_format/>.
1032
854
 
1033
- <instructions>{description}</instructions>
855
+ <manual>
856
+ {description}
857
+ </manual>
1034
858
 
1035
- ## Execution Rules
1036
- 1. **Follow instructions above** carefully
1037
- 2. **Answer user question** as primary goal
1038
- 3. **Execute** one action per call
1039
- 4. **Collect feedback** from each action result
1040
- 5. **Decide** next step:
859
+ <execution_rules>
860
+ 1. **Execute** one action per call
861
+ 2. **Collect** feedback from each action result
862
+ 3. **Decide** next step based on feedback:
1041
863
  - **proceed**: More work needed
1042
- - **complete**: Question answered (do NOT provide action field)
864
+ - **complete**: Task finished (omit action field)
1043
865
  - **retry**: Current action failed
1044
- 6. **Provide** parameter object matching action name
1045
- 7. **Continue** until complete
866
+ 4. **Provide** parameters matching the action name
867
+ 5. **Continue** until task is complete
868
+ 6. Note: You are an agent exposed as an MCP tool - **"action" is an internal parameter, NOT an external MCP tool you can call**
869
+ </execution_rules>
1046
870
 
1047
- ## Call Format
871
+ <call_format>
1048
872
  \`\`\`json
1049
873
  {
1050
- "action": "tool_name",
874
+ "action": "action_name",
1051
875
  "decision": "proceed|retry",
1052
- "tool_name": { /* tool parameters */ }
876
+ "action_name": { /* action parameters */ }
1053
877
  }
1054
878
  \`\`\`
1055
879
 
1056
- **When task is complete:**
880
+ When complete:
1057
881
  \`\`\`json
1058
882
  {
1059
883
  "decision": "complete"
1060
884
  }
1061
- \`\`\``,
885
+ \`\`\`
886
+ </call_format>`,
1062
887
  /**
1063
888
  * Workflow execution system prompt
1064
889
  */
1065
- WORKFLOW_EXECUTION: `Agentic workflow execution tool \`{toolName}\` that processes requests through structured multi-step workflows.
1066
-
1067
- <instructions>{description}</instructions>
1068
-
1069
- ## Workflow Execution Protocol
1070
-
1071
- **\u{1F3AF} FIRST CALL (Planning):**
1072
- {planningInstructions}
1073
-
1074
- **\u26A1 SUBSEQUENT CALLS (Execution):**
1075
- - Provide ONLY current step parameters
1076
- - **ADVANCE STEP**: Set \`decision: "proceed"\` to move to next step
1077
- - **RETRY STEP**: Set \`decision: "retry"\`
1078
- - **COMPLETE WORKFLOW**: Set \`decision: "complete"\` when ready to finish
1079
-
1080
- **\u{1F6AB} Do NOT include \`steps\` parameter during normal execution**
1081
- **\u2705 Include \`steps\` parameter ONLY when restarting workflow with \`init: true\`**
1082
- **\u26A0\uFE0F CRITICAL: When retrying failed steps, MUST use \`decision: "retry"\`**`,
890
+ WORKFLOW_EXECUTION: `Workflow tool \`{toolName}\` that executes multi-step workflows. Use this when your task requires sequential steps.
891
+
892
+ <manual>
893
+ {description}
894
+ </manual>
895
+
896
+ <rules>
897
+ 1. First call: {planningInstructions}
898
+ 2. Subsequent calls: Provide only current step parameters
899
+ 3. Use \`decision: "proceed"\` to advance, \`"retry"\` to retry, \`"complete"\` when done
900
+ 4. Include \`steps\` ONLY with \`init: true\`, never during execution
901
+ </rules>`,
1083
902
  /**
1084
- * JSON-only execution system prompt
903
+ * JSON-only execution system prompt for autonomous sampling mode
904
+ *
905
+ * Note: Sampling mode runs an internal LLM loop that autonomously calls tools until complete.
1085
906
  */
1086
- SAMPLING_EXECUTION: `Autonomous AI Agent \`{toolName}\` that answers user questions by iteratively collecting feedback and adapting your approach.
1087
-
1088
- <instructions>{description}</instructions>
1089
-
1090
- ## Execution Rules
1091
- - Respond with valid JSON only
1092
- - **Follow instructions above** carefully
1093
- - **Answer user question** as primary goal
1094
- - **Collect feedback** from each action result
1095
- - **Adapt approach** based on gathered information
1096
- - action = "X" \u2192 provide parameter "X"
1097
- - Continue until question answered
1098
-
1099
- ## JSON Response Format
1100
- **During execution:**
907
+ SAMPLING_EXECUTION: `Agent \`{toolName}\` that completes tasks by calling tools in an autonomous loop.
908
+
909
+ <manual>
910
+ {description}
911
+ </manual>
912
+
913
+ <rules>
914
+ 1. Return valid JSON only (no markdown, no explanations)
915
+ 2. Execute one action per iteration
916
+ 3. When \`action\` is "X", include parameter "X" with tool inputs
917
+ 4. Adapt based on results from previous actions
918
+ 5. Continue until task is complete
919
+ </rules>
920
+
921
+ <format>
922
+ During execution:
1101
923
  \`\`\`json
1102
924
  {
1103
925
  "action": "tool_name",
1104
926
  "decision": "proceed|retry",
1105
- "tool_name": { /* tool parameters */ }
927
+ "tool_name": { /* parameters */ }
1106
928
  }
1107
929
  \`\`\`
1108
930
 
1109
- **When task is complete (do NOT include action):**
931
+ When complete (omit action):
1110
932
  \`\`\`json
1111
- {
1112
- "decision": "complete"
1113
- }
933
+ { "decision": "complete" }
1114
934
  \`\`\`
1115
935
 
1116
- ## Available Tools
1117
- {toolList}`,
936
+ Decisions:
937
+ - \`proceed\` = action succeeded, continue
938
+ - \`retry\` = action failed, try again
939
+ - \`complete\` = task finished
940
+ </format>
941
+
942
+ <tools>
943
+ {toolList}
944
+ </tools>`,
1118
945
  /**
1119
946
  * Sampling workflow execution system prompt combining sampling with workflow capabilities
947
+ *
948
+ * Note: Sampling mode runs an internal LLM loop that autonomously executes workflows.
1120
949
  */
1121
- SAMPLING_WORKFLOW_EXECUTION: `You are an autonomous AI Agent named \`{toolName}\` that processes instructions through iterative sampling execution within structured workflows.
1122
-
1123
- <instructions>{description}</instructions>
1124
-
1125
- ## Agentic Sampling Workflow Protocol
1126
-
1127
- **\u{1F9E0} AGENTIC REASONING (First Call - Workflow Planning):**
1128
- 1. **Autonomous Analysis:** Independently analyze the user's instruction and identify the end goal
1129
- 2. **Workflow Design:** Autonomously design a structured workflow with clear steps
1130
- 3. **Tool Mapping:** Determine which tools are needed for each workflow step
1131
- 4. **Initialization:** Start the workflow with proper step definitions
1132
-
1133
- **\u26A1 AGENTIC EXECUTION RULES (Subsequent Calls):**
1134
- - Each response demonstrates autonomous reasoning and decision-making within workflow context
1135
- - Make self-directed choices about step execution, retry, or advancement
1136
- - Adapt your approach based on previous step results without external guidance
1137
- - Balance workflow structure with autonomous flexibility
1138
-
1139
- **\u{1F504} JSON Response Format (Agentic Workflow Decision Output):**
1140
- You MUST respond with a JSON object for workflow execution:
1141
-
1142
- **For Workflow Initialization (First Call):**
1143
- - action: "{toolName}"
1144
- - init: true
1145
- - steps: Autonomously designed workflow steps array
1146
- - [other workflow parameters]: As you autonomously determine
1147
-
1148
- **For Step Execution (Subsequent Calls):**
1149
- - action: "{toolName}"
1150
- - decision: "proceed" (advance), "retry" (retry)
1151
- - [step parameters]: Tool-specific parameters you autonomously determine for current step
1152
-
1153
- **When Workflow is Complete (do NOT include action):**
1154
- - decision: "complete"
1155
-
1156
- **\u{1F3AF} AGENTIC WORKFLOW CONSTRAINTS:**
1157
- - Response must be pure JSON demonstrating autonomous decision-making within workflow structure
1158
- - Invalid JSON indicates failure in agentic workflow reasoning
1159
- - Tool parameters must reflect your independent analysis and workflow planning
1160
- - Balance autonomous decision-making with structured workflow progression
1161
-
1162
- **\u{1F6AB} Do NOT include \`steps\` parameter during normal execution**
1163
- **\u2705 Include \`steps\` parameter ONLY when restarting workflow with \`init: true\`**
1164
- **\u26A0\uFE0F CRITICAL: When retrying failed steps, MUST use \`decision: "retry"\`**`
950
+ SAMPLING_WORKFLOW_EXECUTION: `Workflow agent \`{toolName}\` that executes multi-step workflows autonomously.
951
+
952
+ <manual>
953
+ {description}
954
+ </manual>
955
+
956
+ <rules>
957
+ 1. Return valid JSON only
958
+ 2. First iteration: Plan workflow and initialize with \`init: true\`
959
+ 3. Subsequent iterations: Execute current step
960
+ 4. Adapt based on step results
961
+ 5. Continue until all steps complete
962
+ </rules>
963
+
964
+ <format>
965
+ Initialize workflow (first iteration):
966
+ \`\`\`json
967
+ {
968
+ "action": "{toolName}",
969
+ "init": true,
970
+ "steps": [/* workflow steps */]
971
+ }
972
+ \`\`\`
973
+
974
+ Execute step (subsequent iterations):
975
+ \`\`\`json
976
+ {
977
+ "action": "{toolName}",
978
+ "decision": "proceed|retry",
979
+ /* step parameters */
980
+ }
981
+ \`\`\`
982
+
983
+ Complete workflow (omit action):
984
+ \`\`\`json
985
+ { "decision": "complete" }
986
+ \`\`\`
987
+
988
+ Decisions:
989
+ - \`proceed\` = step succeeded, next step
990
+ - \`retry\` = step failed, retry current
991
+ - \`complete\` = workflow finished
992
+
993
+ Rules:
994
+ - Include \`steps\` ONLY with \`init: true\`
995
+ - Omit \`steps\` during step execution
996
+ - Use \`decision: "retry"\` for failed steps
997
+ </format>`
1165
998
  };
1166
999
  var WorkflowPrompts = {
1167
1000
  /**
1168
1001
  * Workflow initialization instructions
1169
1002
  */
1170
- WORKFLOW_INIT: `Workflow initialized with {stepCount} steps. Agent MUST start the workflow with the first step to \`{currentStepDescription}\`.
1171
-
1172
- ## EXECUTE tool \`{toolName}\` with the following new parameter definition
1173
-
1174
- {schemaDefinition}
1175
-
1176
- ## Important Instructions
1177
- - **Include 'steps' parameter ONLY when restarting workflow (with 'init: true')**
1178
- - **Do NOT include 'steps' parameter during normal step execution**
1179
- - **MUST Use the provided JSON schema definition above for parameter generation and validation**
1180
- - **ADVANCE STEP: Set 'decision' to "proceed" to advance to next step**
1181
- - **RETRY STEP: Set 'decision' to "retry" to re-execute current step**
1182
- - **FINAL STEP: Execute normally for workflow completion, do NOT use 'decision: complete' unless workflow is truly finished**
1183
- - **\u26A0\uFE0F CRITICAL: When retrying failed steps, MUST set 'decision' to "retry"**
1184
- - **\u26A0\uFE0F CRITICAL: Only use 'decision: complete' when the entire workflow has been successfully executed**
1003
+ WORKFLOW_INIT: `Workflow initialized with {stepCount} steps. Execute step 1: \`{currentStepDescription}\`
1004
+
1005
+ Schema: {schemaDefinition}
1006
+
1007
+ Call \`{toolName}\` with:
1008
+ - Parameters matching schema above
1009
+ - \`decision: "proceed"\` to advance, \`"retry"\` to retry, \`"complete"\` when done
1010
+ - Omit \`steps\` (only used with \`init: true\`)
1185
1011
 
1186
1012
  {workflowSteps}`,
1187
1013
  /**
@@ -1202,45 +1028,31 @@ var WorkflowPrompts = {
1202
1028
  /**
1203
1029
  * Next step decision prompt
1204
1030
  */
1205
- NEXT_STEP_DECISION: `**Next Step Decision Required**
1031
+ NEXT_STEP_DECISION: `Previous step completed.
1206
1032
 
1207
- Previous step completed. Choose your action:
1208
-
1209
- **\u{1F504} RETRY Current Step:**
1210
- - Call \`{toolName}\` with current parameters
1211
- - \u26A0\uFE0F CRITICAL: Set \`decision: "retry"\`
1212
-
1213
- **\u25B6\uFE0F PROCEED to Next Step:**
1214
- - Call \`{toolName}\` with parameters below
1215
- - Set \`decision: "proceed"\`
1216
-
1217
- Next step: \`{nextStepDescription}\`
1033
+ Choose action:
1034
+ - RETRY: Call \`{toolName}\` with \`decision: "retry"\`
1035
+ - PROCEED: Call \`{toolName}\` with \`decision: "proceed"\` and parameters below
1218
1036
 
1037
+ Next: \`{nextStepDescription}\`
1219
1038
  {nextStepSchema}
1220
1039
 
1221
- **Important:** Exclude \`steps\` key from parameters`,
1040
+ (Omit \`steps\` parameter)`,
1222
1041
  /**
1223
1042
  * Final step completion prompt
1224
1043
  */
1225
- FINAL_STEP_COMPLETION: `**Final Step Complete** {statusIcon}
1226
-
1227
- Step executed {statusText}. Choose action:
1044
+ FINAL_STEP_COMPLETION: `Final step executed {statusIcon} - {statusText}
1228
1045
 
1229
- **\u{1F504} RETRY:** Call \`{toolName}\` with \`decision: "retry"\`
1230
- **\u2705 COMPLETE:** Call \`{toolName}\` with \`decision: "complete"\`
1231
- **\u{1F195} NEW:** Call \`{toolName}\` with \`init: true\`{newWorkflowInstructions}`,
1046
+ Choose:
1047
+ - RETRY: \`decision: "retry"\`
1048
+ - COMPLETE: \`decision: "complete"\`
1049
+ - NEW: \`init: true\`{newWorkflowInstructions}`,
1232
1050
  /**
1233
1051
  * Workflow completion success message
1234
1052
  */
1235
- WORKFLOW_COMPLETED: `**Workflow Completed Successfully** \u2705
1053
+ WORKFLOW_COMPLETED: `Workflow completed ({totalSteps} steps)
1236
1054
 
1237
- All workflow steps have been executed and the workflow is now complete.
1238
-
1239
- **Summary:**
1240
- - Total steps: {totalSteps}
1241
- - All steps executed successfully
1242
-
1243
- Agent can now start a new workflow if needed by calling \`{toolName}\` with \`init: true\`{newWorkflowInstructions}.`,
1055
+ Start new workflow: \`{toolName}\` with \`init: true\`{newWorkflowInstructions}`,
1244
1056
  /**
1245
1057
  * Error messages
1246
1058
  */
@@ -1259,57 +1071,41 @@ var ResponseTemplates = {
1259
1071
  /**
1260
1072
  * Success response for action execution
1261
1073
  */
1262
- ACTION_SUCCESS: `**Action Completed Successfully** \u2705
1263
-
1264
- Previous action (\`{currentAction}\`) executed successfully.
1265
-
1266
- **Next Action Required:** \`{nextAction}\`
1074
+ ACTION_SUCCESS: `Action \`{currentAction}\` completed.
1267
1075
 
1268
- Agent MUST call tool \`{toolName}\` again with the \`{nextAction}\` action to continue the autonomous execution sequence.
1269
-
1270
- **Instructions:**
1271
- - Analyze the result from previous action: \`{currentAction}\`
1272
- - Execute the next planned action: \`{nextAction}\`
1273
- - Maintain execution context and progress toward the final goal`,
1076
+ Next: Execute \`{nextAction}\` by calling \`{toolName}\` again.`,
1274
1077
  /**
1275
1078
  * Planning prompt when no next action is specified
1276
1079
  */
1277
- PLANNING_PROMPT: `**Action Evaluation & Planning Required** \u{1F3AF}
1278
-
1279
- Previous action (\`{currentAction}\`) completed. You need to determine the next step.
1280
-
1281
- **Evaluation & Planning Process:**
1282
- 1. **Analyze Results:** Review the outcome of \`{currentAction}\`
1283
- 2. **Assess Progress:** Determine how close you are to fulfilling the user request
1284
- 3. **Plan Next Action:** Identify the most appropriate next action (if needed)
1285
- 4. **Execute Decision:** Call \`{toolName}\` with the planned action
1286
-
1287
- **Options:**
1288
- - **Continue:** If more actions are needed to fulfill the request
1289
- - **Complete:** If the user request has been fully satisfied
1080
+ PLANNING_PROMPT: `Action \`{currentAction}\` completed. Determine next step:
1290
1081
 
1291
- Choose the next action that best advances toward completing the user's request.`,
1082
+ 1. Analyze results from \`{currentAction}\`
1083
+ 2. Decide: Continue with another action or Complete?
1084
+ 3. Call \`{toolName}\` with chosen action or \`decision: "complete"\``,
1292
1085
  /**
1293
- * Error response template
1086
+ * Error response templates
1294
1087
  */
1295
- ERROR_RESPONSE: `Action argument validation failed: {errorMessage}`,
1296
- WORKFLOW_ERROR_RESPONSE: `Action argument validation failed: {errorMessage}
1297
- Set \`decision: "retry"\` to retry the current step, or check your parameters and try again.`,
1088
+ ERROR_RESPONSE: `Validation failed: {errorMessage}
1089
+
1090
+ Adjust parameters and retry.`,
1091
+ WORKFLOW_ERROR_RESPONSE: `Step failed: {errorMessage}
1092
+
1093
+ Fix parameters and call with \`decision: "retry"\``,
1298
1094
  /**
1299
1095
  * Completion message
1300
1096
  */
1301
- COMPLETION_MESSAGE: `Completed, no dependent actions to execute`,
1097
+ COMPLETION_MESSAGE: `Task completed.`,
1302
1098
  /**
1303
1099
  * Security validation messages
1304
1100
  */
1305
1101
  SECURITY_VALIDATION: {
1306
- PASSED: `Security validation PASSED for {operation} on {path}`,
1307
- FAILED: `Security validation FAILED for {operation} on {path}`
1102
+ PASSED: `Security check passed: {operation} on {path}`,
1103
+ FAILED: `Security check failed: {operation} on {path}`
1308
1104
  },
1309
1105
  /**
1310
1106
  * Audit log messages
1311
1107
  */
1312
- AUDIT_LOG: `Audit log entry created: [{timestamp}] {level}: {action} on {resource}{userInfo}`
1108
+ AUDIT_LOG: `[{timestamp}] {level}: {action} on {resource}{userInfo}`
1313
1109
  };
1314
1110
  var CompiledPrompts = {
1315
1111
  autonomousExecution: p(SystemPrompts.AUTONOMOUS_EXECUTION),
@@ -1356,14 +1152,14 @@ ${JSON.stringify(steps, null, 2)}`;
1356
1152
  */
1357
1153
  formatWorkflowProgress: (progressData) => {
1358
1154
  const statusIcons = {
1359
- pending: "\u23F3",
1360
- running: "\u{1F504}",
1361
- completed: "\u2705",
1362
- failed: "\u274C"
1155
+ pending: "[PENDING]",
1156
+ running: "[RUNNING]",
1157
+ completed: "[DONE]",
1158
+ failed: "[FAILED]"
1363
1159
  };
1364
1160
  return progressData.steps.map((step, index) => {
1365
1161
  const status = progressData.statuses[index] || "pending";
1366
- const icon = statusIcons[status] || "\u23F3";
1162
+ const icon = statusIcons[status] || "[PENDING]";
1367
1163
  const current = index === progressData.currentStepIndex ? " **[CURRENT]**" : "";
1368
1164
  const actions = step.actions.length > 0 ? ` | Action: ${step.actions.join(", ")}` : "";
1369
1165
  return `${icon} **Step ${index + 1}:** ${step.description}${actions}${current}`;
@@ -3207,10 +3003,199 @@ function processToolTags({ description, tagToResults, $, tools, toolOverrides, t
3207
3003
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/compose.js
3208
3004
  init_built_in();
3209
3005
  init_logger();
3210
- init_plugin_utils();
3006
+
3007
+ // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/plugin-utils.js
3008
+ var pluginCache = /* @__PURE__ */ new Map();
3009
+ function shouldApplyPlugin(plugin, mode) {
3010
+ if (!plugin.apply) return true;
3011
+ if (typeof plugin.apply === "string") {
3012
+ return mode.includes(plugin.apply);
3013
+ }
3014
+ if (typeof plugin.apply === "function") {
3015
+ try {
3016
+ return plugin.apply(mode);
3017
+ } catch (error) {
3018
+ console.warn(`Plugin "${plugin.name}" apply function failed: ${error}. Defaulting to true.`);
3019
+ return true;
3020
+ }
3021
+ }
3022
+ return true;
3023
+ }
3024
+ function sortPluginsByOrder(plugins) {
3025
+ const pluginMap = /* @__PURE__ */ new Map();
3026
+ for (const plugin of plugins) {
3027
+ pluginMap.set(plugin.name, plugin);
3028
+ }
3029
+ const visited = /* @__PURE__ */ new Set();
3030
+ const sorted = [];
3031
+ function visit(plugin) {
3032
+ if (visited.has(plugin.name)) return;
3033
+ visited.add(plugin.name);
3034
+ if (plugin.dependencies) {
3035
+ for (const depName of plugin.dependencies) {
3036
+ const dep = pluginMap.get(depName);
3037
+ if (dep) {
3038
+ visit(dep);
3039
+ } else {
3040
+ console.warn(`Plugin "${plugin.name}" depends on "${depName}" which is not loaded`);
3041
+ }
3042
+ }
3043
+ }
3044
+ sorted.push(plugin);
3045
+ }
3046
+ const prePlugins = plugins.filter((p2) => p2.enforce === "pre");
3047
+ const normalPlugins = plugins.filter((p2) => !p2.enforce);
3048
+ const postPlugins = plugins.filter((p2) => p2.enforce === "post");
3049
+ [
3050
+ ...prePlugins,
3051
+ ...normalPlugins,
3052
+ ...postPlugins
3053
+ ].forEach(visit);
3054
+ return sorted;
3055
+ }
3056
+ function isValidPlugin(plugin) {
3057
+ if (!plugin || typeof plugin !== "object") return false;
3058
+ const p2 = plugin;
3059
+ if (!p2.name || typeof p2.name !== "string" || p2.name.trim() === "") {
3060
+ return false;
3061
+ }
3062
+ const hasHook = typeof p2.configureServer === "function" || typeof p2.composeStart === "function" || typeof p2.transformTool === "function" || typeof p2.finalizeComposition === "function" || typeof p2.composeEnd === "function" || typeof p2.transformInput === "function" || typeof p2.transformOutput === "function" || typeof p2.dispose === "function";
3063
+ if (!hasHook) return false;
3064
+ if (p2.enforce && p2.enforce !== "pre" && p2.enforce !== "post") {
3065
+ return false;
3066
+ }
3067
+ if (p2.apply && typeof p2.apply !== "string" && typeof p2.apply !== "function") {
3068
+ return false;
3069
+ }
3070
+ if (p2.dependencies && !Array.isArray(p2.dependencies)) {
3071
+ return false;
3072
+ }
3073
+ return true;
3074
+ }
3075
+ function parseQueryParams(params) {
3076
+ const typedParams = {};
3077
+ for (const [key, value] of Object.entries(params)) {
3078
+ const numValue = Number(value);
3079
+ if (!isNaN(numValue) && value.trim() !== "") {
3080
+ typedParams[key] = numValue;
3081
+ continue;
3082
+ }
3083
+ if (value === "true") {
3084
+ typedParams[key] = true;
3085
+ continue;
3086
+ }
3087
+ if (value === "false") {
3088
+ typedParams[key] = false;
3089
+ continue;
3090
+ }
3091
+ if (value.includes(",")) {
3092
+ typedParams[key] = value.split(",").map((v) => v.trim());
3093
+ continue;
3094
+ }
3095
+ typedParams[key] = value;
3096
+ }
3097
+ return typedParams;
3098
+ }
3099
+ async function loadPlugin(pluginPath, options = {
3100
+ cache: true
3101
+ }) {
3102
+ if (options.cache && pluginCache.has(pluginPath)) {
3103
+ return pluginCache.get(pluginPath);
3104
+ }
3105
+ try {
3106
+ const [rawPath, queryString] = pluginPath.split("?", 2);
3107
+ const searchParams = new URLSearchParams(queryString || "");
3108
+ const params = Object.fromEntries(searchParams.entries());
3109
+ const resolveFn = import.meta.resolve;
3110
+ const importPath = typeof resolveFn === "function" ? resolveFn(rawPath) : new URL(rawPath, import.meta.url).href;
3111
+ const pluginModule = await import(importPath);
3112
+ const pluginFactory = pluginModule.createPlugin;
3113
+ const defaultPlugin = pluginModule.default;
3114
+ let plugin;
3115
+ if (Object.keys(params).length > 0) {
3116
+ if (typeof pluginFactory !== "function") {
3117
+ throw new Error(`Plugin "${rawPath}" has parameters but no createPlugin export function`);
3118
+ }
3119
+ const typedParams = parseQueryParams(params);
3120
+ plugin = pluginFactory(typedParams);
3121
+ } else {
3122
+ if (defaultPlugin) {
3123
+ plugin = defaultPlugin;
3124
+ } else if (typeof pluginFactory === "function") {
3125
+ plugin = pluginFactory();
3126
+ } else {
3127
+ throw new Error(`Plugin "${rawPath}" has no default export or createPlugin function`);
3128
+ }
3129
+ }
3130
+ if (!isValidPlugin(plugin)) {
3131
+ throw new Error(`Invalid plugin format in "${rawPath}": must have a unique name and at least one lifecycle hook`);
3132
+ }
3133
+ if (options.cache) {
3134
+ pluginCache.set(pluginPath, plugin);
3135
+ }
3136
+ return plugin;
3137
+ } catch (error) {
3138
+ const errorMsg = error instanceof Error ? error.message : String(error);
3139
+ throw new Error(`Failed to load plugin from "${pluginPath}": ${errorMsg}`);
3140
+ }
3141
+ }
3142
+ function checkCircularDependencies(plugins) {
3143
+ const errors = [];
3144
+ const pluginMap = /* @__PURE__ */ new Map();
3145
+ for (const plugin of plugins) {
3146
+ pluginMap.set(plugin.name, plugin);
3147
+ }
3148
+ function checkCircular(pluginName, visited, path) {
3149
+ if (visited.has(pluginName)) {
3150
+ const cycle = [
3151
+ ...path,
3152
+ pluginName
3153
+ ].join(" -> ");
3154
+ errors.push(`Circular dependency detected: ${cycle}`);
3155
+ return;
3156
+ }
3157
+ const plugin = pluginMap.get(pluginName);
3158
+ if (!plugin || !plugin.dependencies) return;
3159
+ visited.add(pluginName);
3160
+ path.push(pluginName);
3161
+ for (const dep of plugin.dependencies) {
3162
+ checkCircular(dep, new Set(visited), [
3163
+ ...path
3164
+ ]);
3165
+ }
3166
+ }
3167
+ for (const plugin of plugins) {
3168
+ checkCircular(plugin.name, /* @__PURE__ */ new Set(), []);
3169
+ }
3170
+ return errors;
3171
+ }
3172
+ function validatePlugins(plugins) {
3173
+ const errors = [];
3174
+ const names = /* @__PURE__ */ new Map();
3175
+ for (const plugin of plugins) {
3176
+ const count = names.get(plugin.name) || 0;
3177
+ names.set(plugin.name, count + 1);
3178
+ }
3179
+ for (const [name, count] of names.entries()) {
3180
+ if (count > 1) {
3181
+ errors.push(`Duplicate plugin name: "${name}" (${count} instances)`);
3182
+ }
3183
+ }
3184
+ const circularErrors = checkCircularDependencies(plugins);
3185
+ errors.push(...circularErrors);
3186
+ for (const plugin of plugins) {
3187
+ if (!isValidPlugin(plugin)) {
3188
+ const name = plugin.name || "unknown";
3189
+ errors.push(`Invalid plugin: "${name}"`);
3190
+ }
3191
+ }
3192
+ return {
3193
+ valid: errors.length === 0,
3194
+ errors
3195
+ };
3196
+ }
3211
3197
 
3212
3198
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/plugin-manager.js
3213
- init_plugin_utils();
3214
3199
  init_logger();
3215
3200
  var PluginManager = class {
3216
3201
  server;
@@ -3378,6 +3363,7 @@ var PluginManager = class {
3378
3363
  };
3379
3364
 
3380
3365
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/tool-manager.js
3366
+ init_schema();
3381
3367
  var ToolManager = class {
3382
3368
  toolRegistry = /* @__PURE__ */ new Map();
3383
3369
  toolConfigs = /* @__PURE__ */ new Map();
@@ -3562,10 +3548,33 @@ var ToolManager = class {
3562
3548
  getToolRegistry() {
3563
3549
  return this.toolRegistry;
3564
3550
  }
3551
+ /**
3552
+ * Get all registered tools as ComposedTool objects
3553
+ * This includes tools registered via server.tool() in setup hooks
3554
+ */
3555
+ getRegisteredToolsAsComposed() {
3556
+ const composedTools = {};
3557
+ for (const [name, tool] of this.toolRegistry.entries()) {
3558
+ if (this.toolConfigs.get(name)?.visibility?.public === true) {
3559
+ continue;
3560
+ }
3561
+ composedTools[name] = {
3562
+ name,
3563
+ description: tool.description,
3564
+ inputSchema: jsonSchema(tool.schema || {
3565
+ type: "object",
3566
+ properties: {}
3567
+ }),
3568
+ execute: tool.callback
3569
+ };
3570
+ }
3571
+ return composedTools;
3572
+ }
3565
3573
  };
3566
3574
 
3567
3575
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/compose.js
3568
3576
  init_compose_helpers();
3577
+ init_provider();
3569
3578
  var ALL_TOOLS_PLACEHOLDER2 = "__ALL__";
3570
3579
  var ComposableMCPServer = class extends Server {
3571
3580
  pluginManager;
@@ -3616,8 +3625,7 @@ var ComposableMCPServer = class extends Server {
3616
3625
  if (plugins.length === 0) {
3617
3626
  return data;
3618
3627
  }
3619
- const { sortPluginsByOrder: sortPluginsByOrder2 } = await Promise.resolve().then(() => (init_plugin_utils(), plugin_utils_exports));
3620
- const sortedPlugins = sortPluginsByOrder2(plugins);
3628
+ const sortedPlugins = sortPluginsByOrder(plugins);
3621
3629
  let currentData = data;
3622
3630
  const context2 = {
3623
3631
  toolName,
@@ -3725,6 +3733,14 @@ var ComposableMCPServer = class extends Server {
3725
3733
  getHiddenToolNames() {
3726
3734
  return this.toolManager.getHiddenToolNames();
3727
3735
  }
3736
+ /**
3737
+ * Get all internal tool names (tools that are not public)
3738
+ */
3739
+ getInternalToolNames() {
3740
+ const allToolNames = Array.from(this.toolManager.getToolRegistry().keys());
3741
+ const publicToolNames = this.getPublicToolNames();
3742
+ return allToolNames.filter((name) => !publicToolNames.includes(name));
3743
+ }
3728
3744
  /**
3729
3745
  * Get hidden tool schema by name (for internal access)
3730
3746
  */
@@ -3819,15 +3835,13 @@ var ComposableMCPServer = class extends Server {
3819
3835
  const availableToolNames = /* @__PURE__ */ new Set();
3820
3836
  tagToResults.tool.forEach((tool) => {
3821
3837
  if (tool.attribs.name) {
3822
- requestedToolNames.add(tool.attribs.name);
3838
+ requestedToolNames.add(sanitizePropertyKey(tool.attribs.name));
3823
3839
  }
3824
3840
  });
3825
3841
  const { tools, cleanupClients } = await composeMcpDepTools(depsConfig, ({ mcpName, toolNameWithScope, toolId }) => {
3826
3842
  toolNameToIdMapping.set(toolNameWithScope, toolId);
3827
3843
  availableToolNames.add(toolNameWithScope);
3828
3844
  availableToolNames.add(toolId);
3829
- availableToolNames.add(`${mcpName}.${ALL_TOOLS_PLACEHOLDER2}`);
3830
- availableToolNames.add(mcpName);
3831
3845
  this.toolManager.setToolNameMapping(toolNameWithScope, toolId);
3832
3846
  const internalName = toolNameWithScope.includes(".") ? toolNameWithScope.split(".").slice(1).join(".") : toolNameWithScope;
3833
3847
  if (!this.toolNameMapping.has(internalName)) {
@@ -3849,23 +3863,34 @@ var ComposableMCPServer = class extends Server {
3849
3863
  return tool.attribs.name === toolNameWithScope || tool.attribs.name === toolId;
3850
3864
  });
3851
3865
  });
3852
- const unmatchedTools = Array.from(requestedToolNames).filter((toolName) => !availableToolNames.has(toolName));
3866
+ Object.entries(tools).forEach(([toolId, tool]) => {
3867
+ this.toolManager.registerTool(toolId, tool.description || "", tool.inputSchema, tool.execute);
3868
+ });
3869
+ const registeredTools = this.toolManager.getRegisteredToolsAsComposed();
3870
+ const allTools = {
3871
+ ...tools
3872
+ };
3873
+ Object.entries(registeredTools).forEach(([toolName, tool]) => {
3874
+ if (!allTools[toolName]) {
3875
+ allTools[toolName] = tool;
3876
+ }
3877
+ availableToolNames.add(toolName);
3878
+ });
3879
+ const unmatchedTools = Array.from(requestedToolNames).filter((toolName) => !allTools[toolName]);
3853
3880
  if (unmatchedTools.length > 0) {
3854
3881
  await this.logger.warning(`Tool matching warnings for agent "${name}":`);
3855
- for (const toolName of unmatchedTools) {
3856
- await this.logger.warning(` \u2022 Tool not found: "${toolName}"`);
3857
- }
3858
- await this.logger.warning(` Available tools: ${Array.from(availableToolNames).sort().join(", ")}`);
3882
+ unmatchedTools.forEach((toolName) => {
3883
+ this.logger.warning(` \u2022 Tool not found: "${toolName}"`);
3884
+ });
3885
+ const available = Array.from(availableToolNames).sort().join(", ");
3886
+ await this.logger.warning(` Available tools: ${available}`);
3859
3887
  }
3860
- Object.entries(tools).forEach(([toolId, tool]) => {
3861
- this.toolManager.registerTool(toolId, tool.description || "No description available", tool.inputSchema, tool.execute);
3862
- });
3863
- await this.processToolsWithPlugins(tools, options.mode ?? "agentic");
3864
- await this.pluginManager.triggerFinalizeComposition(tools, {
3888
+ await this.processToolsWithPlugins(allTools, options.mode ?? "agentic");
3889
+ await this.pluginManager.triggerFinalizeComposition(allTools, {
3865
3890
  serverName: name ?? "anonymous",
3866
3891
  mode: options.mode ?? "agentic",
3867
3892
  server: this,
3868
- toolNames: Object.keys(tools)
3893
+ toolNames: Object.keys(allTools)
3869
3894
  });
3870
3895
  this.onclose = async () => {
3871
3896
  await cleanupClients();
@@ -3878,16 +3903,16 @@ var ComposableMCPServer = class extends Server {
3878
3903
  await this.disposePlugins();
3879
3904
  await this.logger.info(`[${name}] Action: cleaned up dependent clients and plugins`);
3880
3905
  };
3881
- const toolNameToDetailList = Object.entries(tools);
3906
+ const toolNameToDetailList = Object.entries(allTools);
3882
3907
  const publicToolNames = this.getPublicToolNames();
3883
3908
  const hiddenToolNames = this.getHiddenToolNames();
3884
3909
  const contextToolNames = toolNameToDetailList.map(([name2]) => name2).filter((n) => !hiddenToolNames.includes(n));
3885
3910
  publicToolNames.forEach((toolId) => {
3886
- const tool = tools[toolId];
3911
+ const tool = allTools[toolId];
3887
3912
  if (!tool) {
3888
- throw new Error(`Public tool ${toolId} not found in registry, available: ${Object.keys(tools).join(", ")}`);
3913
+ throw new Error(`Public tool ${toolId} not found in registry, available: ${Object.keys(allTools).join(", ")}`);
3889
3914
  }
3890
- this.tool(toolId, tool.description || "No description available", jsonSchema(tool.inputSchema), tool.execute, {
3915
+ this.tool(toolId, tool.description || "", jsonSchema(tool.inputSchema), tool.execute, {
3891
3916
  internal: false
3892
3917
  });
3893
3918
  });
@@ -3912,7 +3937,7 @@ var ComposableMCPServer = class extends Server {
3912
3937
  description = processToolTags({
3913
3938
  ...desTags,
3914
3939
  description,
3915
- tools,
3940
+ tools: allTools,
3916
3941
  toolOverrides: /* @__PURE__ */ new Map(),
3917
3942
  toolNameMapping: toolNameToIdMapping
3918
3943
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcpc-tech/cli",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "homepage": "https://jsr.io/@mcpc/cli",
5
5
  "type": "module",
6
6
  "dependencies": {