@ai-sdk/mcp 1.0.47 → 1.0.48
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 +9 -0
- package/dist/index.d.mts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +18 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -3
- package/dist/index.mjs.map +1 -1
- package/dist/mcp-stdio/index.d.mts +4 -0
- package/dist/mcp-stdio/index.d.ts +4 -0
- package/package.json +4 -4
- package/src/tool/mcp-client.ts +5 -1
- package/src/tool/mcp-http-transport.ts +4 -0
- package/src/tool/mcp-sse-transport.ts +4 -0
- package/src/tool/mcp-transport.ts +5 -0
- package/src/tool/oauth.ts +14 -0
|
@@ -66,6 +66,10 @@ interface MCPTransport {
|
|
|
66
66
|
* The protocol version negotiated during initialization.
|
|
67
67
|
*/
|
|
68
68
|
protocolVersion?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Set the protocol version negotiated during initialization.
|
|
71
|
+
*/
|
|
72
|
+
setProtocolVersion?(version: string): void;
|
|
69
73
|
}
|
|
70
74
|
|
|
71
75
|
interface StdioConfig {
|
|
@@ -66,6 +66,10 @@ interface MCPTransport {
|
|
|
66
66
|
* The protocol version negotiated during initialization.
|
|
67
67
|
*/
|
|
68
68
|
protocolVersion?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Set the protocol version negotiated during initialization.
|
|
71
|
+
*/
|
|
72
|
+
setProtocolVersion?(version: string): void;
|
|
69
73
|
}
|
|
70
74
|
|
|
71
75
|
interface StdioConfig {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/mcp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.48",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"pkce-challenge": "^5.0.0",
|
|
36
36
|
"@ai-sdk/provider": "3.0.10",
|
|
37
|
-
"@ai-sdk/provider-utils": "4.0.
|
|
37
|
+
"@ai-sdk/provider-utils": "4.0.28"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/node": "20.17.24",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"typescript": "5.8.3",
|
|
43
43
|
"vitest": "^4.1.0",
|
|
44
44
|
"zod": "3.25.76",
|
|
45
|
-
"@ai-
|
|
46
|
-
"@
|
|
45
|
+
"@vercel/ai-tsconfig": "0.0.0",
|
|
46
|
+
"@ai-sdk/test-server": "1.0.5"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"zod": "^3.25.76 || ^4.1.8"
|
package/src/tool/mcp-client.ts
CHANGED
|
@@ -312,8 +312,12 @@ class DefaultMCPClient implements MCPClient {
|
|
|
312
312
|
|
|
313
313
|
this.serverCapabilities = result.capabilities;
|
|
314
314
|
this._serverInfo = result.serverInfo;
|
|
315
|
+
if (this.transport.setProtocolVersion) {
|
|
316
|
+
this.transport.setProtocolVersion(result.protocolVersion);
|
|
317
|
+
} else {
|
|
318
|
+
this.transport.protocolVersion = result.protocolVersion;
|
|
319
|
+
}
|
|
315
320
|
this._serverInstructions = result.instructions;
|
|
316
|
-
this.transport.protocolVersion = result.protocolVersion;
|
|
317
321
|
|
|
318
322
|
// Complete initialization handshake:
|
|
319
323
|
await this.notification({
|
|
@@ -75,6 +75,10 @@ export class HttpMCPTransport implements MCPTransport {
|
|
|
75
75
|
this.fetchFn = fetchFn ?? globalThis.fetch;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
setProtocolVersion(version: string): void {
|
|
79
|
+
this.protocolVersion = version;
|
|
80
|
+
}
|
|
81
|
+
|
|
78
82
|
private async commonHeaders(
|
|
79
83
|
base: Record<string, string>,
|
|
80
84
|
): Promise<Record<string, string>> {
|
|
@@ -55,6 +55,10 @@ export class SseMCPTransport implements MCPTransport {
|
|
|
55
55
|
this.fetchFn = fetchFn ?? globalThis.fetch;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
setProtocolVersion(version: string): void {
|
|
59
|
+
this.protocolVersion = version;
|
|
60
|
+
}
|
|
61
|
+
|
|
58
62
|
private async commonHeaders(
|
|
59
63
|
base: Record<string, string>,
|
|
60
64
|
): Promise<Record<string, string>> {
|
|
@@ -45,6 +45,11 @@ export interface MCPTransport {
|
|
|
45
45
|
* The protocol version negotiated during initialization.
|
|
46
46
|
*/
|
|
47
47
|
protocolVersion?: string;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Set the protocol version negotiated during initialization.
|
|
51
|
+
*/
|
|
52
|
+
setProtocolVersion?(version: string): void;
|
|
48
53
|
}
|
|
49
54
|
|
|
50
55
|
export type MCPTransportConfig = {
|
package/src/tool/oauth.ts
CHANGED
|
@@ -95,6 +95,14 @@ export interface OAuthClientProvider {
|
|
|
95
95
|
saveAuthorizationServerInformation?(
|
|
96
96
|
authorizationServerInformation: OAuthAuthorizationServerInformation,
|
|
97
97
|
): void | Promise<void>;
|
|
98
|
+
/**
|
|
99
|
+
* Validates an authorization server URL discovered from MCP protected resource
|
|
100
|
+
* metadata before the client fetches its OAuth metadata.
|
|
101
|
+
*/
|
|
102
|
+
validateAuthorizationServerURL?(
|
|
103
|
+
serverUrl: string | URL,
|
|
104
|
+
authorizationServerUrl: string | URL,
|
|
105
|
+
): void | Promise<void>;
|
|
98
106
|
state?(): string | Promise<string>;
|
|
99
107
|
saveState?(state: string): void | Promise<void>;
|
|
100
108
|
storedState?(): string | undefined | Promise<string | undefined>;
|
|
@@ -1115,6 +1123,12 @@ async function authInternal(
|
|
|
1115
1123
|
resourceMetadata,
|
|
1116
1124
|
);
|
|
1117
1125
|
|
|
1126
|
+
/** Let applications constrain discovered AS URLs before metadata fetches. */
|
|
1127
|
+
await provider.validateAuthorizationServerURL?.(
|
|
1128
|
+
serverUrl,
|
|
1129
|
+
authorizationServerUrl,
|
|
1130
|
+
);
|
|
1131
|
+
|
|
1118
1132
|
/** Discover AS metadata and derive the credential pin for this flow */
|
|
1119
1133
|
const metadata = await discoverAuthorizationServerMetadata(
|
|
1120
1134
|
authorizationServerUrl,
|