@mcp-use/client 2.2.5 → 2.3.0

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/dist/index.d.ts CHANGED
@@ -13,6 +13,7 @@ export { FileKVStore } from "./auth/storage-file.js";
13
13
  export * from "./core/config.js";
14
14
  export * from "./core/node.js";
15
15
  export * from "./core/session.js";
16
+ export * from "./adapters/ai-sdk.js";
16
17
  export * from "./transport/base.js";
17
18
  export * from "./transport/http.js";
18
19
  export * from "./transport/stdio.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,+BAA+B,CAAC;AAEvC,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EACL,iBAAiB,EACjB,0BAA0B,EAC1B,cAAc,GACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,EACd,KAAK,8BAA8B,EACnC,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,GAC1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAGlC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AAGrC,cAAc,kCAAkC,CAAC;AAGjD,cAAc,0BAA0B,CAAC;AAGzC,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,GAAG,EACH,SAAS,EACT,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,+BAA+B,CAAC;AAEvC,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EACL,iBAAiB,EACjB,0BAA0B,EAC1B,cAAc,GACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,EACd,KAAK,8BAA8B,EACnC,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,GAC1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AAGrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AAGrC,cAAc,kCAAkC,CAAC;AAGjD,cAAc,0BAA0B,CAAC;AAGzC,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,GAAG,EACH,SAAS,EACT,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC"}
package/dist/index.js CHANGED
@@ -1527,7 +1527,7 @@ init_connector_telemetry();
1527
1527
  init_logging();
1528
1528
 
1529
1529
  // src/utils/version.ts
1530
- var VERSION = "2.2.5";
1530
+ var VERSION = "2.3.0";
1531
1531
  function getPackageVersion() {
1532
1532
  return VERSION;
1533
1533
  }
@@ -6057,6 +6057,72 @@ var MCPClient = class _MCPClient extends BaseMCPClient {
6057
6057
  }
6058
6058
  };
6059
6059
 
6060
+ // src/adapters/ai-sdk.ts
6061
+ var AI_SDK_SCHEMA_SYMBOL = /* @__PURE__ */ Symbol.for("vercel.ai.schema");
6062
+ var AI_SDK_VALIDATOR_SYMBOL = /* @__PURE__ */ Symbol.for("vercel.ai.validator");
6063
+ async function createAiSdkTools(connection, options = {}) {
6064
+ const tools = options.tools ?? await connection.listTools();
6065
+ const result = /* @__PURE__ */ Object.create(null);
6066
+ for (const mcpTool of tools) {
6067
+ const name = mcpTool.name;
6068
+ if (Object.prototype.hasOwnProperty.call(result, name)) {
6069
+ throw new Error(`Duplicate MCP tool name: ${name}`);
6070
+ }
6071
+ const rawInputSchema = mcpTool.inputSchema;
6072
+ const transformedInputSchema = options.transformInputSchema?.(rawInputSchema) ?? rawInputSchema;
6073
+ const inputSchema = toAiSdkInputSchema(
6074
+ asInputSchema(transformedInputSchema)
6075
+ );
6076
+ const title = mcpTool.title ?? mcpTool.annotations?.title;
6077
+ const metadata = {
6078
+ toolName: name,
6079
+ ...options.clientName !== void 0 ? { clientName: options.clientName } : {},
6080
+ ...title !== void 0 ? { title } : {},
6081
+ ...mcpTool.annotations !== void 0 ? { annotations: mcpTool.annotations } : {},
6082
+ ...mcpTool._meta !== void 0 ? { _meta: mcpTool._meta } : {}
6083
+ };
6084
+ const execute = async (args, executionOptions = {}) => {
6085
+ executionOptions?.abortSignal?.throwIfAborted();
6086
+ return connection.callTool(name, args, {
6087
+ signal: executionOptions?.abortSignal
6088
+ });
6089
+ };
6090
+ const dynamicDefinition = {
6091
+ type: "dynamic",
6092
+ ...mcpTool.description !== void 0 ? { description: mcpTool.description } : {},
6093
+ ...title !== void 0 ? { title } : {},
6094
+ inputSchema,
6095
+ execute,
6096
+ metadata,
6097
+ ...mcpTool.annotations !== void 0 ? { annotations: mcpTool.annotations } : {},
6098
+ ...mcpTool._meta !== void 0 ? { _meta: mcpTool._meta } : {}
6099
+ };
6100
+ Object.defineProperty(result, name, {
6101
+ configurable: true,
6102
+ enumerable: true,
6103
+ value: dynamicDefinition,
6104
+ writable: true
6105
+ });
6106
+ }
6107
+ return result;
6108
+ }
6109
+ function asInputSchema(schema) {
6110
+ if (schema && typeof schema === "object" && !Array.isArray(schema)) {
6111
+ return schema;
6112
+ }
6113
+ return {};
6114
+ }
6115
+ function toAiSdkInputSchema(jsonSchema) {
6116
+ const schema = {
6117
+ [AI_SDK_SCHEMA_SYMBOL]: true,
6118
+ [AI_SDK_VALIDATOR_SYMBOL]: true,
6119
+ _type: void 0,
6120
+ jsonSchema,
6121
+ validate: (value) => ({ success: true, value })
6122
+ };
6123
+ return schema;
6124
+ }
6125
+
6060
6126
  // src/index.ts
6061
6127
  init_base();
6062
6128
  init_stdio();
@@ -6092,6 +6158,7 @@ export {
6092
6158
  cancel,
6093
6159
  capturePostHog,
6094
6160
  completeOAuthFlow,
6161
+ createAiSdkTools,
6095
6162
  createConnectorFromConfig,
6096
6163
  createOAuthProvider,
6097
6164
  decline,