diff --git a/packages/api/src/mcp/__tests__/MCPOAuthClientRegistrationReuse.test.ts b/packages/api/src/mcp/__tests__/MCPOAuthClientRegistrationReuse.test.ts index 507be31f3a..da69a5060f 100644 --- a/packages/api/src/mcp/__tests__/MCPOAuthClientRegistrationReuse.test.ts +++ b/packages/api/src/mcp/__tests__/MCPOAuthClientRegistrationReuse.test.ts @@ -23,6 +23,7 @@ * fix and would require a distributed lock (e.g., Redis SETNX) around registration. */ +import type { OAuthClientInformation } from '@modelcontextprotocol/sdk/shared/auth.js'; import type { OAuthTestServer } from './helpers/oauthTestServer'; import { InMemoryTokenStore, createOAuthMCPServer } from './helpers/oauthTestServer'; import { MCPOAuthHandler, MCPTokenStorage } from '~/mcp/oauth'; @@ -210,7 +211,7 @@ describe('MCPOAuthHandler - client registration reuse on reconnection', () => { client_id: 'old-client-id', client_secret: 'old-secret', redirect_uris: ['http://old-domain.com/api/mcp/test-server/oauth/callback'], - }, + } as OAuthClientInformation & { redirect_uris: string[] }, }); const result = await MCPOAuthHandler.initiateOAuthFlow( @@ -242,7 +243,7 @@ describe('MCPOAuthHandler - client registration reuse on reconnection', () => { client_id: 'empty-redirect-client', client_secret: 'secret', redirect_uris: [], - }, + } as OAuthClientInformation & { redirect_uris: string[] }, }); const result = await MCPOAuthHandler.initiateOAuthFlow( diff --git a/packages/api/src/mcp/oauth/handler.ts b/packages/api/src/mcp/oauth/handler.ts index bc351d9660..db6cf50697 100644 --- a/packages/api/src/mcp/oauth/handler.ts +++ b/packages/api/src/mcp/oauth/handler.ts @@ -509,7 +509,8 @@ export class MCPOAuthHandler { findToken, }); if (existing?.clientInfo?.client_id) { - const storedRedirectUri = existing.clientInfo.redirect_uris?.[0]; + const storedRedirectUri = (existing.clientInfo as OAuthClientInformation) + .redirect_uris?.[0]; if (!storedRedirectUri || storedRedirectUri !== redirectUri) { logger.debug( `[MCPOAuth] Stored redirect_uri "${storedRedirectUri}" differs from current "${redirectUri}", will re-register`,