@@ -38,15 +38,18 @@ class MockUnauthorizedError extends Error {
3838const transportCalls : Array < {
3939 type : "streamable" | "sse"
4040 url : string
41- options : { authProvider ?: unknown }
41+ options : { authProvider ?: unknown ; requestInit ?: RequestInit }
4242} > = [ ]
4343
4444// Mock the transport constructors
4545void mock . module ( "@modelcontextprotocol/sdk/client/streamableHttp.js" , ( ) => ( {
4646 StreamableHTTPClientTransport : class MockStreamableHTTP {
4747 url : string
4848 authProvider : { redirectToAuthorization ?: ( url : URL ) => Promise < void > } | undefined
49- constructor ( url : URL , options ?: { authProvider ?: { redirectToAuthorization ?: ( url : URL ) => Promise < void > } } ) {
49+ constructor (
50+ url : URL ,
51+ options ?: { authProvider ?: { redirectToAuthorization ?: ( url : URL ) => Promise < void > } ; requestInit ?: RequestInit } ,
52+ ) {
5053 this . url = url . toString ( )
5154 this . authProvider = options ?. authProvider
5255 transportCalls . push ( {
@@ -127,11 +130,12 @@ const mcpTest = testEffect(
127130)
128131const service = MCP . Service as unknown as Effect . Effect < MCPNS . Interface , never , never >
129132
130- const config = ( name : string ) => ( {
133+ const config = ( name : string , headers ?: Record < string , string > ) => ( {
131134 mcp : {
132135 [ name ] : {
133136 type : "remote" as const ,
134137 url : "https://example.com/mcp" ,
138+ headers,
135139 } ,
136140 } ,
137141} )
@@ -227,6 +231,7 @@ mcpTest.instance(
227231 expect ( failure ) . toEqual ( Option . none ( ) )
228232 expect ( typeof url ) . toBe ( "string" )
229233 expect ( url ) . toContain ( "https://" )
234+ expect ( transportCalls . at ( - 1 ) ?. options . requestInit ?. headers ) . toEqual ( { "X-Custom-Header" : "custom-value" } )
230235 } ) ,
231- { config : config ( "test-oauth-server-3" ) } ,
236+ { config : config ( "test-oauth-server-3" , { "X-Custom-Header" : "custom-value" } ) } ,
232237)
0 commit comments