File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed
Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " mcp-handler " : patch
3+ ---
4+
5+ Ensure auth profiles stay tied to the request
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ interface SerializedRequest {
2929 method : string ;
3030 body : BodyType ;
3131 headers : IncomingHttpHeaders ;
32+ auth ?: AuthInfo ;
3233}
3334
3435type LogLevel = "log" | "error" | "warn" | "info" | "debug" ;
@@ -571,11 +572,13 @@ export function initializeMcpApiHandler(
571572 const request = JSON . parse ( message ) as SerializedRequest ;
572573
573574 // Make in IncomingMessage object because that is what the SDK expects.
575+ // Pass auth from the serialized request to preserve the caller's auth context
574576 const req = createFakeIncomingMessage ( {
575577 method : request . method ,
576578 url : request . url ,
577579 headers : request . headers ,
578580 body : request . body ,
581+ auth : request . auth ,
579582 } ) ;
580583
581584 const syntheticRes = new EventEmittingResponse (
@@ -720,6 +723,7 @@ export function initializeMcpApiHandler(
720723 method : req . method || "" ,
721724 body : parsedBody ,
722725 headers : Object . fromEntries ( req . headers . entries ( ) ) ,
726+ auth : req . auth ,
723727 } ;
724728
725729 // Declare timeout and response handling state before subscription
You can’t perform that action at this time.
0 commit comments