This commit is contained in:
Sunil Pai 2025-03-24 10:48:46 +00:00
parent 65e55c3823
commit d332273355
8 changed files with 21 additions and 29 deletions

View file

@ -534,7 +534,7 @@ export function useMcp(options: UseMcpOptions): UseMcpResult {
metadataRef.current = await discoverOAuthMetadata(url)
addLog('debug', `OAuth metadata: ${metadataRef.current ? 'Found' : 'Not available'}`)
}
// If metadata is found, start auth flow
if (metadataRef.current) {
setState('authenticating')
@ -599,7 +599,7 @@ export function useMcp(options: UseMcpOptions): UseMcpResult {
}
} catch (connectErr) {
addLog('error', `Client connect error: ${connectErr instanceof Error ? connectErr.message : String(connectErr)}`)
if (connectErr instanceof Error && connectErr.message.includes('Unauthorized')) {
// Only discover OAuth and authenticate if we get a 401
await discoverOAuthAndAuthenticate(connectErr)