11import { Client } from "@modelcontextprotocol/sdk/client/index.js" ;
2- import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js" ;
3-
42import {
53 SSEClientTransport ,
64 SseError ,
75} from "@modelcontextprotocol/sdk/client/sse.js" ;
86import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js" ;
97import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js" ;
108import { WebSocketClientTransport } from "@modelcontextprotocol/sdk/client/websocket.js" ;
11-
9+ import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js" ;
10+ import { Agent as HttpsAgent } from "https" ;
1211import {
1312 IDE ,
1413 MCPConnectionStatus ,
@@ -393,6 +392,11 @@ class MCPConnection {
393392 case "websocket" :
394393 return new WebSocketClientTransport ( new URL ( options . transport . url ) ) ;
395394 case "sse" :
395+ const sseAgent =
396+ options . transport . requestOptions ?. verifySsl === false
397+ ? new HttpsAgent ( { rejectUnauthorized : false } )
398+ : undefined ;
399+
396400 return new SSEClientTransport ( new URL ( options . transport . url ) , {
397401 eventSourceInit : {
398402 fetch : ( input , init ) =>
@@ -404,17 +408,27 @@ class MCPConnection {
404408 | Record < string , string >
405409 | undefined ) ,
406410 } ,
411+ ...( sseAgent && { agent : sseAgent } ) ,
407412 } ) ,
408413 } ,
409- requestInit : { headers : options . transport . requestOptions ?. headers } ,
414+ requestInit : {
415+ headers : options . transport . requestOptions ?. headers ,
416+ ...( sseAgent && { agent : sseAgent } ) ,
417+ } ,
410418 } ) ;
411419 case "streamable-http" :
412- return new StreamableHTTPClientTransport (
413- new URL ( options . transport . url ) ,
414- {
415- requestInit : { headers : options . transport . requestOptions ?. headers } ,
420+ const { url, requestOptions } = options . transport ;
421+ const streamableAgent =
422+ requestOptions ?. verifySsl === false
423+ ? new HttpsAgent ( { rejectUnauthorized : false } )
424+ : undefined ;
425+
426+ return new StreamableHTTPClientTransport ( new URL ( url ) , {
427+ requestInit : {
428+ headers : requestOptions ?. headers ,
429+ ...( streamableAgent && { agent : streamableAgent } ) ,
416430 } ,
417- ) ;
431+ } ) ;
418432 default :
419433 throw new Error (
420434 `Unsupported transport type: ${ ( options . transport as any ) . type } ` ,
0 commit comments