@mcp-ts/sdk 2.3.2 → 2.3.3
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.js +15 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -0
- package/dist/index.mjs.map +1 -1
- package/dist/server/index.js +15 -0
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +15 -0
- package/dist/server/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/server/mcp/oauth-client.ts +22 -0
package/package.json
CHANGED
|
@@ -60,6 +60,20 @@ interface McpAppClientCapabilities extends Omit<ClientCapabilities, 'extensions'
|
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
function isInvalidRefreshTokenError(error: unknown): boolean {
|
|
64
|
+
if (!(error instanceof Error)) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const text = `${error.name} ${error.message}`.toLowerCase();
|
|
69
|
+
return (
|
|
70
|
+
text.includes('invalidgrant') ||
|
|
71
|
+
text.includes('invalid_grant') ||
|
|
72
|
+
text.includes('invalid refresh token') ||
|
|
73
|
+
/refresh\s+token\s+(?:is\s+)?(?:invalid|expired|revoked)/i.test(text)
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
63
77
|
export interface MCPOAuthClientOptions {
|
|
64
78
|
serverUrl?: string;
|
|
65
79
|
serverName?: string;
|
|
@@ -970,6 +984,14 @@ export class MCPClient {
|
|
|
970
984
|
return true;
|
|
971
985
|
} catch (error) {
|
|
972
986
|
console.error('[OAuth] Token refresh failed:', error);
|
|
987
|
+
if (isInvalidRefreshTokenError(error)) {
|
|
988
|
+
try {
|
|
989
|
+
await this.oauthProvider.invalidateCredentials?.('tokens');
|
|
990
|
+
this.emitProgress('OAuth refresh token is invalid; requesting reauthorization...');
|
|
991
|
+
} catch (invalidateError) {
|
|
992
|
+
console.warn('[OAuth] Failed to invalidate stale refresh token credentials:', invalidateError);
|
|
993
|
+
}
|
|
994
|
+
}
|
|
973
995
|
return false;
|
|
974
996
|
}
|
|
975
997
|
}
|