@mcpc-tech/cli 0.1.33 → 0.1.35

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 (3) hide show
  1. package/bin/mcpc.cjs +199 -92
  2. package/bin/mcpc.mjs +199 -92
  3. package/package.json +1 -1
package/bin/mcpc.cjs CHANGED
@@ -8324,6 +8324,23 @@ Execute a tool:
8324
8324
  "args": { /* tool parameters */ }
8325
8325
  }
8326
8326
  \`\`\`
8327
+ </format>`,
8328
+ /**
8329
+ * Compact system prompt for autonomous MCP execution (when manual is provided)
8330
+ *
8331
+ * Uses simplified description with progressive disclosure:
8332
+ * - Short description shown by default
8333
+ * - Use `man` command with args `{ manual: true }` to get full manual
8334
+ */
8335
+ AUTONOMOUS_EXECUTION_COMPACT: `Agentic tool \`{toolName}\`: {description}
8336
+
8337
+ Use \`man\` command with args \`{ tools: [], manual: true }\` to get the full manual, or \`{ tools: ["tool1"] }\` to get tool schemas.
8338
+
8339
+ <format>
8340
+ Get full manual: \`{ "tool": "man", "args": { "tools": [], "manual": true } }\`
8341
+ Get tool schemas: \`{ "tool": "man", "args": { "tools": ["tool1", "tool2"] } }\`
8342
+ Get both: \`{ "tool": "man", "args": { "tools": ["tool1"], "manual": true } }\`
8343
+ Execute a tool: \`{ "tool": "tool_name", "args": { /* parameters */ } }\`
8327
8344
  </format>`,
8328
8345
  /**
8329
8346
  * Tool description for sampling tools (shown in MCP tools list)
@@ -8401,6 +8418,7 @@ Adjust parameters and retry.`,
8401
8418
  };
8402
8419
  var CompiledPrompts = {
8403
8420
  autonomousExecution: p(SystemPrompts.AUTONOMOUS_EXECUTION),
8421
+ autonomousExecutionCompact: p(SystemPrompts.AUTONOMOUS_EXECUTION_COMPACT),
8404
8422
  samplingToolDescription: p(SystemPrompts.SAMPLING_TOOL_DESCRIPTION),
8405
8423
  aiLoopSystem: p(SystemPrompts.AI_LOOP_SYSTEM),
8406
8424
  actionSuccess: p(ResponseTemplates.ACTION_SUCCESS),
@@ -8467,7 +8485,7 @@ function createArgsDefFactory(_name, _allToolNames, _depGroups, _predefinedSteps
8467
8485
  },
8468
8486
  args: {
8469
8487
  type: "object",
8470
- description: `For "man": { tools: ["tool1", "tool2"] }. For other tools: tool parameters that strictly adhere to the tool's JSON schema.`
8488
+ description: `For "man": { tools: ["tool1", "tool2"], manual?: true }. For other tools: tool parameters that strictly adhere to the tool's JSON schema.`
8471
8489
  }
8472
8490
  },
8473
8491
  required: [
@@ -8478,7 +8496,10 @@ function createArgsDefFactory(_name, _allToolNames, _depGroups, _predefinedSteps
8478
8496
  },
8479
8497
  /**
8480
8498
  * Schema for "man" command args validation
8481
- * Expected format: { tools: ["tool1", "tool2"] }
8499
+ * Expected format: { tools: ["tool1", "tool2"], manual?: true }
8500
+ *
8501
+ * - Always require `tools`
8502
+ * - Allow empty tools only when `manual: true`
8482
8503
  */
8483
8504
  forMan: function(allToolNames) {
8484
8505
  return {
@@ -8492,16 +8513,50 @@ function createArgsDefFactory(_name, _allToolNames, _depGroups, _predefinedSteps
8492
8513
  errorMessage: {
8493
8514
  enum: `Invalid tool name. Available: ${allToolNames.join(", ")}`
8494
8515
  }
8495
- },
8496
- minItems: 1,
8497
- errorMessage: {
8498
- minItems: "At least one tool name is required"
8499
8516
  }
8517
+ },
8518
+ manual: {
8519
+ type: "boolean",
8520
+ description: "Set to true to get the full manual for this agent (progressive disclosure)."
8500
8521
  }
8501
8522
  },
8502
8523
  required: [
8503
8524
  "tools"
8504
8525
  ],
8526
+ additionalProperties: false,
8527
+ anyOf: [
8528
+ // manual-only (tools can be empty)
8529
+ {
8530
+ properties: {
8531
+ manual: {
8532
+ enum: [
8533
+ true
8534
+ ]
8535
+ },
8536
+ tools: {
8537
+ minItems: 0
8538
+ }
8539
+ },
8540
+ required: [
8541
+ "tools",
8542
+ "manual"
8543
+ ]
8544
+ },
8545
+ // tool schemas (require at least one tool)
8546
+ {
8547
+ properties: {
8548
+ tools: {
8549
+ minItems: 1,
8550
+ errorMessage: {
8551
+ minItems: "At least one tool name is required"
8552
+ }
8553
+ }
8554
+ },
8555
+ required: [
8556
+ "tools"
8557
+ ]
8558
+ }
8559
+ ],
8505
8560
  errorMessage: {
8506
8561
  required: {
8507
8562
  tools: 'Missing "tools" field. Expected: { tools: ["tool1", "tool2"] }'
@@ -8623,14 +8678,16 @@ var AgenticExecutor = class {
8623
8678
  allToolNames;
8624
8679
  toolNameToDetailList;
8625
8680
  server;
8681
+ manual;
8626
8682
  logger;
8627
8683
  tracingEnabled;
8628
8684
  toolSchemaMap;
8629
- constructor(name, allToolNames, toolNameToDetailList, server) {
8685
+ constructor(name, allToolNames, toolNameToDetailList, server, manual) {
8630
8686
  this.name = name;
8631
8687
  this.allToolNames = allToolNames;
8632
8688
  this.toolNameToDetailList = toolNameToDetailList;
8633
8689
  this.server = server;
8690
+ this.manual = manual;
8634
8691
  this.tracingEnabled = false;
8635
8692
  this.logger = createLogger(`mcpc.agentic.${name}`, server);
8636
8693
  this.toolSchemaMap = new Map(toolNameToDetailList);
@@ -8698,7 +8755,34 @@ var AgenticExecutor = class {
8698
8755
  };
8699
8756
  }
8700
8757
  const argsObj = args.args;
8701
- return this.handleManCommand(argsObj.tools, executeSpan);
8758
+ const tools = argsObj.tools ?? [];
8759
+ const wantManual = argsObj.manual === true;
8760
+ const wantTools = tools.length > 0;
8761
+ if (wantTools && wantManual) {
8762
+ const toolSchemas = this.handleManCommand(tools, null);
8763
+ const manualResult = this.handleManualRequest(null);
8764
+ if (executeSpan) {
8765
+ executeSpan.setAttributes({
8766
+ toolType: "man",
8767
+ requestType: "tools+manual"
8768
+ });
8769
+ endSpan(executeSpan);
8770
+ }
8771
+ return {
8772
+ content: [
8773
+ ...toolSchemas.content,
8774
+ {
8775
+ type: "text",
8776
+ text: "\n---\n"
8777
+ },
8778
+ ...manualResult.content
8779
+ ]
8780
+ };
8781
+ }
8782
+ if (wantManual) {
8783
+ return this.handleManualRequest(executeSpan);
8784
+ }
8785
+ return this.handleManCommand(tools, executeSpan);
8702
8786
  }
8703
8787
  const toolArgs = args.args || {};
8704
8788
  return await this.executeTool(tool2, toolArgs, executeSpan);
@@ -8721,6 +8805,44 @@ var AgenticExecutor = class {
8721
8805
  };
8722
8806
  }
8723
8807
  }
8808
+ /**
8809
+ * Handle `man { manual: true }` - return full manual for progressive disclosure
8810
+ */
8811
+ handleManualRequest(executeSpan) {
8812
+ if (executeSpan) {
8813
+ executeSpan.setAttributes({
8814
+ toolType: "man",
8815
+ requestType: "manual"
8816
+ });
8817
+ }
8818
+ if (!this.manual) {
8819
+ if (executeSpan) {
8820
+ endSpan(executeSpan);
8821
+ }
8822
+ return {
8823
+ content: [
8824
+ {
8825
+ type: "text",
8826
+ text: "No manual available for this agent."
8827
+ }
8828
+ ]
8829
+ };
8830
+ }
8831
+ if (executeSpan) {
8832
+ executeSpan.setAttributes({
8833
+ success: true
8834
+ });
8835
+ endSpan(executeSpan);
8836
+ }
8837
+ return {
8838
+ content: [
8839
+ {
8840
+ type: "text",
8841
+ text: this.manual
8842
+ }
8843
+ ]
8844
+ };
8845
+ }
8724
8846
  /**
8725
8847
  * Handle `man` command - return schemas for requested tools
8726
8848
  * @param requestedTools - Array of tool names (already validated via JSON Schema)
@@ -8762,15 +8884,29 @@ ${JSON.stringify(cleanedSchema, null, 2)}
8762
8884
  * Execute a tool with runtime validation
8763
8885
  */
8764
8886
  async executeTool(tool2, toolArgs, executeSpan) {
8765
- const externalTool = this.toolNameToDetailList.find(([name]) => name === tool2);
8766
- if (externalTool) {
8767
- const [, toolDetail] = externalTool;
8887
+ const isExternalTool = this.toolNameToDetailList.some(([name]) => name === tool2);
8888
+ const isInternalTool = this.allToolNames.includes(tool2);
8889
+ if (!isExternalTool && !isInternalTool) {
8768
8890
  if (executeSpan) {
8769
8891
  executeSpan.setAttributes({
8770
- toolType: "external",
8771
- selectedTool: tool2
8892
+ toolType: "not_found",
8893
+ tool: tool2
8772
8894
  });
8895
+ endSpan(executeSpan);
8773
8896
  }
8897
+ return {
8898
+ content: [
8899
+ {
8900
+ type: "text",
8901
+ text: `Tool "${tool2}" not found. Available tools: ${this.allToolNames.join(", ")}`
8902
+ }
8903
+ ],
8904
+ isError: true
8905
+ };
8906
+ }
8907
+ if (isExternalTool) {
8908
+ const externalTool = this.toolNameToDetailList.find(([name]) => name === tool2);
8909
+ const [, toolDetail] = externalTool;
8774
8910
  if (toolDetail.inputSchema) {
8775
8911
  const rawSchema = extractJsonSchema(toolDetail.inputSchema);
8776
8912
  const validation = validateSchema(toolArgs, rawSchema);
@@ -8793,84 +8929,53 @@ ${JSON.stringify(cleanedSchema, null, 2)}
8793
8929
  };
8794
8930
  }
8795
8931
  }
8796
- this.logger.debug({
8797
- message: "Executing external tool",
8798
- tool: tool2
8932
+ }
8933
+ const toolType = isExternalTool ? "external" : "internal";
8934
+ if (executeSpan) {
8935
+ executeSpan.setAttributes({
8936
+ toolType,
8937
+ selectedTool: tool2
8799
8938
  });
8800
- const result = await toolDetail.execute(toolArgs);
8939
+ }
8940
+ this.logger.debug({
8941
+ message: `Executing ${toolType} tool`,
8942
+ tool: tool2
8943
+ });
8944
+ try {
8945
+ const result = await this.server.callTool(tool2, toolArgs, {
8946
+ agentName: this.name
8947
+ });
8948
+ const callToolResult = result ?? {
8949
+ content: []
8950
+ };
8801
8951
  if (executeSpan) {
8802
8952
  executeSpan.setAttributes({
8803
8953
  success: true,
8804
- isError: !!result.isError,
8805
- resultContentLength: result.content?.length || 0
8954
+ isError: !!callToolResult.isError,
8955
+ resultContentLength: callToolResult.content?.length || 0
8806
8956
  });
8807
8957
  endSpan(executeSpan);
8808
8958
  }
8809
- return result;
8810
- }
8811
- if (this.allToolNames.includes(tool2)) {
8959
+ return callToolResult;
8960
+ } catch (error) {
8812
8961
  if (executeSpan) {
8813
- executeSpan.setAttributes({
8814
- toolType: "internal",
8815
- selectedTool: tool2
8816
- });
8817
- }
8818
- this.logger.debug({
8819
- message: "Executing internal tool",
8820
- tool: tool2
8821
- });
8822
- try {
8823
- const result = await this.server.callTool(tool2, toolArgs, {
8824
- agentName: this.name
8825
- });
8826
- const callToolResult = result ?? {
8827
- content: []
8828
- };
8829
- if (executeSpan) {
8830
- executeSpan.setAttributes({
8831
- success: true,
8832
- isError: !!callToolResult.isError,
8833
- resultContentLength: callToolResult.content?.length || 0
8834
- });
8835
- endSpan(executeSpan);
8836
- }
8837
- return callToolResult;
8838
- } catch (error) {
8839
- if (executeSpan) {
8840
- endSpan(executeSpan, error);
8841
- }
8842
- this.logger.error({
8843
- message: "Error executing internal tool",
8844
- tool: tool2,
8845
- error: String(error)
8846
- });
8847
- return {
8848
- content: [
8849
- {
8850
- type: "text",
8851
- text: `Error executing tool "${tool2}": ${error instanceof Error ? error.message : String(error)}`
8852
- }
8853
- ],
8854
- isError: true
8855
- };
8962
+ endSpan(executeSpan, error);
8856
8963
  }
8857
- }
8858
- if (executeSpan) {
8859
- executeSpan.setAttributes({
8860
- toolType: "not_found",
8861
- tool: tool2
8964
+ this.logger.error({
8965
+ message: `Error executing ${toolType} tool`,
8966
+ tool: tool2,
8967
+ error: String(error)
8862
8968
  });
8863
- endSpan(executeSpan);
8969
+ return {
8970
+ content: [
8971
+ {
8972
+ type: "text",
8973
+ text: `Error executing tool "${tool2}": ${error instanceof Error ? error.message : String(error)}`
8974
+ }
8975
+ ],
8976
+ isError: true
8977
+ };
8864
8978
  }
8865
- return {
8866
- content: [
8867
- {
8868
- type: "text",
8869
- text: `Tool "${tool2}" not found. Available tools: ${this.allToolNames.join(", ")}`
8870
- }
8871
- ],
8872
- isError: true
8873
- };
8874
8979
  }
8875
8980
  validate(args, schema) {
8876
8981
  return validateSchema(args, schema);
@@ -8878,19 +8983,18 @@ ${JSON.stringify(cleanedSchema, null, 2)}
8878
8983
  };
8879
8984
 
8880
8985
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/executors/agentic/agentic-tool-registrar.js
8881
- function registerAgenticTool(server, { description, name, allToolNames, depGroups, toolNameToDetailList }) {
8986
+ function registerAgenticTool(server, { description, name, allToolNames, depGroups, toolNameToDetailList, manual }) {
8882
8987
  const createArgsDef = createArgsDefFactory(name, allToolNames, depGroups, void 0, void 0);
8883
- const agenticExecutor = new AgenticExecutor(name, allToolNames, toolNameToDetailList, server);
8884
- description = CompiledPrompts.autonomousExecution({
8988
+ const agenticExecutor = new AgenticExecutor(name, allToolNames, toolNameToDetailList, server, manual);
8989
+ description = manual ? CompiledPrompts.autonomousExecutionCompact({
8990
+ toolName: name,
8991
+ description
8992
+ }) : CompiledPrompts.autonomousExecution({
8885
8993
  toolName: name,
8886
8994
  description
8887
8995
  });
8888
8996
  const agenticArgsDef = createArgsDef.forAgentic(allToolNames);
8889
- const argsDef = agenticArgsDef;
8890
- const schema = allToolNames.length > 0 ? argsDef : {
8891
- type: "object",
8892
- properties: {}
8893
- };
8997
+ const schema = agenticArgsDef;
8894
8998
  server.tool(name, description, jsonSchema(createModelCompatibleJSONSchema(schema)), async (args) => {
8895
8999
  return await agenticExecutor.execute(args, schema);
8896
9000
  });
@@ -8909,7 +9013,8 @@ var createAgenticModePlugin = () => ({
8909
9013
  name: context2.name,
8910
9014
  allToolNames: context2.allToolNames,
8911
9015
  depGroups: context2.depGroups,
8912
- toolNameToDetailList: context2.toolNameToDetailList
9016
+ toolNameToDetailList: context2.toolNameToDetailList,
9017
+ manual: context2.manual
8913
9018
  });
8914
9019
  }
8915
9020
  });
@@ -11013,9 +11118,10 @@ var ComposableMCPServer = class extends Server {
11013
11118
  mcpServers: {}
11014
11119
  }, options = {
11015
11120
  mode: "agentic"
11016
- }) {
11121
+ }, manual) {
11017
11122
  const refDesc = options.refs?.join("") ?? "";
11018
- const { tagToResults } = parseTags(description + refDesc, [
11123
+ const combinedSource = description + refDesc + (manual ?? "");
11124
+ const { tagToResults } = parseTags(combinedSource, [
11019
11125
  "tool",
11020
11126
  "fn"
11021
11127
  ]);
@@ -11166,6 +11272,7 @@ var ComposableMCPServer = class extends Server {
11166
11272
  server: this,
11167
11273
  name,
11168
11274
  description,
11275
+ manual,
11169
11276
  mode,
11170
11277
  allToolNames,
11171
11278
  toolNameToDetailList,
@@ -11244,7 +11351,7 @@ async function mcpc(serverConf, composeConf, optionsOrSetup) {
11244
11351
  await options.setup(server);
11245
11352
  }
11246
11353
  for (const mcpcConfig of parsed) {
11247
- await server.compose(mcpcConfig.name, mcpcConfig.description ?? "", mcpcConfig.deps, mcpcConfig.options);
11354
+ await server.compose(mcpcConfig.name, mcpcConfig.description ?? "", mcpcConfig.deps, mcpcConfig.options, mcpcConfig.manual);
11248
11355
  }
11249
11356
  return server;
11250
11357
  }
package/bin/mcpc.mjs CHANGED
@@ -8332,6 +8332,23 @@ Execute a tool:
8332
8332
  "args": { /* tool parameters */ }
8333
8333
  }
8334
8334
  \`\`\`
8335
+ </format>`,
8336
+ /**
8337
+ * Compact system prompt for autonomous MCP execution (when manual is provided)
8338
+ *
8339
+ * Uses simplified description with progressive disclosure:
8340
+ * - Short description shown by default
8341
+ * - Use `man` command with args `{ manual: true }` to get full manual
8342
+ */
8343
+ AUTONOMOUS_EXECUTION_COMPACT: `Agentic tool \`{toolName}\`: {description}
8344
+
8345
+ Use \`man\` command with args \`{ tools: [], manual: true }\` to get the full manual, or \`{ tools: ["tool1"] }\` to get tool schemas.
8346
+
8347
+ <format>
8348
+ Get full manual: \`{ "tool": "man", "args": { "tools": [], "manual": true } }\`
8349
+ Get tool schemas: \`{ "tool": "man", "args": { "tools": ["tool1", "tool2"] } }\`
8350
+ Get both: \`{ "tool": "man", "args": { "tools": ["tool1"], "manual": true } }\`
8351
+ Execute a tool: \`{ "tool": "tool_name", "args": { /* parameters */ } }\`
8335
8352
  </format>`,
8336
8353
  /**
8337
8354
  * Tool description for sampling tools (shown in MCP tools list)
@@ -8409,6 +8426,7 @@ Adjust parameters and retry.`,
8409
8426
  };
8410
8427
  var CompiledPrompts = {
8411
8428
  autonomousExecution: p(SystemPrompts.AUTONOMOUS_EXECUTION),
8429
+ autonomousExecutionCompact: p(SystemPrompts.AUTONOMOUS_EXECUTION_COMPACT),
8412
8430
  samplingToolDescription: p(SystemPrompts.SAMPLING_TOOL_DESCRIPTION),
8413
8431
  aiLoopSystem: p(SystemPrompts.AI_LOOP_SYSTEM),
8414
8432
  actionSuccess: p(ResponseTemplates.ACTION_SUCCESS),
@@ -8475,7 +8493,7 @@ function createArgsDefFactory(_name, _allToolNames, _depGroups, _predefinedSteps
8475
8493
  },
8476
8494
  args: {
8477
8495
  type: "object",
8478
- description: `For "man": { tools: ["tool1", "tool2"] }. For other tools: tool parameters that strictly adhere to the tool's JSON schema.`
8496
+ description: `For "man": { tools: ["tool1", "tool2"], manual?: true }. For other tools: tool parameters that strictly adhere to the tool's JSON schema.`
8479
8497
  }
8480
8498
  },
8481
8499
  required: [
@@ -8486,7 +8504,10 @@ function createArgsDefFactory(_name, _allToolNames, _depGroups, _predefinedSteps
8486
8504
  },
8487
8505
  /**
8488
8506
  * Schema for "man" command args validation
8489
- * Expected format: { tools: ["tool1", "tool2"] }
8507
+ * Expected format: { tools: ["tool1", "tool2"], manual?: true }
8508
+ *
8509
+ * - Always require `tools`
8510
+ * - Allow empty tools only when `manual: true`
8490
8511
  */
8491
8512
  forMan: function(allToolNames) {
8492
8513
  return {
@@ -8500,16 +8521,50 @@ function createArgsDefFactory(_name, _allToolNames, _depGroups, _predefinedSteps
8500
8521
  errorMessage: {
8501
8522
  enum: `Invalid tool name. Available: ${allToolNames.join(", ")}`
8502
8523
  }
8503
- },
8504
- minItems: 1,
8505
- errorMessage: {
8506
- minItems: "At least one tool name is required"
8507
8524
  }
8525
+ },
8526
+ manual: {
8527
+ type: "boolean",
8528
+ description: "Set to true to get the full manual for this agent (progressive disclosure)."
8508
8529
  }
8509
8530
  },
8510
8531
  required: [
8511
8532
  "tools"
8512
8533
  ],
8534
+ additionalProperties: false,
8535
+ anyOf: [
8536
+ // manual-only (tools can be empty)
8537
+ {
8538
+ properties: {
8539
+ manual: {
8540
+ enum: [
8541
+ true
8542
+ ]
8543
+ },
8544
+ tools: {
8545
+ minItems: 0
8546
+ }
8547
+ },
8548
+ required: [
8549
+ "tools",
8550
+ "manual"
8551
+ ]
8552
+ },
8553
+ // tool schemas (require at least one tool)
8554
+ {
8555
+ properties: {
8556
+ tools: {
8557
+ minItems: 1,
8558
+ errorMessage: {
8559
+ minItems: "At least one tool name is required"
8560
+ }
8561
+ }
8562
+ },
8563
+ required: [
8564
+ "tools"
8565
+ ]
8566
+ }
8567
+ ],
8513
8568
  errorMessage: {
8514
8569
  required: {
8515
8570
  tools: 'Missing "tools" field. Expected: { tools: ["tool1", "tool2"] }'
@@ -8631,14 +8686,16 @@ var AgenticExecutor = class {
8631
8686
  allToolNames;
8632
8687
  toolNameToDetailList;
8633
8688
  server;
8689
+ manual;
8634
8690
  logger;
8635
8691
  tracingEnabled;
8636
8692
  toolSchemaMap;
8637
- constructor(name, allToolNames, toolNameToDetailList, server) {
8693
+ constructor(name, allToolNames, toolNameToDetailList, server, manual) {
8638
8694
  this.name = name;
8639
8695
  this.allToolNames = allToolNames;
8640
8696
  this.toolNameToDetailList = toolNameToDetailList;
8641
8697
  this.server = server;
8698
+ this.manual = manual;
8642
8699
  this.tracingEnabled = false;
8643
8700
  this.logger = createLogger(`mcpc.agentic.${name}`, server);
8644
8701
  this.toolSchemaMap = new Map(toolNameToDetailList);
@@ -8706,7 +8763,34 @@ var AgenticExecutor = class {
8706
8763
  };
8707
8764
  }
8708
8765
  const argsObj = args.args;
8709
- return this.handleManCommand(argsObj.tools, executeSpan);
8766
+ const tools = argsObj.tools ?? [];
8767
+ const wantManual = argsObj.manual === true;
8768
+ const wantTools = tools.length > 0;
8769
+ if (wantTools && wantManual) {
8770
+ const toolSchemas = this.handleManCommand(tools, null);
8771
+ const manualResult = this.handleManualRequest(null);
8772
+ if (executeSpan) {
8773
+ executeSpan.setAttributes({
8774
+ toolType: "man",
8775
+ requestType: "tools+manual"
8776
+ });
8777
+ endSpan(executeSpan);
8778
+ }
8779
+ return {
8780
+ content: [
8781
+ ...toolSchemas.content,
8782
+ {
8783
+ type: "text",
8784
+ text: "\n---\n"
8785
+ },
8786
+ ...manualResult.content
8787
+ ]
8788
+ };
8789
+ }
8790
+ if (wantManual) {
8791
+ return this.handleManualRequest(executeSpan);
8792
+ }
8793
+ return this.handleManCommand(tools, executeSpan);
8710
8794
  }
8711
8795
  const toolArgs = args.args || {};
8712
8796
  return await this.executeTool(tool2, toolArgs, executeSpan);
@@ -8729,6 +8813,44 @@ var AgenticExecutor = class {
8729
8813
  };
8730
8814
  }
8731
8815
  }
8816
+ /**
8817
+ * Handle `man { manual: true }` - return full manual for progressive disclosure
8818
+ */
8819
+ handleManualRequest(executeSpan) {
8820
+ if (executeSpan) {
8821
+ executeSpan.setAttributes({
8822
+ toolType: "man",
8823
+ requestType: "manual"
8824
+ });
8825
+ }
8826
+ if (!this.manual) {
8827
+ if (executeSpan) {
8828
+ endSpan(executeSpan);
8829
+ }
8830
+ return {
8831
+ content: [
8832
+ {
8833
+ type: "text",
8834
+ text: "No manual available for this agent."
8835
+ }
8836
+ ]
8837
+ };
8838
+ }
8839
+ if (executeSpan) {
8840
+ executeSpan.setAttributes({
8841
+ success: true
8842
+ });
8843
+ endSpan(executeSpan);
8844
+ }
8845
+ return {
8846
+ content: [
8847
+ {
8848
+ type: "text",
8849
+ text: this.manual
8850
+ }
8851
+ ]
8852
+ };
8853
+ }
8732
8854
  /**
8733
8855
  * Handle `man` command - return schemas for requested tools
8734
8856
  * @param requestedTools - Array of tool names (already validated via JSON Schema)
@@ -8770,15 +8892,29 @@ ${JSON.stringify(cleanedSchema, null, 2)}
8770
8892
  * Execute a tool with runtime validation
8771
8893
  */
8772
8894
  async executeTool(tool2, toolArgs, executeSpan) {
8773
- const externalTool = this.toolNameToDetailList.find(([name]) => name === tool2);
8774
- if (externalTool) {
8775
- const [, toolDetail] = externalTool;
8895
+ const isExternalTool = this.toolNameToDetailList.some(([name]) => name === tool2);
8896
+ const isInternalTool = this.allToolNames.includes(tool2);
8897
+ if (!isExternalTool && !isInternalTool) {
8776
8898
  if (executeSpan) {
8777
8899
  executeSpan.setAttributes({
8778
- toolType: "external",
8779
- selectedTool: tool2
8900
+ toolType: "not_found",
8901
+ tool: tool2
8780
8902
  });
8903
+ endSpan(executeSpan);
8781
8904
  }
8905
+ return {
8906
+ content: [
8907
+ {
8908
+ type: "text",
8909
+ text: `Tool "${tool2}" not found. Available tools: ${this.allToolNames.join(", ")}`
8910
+ }
8911
+ ],
8912
+ isError: true
8913
+ };
8914
+ }
8915
+ if (isExternalTool) {
8916
+ const externalTool = this.toolNameToDetailList.find(([name]) => name === tool2);
8917
+ const [, toolDetail] = externalTool;
8782
8918
  if (toolDetail.inputSchema) {
8783
8919
  const rawSchema = extractJsonSchema(toolDetail.inputSchema);
8784
8920
  const validation = validateSchema(toolArgs, rawSchema);
@@ -8801,84 +8937,53 @@ ${JSON.stringify(cleanedSchema, null, 2)}
8801
8937
  };
8802
8938
  }
8803
8939
  }
8804
- this.logger.debug({
8805
- message: "Executing external tool",
8806
- tool: tool2
8940
+ }
8941
+ const toolType = isExternalTool ? "external" : "internal";
8942
+ if (executeSpan) {
8943
+ executeSpan.setAttributes({
8944
+ toolType,
8945
+ selectedTool: tool2
8807
8946
  });
8808
- const result = await toolDetail.execute(toolArgs);
8947
+ }
8948
+ this.logger.debug({
8949
+ message: `Executing ${toolType} tool`,
8950
+ tool: tool2
8951
+ });
8952
+ try {
8953
+ const result = await this.server.callTool(tool2, toolArgs, {
8954
+ agentName: this.name
8955
+ });
8956
+ const callToolResult = result ?? {
8957
+ content: []
8958
+ };
8809
8959
  if (executeSpan) {
8810
8960
  executeSpan.setAttributes({
8811
8961
  success: true,
8812
- isError: !!result.isError,
8813
- resultContentLength: result.content?.length || 0
8962
+ isError: !!callToolResult.isError,
8963
+ resultContentLength: callToolResult.content?.length || 0
8814
8964
  });
8815
8965
  endSpan(executeSpan);
8816
8966
  }
8817
- return result;
8818
- }
8819
- if (this.allToolNames.includes(tool2)) {
8967
+ return callToolResult;
8968
+ } catch (error) {
8820
8969
  if (executeSpan) {
8821
- executeSpan.setAttributes({
8822
- toolType: "internal",
8823
- selectedTool: tool2
8824
- });
8825
- }
8826
- this.logger.debug({
8827
- message: "Executing internal tool",
8828
- tool: tool2
8829
- });
8830
- try {
8831
- const result = await this.server.callTool(tool2, toolArgs, {
8832
- agentName: this.name
8833
- });
8834
- const callToolResult = result ?? {
8835
- content: []
8836
- };
8837
- if (executeSpan) {
8838
- executeSpan.setAttributes({
8839
- success: true,
8840
- isError: !!callToolResult.isError,
8841
- resultContentLength: callToolResult.content?.length || 0
8842
- });
8843
- endSpan(executeSpan);
8844
- }
8845
- return callToolResult;
8846
- } catch (error) {
8847
- if (executeSpan) {
8848
- endSpan(executeSpan, error);
8849
- }
8850
- this.logger.error({
8851
- message: "Error executing internal tool",
8852
- tool: tool2,
8853
- error: String(error)
8854
- });
8855
- return {
8856
- content: [
8857
- {
8858
- type: "text",
8859
- text: `Error executing tool "${tool2}": ${error instanceof Error ? error.message : String(error)}`
8860
- }
8861
- ],
8862
- isError: true
8863
- };
8970
+ endSpan(executeSpan, error);
8864
8971
  }
8865
- }
8866
- if (executeSpan) {
8867
- executeSpan.setAttributes({
8868
- toolType: "not_found",
8869
- tool: tool2
8972
+ this.logger.error({
8973
+ message: `Error executing ${toolType} tool`,
8974
+ tool: tool2,
8975
+ error: String(error)
8870
8976
  });
8871
- endSpan(executeSpan);
8977
+ return {
8978
+ content: [
8979
+ {
8980
+ type: "text",
8981
+ text: `Error executing tool "${tool2}": ${error instanceof Error ? error.message : String(error)}`
8982
+ }
8983
+ ],
8984
+ isError: true
8985
+ };
8872
8986
  }
8873
- return {
8874
- content: [
8875
- {
8876
- type: "text",
8877
- text: `Tool "${tool2}" not found. Available tools: ${this.allToolNames.join(", ")}`
8878
- }
8879
- ],
8880
- isError: true
8881
- };
8882
8987
  }
8883
8988
  validate(args, schema) {
8884
8989
  return validateSchema(args, schema);
@@ -8886,19 +8991,18 @@ ${JSON.stringify(cleanedSchema, null, 2)}
8886
8991
  };
8887
8992
 
8888
8993
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/executors/agentic/agentic-tool-registrar.js
8889
- function registerAgenticTool(server, { description, name, allToolNames, depGroups, toolNameToDetailList }) {
8994
+ function registerAgenticTool(server, { description, name, allToolNames, depGroups, toolNameToDetailList, manual }) {
8890
8995
  const createArgsDef = createArgsDefFactory(name, allToolNames, depGroups, void 0, void 0);
8891
- const agenticExecutor = new AgenticExecutor(name, allToolNames, toolNameToDetailList, server);
8892
- description = CompiledPrompts.autonomousExecution({
8996
+ const agenticExecutor = new AgenticExecutor(name, allToolNames, toolNameToDetailList, server, manual);
8997
+ description = manual ? CompiledPrompts.autonomousExecutionCompact({
8998
+ toolName: name,
8999
+ description
9000
+ }) : CompiledPrompts.autonomousExecution({
8893
9001
  toolName: name,
8894
9002
  description
8895
9003
  });
8896
9004
  const agenticArgsDef = createArgsDef.forAgentic(allToolNames);
8897
- const argsDef = agenticArgsDef;
8898
- const schema = allToolNames.length > 0 ? argsDef : {
8899
- type: "object",
8900
- properties: {}
8901
- };
9005
+ const schema = agenticArgsDef;
8902
9006
  server.tool(name, description, jsonSchema(createModelCompatibleJSONSchema(schema)), async (args) => {
8903
9007
  return await agenticExecutor.execute(args, schema);
8904
9008
  });
@@ -8917,7 +9021,8 @@ var createAgenticModePlugin = () => ({
8917
9021
  name: context2.name,
8918
9022
  allToolNames: context2.allToolNames,
8919
9023
  depGroups: context2.depGroups,
8920
- toolNameToDetailList: context2.toolNameToDetailList
9024
+ toolNameToDetailList: context2.toolNameToDetailList,
9025
+ manual: context2.manual
8921
9026
  });
8922
9027
  }
8923
9028
  });
@@ -11020,9 +11125,10 @@ var ComposableMCPServer = class extends Server {
11020
11125
  mcpServers: {}
11021
11126
  }, options = {
11022
11127
  mode: "agentic"
11023
- }) {
11128
+ }, manual) {
11024
11129
  const refDesc = options.refs?.join("") ?? "";
11025
- const { tagToResults } = parseTags(description + refDesc, [
11130
+ const combinedSource = description + refDesc + (manual ?? "");
11131
+ const { tagToResults } = parseTags(combinedSource, [
11026
11132
  "tool",
11027
11133
  "fn"
11028
11134
  ]);
@@ -11173,6 +11279,7 @@ var ComposableMCPServer = class extends Server {
11173
11279
  server: this,
11174
11280
  name,
11175
11281
  description,
11282
+ manual,
11176
11283
  mode,
11177
11284
  allToolNames,
11178
11285
  toolNameToDetailList,
@@ -11251,7 +11358,7 @@ async function mcpc(serverConf, composeConf, optionsOrSetup) {
11251
11358
  await options.setup(server);
11252
11359
  }
11253
11360
  for (const mcpcConfig of parsed) {
11254
- await server.compose(mcpcConfig.name, mcpcConfig.description ?? "", mcpcConfig.deps, mcpcConfig.options);
11361
+ await server.compose(mcpcConfig.name, mcpcConfig.description ?? "", mcpcConfig.deps, mcpcConfig.options, mcpcConfig.manual);
11255
11362
  }
11256
11363
  return server;
11257
11364
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcpc-tech/cli",
3
- "version": "0.1.33",
3
+ "version": "0.1.35",
4
4
  "homepage": "https://jsr.io/@mcpc/cli",
5
5
  "dependencies": {
6
6
  "@hono/zod-openapi": "^0.19.2",