@mcpc-tech/cli 0.1.5 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/mcpc.mjs CHANGED
@@ -41,6 +41,56 @@ var init_schema = __esm({
41
41
  }
42
42
  });
43
43
 
44
+ // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/config.js
45
+ import process2 from "node:process";
46
+ var GEMINI_PREFERRED_FORMAT;
47
+ var init_config = __esm({
48
+ "__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/config.js"() {
49
+ GEMINI_PREFERRED_FORMAT = process2.env.GEMINI_PREFERRED_FORMAT === "0" ? false : true;
50
+ }
51
+ });
52
+
53
+ // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/json.js
54
+ import { jsonrepair as jsonrepair2 } from "jsonrepair";
55
+ var init_json = __esm({
56
+ "__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/json.js"() {
57
+ }
58
+ });
59
+
60
+ // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/provider.js
61
+ function sanitizePropertyKey(name) {
62
+ return name.replace(/[^a-zA-Z0-9_-]/g, "_").substring(0, 64);
63
+ }
64
+ var createGoogleCompatibleJSONSchema;
65
+ var init_provider = __esm({
66
+ "__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/provider.js"() {
67
+ init_config();
68
+ init_json();
69
+ createGoogleCompatibleJSONSchema = (schema) => {
70
+ if (!GEMINI_PREFERRED_FORMAT) {
71
+ return schema;
72
+ }
73
+ const { oneOf: _oneOf, allOf: _allOf, anyOf: _anyOf, ...cleanSchema } = schema;
74
+ const removeAdditionalProperties = (obj) => {
75
+ if (Array.isArray(obj)) {
76
+ return obj.map(removeAdditionalProperties);
77
+ }
78
+ if (obj && typeof obj === "object") {
79
+ const result = {};
80
+ for (const [key, value] of Object.entries(obj)) {
81
+ if (key !== "additionalProperties") {
82
+ result[key] = removeAdditionalProperties(value);
83
+ }
84
+ }
85
+ return result;
86
+ }
87
+ return obj;
88
+ };
89
+ return removeAdditionalProperties(cleanSchema);
90
+ };
91
+ }
92
+ });
93
+
44
94
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/logger.js
45
95
  function createLogger(name, server2) {
46
96
  return new MCPLogger(name, server2);
@@ -90,16 +140,8 @@ var init_logger = __esm({
90
140
  }
91
141
  logToConsole(level, data) {
92
142
  const message = typeof data === "string" ? data : JSON.stringify(data);
93
- const prefix = `[${this.loggerName}]`;
94
- if (level === "debug") {
95
- console.debug(prefix, message);
96
- } else if (level === "info" || level === "notice") {
97
- console.info(prefix, message);
98
- } else if (level === "warning") {
99
- console.warn(prefix, message);
100
- } else {
101
- console.error(prefix, message);
102
- }
143
+ const prefix = `[${this.loggerName}:${level}]`;
144
+ console.error(prefix, message);
103
145
  }
104
146
  debug(data) {
105
147
  return this.log("debug", data);
@@ -167,15 +209,17 @@ var init_tool_name_mapping_plugin = __esm({
167
209
  transformTool: (tool, context2) => {
168
210
  const server2 = context2.server;
169
211
  const toolName = context2.toolName;
170
- const dotNotation = toolName.replace(/_/g, ".");
171
- const underscoreNotation = toolName.replace(/\./g, "_");
172
- if (dotNotation !== toolName && server2.toolNameMapping) {
212
+ const originalName = tool._originalName || toolName;
213
+ const dotNotation = originalName.replace(/_/g, ".");
214
+ const underscoreNotation = originalName.replace(/\./g, "_");
215
+ if (dotNotation !== originalName && server2.toolNameMapping) {
173
216
  server2.toolNameMapping.set(dotNotation, toolName);
174
- server2.toolNameMapping.set(toolName, dotNotation);
175
217
  }
176
- if (underscoreNotation !== toolName && server2.toolNameMapping) {
218
+ if (underscoreNotation !== originalName && server2.toolNameMapping) {
177
219
  server2.toolNameMapping.set(underscoreNotation, toolName);
178
- server2.toolNameMapping.set(toolName, underscoreNotation);
220
+ }
221
+ if (originalName !== toolName && server2.toolNameMapping) {
222
+ server2.toolNameMapping.set(originalName, toolName);
179
223
  }
180
224
  return tool;
181
225
  }
@@ -566,7 +610,8 @@ function buildDependencyGroups(toolNameToDetailList, hiddenToolNames, publicTool
566
610
  const baseProperties = baseSchema.type === "object" && baseSchema.properties ? baseSchema.properties : {};
567
611
  const baseRequired = baseSchema.type === "object" && Array.isArray(baseSchema.required) ? baseSchema.required : [];
568
612
  const updatedProperties = updateRefPaths(baseProperties, toolName);
569
- depGroups[toolName] = {
613
+ const sanitizedKey = sanitizePropertyKey(toolName);
614
+ depGroups[sanitizedKey] = {
570
615
  type: "object",
571
616
  description: tool.description,
572
617
  properties: updatedProperties,
@@ -591,6 +636,7 @@ var init_compose_helpers = __esm({
591
636
  "__mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/compose-helpers.js"() {
592
637
  init_schema2();
593
638
  init_schema();
639
+ init_provider();
594
640
  }
595
641
  });
596
642
 
@@ -660,9 +706,42 @@ function stripMarkdownAndText(text) {
660
706
  text = text.replace(/^```(?:json)?\s*\n?/i, "");
661
707
  text = text.replace(/\n?```\s*$/, "");
662
708
  text = text.replace(/^(?:here is|here's|response|result|output|json):\s*/i, "");
663
- const jsonMatch = text.match(/(\{[\s\S]*\}|\[[\s\S]*\])/);
664
- if (jsonMatch) {
665
- text = jsonMatch[1];
709
+ const firstJsonIndex = text.search(/[\{\[]/);
710
+ if (firstJsonIndex >= 0) {
711
+ text = text.slice(firstJsonIndex);
712
+ let depth = 0;
713
+ let inString = false;
714
+ let escapeNext = false;
715
+ const startChar = text[0];
716
+ const endChar = startChar === "{" ? "}" : "]";
717
+ for (let i = 0; i < text.length; i++) {
718
+ const char = text[i];
719
+ if (escapeNext) {
720
+ escapeNext = false;
721
+ continue;
722
+ }
723
+ if (char === "\\") {
724
+ escapeNext = true;
725
+ continue;
726
+ }
727
+ if (char === '"' && !inString) {
728
+ inString = true;
729
+ continue;
730
+ }
731
+ if (char === '"' && inString) {
732
+ inString = false;
733
+ continue;
734
+ }
735
+ if (inString) continue;
736
+ if (char === startChar) {
737
+ depth++;
738
+ } else if (char === endChar) {
739
+ depth--;
740
+ if (depth === 0) {
741
+ return text.slice(0, i + 1);
742
+ }
743
+ }
744
+ }
666
745
  }
667
746
  return text.trim();
668
747
  }
@@ -775,8 +854,9 @@ function smitheryToolNameCompatibale(name, scope) {
775
854
  }
776
855
 
777
856
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/mcp.js
857
+ init_provider();
778
858
  import { cwd } from "node:process";
779
- import process2 from "node:process";
859
+ import process3 from "node:process";
780
860
  import { createHash } from "node:crypto";
781
861
  var mcpClientPool = /* @__PURE__ */ new Map();
782
862
  var mcpClientConnecting = /* @__PURE__ */ new Map();
@@ -822,7 +902,7 @@ async function getOrCreateMcpClient(defKey, def) {
822
902
  command: def.command,
823
903
  args: def.args,
824
904
  env: {
825
- ...process2.env,
905
+ ...process3.env,
826
906
  ...def.env ?? {}
827
907
  },
828
908
  cwd: cwd()
@@ -876,11 +956,11 @@ var cleanupAllPooledClients = async () => {
876
956
  }
877
957
  }));
878
958
  };
879
- process2.once?.("exit", () => {
959
+ process3.once?.("exit", () => {
880
960
  cleanupAllPooledClients();
881
961
  });
882
- process2.once?.("SIGINT", () => {
883
- cleanupAllPooledClients().finally(() => process2.exit(0));
962
+ process3.once?.("SIGINT", () => {
963
+ cleanupAllPooledClients().finally(() => process3.exit(0));
884
964
  });
885
965
  async function composeMcpDepTools(mcpConfig, filterIn) {
886
966
  const allTools = {};
@@ -898,7 +978,8 @@ async function composeMcpDepTools(mcpConfig, filterIn) {
898
978
  const { tools } = await client.listTools();
899
979
  tools.forEach((tool) => {
900
980
  const { toolNameWithScope, toolName: internalToolName } = smitheryToolNameCompatibale(tool.name, name);
901
- const toolId = `${serverId}_${internalToolName}`;
981
+ const rawToolId = `${serverId}_${internalToolName}`;
982
+ const toolId = sanitizePropertyKey(rawToolId);
902
983
  if (filterIn && !filterIn({
903
984
  action: internalToolName,
904
985
  tool,
@@ -917,7 +998,8 @@ async function composeMcpDepTools(mcpConfig, filterIn) {
917
998
  });
918
999
  allTools[toolId] = {
919
1000
  ...tool,
920
- execute
1001
+ execute,
1002
+ _originalName: toolNameWithScope
921
1003
  };
922
1004
  });
923
1005
  } catch (error) {
@@ -939,37 +1021,7 @@ async function composeMcpDepTools(mcpConfig, filterIn) {
939
1021
 
940
1022
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/executors/agentic/agentic-tool-registrar.js
941
1023
  init_schema();
942
-
943
- // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/config.js
944
- import process3 from "node:process";
945
- var GEMINI_PREFERRED_FORMAT = process3.env.GEMINI_PREFERRED_FORMAT === "0" ? false : true;
946
-
947
- // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/json.js
948
- import { jsonrepair as jsonrepair2 } from "jsonrepair";
949
-
950
- // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/provider.js
951
- var createGoogleCompatibleJSONSchema = (schema) => {
952
- if (!GEMINI_PREFERRED_FORMAT) {
953
- return schema;
954
- }
955
- const { oneOf: _oneOf, allOf: _allOf, anyOf: _anyOf, ...cleanSchema } = schema;
956
- const removeAdditionalProperties = (obj) => {
957
- if (Array.isArray(obj)) {
958
- return obj.map(removeAdditionalProperties);
959
- }
960
- if (obj && typeof obj === "object") {
961
- const result = {};
962
- for (const [key, value] of Object.entries(obj)) {
963
- if (key !== "additionalProperties") {
964
- result[key] = removeAdditionalProperties(value);
965
- }
966
- }
967
- return result;
968
- }
969
- return obj;
970
- };
971
- return removeAdditionalProperties(cleanSchema);
972
- };
1024
+ init_provider();
973
1025
 
974
1026
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/prompts/index.js
975
1027
  var SystemPrompts = {
@@ -2025,7 +2077,7 @@ var BaseSamplingExecutor = class {
2025
2077
  role: "user",
2026
2078
  content: {
2027
2079
  type: "text",
2028
- text: 'Return ONLY raw JSON (no code fences or explanations). The JSON MUST include action and decision. Example: {"action":"<tool>","decision":"proceed|complete","<tool>":{}}'
2080
+ text: 'Return ONE AND ONLY ONE raw JSON object (no code fences, explanations, or multiple objects). The JSON MUST include action and decision. Example: {"action":"<tool>","decision":"proceed|complete","<tool>":{}}'
2029
2081
  }
2030
2082
  }
2031
2083
  ];
@@ -2061,15 +2113,13 @@ var BaseSamplingExecutor = class {
2061
2113
  if (iterationSpan) endSpan(iterationSpan);
2062
2114
  continue;
2063
2115
  }
2064
- if (parsedData) {
2065
- this.conversationHistory.push({
2066
- role: "assistant",
2067
- content: {
2068
- type: "text",
2069
- text: JSON.stringify(parsedData, null, 2)
2070
- }
2071
- });
2072
- }
2116
+ this.conversationHistory.push({
2117
+ role: "assistant",
2118
+ content: {
2119
+ type: "text",
2120
+ text: JSON.stringify(parsedData, null, 2)
2121
+ }
2122
+ });
2073
2123
  const action = parsedData["action"];
2074
2124
  const actionStr = action && typeof action === "string" ? String(action) : "unknown_action";
2075
2125
  const spanName = `mcpc.sampling_iteration.${actionStr}`;
@@ -2147,23 +2197,15 @@ var BaseSamplingExecutor = class {
2147
2197
  return await this.createExecutionError(error, loopSpan);
2148
2198
  }
2149
2199
  }
2150
- addParsingErrorToHistory(responseText, parseError) {
2151
- this.conversationHistory.push({
2152
- role: "assistant",
2153
- content: {
2154
- type: "text",
2155
- text: `JSON parsing failed. Response was: ${responseText}`
2156
- }
2157
- });
2200
+ addParsingErrorToHistory(_responseText, parseError) {
2201
+ const errorMsg = parseError instanceof Error ? parseError.message : String(parseError);
2158
2202
  this.conversationHistory.push({
2159
2203
  role: "user",
2160
2204
  content: {
2161
2205
  type: "text",
2162
- text: CompiledPrompts.errorResponse({
2163
- errorMessage: `JSON parsing failed: ${parseError instanceof Error ? parseError.message : String(parseError)}
2206
+ text: `Invalid JSON: ${errorMsg}
2164
2207
 
2165
- Please respond with valid JSON.`
2166
- })
2208
+ Respond with valid JSON.`
2167
2209
  }
2168
2210
  });
2169
2211
  }
@@ -2301,11 +2343,11 @@ ${msg.content.text}`;
2301
2343
  });
2302
2344
  }
2303
2345
  injectJsonInstruction({ prompt, schema, schemaPrefix = "JSON schema:", schemaSuffix = `STRICT REQUIREMENTS:
2304
- 1. Return ONLY raw JSON that passes JSON.parse() - no markdown, code blocks, explanatory text, or extra characters
2346
+ 1. Return ONE AND ONLY ONE raw JSON object that passes JSON.parse() - no markdown, code blocks, explanatory text, or multiple JSON objects
2305
2347
  2. Include ALL required fields with correct data types and satisfy ALL schema constraints (anyOf, oneOf, allOf, not, enum, pattern, min/max, conditionals)
2306
- 3. Your response must be the JSON object itself, nothing else
2348
+ 3. Your response must be a single JSON object, nothing else
2307
2349
 
2308
- INVALID: \`\`\`json{"key":"value"}\`\`\` or "Here is: {"key":"value"}"
2350
+ INVALID: \`\`\`json{"key":"value"}\`\`\` or "Here is: {"key":"value"}" or {"key":"value"}{"key":"value"}
2309
2351
  VALID: {"key":"value"}` }) {
2310
2352
  return [
2311
2353
  prompt != null && prompt.length > 0 ? prompt : void 0,
@@ -2426,10 +2468,10 @@ ${JSON.stringify(context2, null, 2)}`;
2426
2468
  const taskPrompt = `
2427
2469
 
2428
2470
  ## Current Task
2429
- I will now use agentic sampling to complete the following task: "${userRequest}"${contextInfo}
2471
+ You will now use agentic sampling to complete the following task: "${userRequest}"${contextInfo}
2430
2472
 
2431
- When I need to use a tool, I should specify the tool name in 'action' and provide tool-specific parameters as additional properties.
2432
- When the task is complete, I should use "action": "complete".`;
2473
+ When you need to use a tool, specify the tool name in 'action' and provide tool-specific parameters as additional properties.
2474
+ When the task is complete, use "action": "complete".`;
2433
2475
  return this.injectJsonInstruction({
2434
2476
  prompt: basePrompt + taskPrompt,
2435
2477
  schema: agenticSchema
@@ -2639,6 +2681,9 @@ var WorkflowState = class {
2639
2681
  }
2640
2682
  };
2641
2683
 
2684
+ // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/executors/workflow/workflow-tool-registrar.js
2685
+ init_provider();
2686
+
2642
2687
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/executors/workflow/workflow-executor.js
2643
2688
  import { Ajv as Ajv3 } from "ajv";
2644
2689
  import { AggregateAjvError as AggregateAjvError3 } from "@segment/ajv-human-errors";
@@ -3110,6 +3155,8 @@ function processToolTags({ description, tagToResults, $, tools, toolOverrides, t
3110
3155
  const toolId = findToolId(toolName, tools, toolNameMapping);
3111
3156
  if (toolId) {
3112
3157
  $(toolEl).replaceWith(`<action action="${toolId}"/>`);
3158
+ } else {
3159
+ $(toolEl).remove();
3113
3160
  }
3114
3161
  }
3115
3162
  });
@@ -3868,6 +3915,9 @@ if (isSCF()) {
3868
3915
  });
3869
3916
  }
3870
3917
 
3918
+ // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/mod.js
3919
+ init_json();
3920
+
3871
3921
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/set-up-mcp-compose.js
3872
3922
  function parseMcpcConfigs(conf) {
3873
3923
  const mcpcConfigs = conf ?? [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcpc-tech/cli",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "homepage": "https://jsr.io/@mcpc/cli",
5
5
  "type": "module",
6
6
  "dependencies": {
@@ -1 +1 @@
1
- {"version":3,"file":"app.d.ts","sources":["../../src/app.ts"],"names":[],"mappings":"AAAA,SAAS,WAAW,4BAAwC;AAI5D,cAAc,mBAAmB,0BAA0D;AAC3F,cAAc,UAAU,6BAA6B;AAErD,OAAO,cAAM,eACX,SAAS,eACR,QAAQ,qBA8BT;AAEF,OAAO,cAAM,iBAAgB,YAO3B"}
1
+ {"version":3,"file":"app.d.ts","sources":["../../src/app.ts"],"names":[],"mappings":"AAAA,SAAS,WAAW,4BAAwC;AAI5D,cAAc,mBAAmB,0BAAmD;AACpF,cAAc,UAAU,6BAA6B;AAErD,OAAO,cAAM,eACX,SAAS,eACR,QAAQ,qBA8BT;AAEF,OAAO,cAAM,iBAAgB,YAO3B"}
@@ -1 +1 @@
1
- {"version":3,"file":"loader.d.ts","sources":["../../../src/config/loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2CC,GAED,cAAc,iBAAiB,0BAAuC;AAKtE,iBAAiB;EACf;;GAEC,GACD,OAAO,MAAM;EACb;;GAEC,GACD,UAAU,MAAM;EAChB;;GAEC,GACD;IACE,QAAQ,OAAO,MAAM,EAAE,OAAO;IAC9B,WAAW,OAAO,MAAM,EAAE,OAAO;;EAEnC;;GAEC,GACD,QAAQ;;AAwHV;;;CAGC,GACD,OAAO,iBAAe,cAAc,QAAQ,aAAa,IAAI;AAoK7D;;CAEC,GACD,OAAO,iBAAS,eAAe,QAAQ,UAAU,GAAG,IAAI"}
1
+ {"version":3,"file":"loader.d.ts","sources":["../../../src/config/loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2CC,GAED,cAAc,iBAAiB,0BAAgC;AAK/D,iBAAiB;EACf;;GAEC,GACD,OAAO,MAAM;EACb;;GAEC,GACD,UAAU,MAAM;EAChB;;GAEC,GACD;IACE,QAAQ,OAAO,MAAM,EAAE,OAAO;IAC9B,WAAW,OAAO,MAAM,EAAE,OAAO;;EAEnC;;GAEC,GACD,QAAQ;;AAwHV;;;CAGC,GACD,OAAO,iBAAe,cAAc,QAAQ,aAAa,IAAI;AAoK7D;;CAEC,GACD,OAAO,iBAAS,eAAe,QAAQ,UAAU,GAAG,IAAI"}