@mcpc-tech/cli 0.1.19 → 0.1.20

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 +123 -123
  2. package/package.json +3 -3
package/bin/mcpc.mjs CHANGED
@@ -646,31 +646,6 @@ import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
646
646
  import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
647
647
  import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js";
648
648
 
649
- // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/registory.js
650
- function connectToSmitheryServer(smitheryConfig) {
651
- const serverUrl = new URL(smitheryConfig.deploymentUrl);
652
- serverUrl.searchParams.set("config", btoa(JSON.stringify(smitheryConfig.config)));
653
- serverUrl.searchParams.set("api_key", smitheryConfig?.smitheryApiKey ?? smitheryConfig?.config?.smitheryApiKey);
654
- return {
655
- url: serverUrl.toString()
656
- };
657
- }
658
- function smitheryToolNameCompatibale(name, scope) {
659
- if (!name.startsWith("toolbox_")) {
660
- return {
661
- toolNameWithScope: `${scope}.${name}`,
662
- toolName: name
663
- };
664
- }
665
- const [, ...toolNames] = name.split("_");
666
- const toolName = toolNames.join("_");
667
- const toolNameWithScope = `${scope}.${toolName}`;
668
- return {
669
- toolNameWithScope,
670
- toolName
671
- };
672
- }
673
-
674
649
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/config.js
675
650
  import process3 from "node:process";
676
651
  var GEMINI_PREFERRED_FORMAT = process3.env.GEMINI_PREFERRED_FORMAT === "0" ? false : true;
@@ -682,27 +657,38 @@ import { jsonrepair as jsonrepair2 } from "jsonrepair";
682
657
  function sanitizePropertyKey(name) {
683
658
  return name.replace(/[@.,/\\:;!?#$%^&*()[\]{}]/g, "_").substring(0, 64);
684
659
  }
685
- var createGoogleCompatibleJSONSchema = (schema) => {
686
- if (!GEMINI_PREFERRED_FORMAT) {
687
- return schema;
688
- }
689
- const { oneOf: _oneOf, allOf: _allOf, anyOf: _anyOf, ...cleanSchema } = schema;
690
- const removeAdditionalProperties = (obj) => {
660
+ var createModelCompatibleJSONSchema = (schema) => {
661
+ const validatorOnlyKeys = [
662
+ "errorMessage"
663
+ ];
664
+ const geminiRestrictedKeys = GEMINI_PREFERRED_FORMAT ? [
665
+ "additionalProperties"
666
+ ] : [];
667
+ const keysToRemove = /* @__PURE__ */ new Set([
668
+ ...validatorOnlyKeys,
669
+ ...geminiRestrictedKeys
670
+ ]);
671
+ let cleanSchema = schema;
672
+ if (GEMINI_PREFERRED_FORMAT) {
673
+ const { oneOf: _oneOf, allOf: _allOf, anyOf: _anyOf, ...rest2 } = schema;
674
+ cleanSchema = rest2;
675
+ }
676
+ const cleanRecursively = (obj) => {
691
677
  if (Array.isArray(obj)) {
692
- return obj.map(removeAdditionalProperties);
678
+ return obj.map(cleanRecursively);
693
679
  }
694
680
  if (obj && typeof obj === "object") {
695
681
  const result = {};
696
682
  for (const [key, value] of Object.entries(obj)) {
697
- if (key !== "additionalProperties") {
698
- result[key] = removeAdditionalProperties(value);
683
+ if (!keysToRemove.has(key)) {
684
+ result[key] = cleanRecursively(value);
699
685
  }
700
686
  }
701
687
  return result;
702
688
  }
703
689
  return obj;
704
690
  };
705
- return removeAdditionalProperties(cleanSchema);
691
+ return cleanRecursively(cleanSchema);
706
692
  };
707
693
 
708
694
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/mcp.js
@@ -849,7 +835,8 @@ async function composeMcpDepTools(mcpConfig, filterIn) {
849
835
  allClients[serverId] = client;
850
836
  const { tools } = await client.listTools();
851
837
  tools.forEach((tool) => {
852
- const { toolNameWithScope, toolName: internalToolName } = smitheryToolNameCompatibale(tool.name, name);
838
+ const toolNameWithScope = `${name}.${tool.name}`;
839
+ const internalToolName = tool.name;
853
840
  const rawToolId = `${serverId}_${internalToolName}`;
854
841
  const toolId = sanitizePropertyKey(rawToolId);
855
842
  if (filterIn && !filterIn({
@@ -1441,19 +1428,32 @@ ${JSON.stringify(steps, null, 2)}`;
1441
1428
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/schema-validator.js
1442
1429
  import { Ajv } from "ajv";
1443
1430
  import addFormats from "ajv-formats";
1431
+ import ajvErrors from "ajv-errors";
1444
1432
  import { AggregateAjvError } from "@segment/ajv-human-errors";
1445
1433
  var ajv = new Ajv({
1446
1434
  allErrors: true,
1447
1435
  verbose: true
1448
1436
  });
1449
1437
  addFormats.default(ajv);
1438
+ ajvErrors.default(ajv);
1450
1439
  function validateSchema(args, schema) {
1451
1440
  const validate = ajv.compile(schema);
1452
1441
  if (!validate(args)) {
1453
- const errors = new AggregateAjvError(validate.errors);
1442
+ const errors = validate.errors;
1443
+ const customErrors = errors.filter((err) => err.keyword === "errorMessage");
1444
+ if (customErrors.length > 0) {
1445
+ const messages = [
1446
+ ...new Set(customErrors.map((err) => err.message))
1447
+ ];
1448
+ return {
1449
+ valid: false,
1450
+ error: messages.join("; ")
1451
+ };
1452
+ }
1453
+ const aggregateError = new AggregateAjvError(errors);
1454
1454
  return {
1455
1455
  valid: false,
1456
- error: errors.message
1456
+ error: aggregateError.message
1457
1457
  };
1458
1458
  }
1459
1459
  return {
@@ -1604,11 +1604,17 @@ var AgenticExecutor = class {
1604
1604
  });
1605
1605
  endSpan(executeSpan);
1606
1606
  }
1607
- const result2 = {
1607
+ const result = {
1608
1608
  content: []
1609
1609
  };
1610
- this.appendToolSchemas(result2, definitionsOf, hasDefinitions);
1611
- return result2;
1610
+ this.appendToolSchemas(result, definitionsOf, hasDefinitions);
1611
+ if (result.content.length === 0 && definitionsOf.length > 0) {
1612
+ result.content.push({
1613
+ type: "text",
1614
+ text: `All requested tool schemas are already in hasDefinitions. You can now call a tool using "${this.USE_TOOL_KEY}".`
1615
+ });
1616
+ }
1617
+ return result;
1612
1618
  }
1613
1619
  if (executeSpan) {
1614
1620
  try {
@@ -1658,8 +1664,8 @@ var AgenticExecutor = class {
1658
1664
  selectTool: useTool
1659
1665
  });
1660
1666
  try {
1661
- const result2 = await this.server.callTool(useTool, args[useTool]);
1662
- const callToolResult = result2 ?? {
1667
+ const result = await this.server.callTool(useTool, args[useTool]);
1668
+ const callToolResult = result ?? {
1663
1669
  content: []
1664
1670
  };
1665
1671
  this.appendToolSchemas(callToolResult, definitionsOf, hasDefinitions);
@@ -1700,16 +1706,15 @@ var AgenticExecutor = class {
1700
1706
  });
1701
1707
  endSpan(executeSpan);
1702
1708
  }
1703
- this.logger.warning({
1704
- message: "Tool not found",
1705
- useTool,
1706
- availableTools: this.allToolNames
1707
- });
1708
- const result = {
1709
- content: []
1709
+ return {
1710
+ content: [
1711
+ {
1712
+ type: "text",
1713
+ text: `Tool "${useTool}" not found. Available tools: ${this.allToolNames.join(", ")}.`
1714
+ }
1715
+ ],
1716
+ isError: true
1710
1717
  };
1711
- this.appendToolSchemas(result, definitionsOf, hasDefinitions);
1712
- return result;
1713
1718
  } catch (error) {
1714
1719
  if (executeSpan) {
1715
1720
  endSpan(executeSpan, error);
@@ -1937,7 +1942,10 @@ Workflow step definitions - provide ONLY on initial call.
1937
1942
  decision: () => ({
1938
1943
  type: "string",
1939
1944
  enum: Object.values(DECISION_OPTIONS),
1940
- description: `**Step control: \`${DECISION_OPTIONS.PROCEED}\` = next step, \`${DECISION_OPTIONS.RETRY}\` = retry/repeat current, \`${DECISION_OPTIONS.COMPLETE}\` = finish workflow**`
1945
+ description: `**Step control: \`${DECISION_OPTIONS.PROCEED}\` = next step, \`${DECISION_OPTIONS.RETRY}\` = retry/repeat current, \`${DECISION_OPTIONS.COMPLETE}\` = finish workflow**`,
1946
+ errorMessage: {
1947
+ enum: `Invalid decision. Must be one of: ${Object.values(DECISION_OPTIONS).join(", ")}.`
1948
+ }
1941
1949
  }),
1942
1950
  action: () => ({
1943
1951
  type: "string",
@@ -1945,7 +1953,10 @@ Workflow step definitions - provide ONLY on initial call.
1945
1953
  enum: allToolNames,
1946
1954
  required: [
1947
1955
  "action"
1948
- ]
1956
+ ],
1957
+ errorMessage: {
1958
+ enum: `Invalid action. Must be one of: ${allToolNames.join(", ")}.`
1959
+ }
1949
1960
  }),
1950
1961
  forTool: function() {
1951
1962
  return this.common({});
@@ -1987,58 +1998,17 @@ Workflow step definitions - provide ONLY on initial call.
1987
1998
  required: [
1988
1999
  "userRequest",
1989
2000
  "context"
1990
- ]
2001
+ ],
2002
+ errorMessage: {
2003
+ required: {
2004
+ userRequest: "Missing required field 'userRequest'. Please provide a clear task description.",
2005
+ context: "Missing required field 'context'. Please provide relevant context (e.g., current working directory)."
2006
+ }
2007
+ }
1991
2008
  };
1992
2009
  },
1993
2010
  forAgentic: function(toolNameToDetailList, _sampling = false, USE_TOOL_KEY = "useTool") {
1994
2011
  const allOf = [
1995
- // When hasDefinitions is empty, definitionsOf must be provided
1996
- {
1997
- if: {
1998
- properties: {
1999
- hasDefinitions: {
2000
- type: "array",
2001
- maxItems: 0
2002
- }
2003
- },
2004
- required: [
2005
- "hasDefinitions"
2006
- ]
2007
- },
2008
- then: {
2009
- required: [
2010
- "definitionsOf"
2011
- ]
2012
- }
2013
- },
2014
- // When useTool is present, hasDefinitions must contain that tool
2015
- ...toolNameToDetailList.map(([toolName, _toolDetail]) => {
2016
- return {
2017
- if: {
2018
- properties: {
2019
- [USE_TOOL_KEY]: {
2020
- const: toolName
2021
- }
2022
- },
2023
- required: [
2024
- USE_TOOL_KEY
2025
- ]
2026
- },
2027
- then: {
2028
- properties: {
2029
- hasDefinitions: {
2030
- type: "array",
2031
- contains: {
2032
- const: toolName
2033
- }
2034
- }
2035
- },
2036
- required: [
2037
- "hasDefinitions"
2038
- ]
2039
- }
2040
- };
2041
- }),
2042
2012
  // When a specific tool is selected, its parameters must be provided
2043
2013
  ...toolNameToDetailList.map(([toolName, _toolDetail]) => {
2044
2014
  return {
@@ -2055,7 +2025,12 @@ Workflow step definitions - provide ONLY on initial call.
2055
2025
  then: {
2056
2026
  required: [
2057
2027
  toolName
2058
- ]
2028
+ ],
2029
+ errorMessage: {
2030
+ required: {
2031
+ [toolName]: `Tool "${toolName}" is selected but its parameters are missing. Please provide "${toolName}": { ...parameters }.`
2032
+ }
2033
+ }
2059
2034
  }
2060
2035
  };
2061
2036
  })
@@ -2071,7 +2046,10 @@ Workflow step definitions - provide ONLY on initial call.
2071
2046
  [USE_TOOL_KEY]: {
2072
2047
  type: "string",
2073
2048
  enum: allToolNames,
2074
- description: useToolDescription
2049
+ description: useToolDescription,
2050
+ errorMessage: {
2051
+ enum: `Invalid tool name. Available tools: ${allToolNames.join(", ")}.`
2052
+ }
2075
2053
  },
2076
2054
  hasDefinitions: {
2077
2055
  type: "array",
@@ -2094,6 +2072,41 @@ Workflow step definitions - provide ONLY on initial call.
2094
2072
  if (allOf.length > 0) {
2095
2073
  schema.allOf = allOf;
2096
2074
  }
2075
+ if (allToolNames.length > 0) {
2076
+ const thenClause = {
2077
+ required: [
2078
+ USE_TOOL_KEY
2079
+ ],
2080
+ errorMessage: {
2081
+ required: {
2082
+ [USE_TOOL_KEY]: `No tool selected. Please specify "${USE_TOOL_KEY}" to select one of: ${allToolNames.join(", ")}. Or use "definitionsOf" with tool names to get their schemas first.`
2083
+ }
2084
+ }
2085
+ };
2086
+ Object.assign(schema, {
2087
+ if: {
2088
+ // definitionsOf is not provided OR is empty array
2089
+ anyOf: [
2090
+ {
2091
+ not: {
2092
+ required: [
2093
+ "definitionsOf"
2094
+ ]
2095
+ }
2096
+ },
2097
+ {
2098
+ properties: {
2099
+ definitionsOf: {
2100
+ type: "array",
2101
+ maxItems: 0
2102
+ }
2103
+ }
2104
+ }
2105
+ ]
2106
+ },
2107
+ then: thenClause
2108
+ });
2109
+ }
2097
2110
  return schema;
2098
2111
  },
2099
2112
  forNextState: function(state) {
@@ -2151,7 +2164,7 @@ function registerAgenticTool(server2, { description, name, allToolNames, depGrou
2151
2164
  type: "object",
2152
2165
  properties: {}
2153
2166
  };
2154
- server2.tool(name, description, jsonSchema(createGoogleCompatibleJSONSchema(schema)), async (args) => {
2167
+ server2.tool(name, description, jsonSchema(createModelCompatibleJSONSchema(schema)), async (args) => {
2155
2168
  return await agenticExecutor.execute(args, schema);
2156
2169
  });
2157
2170
  }
@@ -2666,7 +2679,7 @@ function registerAgenticWorkflowTool(server2, { description, name, allToolNames,
2666
2679
  });
2667
2680
  const argsDef = createArgsDef.forTool();
2668
2681
  const toolDescription = createArgsDef.forToolDescription(baseDescription, workflowState);
2669
- server2.tool(name, toolDescription, jsonSchema(createGoogleCompatibleJSONSchema(argsDef)), async (args) => {
2682
+ server2.tool(name, toolDescription, jsonSchema(createModelCompatibleJSONSchema(argsDef)), async (args) => {
2670
2683
  try {
2671
2684
  return await workflowExecutor.execute(args, workflowState);
2672
2685
  } catch (error) {
@@ -3188,7 +3201,7 @@ function registerAgenticSamplingTool(server2, { description, name, allToolNames,
3188
3201
  type: "object",
3189
3202
  properties: {}
3190
3203
  };
3191
- server2.tool(name, description, jsonSchema(createGoogleCompatibleJSONSchema(schema)), async (args) => {
3204
+ server2.tool(name, description, jsonSchema(createModelCompatibleJSONSchema(schema)), async (args) => {
3192
3205
  return await samplingExecutor.executeSampling(args, schema);
3193
3206
  });
3194
3207
  }
@@ -3302,7 +3315,7 @@ function registerWorkflowSamplingTool(server2, { description, name, allToolNames
3302
3315
  type: "object",
3303
3316
  properties: {}
3304
3317
  };
3305
- server2.tool(name, baseDescription, jsonSchema(createGoogleCompatibleJSONSchema(schema)), async (args) => {
3318
+ server2.tool(name, baseDescription, jsonSchema(createModelCompatibleJSONSchema(schema)), async (args) => {
3306
3319
  try {
3307
3320
  return await workflowSamplingExecutor.executeWorkflowSampling(args, schema, workflowState);
3308
3321
  } catch (error) {
@@ -4464,20 +4477,7 @@ if (isSCF()) {
4464
4477
 
4465
4478
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/set-up-mcp-compose.js
4466
4479
  function parseMcpcConfigs(conf) {
4467
- const mcpcConfigs = conf ?? [];
4468
- const newMcpcConfigs = [];
4469
- for (const mcpcConfig of mcpcConfigs) {
4470
- if (mcpcConfig?.deps?.mcpServers) {
4471
- for (const [name, config2] of Object.entries(mcpcConfig.deps.mcpServers)) {
4472
- if (config2.smitheryConfig) {
4473
- const streamConfig = connectToSmitheryServer(config2.smitheryConfig);
4474
- mcpcConfig.deps.mcpServers[name] = streamConfig;
4475
- }
4476
- }
4477
- }
4478
- newMcpcConfigs.push(mcpcConfig);
4479
- }
4480
- return newMcpcConfigs;
4480
+ return conf ?? [];
4481
4481
  }
4482
4482
  async function mcpc(serverConf, composeConf, setupCallback) {
4483
4483
  const server2 = new ComposableMCPServer(...serverConf);
@@ -4826,7 +4826,7 @@ var createServer = async (config2) => {
4826
4826
  description: "",
4827
4827
  plugins: [
4828
4828
  createLargeResultPlugin({}),
4829
- codeExecutionPlugin()
4829
+ codeExecutionPlugin
4830
4830
  ],
4831
4831
  options: {
4832
4832
  mode: "code_execution"
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@mcpc-tech/cli",
3
- "version": "0.1.19",
3
+ "version": "0.1.20",
4
4
  "homepage": "https://jsr.io/@mcpc/cli",
5
5
  "type": "module",
6
6
  "dependencies": {
7
7
  "@hono/zod-openapi": "^0.19.2",
8
- "@mcpc-tech/plugin-code-execution": "^0.0.6",
8
+ "@mcpc-tech/plugin-code-execution": "^0.0.8",
9
9
  "@modelcontextprotocol/sdk": "^1.8.0",
10
10
  "zod": "^3.24.2",
11
11
  "@mcpc-tech/ripgrep-napi": "^0.0.4",
@@ -17,9 +17,9 @@
17
17
  "@opentelemetry/semantic-conventions": "^1.29.0",
18
18
  "@segment/ajv-human-errors": "^2.15.0",
19
19
  "ajv": "^8.17.1",
20
+ "ajv-errors": "^3.0.0",
20
21
  "ajv-formats": "^3.0.1",
21
22
  "cheerio": "^1.0.0",
22
- "json-schema-to-zod": "^2.6.1",
23
23
  "json-schema-traverse": "^1.0.0",
24
24
  "jsonrepair": "^3.13.0"
25
25
  },