File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import { findActualExecutable } from "spawn-rx";
2020import mcpProxy from "./mcpProxy.js" ;
2121
2222const SSE_HEADERS_PASSTHROUGH = [ "authorization" ] ;
23+ const STREAMABLE_HTTP_HEADERS_PASSTHROUGH = [ "authorization" ] ;
2324
2425const defaultEnvironment = {
2526 ...getDefaultEnvironment ( ) ,
@@ -96,8 +97,24 @@ const createTransport = async (req: express.Request): Promise<Transport> => {
9697 console . log ( "Connected to SSE transport" ) ;
9798 return transport ;
9899 } else if ( transportType === "streamable - http ") {
100+ const headers : HeadersInit = { } ;
101+
102+ for ( const key of STREAMABLE_HTTP_HEADERS_PASSTHROUGH ) {
103+ if ( req . headers [ key ] === undefined ) {
104+ continue ;
105+ }
106+
107+ const value = req . headers [ key ] ;
108+ headers [ key ] = Array . isArray ( value ) ? value [ value . length - 1 ] : value ;
109+ }
110+
99111 const transport = new StreamableHTTPClientTransport (
100112 new URL ( query . url as string ) ,
113+ {
114+ requestInit : {
115+ headers,
116+ } ,
117+ } ,
101118 ) ;
102119 await transport . start ( ) ;
103120 console . log ( "Connected to Streamable HTTP transport" ) ;
You can’t perform that action at this time.
0 commit comments