@@ -351,9 +351,11 @@ export const createMcpConnector = (input: ConnectorInput): McpConnector => {
351351 // error), which used to misclassify an expired token as a generic
352352 // connection failure. Propagate it as-is instead.
353353 return connectStreamableHttp . pipe (
354- Effect . catch ( ( error ) => {
355- if ( Predicate . isTagged ( error , "McpOAuthReauthorizationRequired" ) ) return Effect . fail ( error ) ;
356- if ( error . httpStatus === 401 || error . httpStatus === 403 ) return Effect . fail ( error ) ;
354+ Effect . catch ( ( failure ) => {
355+ if ( Predicate . isTagged ( failure , "McpOAuthReauthorizationRequired" ) ) {
356+ return Effect . fail ( failure ) ;
357+ }
358+ if ( failure . httpStatus === 401 || failure . httpStatus === 403 ) return Effect . fail ( failure ) ;
357359 // When the fallback ALSO fails, the streamable-http failure is the
358360 // interesting one: most modern servers don't serve legacy SSE at all
359361 // (GET → 405), so reporting only "Failed connecting via sse" points
@@ -362,16 +364,16 @@ export const createMcpConnector = (input: ConnectorInput): McpConnector => {
362364 return connectSse . pipe (
363365 Effect . catch (
364366 (
365- sseError ,
367+ sseFailure ,
366368 ) : Effect . Effect < never , McpConnectionError | McpOAuthReauthorizationRequired > => {
367- if ( Predicate . isTagged ( sseError , "McpOAuthReauthorizationRequired" ) ) {
368- return Effect . fail ( sseError ) ;
369+ if ( Predicate . isTagged ( sseFailure , "McpOAuthReauthorizationRequired" ) ) {
370+ return Effect . fail ( sseFailure ) ;
369371 }
370372 return Effect . fail (
371373 new McpConnectionError ( {
372374 transport : "streamable-http" ,
373- message : `${ error . message } ; SSE fallback also failed: ${ sseError . message } ` ,
374- ...( error . httpStatus === undefined ? { } : { httpStatus : error . httpStatus } ) ,
375+ message : `${ failure . message } ; SSE fallback also failed: ${ sseFailure . message } ` ,
376+ ...( failure . httpStatus === undefined ? { } : { httpStatus : failure . httpStatus } ) ,
375377 } ) ,
376378 ) ;
377379 } ,
0 commit comments