@copilotkit/runtime 1.8.7 → 1.8.8-next.1

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 (38) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/{chunk-TOZ7TDZQ.mjs → chunk-3UU33HF6.mjs} +2 -2
  3. package/dist/{chunk-D453SZIW.mjs → chunk-HBCCZQBE.mjs} +29 -19
  4. package/dist/chunk-HBCCZQBE.mjs.map +1 -0
  5. package/dist/{chunk-ZD6BIBVB.mjs → chunk-O4WMMGSX.mjs} +2 -2
  6. package/dist/{chunk-S2W2IABM.mjs → chunk-QF6GPOZV.mjs} +2 -2
  7. package/dist/index.d.ts +1 -1
  8. package/dist/index.js +28 -18
  9. package/dist/index.js.map +1 -1
  10. package/dist/index.mjs +4 -4
  11. package/dist/lib/index.d.ts +1 -1
  12. package/dist/lib/index.js +28 -18
  13. package/dist/lib/index.js.map +1 -1
  14. package/dist/lib/index.mjs +4 -4
  15. package/dist/lib/integrations/index.d.ts +2 -2
  16. package/dist/lib/integrations/index.js +1 -1
  17. package/dist/lib/integrations/index.js.map +1 -1
  18. package/dist/lib/integrations/index.mjs +4 -4
  19. package/dist/lib/integrations/nest/index.d.ts +1 -1
  20. package/dist/lib/integrations/nest/index.js +1 -1
  21. package/dist/lib/integrations/nest/index.js.map +1 -1
  22. package/dist/lib/integrations/nest/index.mjs +2 -2
  23. package/dist/lib/integrations/node-express/index.d.ts +1 -1
  24. package/dist/lib/integrations/node-express/index.js +1 -1
  25. package/dist/lib/integrations/node-express/index.js.map +1 -1
  26. package/dist/lib/integrations/node-express/index.mjs +2 -2
  27. package/dist/lib/integrations/node-http/index.d.ts +1 -1
  28. package/dist/lib/integrations/node-http/index.js +1 -1
  29. package/dist/lib/integrations/node-http/index.js.map +1 -1
  30. package/dist/lib/integrations/node-http/index.mjs +1 -1
  31. package/dist/{shared-350db43f.d.ts → shared-32a46e93.d.ts} +7 -6
  32. package/package.json +2 -2
  33. package/src/lib/runtime/copilot-runtime.ts +34 -24
  34. package/src/lib/runtime/mcp-tools-utils.ts +16 -5
  35. package/dist/chunk-D453SZIW.mjs.map +0 -1
  36. /package/dist/{chunk-TOZ7TDZQ.mjs.map → chunk-3UU33HF6.mjs.map} +0 -0
  37. /package/dist/{chunk-ZD6BIBVB.mjs.map → chunk-O4WMMGSX.mjs.map} +0 -0
  38. /package/dist/{chunk-S2W2IABM.mjs.map → chunk-QF6GPOZV.mjs.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @copilotkit/runtime
2
2
 
3
+ ## 1.8.8-next.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 8c26335: - fix: update MCP tool parameter extraction to handle full tool objects
8
+ - @copilotkit/shared@1.8.8-next.1
9
+
10
+ ## 1.8.8-next.0
11
+
12
+ ### Patch Changes
13
+
14
+ - dfb67c3: - refactor: rename mcpEndpoints to mcpServers for naming consistency
15
+ - doc changes
16
+ - @copilotkit/shared@1.8.8-next.0
17
+
3
18
  ## 1.8.7
4
19
 
5
20
  ### Patch Changes
@@ -2,7 +2,7 @@ import {
2
2
  copilotRuntimeNodeHttpEndpoint,
3
3
  getRuntimeInstanceTelemetryInfo,
4
4
  telemetry_client_default
5
- } from "./chunk-D453SZIW.mjs";
5
+ } from "./chunk-HBCCZQBE.mjs";
6
6
  import {
7
7
  __name
8
8
  } from "./chunk-FHD4JECV.mjs";
@@ -22,4 +22,4 @@ __name(copilotRuntimeNodeExpressEndpoint, "copilotRuntimeNodeExpressEndpoint");
22
22
  export {
23
23
  copilotRuntimeNodeExpressEndpoint
24
24
  };
25
- //# sourceMappingURL=chunk-TOZ7TDZQ.mjs.map
25
+ //# sourceMappingURL=chunk-3UU33HF6.mjs.map
@@ -40,7 +40,7 @@ var require_package = __commonJS({
40
40
  publishConfig: {
41
41
  access: "public"
42
42
  },
43
- version: "1.8.7",
43
+ version: "1.8.8-next.1",
44
44
  sideEffects: false,
45
45
  main: "./dist/index.js",
46
46
  module: "./dist/index.mjs",
@@ -2958,11 +2958,13 @@ import { from } from "rxjs";
2958
2958
  import { Client as LangGraphClient2 } from "@langchain/langgraph-sdk";
2959
2959
 
2960
2960
  // src/lib/runtime/mcp-tools-utils.ts
2961
- function extractParametersFromSchema(toolSchema) {
2962
- var _a, _b;
2961
+ function extractParametersFromSchema(toolOrSchema) {
2962
+ var _a;
2963
2963
  const parameters = [];
2964
- const properties = (_a = toolSchema == null ? void 0 : toolSchema.parameters) == null ? void 0 : _a.properties;
2965
- const requiredParams = new Set(((_b = toolSchema == null ? void 0 : toolSchema.parameters) == null ? void 0 : _b.required) || []);
2964
+ const schema = "schema" in (toolOrSchema || {}) ? toolOrSchema.schema : toolOrSchema;
2965
+ const toolParameters = (schema == null ? void 0 : schema.parameters) || ((_a = schema == null ? void 0 : schema.parameters) == null ? void 0 : _a.jsonSchema);
2966
+ const properties = toolParameters == null ? void 0 : toolParameters.properties;
2967
+ const requiredParams = new Set((toolParameters == null ? void 0 : toolParameters.required) || []);
2966
2968
  if (!properties) {
2967
2969
  return parameters;
2968
2970
  }
@@ -2985,7 +2987,7 @@ __name(extractParametersFromSchema, "extractParametersFromSchema");
2985
2987
  function convertMCPToolsToActions(mcpTools, mcpEndpoint) {
2986
2988
  const actions = [];
2987
2989
  for (const [toolName, tool] of Object.entries(mcpTools)) {
2988
- const parameters = extractParametersFromSchema(tool.schema);
2990
+ const parameters = extractParametersFromSchema(tool);
2989
2991
  const handler = /* @__PURE__ */ __name(async (params) => {
2990
2992
  try {
2991
2993
  const result = await tool.execute({
@@ -3023,7 +3025,7 @@ var CopilotRuntime = class {
3023
3025
  observability;
3024
3026
  availableAgents;
3025
3027
  // +++ MCP Properties +++
3026
- mcpEndpointsConfig;
3028
+ mcpServersConfig;
3027
3029
  mcpActionCache = /* @__PURE__ */ new Map();
3028
3030
  // --- MCP Properties ---
3029
3031
  // +++ MCP Client Factory +++
@@ -3046,14 +3048,14 @@ var CopilotRuntime = class {
3046
3048
  this.delegateAgentProcessingToServiceAdapter = (params == null ? void 0 : params.delegateAgentProcessingToServiceAdapter) || false;
3047
3049
  this.observability = params == null ? void 0 : params.observability_c;
3048
3050
  this.agents = (params == null ? void 0 : params.agents) ?? {};
3049
- this.mcpEndpointsConfig = params == null ? void 0 : params.mcpEndpoints;
3051
+ this.mcpServersConfig = params == null ? void 0 : params.mcpServers;
3050
3052
  this.createMCPClientImpl = params == null ? void 0 : params.createMCPClient;
3051
- if (this.mcpEndpointsConfig && this.mcpEndpointsConfig.length > 0 && !this.createMCPClientImpl) {
3053
+ if (this.mcpServersConfig && this.mcpServersConfig.length > 0 && !this.createMCPClientImpl) {
3052
3054
  throw new CopilotKitMisuseError2({
3053
- message: "MCP Integration Error: `mcpEndpoints` were provided, but the `createMCPClient` function was not passed to the CopilotRuntime constructor. Please provide an implementation for `createMCPClient`."
3055
+ message: "MCP Integration Error: `mcpServers` were provided, but the `createMCPClient` function was not passed to the CopilotRuntime constructor. Please provide an implementation for `createMCPClient`."
3054
3056
  });
3055
3057
  }
3056
- if ((params == null ? void 0 : params.actions) && (((_c = params == null ? void 0 : params.remoteEndpoints) == null ? void 0 : _c.some((e) => e.type === EndpointType.LangGraphPlatform)) || ((_d = this.mcpEndpointsConfig) == null ? void 0 : _d.length))) {
3058
+ if ((params == null ? void 0 : params.actions) && (((_c = params == null ? void 0 : params.remoteEndpoints) == null ? void 0 : _c.some((e) => e.type === EndpointType.LangGraphPlatform)) || ((_d = this.mcpServersConfig) == null ? void 0 : _d.length))) {
3057
3059
  console.warn("Local 'actions' defined in CopilotRuntime might not be available to remote agents (LangGraph, MCP). Consider defining actions closer to the agent implementation if needed.");
3058
3060
  }
3059
3061
  }
@@ -3063,7 +3065,11 @@ var CopilotRuntime = class {
3063
3065
  if (!mcpActionsForRequest || mcpActionsForRequest.length === 0) {
3064
3066
  return messages;
3065
3067
  }
3066
- const mcpToolInstructions = mcpActionsForRequest.map((action) => {
3068
+ const uniqueMcpTools = /* @__PURE__ */ new Map();
3069
+ mcpActionsForRequest.forEach((action) => {
3070
+ uniqueMcpTools.set(action.name, action);
3071
+ });
3072
+ const mcpToolInstructions = Array.from(uniqueMcpTools.values()).map((action) => {
3067
3073
  const paramsString = action.parameters && action.parameters.length > 0 ? ` Parameters: ${action.parameters.map((p) => `${p.name}${p.required ? "*" : ""}(${p.type})`).join(", ")}` : "";
3068
3074
  return `- ${action.name}:${paramsString} ${action.description || ""}`;
3069
3075
  }).join("\n");
@@ -3646,7 +3652,7 @@ please use an LLM adapter instead.`
3646
3652
  }
3647
3653
  }
3648
3654
  async getServerSideActions(request) {
3649
- var _a;
3655
+ var _a, _b;
3650
3656
  const { graphqlContext, messages: rawMessages, agentStates, url } = request;
3651
3657
  const inputMessages = convertGqlInputToMessages(rawMessages);
3652
3658
  const langserveFunctions = [];
@@ -3676,11 +3682,17 @@ please use an LLM adapter instead.`
3676
3682
  }) : this.actions;
3677
3683
  const requestSpecificMCPActions = [];
3678
3684
  if (this.createMCPClientImpl) {
3679
- const baseEndpoints = this.mcpEndpointsConfig || [];
3680
- const requestEndpoints = ((_a = graphqlContext.properties) == null ? void 0 : _a.mcpEndpoints) || [];
3685
+ const baseEndpoints = this.mcpServersConfig || [];
3686
+ const requestEndpoints = ((_a = graphqlContext.properties) == null ? void 0 : _a.mcpServers) || ((_b = graphqlContext.properties) == null ? void 0 : _b.mcpEndpoints) || [];
3681
3687
  const effectiveEndpointsMap = /* @__PURE__ */ new Map();
3682
3688
  [
3683
- ...baseEndpoints,
3689
+ ...baseEndpoints
3690
+ ].forEach((ep) => {
3691
+ if (ep && ep.endpoint) {
3692
+ effectiveEndpointsMap.set(ep.endpoint, ep);
3693
+ }
3694
+ });
3695
+ [
3684
3696
  ...requestEndpoints
3685
3697
  ].forEach((ep) => {
3686
3698
  if (ep && ep.endpoint) {
@@ -3694,12 +3706,10 @@ please use an LLM adapter instead.`
3694
3706
  if (!actionsForEndpoint) {
3695
3707
  let client = null;
3696
3708
  try {
3697
- console.log(`MCP: Cache miss. Fetching tools for endpoint: ${endpointUrl}`);
3698
3709
  client = await this.createMCPClientImpl(config);
3699
3710
  const tools = await client.tools();
3700
3711
  actionsForEndpoint = convertMCPToolsToActions(tools, endpointUrl);
3701
3712
  this.mcpActionCache.set(endpointUrl, actionsForEndpoint);
3702
- console.log(`MCP: Fetched and cached ${actionsForEndpoint.length} tools for ${endpointUrl}`);
3703
3713
  } catch (error) {
3704
3714
  console.error(`MCP: Failed to fetch tools from endpoint ${endpointUrl}. Skipping. Error:`, error);
3705
3715
  actionsForEndpoint = [];
@@ -4987,4 +4997,4 @@ export {
4987
4997
  getCommonConfig,
4988
4998
  copilotRuntimeNodeHttpEndpoint
4989
4999
  };
4990
- //# sourceMappingURL=chunk-D453SZIW.mjs.map
5000
+ //# sourceMappingURL=chunk-HBCCZQBE.mjs.map