@mcpc-tech/plugin-markdown-loader 0.0.3 → 0.0.5

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/index.cjs +194 -89
  2. package/index.mjs +194 -89
  3. package/package.json +1 -1
package/index.cjs CHANGED
@@ -467,6 +467,23 @@ Execute a tool:
467
467
  "args": { /* tool parameters */ }
468
468
  }
469
469
  \`\`\`
470
+ </format>`,
471
+ /**
472
+ * Compact system prompt for autonomous MCP execution (when manual is provided)
473
+ *
474
+ * Uses simplified description with progressive disclosure:
475
+ * - Short description shown by default
476
+ * - Use `man` command with args `{ manual: true }` to get full manual
477
+ */
478
+ AUTONOMOUS_EXECUTION_COMPACT: `Agentic tool \`{toolName}\`: {description}
479
+
480
+ Use \`man\` command with args \`{ tools: [], manual: true }\` to get the full manual, or \`{ tools: ["tool1"] }\` to get tool schemas.
481
+
482
+ <format>
483
+ Get full manual: \`{ "tool": "man", "args": { "tools": [], "manual": true } }\`
484
+ Get tool schemas: \`{ "tool": "man", "args": { "tools": ["tool1", "tool2"] } }\`
485
+ Get both: \`{ "tool": "man", "args": { "tools": ["tool1"], "manual": true } }\`
486
+ Execute a tool: \`{ "tool": "tool_name", "args": { /* parameters */ } }\`
470
487
  </format>`,
471
488
  /**
472
489
  * Tool description for sampling tools (shown in MCP tools list)
@@ -544,6 +561,7 @@ Adjust parameters and retry.`,
544
561
  };
545
562
  var CompiledPrompts = {
546
563
  autonomousExecution: p(SystemPrompts.AUTONOMOUS_EXECUTION),
564
+ autonomousExecutionCompact: p(SystemPrompts.AUTONOMOUS_EXECUTION_COMPACT),
547
565
  samplingToolDescription: p(SystemPrompts.SAMPLING_TOOL_DESCRIPTION),
548
566
  aiLoopSystem: p(SystemPrompts.AI_LOOP_SYSTEM),
549
567
  actionSuccess: p(ResponseTemplates.ACTION_SUCCESS),
@@ -610,7 +628,7 @@ function createArgsDefFactory(_name, _allToolNames, _depGroups, _predefinedSteps
610
628
  },
611
629
  args: {
612
630
  type: "object",
613
- description: `For "man": { tools: ["tool1", "tool2"] }. For other tools: tool parameters that strictly adhere to the tool's JSON schema.`
631
+ description: `For "man": { tools: ["tool1", "tool2"], manual?: true }. For other tools: tool parameters that strictly adhere to the tool's JSON schema.`
614
632
  }
615
633
  },
616
634
  required: [
@@ -621,7 +639,10 @@ function createArgsDefFactory(_name, _allToolNames, _depGroups, _predefinedSteps
621
639
  },
622
640
  /**
623
641
  * Schema for "man" command args validation
624
- * Expected format: { tools: ["tool1", "tool2"] }
642
+ * Expected format: { tools: ["tool1", "tool2"], manual?: true }
643
+ *
644
+ * - Always require `tools`
645
+ * - Allow empty tools only when `manual: true`
625
646
  */
626
647
  forMan: function(allToolNames) {
627
648
  return {
@@ -635,16 +656,50 @@ function createArgsDefFactory(_name, _allToolNames, _depGroups, _predefinedSteps
635
656
  errorMessage: {
636
657
  enum: `Invalid tool name. Available: ${allToolNames.join(", ")}`
637
658
  }
638
- },
639
- minItems: 1,
640
- errorMessage: {
641
- minItems: "At least one tool name is required"
642
659
  }
660
+ },
661
+ manual: {
662
+ type: "boolean",
663
+ description: "Set to true to get the full manual for this agent (progressive disclosure)."
643
664
  }
644
665
  },
645
666
  required: [
646
667
  "tools"
647
668
  ],
669
+ additionalProperties: false,
670
+ anyOf: [
671
+ // manual-only (tools can be empty)
672
+ {
673
+ properties: {
674
+ manual: {
675
+ enum: [
676
+ true
677
+ ]
678
+ },
679
+ tools: {
680
+ minItems: 0
681
+ }
682
+ },
683
+ required: [
684
+ "tools",
685
+ "manual"
686
+ ]
687
+ },
688
+ // tool schemas (require at least one tool)
689
+ {
690
+ properties: {
691
+ tools: {
692
+ minItems: 1,
693
+ errorMessage: {
694
+ minItems: "At least one tool name is required"
695
+ }
696
+ }
697
+ },
698
+ required: [
699
+ "tools"
700
+ ]
701
+ }
702
+ ],
648
703
  errorMessage: {
649
704
  required: {
650
705
  tools: 'Missing "tools" field. Expected: { tools: ["tool1", "tool2"] }'
@@ -766,14 +821,16 @@ var AgenticExecutor = class {
766
821
  allToolNames;
767
822
  toolNameToDetailList;
768
823
  server;
824
+ manual;
769
825
  logger;
770
826
  tracingEnabled;
771
827
  toolSchemaMap;
772
- constructor(name, allToolNames, toolNameToDetailList, server) {
828
+ constructor(name, allToolNames, toolNameToDetailList, server, manual) {
773
829
  this.name = name;
774
830
  this.allToolNames = allToolNames;
775
831
  this.toolNameToDetailList = toolNameToDetailList;
776
832
  this.server = server;
833
+ this.manual = manual;
777
834
  this.tracingEnabled = false;
778
835
  this.logger = createLogger(`mcpc.agentic.${name}`, server);
779
836
  this.toolSchemaMap = new Map(toolNameToDetailList);
@@ -841,7 +898,34 @@ var AgenticExecutor = class {
841
898
  };
842
899
  }
843
900
  const argsObj = args.args;
844
- return this.handleManCommand(argsObj.tools, executeSpan);
901
+ const tools = argsObj.tools ?? [];
902
+ const wantManual = argsObj.manual === true;
903
+ const wantTools = tools.length > 0;
904
+ if (wantTools && wantManual) {
905
+ const toolSchemas = this.handleManCommand(tools, null);
906
+ const manualResult = this.handleManualRequest(null);
907
+ if (executeSpan) {
908
+ executeSpan.setAttributes({
909
+ toolType: "man",
910
+ requestType: "tools+manual"
911
+ });
912
+ endSpan(executeSpan);
913
+ }
914
+ return {
915
+ content: [
916
+ ...toolSchemas.content,
917
+ {
918
+ type: "text",
919
+ text: "\n---\n"
920
+ },
921
+ ...manualResult.content
922
+ ]
923
+ };
924
+ }
925
+ if (wantManual) {
926
+ return this.handleManualRequest(executeSpan);
927
+ }
928
+ return this.handleManCommand(tools, executeSpan);
845
929
  }
846
930
  const toolArgs = args.args || {};
847
931
  return await this.executeTool(tool2, toolArgs, executeSpan);
@@ -864,6 +948,44 @@ var AgenticExecutor = class {
864
948
  };
865
949
  }
866
950
  }
951
+ /**
952
+ * Handle `man { manual: true }` - return full manual for progressive disclosure
953
+ */
954
+ handleManualRequest(executeSpan) {
955
+ if (executeSpan) {
956
+ executeSpan.setAttributes({
957
+ toolType: "man",
958
+ requestType: "manual"
959
+ });
960
+ }
961
+ if (!this.manual) {
962
+ if (executeSpan) {
963
+ endSpan(executeSpan);
964
+ }
965
+ return {
966
+ content: [
967
+ {
968
+ type: "text",
969
+ text: "No manual available for this agent."
970
+ }
971
+ ]
972
+ };
973
+ }
974
+ if (executeSpan) {
975
+ executeSpan.setAttributes({
976
+ success: true
977
+ });
978
+ endSpan(executeSpan);
979
+ }
980
+ return {
981
+ content: [
982
+ {
983
+ type: "text",
984
+ text: this.manual
985
+ }
986
+ ]
987
+ };
988
+ }
867
989
  /**
868
990
  * Handle `man` command - return schemas for requested tools
869
991
  * @param requestedTools - Array of tool names (already validated via JSON Schema)
@@ -905,15 +1027,29 @@ ${JSON.stringify(cleanedSchema, null, 2)}
905
1027
  * Execute a tool with runtime validation
906
1028
  */
907
1029
  async executeTool(tool2, toolArgs, executeSpan) {
908
- const externalTool = this.toolNameToDetailList.find(([name]) => name === tool2);
909
- if (externalTool) {
910
- const [, toolDetail] = externalTool;
1030
+ const isExternalTool = this.toolNameToDetailList.some(([name]) => name === tool2);
1031
+ const isInternalTool = this.allToolNames.includes(tool2);
1032
+ if (!isExternalTool && !isInternalTool) {
911
1033
  if (executeSpan) {
912
1034
  executeSpan.setAttributes({
913
- toolType: "external",
914
- selectedTool: tool2
1035
+ toolType: "not_found",
1036
+ tool: tool2
915
1037
  });
1038
+ endSpan(executeSpan);
916
1039
  }
1040
+ return {
1041
+ content: [
1042
+ {
1043
+ type: "text",
1044
+ text: `Tool "${tool2}" not found. Available tools: ${this.allToolNames.join(", ")}`
1045
+ }
1046
+ ],
1047
+ isError: true
1048
+ };
1049
+ }
1050
+ if (isExternalTool) {
1051
+ const externalTool = this.toolNameToDetailList.find(([name]) => name === tool2);
1052
+ const [, toolDetail] = externalTool;
917
1053
  if (toolDetail.inputSchema) {
918
1054
  const rawSchema = extractJsonSchema(toolDetail.inputSchema);
919
1055
  const validation = validateSchema(toolArgs, rawSchema);
@@ -936,84 +1072,53 @@ ${JSON.stringify(cleanedSchema, null, 2)}
936
1072
  };
937
1073
  }
938
1074
  }
939
- this.logger.debug({
940
- message: "Executing external tool",
941
- tool: tool2
1075
+ }
1076
+ const toolType = isExternalTool ? "external" : "internal";
1077
+ if (executeSpan) {
1078
+ executeSpan.setAttributes({
1079
+ toolType,
1080
+ selectedTool: tool2
1081
+ });
1082
+ }
1083
+ this.logger.debug({
1084
+ message: `Executing ${toolType} tool`,
1085
+ tool: tool2
1086
+ });
1087
+ try {
1088
+ const result = await this.server.callTool(tool2, toolArgs, {
1089
+ agentName: this.name
942
1090
  });
943
- const result = await toolDetail.execute(toolArgs);
1091
+ const callToolResult = result ?? {
1092
+ content: []
1093
+ };
944
1094
  if (executeSpan) {
945
1095
  executeSpan.setAttributes({
946
1096
  success: true,
947
- isError: !!result.isError,
948
- resultContentLength: result.content?.length || 0
1097
+ isError: !!callToolResult.isError,
1098
+ resultContentLength: callToolResult.content?.length || 0
949
1099
  });
950
1100
  endSpan(executeSpan);
951
1101
  }
952
- return result;
953
- }
954
- if (this.allToolNames.includes(tool2)) {
1102
+ return callToolResult;
1103
+ } catch (error) {
955
1104
  if (executeSpan) {
956
- executeSpan.setAttributes({
957
- toolType: "internal",
958
- selectedTool: tool2
959
- });
960
- }
961
- this.logger.debug({
962
- message: "Executing internal tool",
963
- tool: tool2
964
- });
965
- try {
966
- const result = await this.server.callTool(tool2, toolArgs, {
967
- agentName: this.name
968
- });
969
- const callToolResult = result ?? {
970
- content: []
971
- };
972
- if (executeSpan) {
973
- executeSpan.setAttributes({
974
- success: true,
975
- isError: !!callToolResult.isError,
976
- resultContentLength: callToolResult.content?.length || 0
977
- });
978
- endSpan(executeSpan);
979
- }
980
- return callToolResult;
981
- } catch (error) {
982
- if (executeSpan) {
983
- endSpan(executeSpan, error);
984
- }
985
- this.logger.error({
986
- message: "Error executing internal tool",
987
- tool: tool2,
988
- error: String(error)
989
- });
990
- return {
991
- content: [
992
- {
993
- type: "text",
994
- text: `Error executing tool "${tool2}": ${error instanceof Error ? error.message : String(error)}`
995
- }
996
- ],
997
- isError: true
998
- };
1105
+ endSpan(executeSpan, error);
999
1106
  }
1000
- }
1001
- if (executeSpan) {
1002
- executeSpan.setAttributes({
1003
- toolType: "not_found",
1004
- tool: tool2
1107
+ this.logger.error({
1108
+ message: `Error executing ${toolType} tool`,
1109
+ tool: tool2,
1110
+ error: String(error)
1005
1111
  });
1006
- endSpan(executeSpan);
1112
+ return {
1113
+ content: [
1114
+ {
1115
+ type: "text",
1116
+ text: `Error executing tool "${tool2}": ${error instanceof Error ? error.message : String(error)}`
1117
+ }
1118
+ ],
1119
+ isError: true
1120
+ };
1007
1121
  }
1008
- return {
1009
- content: [
1010
- {
1011
- type: "text",
1012
- text: `Tool "${tool2}" not found. Available tools: ${this.allToolNames.join(", ")}`
1013
- }
1014
- ],
1015
- isError: true
1016
- };
1017
1122
  }
1018
1123
  validate(args, schema) {
1019
1124
  return validateSchema(args, schema);
@@ -1021,19 +1126,18 @@ ${JSON.stringify(cleanedSchema, null, 2)}
1021
1126
  };
1022
1127
 
1023
1128
  // __mcpc__plugin-markdown-loader_latest/node_modules/@jsr/mcpc__core/src/executors/agentic/agentic-tool-registrar.js
1024
- function registerAgenticTool(server, { description, name, allToolNames, depGroups, toolNameToDetailList }) {
1129
+ function registerAgenticTool(server, { description, name, allToolNames, depGroups, toolNameToDetailList, manual }) {
1025
1130
  const createArgsDef = createArgsDefFactory(name, allToolNames, depGroups, void 0, void 0);
1026
- const agenticExecutor = new AgenticExecutor(name, allToolNames, toolNameToDetailList, server);
1027
- description = CompiledPrompts.autonomousExecution({
1131
+ const agenticExecutor = new AgenticExecutor(name, allToolNames, toolNameToDetailList, server, manual);
1132
+ description = manual ? CompiledPrompts.autonomousExecutionCompact({
1133
+ toolName: name,
1134
+ description
1135
+ }) : CompiledPrompts.autonomousExecution({
1028
1136
  toolName: name,
1029
1137
  description
1030
1138
  });
1031
1139
  const agenticArgsDef = createArgsDef.forAgentic(allToolNames);
1032
- const argsDef = agenticArgsDef;
1033
- const schema = allToolNames.length > 0 ? argsDef : {
1034
- type: "object",
1035
- properties: {}
1036
- };
1140
+ const schema = agenticArgsDef;
1037
1141
  server.tool(name, description, jsonSchema(createModelCompatibleJSONSchema(schema)), async (args) => {
1038
1142
  return await agenticExecutor.execute(args, schema);
1039
1143
  });
@@ -1052,7 +1156,8 @@ var createAgenticModePlugin = () => ({
1052
1156
  name: context2.name,
1053
1157
  allToolNames: context2.allToolNames,
1054
1158
  depGroups: context2.depGroups,
1055
- toolNameToDetailList: context2.toolNameToDetailList
1159
+ toolNameToDetailList: context2.toolNameToDetailList,
1160
+ manual: context2.manual
1056
1161
  });
1057
1162
  }
1058
1163
  });
package/index.mjs CHANGED
@@ -428,6 +428,23 @@ Execute a tool:
428
428
  "args": { /* tool parameters */ }
429
429
  }
430
430
  \`\`\`
431
+ </format>`,
432
+ /**
433
+ * Compact system prompt for autonomous MCP execution (when manual is provided)
434
+ *
435
+ * Uses simplified description with progressive disclosure:
436
+ * - Short description shown by default
437
+ * - Use `man` command with args `{ manual: true }` to get full manual
438
+ */
439
+ AUTONOMOUS_EXECUTION_COMPACT: `Agentic tool \`{toolName}\`: {description}
440
+
441
+ Use \`man\` command with args \`{ tools: [], manual: true }\` to get the full manual, or \`{ tools: ["tool1"] }\` to get tool schemas.
442
+
443
+ <format>
444
+ Get full manual: \`{ "tool": "man", "args": { "tools": [], "manual": true } }\`
445
+ Get tool schemas: \`{ "tool": "man", "args": { "tools": ["tool1", "tool2"] } }\`
446
+ Get both: \`{ "tool": "man", "args": { "tools": ["tool1"], "manual": true } }\`
447
+ Execute a tool: \`{ "tool": "tool_name", "args": { /* parameters */ } }\`
431
448
  </format>`,
432
449
  /**
433
450
  * Tool description for sampling tools (shown in MCP tools list)
@@ -505,6 +522,7 @@ Adjust parameters and retry.`,
505
522
  };
506
523
  var CompiledPrompts = {
507
524
  autonomousExecution: p(SystemPrompts.AUTONOMOUS_EXECUTION),
525
+ autonomousExecutionCompact: p(SystemPrompts.AUTONOMOUS_EXECUTION_COMPACT),
508
526
  samplingToolDescription: p(SystemPrompts.SAMPLING_TOOL_DESCRIPTION),
509
527
  aiLoopSystem: p(SystemPrompts.AI_LOOP_SYSTEM),
510
528
  actionSuccess: p(ResponseTemplates.ACTION_SUCCESS),
@@ -571,7 +589,7 @@ function createArgsDefFactory(_name, _allToolNames, _depGroups, _predefinedSteps
571
589
  },
572
590
  args: {
573
591
  type: "object",
574
- description: `For "man": { tools: ["tool1", "tool2"] }. For other tools: tool parameters that strictly adhere to the tool's JSON schema.`
592
+ description: `For "man": { tools: ["tool1", "tool2"], manual?: true }. For other tools: tool parameters that strictly adhere to the tool's JSON schema.`
575
593
  }
576
594
  },
577
595
  required: [
@@ -582,7 +600,10 @@ function createArgsDefFactory(_name, _allToolNames, _depGroups, _predefinedSteps
582
600
  },
583
601
  /**
584
602
  * Schema for "man" command args validation
585
- * Expected format: { tools: ["tool1", "tool2"] }
603
+ * Expected format: { tools: ["tool1", "tool2"], manual?: true }
604
+ *
605
+ * - Always require `tools`
606
+ * - Allow empty tools only when `manual: true`
586
607
  */
587
608
  forMan: function(allToolNames) {
588
609
  return {
@@ -596,16 +617,50 @@ function createArgsDefFactory(_name, _allToolNames, _depGroups, _predefinedSteps
596
617
  errorMessage: {
597
618
  enum: `Invalid tool name. Available: ${allToolNames.join(", ")}`
598
619
  }
599
- },
600
- minItems: 1,
601
- errorMessage: {
602
- minItems: "At least one tool name is required"
603
620
  }
621
+ },
622
+ manual: {
623
+ type: "boolean",
624
+ description: "Set to true to get the full manual for this agent (progressive disclosure)."
604
625
  }
605
626
  },
606
627
  required: [
607
628
  "tools"
608
629
  ],
630
+ additionalProperties: false,
631
+ anyOf: [
632
+ // manual-only (tools can be empty)
633
+ {
634
+ properties: {
635
+ manual: {
636
+ enum: [
637
+ true
638
+ ]
639
+ },
640
+ tools: {
641
+ minItems: 0
642
+ }
643
+ },
644
+ required: [
645
+ "tools",
646
+ "manual"
647
+ ]
648
+ },
649
+ // tool schemas (require at least one tool)
650
+ {
651
+ properties: {
652
+ tools: {
653
+ minItems: 1,
654
+ errorMessage: {
655
+ minItems: "At least one tool name is required"
656
+ }
657
+ }
658
+ },
659
+ required: [
660
+ "tools"
661
+ ]
662
+ }
663
+ ],
609
664
  errorMessage: {
610
665
  required: {
611
666
  tools: 'Missing "tools" field. Expected: { tools: ["tool1", "tool2"] }'
@@ -727,14 +782,16 @@ var AgenticExecutor = class {
727
782
  allToolNames;
728
783
  toolNameToDetailList;
729
784
  server;
785
+ manual;
730
786
  logger;
731
787
  tracingEnabled;
732
788
  toolSchemaMap;
733
- constructor(name, allToolNames, toolNameToDetailList, server) {
789
+ constructor(name, allToolNames, toolNameToDetailList, server, manual) {
734
790
  this.name = name;
735
791
  this.allToolNames = allToolNames;
736
792
  this.toolNameToDetailList = toolNameToDetailList;
737
793
  this.server = server;
794
+ this.manual = manual;
738
795
  this.tracingEnabled = false;
739
796
  this.logger = createLogger(`mcpc.agentic.${name}`, server);
740
797
  this.toolSchemaMap = new Map(toolNameToDetailList);
@@ -802,7 +859,34 @@ var AgenticExecutor = class {
802
859
  };
803
860
  }
804
861
  const argsObj = args.args;
805
- return this.handleManCommand(argsObj.tools, executeSpan);
862
+ const tools = argsObj.tools ?? [];
863
+ const wantManual = argsObj.manual === true;
864
+ const wantTools = tools.length > 0;
865
+ if (wantTools && wantManual) {
866
+ const toolSchemas = this.handleManCommand(tools, null);
867
+ const manualResult = this.handleManualRequest(null);
868
+ if (executeSpan) {
869
+ executeSpan.setAttributes({
870
+ toolType: "man",
871
+ requestType: "tools+manual"
872
+ });
873
+ endSpan(executeSpan);
874
+ }
875
+ return {
876
+ content: [
877
+ ...toolSchemas.content,
878
+ {
879
+ type: "text",
880
+ text: "\n---\n"
881
+ },
882
+ ...manualResult.content
883
+ ]
884
+ };
885
+ }
886
+ if (wantManual) {
887
+ return this.handleManualRequest(executeSpan);
888
+ }
889
+ return this.handleManCommand(tools, executeSpan);
806
890
  }
807
891
  const toolArgs = args.args || {};
808
892
  return await this.executeTool(tool2, toolArgs, executeSpan);
@@ -825,6 +909,44 @@ var AgenticExecutor = class {
825
909
  };
826
910
  }
827
911
  }
912
+ /**
913
+ * Handle `man { manual: true }` - return full manual for progressive disclosure
914
+ */
915
+ handleManualRequest(executeSpan) {
916
+ if (executeSpan) {
917
+ executeSpan.setAttributes({
918
+ toolType: "man",
919
+ requestType: "manual"
920
+ });
921
+ }
922
+ if (!this.manual) {
923
+ if (executeSpan) {
924
+ endSpan(executeSpan);
925
+ }
926
+ return {
927
+ content: [
928
+ {
929
+ type: "text",
930
+ text: "No manual available for this agent."
931
+ }
932
+ ]
933
+ };
934
+ }
935
+ if (executeSpan) {
936
+ executeSpan.setAttributes({
937
+ success: true
938
+ });
939
+ endSpan(executeSpan);
940
+ }
941
+ return {
942
+ content: [
943
+ {
944
+ type: "text",
945
+ text: this.manual
946
+ }
947
+ ]
948
+ };
949
+ }
828
950
  /**
829
951
  * Handle `man` command - return schemas for requested tools
830
952
  * @param requestedTools - Array of tool names (already validated via JSON Schema)
@@ -866,15 +988,29 @@ ${JSON.stringify(cleanedSchema, null, 2)}
866
988
  * Execute a tool with runtime validation
867
989
  */
868
990
  async executeTool(tool2, toolArgs, executeSpan) {
869
- const externalTool = this.toolNameToDetailList.find(([name]) => name === tool2);
870
- if (externalTool) {
871
- const [, toolDetail] = externalTool;
991
+ const isExternalTool = this.toolNameToDetailList.some(([name]) => name === tool2);
992
+ const isInternalTool = this.allToolNames.includes(tool2);
993
+ if (!isExternalTool && !isInternalTool) {
872
994
  if (executeSpan) {
873
995
  executeSpan.setAttributes({
874
- toolType: "external",
875
- selectedTool: tool2
996
+ toolType: "not_found",
997
+ tool: tool2
876
998
  });
999
+ endSpan(executeSpan);
877
1000
  }
1001
+ return {
1002
+ content: [
1003
+ {
1004
+ type: "text",
1005
+ text: `Tool "${tool2}" not found. Available tools: ${this.allToolNames.join(", ")}`
1006
+ }
1007
+ ],
1008
+ isError: true
1009
+ };
1010
+ }
1011
+ if (isExternalTool) {
1012
+ const externalTool = this.toolNameToDetailList.find(([name]) => name === tool2);
1013
+ const [, toolDetail] = externalTool;
878
1014
  if (toolDetail.inputSchema) {
879
1015
  const rawSchema = extractJsonSchema(toolDetail.inputSchema);
880
1016
  const validation = validateSchema(toolArgs, rawSchema);
@@ -897,84 +1033,53 @@ ${JSON.stringify(cleanedSchema, null, 2)}
897
1033
  };
898
1034
  }
899
1035
  }
900
- this.logger.debug({
901
- message: "Executing external tool",
902
- tool: tool2
1036
+ }
1037
+ const toolType = isExternalTool ? "external" : "internal";
1038
+ if (executeSpan) {
1039
+ executeSpan.setAttributes({
1040
+ toolType,
1041
+ selectedTool: tool2
1042
+ });
1043
+ }
1044
+ this.logger.debug({
1045
+ message: `Executing ${toolType} tool`,
1046
+ tool: tool2
1047
+ });
1048
+ try {
1049
+ const result = await this.server.callTool(tool2, toolArgs, {
1050
+ agentName: this.name
903
1051
  });
904
- const result = await toolDetail.execute(toolArgs);
1052
+ const callToolResult = result ?? {
1053
+ content: []
1054
+ };
905
1055
  if (executeSpan) {
906
1056
  executeSpan.setAttributes({
907
1057
  success: true,
908
- isError: !!result.isError,
909
- resultContentLength: result.content?.length || 0
1058
+ isError: !!callToolResult.isError,
1059
+ resultContentLength: callToolResult.content?.length || 0
910
1060
  });
911
1061
  endSpan(executeSpan);
912
1062
  }
913
- return result;
914
- }
915
- if (this.allToolNames.includes(tool2)) {
1063
+ return callToolResult;
1064
+ } catch (error) {
916
1065
  if (executeSpan) {
917
- executeSpan.setAttributes({
918
- toolType: "internal",
919
- selectedTool: tool2
920
- });
921
- }
922
- this.logger.debug({
923
- message: "Executing internal tool",
924
- tool: tool2
925
- });
926
- try {
927
- const result = await this.server.callTool(tool2, toolArgs, {
928
- agentName: this.name
929
- });
930
- const callToolResult = result ?? {
931
- content: []
932
- };
933
- if (executeSpan) {
934
- executeSpan.setAttributes({
935
- success: true,
936
- isError: !!callToolResult.isError,
937
- resultContentLength: callToolResult.content?.length || 0
938
- });
939
- endSpan(executeSpan);
940
- }
941
- return callToolResult;
942
- } catch (error) {
943
- if (executeSpan) {
944
- endSpan(executeSpan, error);
945
- }
946
- this.logger.error({
947
- message: "Error executing internal tool",
948
- tool: tool2,
949
- error: String(error)
950
- });
951
- return {
952
- content: [
953
- {
954
- type: "text",
955
- text: `Error executing tool "${tool2}": ${error instanceof Error ? error.message : String(error)}`
956
- }
957
- ],
958
- isError: true
959
- };
1066
+ endSpan(executeSpan, error);
960
1067
  }
961
- }
962
- if (executeSpan) {
963
- executeSpan.setAttributes({
964
- toolType: "not_found",
965
- tool: tool2
1068
+ this.logger.error({
1069
+ message: `Error executing ${toolType} tool`,
1070
+ tool: tool2,
1071
+ error: String(error)
966
1072
  });
967
- endSpan(executeSpan);
1073
+ return {
1074
+ content: [
1075
+ {
1076
+ type: "text",
1077
+ text: `Error executing tool "${tool2}": ${error instanceof Error ? error.message : String(error)}`
1078
+ }
1079
+ ],
1080
+ isError: true
1081
+ };
968
1082
  }
969
- return {
970
- content: [
971
- {
972
- type: "text",
973
- text: `Tool "${tool2}" not found. Available tools: ${this.allToolNames.join(", ")}`
974
- }
975
- ],
976
- isError: true
977
- };
978
1083
  }
979
1084
  validate(args, schema) {
980
1085
  return validateSchema(args, schema);
@@ -982,19 +1087,18 @@ ${JSON.stringify(cleanedSchema, null, 2)}
982
1087
  };
983
1088
 
984
1089
  // __mcpc__plugin-markdown-loader_latest/node_modules/@jsr/mcpc__core/src/executors/agentic/agentic-tool-registrar.js
985
- function registerAgenticTool(server, { description, name, allToolNames, depGroups, toolNameToDetailList }) {
1090
+ function registerAgenticTool(server, { description, name, allToolNames, depGroups, toolNameToDetailList, manual }) {
986
1091
  const createArgsDef = createArgsDefFactory(name, allToolNames, depGroups, void 0, void 0);
987
- const agenticExecutor = new AgenticExecutor(name, allToolNames, toolNameToDetailList, server);
988
- description = CompiledPrompts.autonomousExecution({
1092
+ const agenticExecutor = new AgenticExecutor(name, allToolNames, toolNameToDetailList, server, manual);
1093
+ description = manual ? CompiledPrompts.autonomousExecutionCompact({
1094
+ toolName: name,
1095
+ description
1096
+ }) : CompiledPrompts.autonomousExecution({
989
1097
  toolName: name,
990
1098
  description
991
1099
  });
992
1100
  const agenticArgsDef = createArgsDef.forAgentic(allToolNames);
993
- const argsDef = agenticArgsDef;
994
- const schema = allToolNames.length > 0 ? argsDef : {
995
- type: "object",
996
- properties: {}
997
- };
1101
+ const schema = agenticArgsDef;
998
1102
  server.tool(name, description, jsonSchema(createModelCompatibleJSONSchema(schema)), async (args) => {
999
1103
  return await agenticExecutor.execute(args, schema);
1000
1104
  });
@@ -1013,7 +1117,8 @@ var createAgenticModePlugin = () => ({
1013
1117
  name: context2.name,
1014
1118
  allToolNames: context2.allToolNames,
1015
1119
  depGroups: context2.depGroups,
1016
- toolNameToDetailList: context2.toolNameToDetailList
1120
+ toolNameToDetailList: context2.toolNameToDetailList,
1121
+ manual: context2.manual
1017
1122
  });
1018
1123
  }
1019
1124
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcpc-tech/plugin-markdown-loader",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "homepage": "https://jsr.io/@mcpc/plugin-markdown-loader",
5
5
  "dependencies": {
6
6
  "@ai-sdk/provider": "^2.0.0",