@ai-sdk/mcp 1.0.48 → 1.0.49

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/mcp",
3
- "version": "1.0.48",
3
+ "version": "1.0.49",
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.28"
37
+ "@ai-sdk/provider-utils": "4.0.29"
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
- "@vercel/ai-tsconfig": "0.0.0",
46
- "@ai-sdk/test-server": "1.0.5"
45
+ "@ai-sdk/test-server": "1.0.5",
46
+ "@vercel/ai-tsconfig": "0.0.0"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "zod": "^3.25.76 || ^4.1.8"
@@ -610,7 +610,10 @@ class DefaultMCPClient implements MCPClient {
610
610
  _meta,
611
611
  } of definitions.tools) {
612
612
  const resolvedTitle = title ?? annotations?.title;
613
- if (schemas !== 'automatic' && !(name in schemas)) {
613
+ if (
614
+ schemas !== 'automatic' &&
615
+ !Object.prototype.hasOwnProperty.call(schemas, name)
616
+ ) {
614
617
  continue;
615
618
  }
616
619
 
@@ -161,14 +161,23 @@ export class SseMCPTransport implements MCPTransport {
161
161
  const { event, data } = value;
162
162
 
163
163
  if (event === 'endpoint') {
164
- this.endpoint = new URL(data, this.url);
164
+ if (this.endpoint) {
165
+ continue;
166
+ }
167
+
168
+ const endpoint = new URL(data, this.url);
165
169
 
166
- if (this.endpoint.origin !== this.url.origin) {
170
+ if (endpoint.origin !== this.url.origin) {
171
+ this.connected = false;
172
+ this.endpoint = undefined;
173
+ this.sseConnection?.close();
174
+ this.abortController?.abort();
167
175
  throw new MCPClientError({
168
- message: `MCP SSE Transport Error: Endpoint origin does not match connection origin: ${this.endpoint.origin}`,
176
+ message: `MCP SSE Transport Error: Endpoint origin does not match connection origin: ${endpoint.origin}`,
169
177
  });
170
178
  }
171
179
 
180
+ this.endpoint = endpoint;
172
181
  this.connected = true;
173
182
  resolve();
174
183
  } else if (event === 'message') {
@@ -217,6 +226,7 @@ export class SseMCPTransport implements MCPTransport {
217
226
 
218
227
  async close(): Promise<void> {
219
228
  this.connected = false;
229
+ this.endpoint = undefined;
220
230
  this.sseConnection?.close();
221
231
  this.abortController?.abort();
222
232
  this.onclose?.();