@ai-sdk/mcp 2.0.66 → 2.0.67

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": "2.0.66",
3
+ "version": "2.0.67",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -31,8 +31,8 @@
31
31
  }
32
32
  },
33
33
  "dependencies": {
34
- "@ai-sdk/provider": "4.0.21",
35
- "@ai-sdk/provider-utils": "5.0.53",
34
+ "@ai-sdk/provider": "4.0.22",
35
+ "@ai-sdk/provider-utils": "5.0.54",
36
36
  "cross-spawn": "^7.0.6",
37
37
  "pkce-challenge": "^5.0.1"
38
38
  },
package/src/index.ts CHANGED
@@ -45,6 +45,7 @@ export {
45
45
  MCPClientOAuthError,
46
46
  AuthorizationServerMismatchError,
47
47
  } from './error/oauth-error';
48
+ export { MCPClientError } from './error/mcp-client-error';
48
49
  export type {
49
50
  OAuthAuthorizationServerInformation,
50
51
  OAuthClientProvider,
@@ -190,6 +190,10 @@ export class SseMCPTransport implements MCPTransport {
190
190
  const { done, value } = await reader.read();
191
191
 
192
192
  if (done) {
193
+ if (this.abortController?.signal.aborted) {
194
+ return;
195
+ }
196
+
193
197
  if (this.connected) {
194
198
  this.connected = false;
195
199
  throw new MCPClientError({
@@ -197,7 +201,11 @@ export class SseMCPTransport implements MCPTransport {
197
201
  'MCP SSE Transport Error: Connection closed unexpectedly',
198
202
  });
199
203
  }
200
- return;
204
+
205
+ throw new MCPClientError({
206
+ message:
207
+ 'MCP SSE Transport Error: Connection closed before endpoint event was received',
208
+ });
201
209
  }
202
210
 
203
211
  const { event, data } = value;
package/src/tool/oauth.ts CHANGED
@@ -1285,14 +1285,11 @@ export async function auth(
1285
1285
 
1286
1286
  await provider.invalidateCredentials?.('all');
1287
1287
  return await authInternal(provider, options);
1288
- } else if (error instanceof InvalidGrantError) {
1289
- if (refreshAttempt.tokens) {
1290
- await provider.invalidateCredentials?.('tokens', {
1291
- tokens: refreshAttempt.tokens,
1292
- });
1293
- } else {
1294
- await provider.invalidateCredentials?.('tokens');
1295
- }
1288
+ } else if (error instanceof InvalidGrantError && refreshAttempt.tokens) {
1289
+ // Only invalidate the tokens used by a failed refresh.
1290
+ await provider.invalidateCredentials?.('tokens', {
1291
+ tokens: refreshAttempt.tokens,
1292
+ });
1296
1293
  return await authInternal(provider, options);
1297
1294
  }
1298
1295