@ai-sdk/mcp 1.0.76 → 1.0.78
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/CHANGELOG.md +13 -0
- package/dist/index.d.mts +26 -1
- package/dist/index.d.ts +26 -1
- package/dist/index.js +19 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -7
- package/dist/index.mjs.map +1 -1
- package/dist/mcp-stdio/index.js +5 -1
- package/dist/mcp-stdio/index.js.map +1 -1
- package/dist/mcp-stdio/index.mjs +5 -1
- package/dist/mcp-stdio/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +2 -0
- package/src/tool/mcp-client.ts +27 -6
- package/src/tool/types.ts +27 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @ai-sdk/mcp
|
|
2
2
|
|
|
3
|
+
## 1.0.78
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 172d3c0: feat(mcp): surface server-provided tool annotations in tool metadata
|
|
8
|
+
|
|
9
|
+
## 1.0.77
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [cc23556]
|
|
14
|
+
- @ai-sdk/provider-utils@4.0.50
|
|
15
|
+
|
|
3
16
|
## 1.0.76
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -308,6 +308,27 @@ type MCPTransportConfig = {
|
|
|
308
308
|
fetch?: FetchFunction;
|
|
309
309
|
};
|
|
310
310
|
|
|
311
|
+
/**
|
|
312
|
+
* Metadata attached to tools created by the MCP client.
|
|
313
|
+
*/
|
|
314
|
+
type McpProviderMetadata = {
|
|
315
|
+
clientName?: string;
|
|
316
|
+
annotations?: McpToolAnnotations;
|
|
317
|
+
};
|
|
318
|
+
/**
|
|
319
|
+
* Behavioral hints reported by an MCP server for a tool.
|
|
320
|
+
*
|
|
321
|
+
* These annotations are untrusted unless the server itself is trusted.
|
|
322
|
+
*
|
|
323
|
+
* @see https://modelcontextprotocol.io/specification/2025-11-25/server/tools#annotations
|
|
324
|
+
*/
|
|
325
|
+
type McpToolAnnotations = {
|
|
326
|
+
title?: string;
|
|
327
|
+
readOnlyHint?: boolean;
|
|
328
|
+
destructiveHint?: boolean;
|
|
329
|
+
idempotentHint?: boolean;
|
|
330
|
+
openWorldHint?: boolean;
|
|
331
|
+
};
|
|
311
332
|
/** MCP tool metadata - keys should follow MCP _meta key format specification */
|
|
312
333
|
declare const ToolMetaSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
313
334
|
type ToolMeta = z.infer<typeof ToolMetaSchema>;
|
|
@@ -377,6 +398,10 @@ declare const ListToolsResultSchema: z.ZodObject<{
|
|
|
377
398
|
outputSchema: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
378
399
|
annotations: z.ZodOptional<z.ZodObject<{
|
|
379
400
|
title: z.ZodOptional<z.ZodString>;
|
|
401
|
+
readOnlyHint: z.ZodOptional<z.ZodBoolean>;
|
|
402
|
+
destructiveHint: z.ZodOptional<z.ZodBoolean>;
|
|
403
|
+
idempotentHint: z.ZodOptional<z.ZodBoolean>;
|
|
404
|
+
openWorldHint: z.ZodOptional<z.ZodBoolean>;
|
|
380
405
|
}, z.core.$loose>>;
|
|
381
406
|
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
382
407
|
}, z.core.$loose>>;
|
|
@@ -650,4 +675,4 @@ interface MCPClient {
|
|
|
650
675
|
close: () => Promise<void>;
|
|
651
676
|
}
|
|
652
677
|
|
|
653
|
-
export { type CallToolResult, type CompleteRequestParams, type CompleteResult, type Configuration, type ElicitResult, ElicitResultSchema, type ElicitationRequest, ElicitationRequestSchema, type JSONRPCError, type JSONRPCMessage, type JSONRPCNotification, type JSONRPCRequest, type JSONRPCResponse, type ListToolsResult, type MCPClient, type ClientCapabilities as MCPClientCapabilities, type MCPClientConfig, type MCPTransport, type MCPTransportCloseOptions, type MCPTransportSendOptions, type OAuthAuthorizationServerInformation, type OAuthClientInformation, type OAuthClientMetadata, type OAuthClientProvider, type OAuthTokens, UnauthorizedError, auth, createMCPClient, type MCPClient as experimental_MCPClient, type ClientCapabilities as experimental_MCPClientCapabilities, type MCPClientConfig as experimental_MCPClientConfig, createMCPClient as experimental_createMCPClient, validateJSONRPCMessage };
|
|
678
|
+
export { type CallToolResult, type CompleteRequestParams, type CompleteResult, type Configuration, type ElicitResult, ElicitResultSchema, type ElicitationRequest, ElicitationRequestSchema, type JSONRPCError, type JSONRPCMessage, type JSONRPCNotification, type JSONRPCRequest, type JSONRPCResponse, type ListToolsResult, type MCPClient, type ClientCapabilities as MCPClientCapabilities, type MCPClientConfig, type MCPTransport, type MCPTransportCloseOptions, type MCPTransportSendOptions, type McpProviderMetadata, type McpToolAnnotations, type OAuthAuthorizationServerInformation, type OAuthClientInformation, type OAuthClientMetadata, type OAuthClientProvider, type OAuthTokens, UnauthorizedError, auth, createMCPClient, type MCPClient as experimental_MCPClient, type ClientCapabilities as experimental_MCPClientCapabilities, type MCPClientConfig as experimental_MCPClientConfig, createMCPClient as experimental_createMCPClient, validateJSONRPCMessage };
|
package/dist/index.d.ts
CHANGED
|
@@ -308,6 +308,27 @@ type MCPTransportConfig = {
|
|
|
308
308
|
fetch?: FetchFunction;
|
|
309
309
|
};
|
|
310
310
|
|
|
311
|
+
/**
|
|
312
|
+
* Metadata attached to tools created by the MCP client.
|
|
313
|
+
*/
|
|
314
|
+
type McpProviderMetadata = {
|
|
315
|
+
clientName?: string;
|
|
316
|
+
annotations?: McpToolAnnotations;
|
|
317
|
+
};
|
|
318
|
+
/**
|
|
319
|
+
* Behavioral hints reported by an MCP server for a tool.
|
|
320
|
+
*
|
|
321
|
+
* These annotations are untrusted unless the server itself is trusted.
|
|
322
|
+
*
|
|
323
|
+
* @see https://modelcontextprotocol.io/specification/2025-11-25/server/tools#annotations
|
|
324
|
+
*/
|
|
325
|
+
type McpToolAnnotations = {
|
|
326
|
+
title?: string;
|
|
327
|
+
readOnlyHint?: boolean;
|
|
328
|
+
destructiveHint?: boolean;
|
|
329
|
+
idempotentHint?: boolean;
|
|
330
|
+
openWorldHint?: boolean;
|
|
331
|
+
};
|
|
311
332
|
/** MCP tool metadata - keys should follow MCP _meta key format specification */
|
|
312
333
|
declare const ToolMetaSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
313
334
|
type ToolMeta = z.infer<typeof ToolMetaSchema>;
|
|
@@ -377,6 +398,10 @@ declare const ListToolsResultSchema: z.ZodObject<{
|
|
|
377
398
|
outputSchema: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
378
399
|
annotations: z.ZodOptional<z.ZodObject<{
|
|
379
400
|
title: z.ZodOptional<z.ZodString>;
|
|
401
|
+
readOnlyHint: z.ZodOptional<z.ZodBoolean>;
|
|
402
|
+
destructiveHint: z.ZodOptional<z.ZodBoolean>;
|
|
403
|
+
idempotentHint: z.ZodOptional<z.ZodBoolean>;
|
|
404
|
+
openWorldHint: z.ZodOptional<z.ZodBoolean>;
|
|
380
405
|
}, z.core.$loose>>;
|
|
381
406
|
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
382
407
|
}, z.core.$loose>>;
|
|
@@ -650,4 +675,4 @@ interface MCPClient {
|
|
|
650
675
|
close: () => Promise<void>;
|
|
651
676
|
}
|
|
652
677
|
|
|
653
|
-
export { type CallToolResult, type CompleteRequestParams, type CompleteResult, type Configuration, type ElicitResult, ElicitResultSchema, type ElicitationRequest, ElicitationRequestSchema, type JSONRPCError, type JSONRPCMessage, type JSONRPCNotification, type JSONRPCRequest, type JSONRPCResponse, type ListToolsResult, type MCPClient, type ClientCapabilities as MCPClientCapabilities, type MCPClientConfig, type MCPTransport, type MCPTransportCloseOptions, type MCPTransportSendOptions, type OAuthAuthorizationServerInformation, type OAuthClientInformation, type OAuthClientMetadata, type OAuthClientProvider, type OAuthTokens, UnauthorizedError, auth, createMCPClient, type MCPClient as experimental_MCPClient, type ClientCapabilities as experimental_MCPClientCapabilities, type MCPClientConfig as experimental_MCPClientConfig, createMCPClient as experimental_createMCPClient, validateJSONRPCMessage };
|
|
678
|
+
export { type CallToolResult, type CompleteRequestParams, type CompleteResult, type Configuration, type ElicitResult, ElicitResultSchema, type ElicitationRequest, ElicitationRequestSchema, type JSONRPCError, type JSONRPCMessage, type JSONRPCNotification, type JSONRPCRequest, type JSONRPCResponse, type ListToolsResult, type MCPClient, type ClientCapabilities as MCPClientCapabilities, type MCPClientConfig, type MCPTransport, type MCPTransportCloseOptions, type MCPTransportSendOptions, type McpProviderMetadata, type McpToolAnnotations, type OAuthAuthorizationServerInformation, type OAuthClientInformation, type OAuthClientMetadata, type OAuthClientProvider, type OAuthTokens, UnauthorizedError, auth, createMCPClient, type MCPClient as experimental_MCPClient, type ClientCapabilities as experimental_MCPClientCapabilities, type MCPClientConfig as experimental_MCPClientConfig, createMCPClient as experimental_createMCPClient, validateJSONRPCMessage };
|
package/dist/index.js
CHANGED
|
@@ -121,7 +121,11 @@ var ToolSchema = import_v4.z.object({
|
|
|
121
121
|
outputSchema: import_v4.z.optional(import_v4.z.object({}).loose()),
|
|
122
122
|
annotations: import_v4.z.optional(
|
|
123
123
|
import_v4.z.object({
|
|
124
|
-
title: import_v4.z.optional(import_v4.z.string())
|
|
124
|
+
title: import_v4.z.optional(import_v4.z.string()),
|
|
125
|
+
readOnlyHint: import_v4.z.optional(import_v4.z.boolean()),
|
|
126
|
+
destructiveHint: import_v4.z.optional(import_v4.z.boolean()),
|
|
127
|
+
idempotentHint: import_v4.z.optional(import_v4.z.boolean()),
|
|
128
|
+
openWorldHint: import_v4.z.optional(import_v4.z.boolean())
|
|
125
129
|
}).loose()
|
|
126
130
|
),
|
|
127
131
|
_meta: ToolMetaSchema
|
|
@@ -2591,6 +2595,18 @@ var DefaultMCPClient = class {
|
|
|
2591
2595
|
}
|
|
2592
2596
|
const self = this;
|
|
2593
2597
|
const outputSchema = schemas !== "automatic" ? (_a3 = schemas[name3]) == null ? void 0 : _a3.outputSchema : void 0;
|
|
2598
|
+
const metadata = {
|
|
2599
|
+
clientName: this.clientInfo.name,
|
|
2600
|
+
...annotations != null ? {
|
|
2601
|
+
annotations: {
|
|
2602
|
+
...annotations.title != null ? { title: annotations.title } : {},
|
|
2603
|
+
...annotations.readOnlyHint != null ? { readOnlyHint: annotations.readOnlyHint } : {},
|
|
2604
|
+
...annotations.destructiveHint != null ? { destructiveHint: annotations.destructiveHint } : {},
|
|
2605
|
+
...annotations.idempotentHint != null ? { idempotentHint: annotations.idempotentHint } : {},
|
|
2606
|
+
...annotations.openWorldHint != null ? { openWorldHint: annotations.openWorldHint } : {}
|
|
2607
|
+
}
|
|
2608
|
+
} : {}
|
|
2609
|
+
};
|
|
2594
2610
|
const execute = async (args, options) => {
|
|
2595
2611
|
var _a4;
|
|
2596
2612
|
(_a4 = options == null ? void 0 : options.abortSignal) == null ? void 0 : _a4.throwIfAborted();
|
|
@@ -2606,9 +2622,7 @@ var DefaultMCPClient = class {
|
|
|
2606
2622
|
const toolWithExecute = schemas === "automatic" ? (0, import_provider_utils5.dynamicTool)({
|
|
2607
2623
|
description,
|
|
2608
2624
|
title: resolvedTitle,
|
|
2609
|
-
metadata
|
|
2610
|
-
clientName: this.clientInfo.name
|
|
2611
|
-
},
|
|
2625
|
+
metadata,
|
|
2612
2626
|
inputSchema: (0, import_provider_utils5.jsonSchema)({
|
|
2613
2627
|
...inputSchema,
|
|
2614
2628
|
properties: (_b3 = inputSchema.properties) != null ? _b3 : {},
|
|
@@ -2619,9 +2633,7 @@ var DefaultMCPClient = class {
|
|
|
2619
2633
|
}) : (0, import_provider_utils5.tool)({
|
|
2620
2634
|
description,
|
|
2621
2635
|
title: resolvedTitle,
|
|
2622
|
-
metadata
|
|
2623
|
-
clientName: this.clientInfo.name
|
|
2624
|
-
},
|
|
2636
|
+
metadata,
|
|
2625
2637
|
inputSchema: schemas[name3].inputSchema,
|
|
2626
2638
|
...outputSchema != null ? { outputSchema } : {},
|
|
2627
2639
|
execute,
|