@@ -120,6 +120,57 @@ try {
120120const invalidConfigPath = path . join ( TEMP_DIR , "invalid-config.json" ) ;
121121fs . writeFileSync ( invalidConfigPath , '{\n "mcpServers": {\n "invalid": {' ) ;
122122
123+ // Create config files with different transport types for testing
124+ const sseConfigPath = path . join ( TEMP_DIR , "sse-config.json" ) ;
125+ fs . writeFileSync ( sseConfigPath , JSON . stringify ( {
126+ mcpServers : {
127+ "test-sse" : {
128+ type : "sse" ,
129+ url : "http://localhost:3000/sse" ,
130+ note : "Test SSE server"
131+ }
132+ }
133+ } , null , 2 ) ) ;
134+
135+ const httpConfigPath = path . join ( TEMP_DIR , "http-config.json" ) ;
136+ fs . writeFileSync ( httpConfigPath , JSON . stringify ( {
137+ mcpServers : {
138+ "test-http" : {
139+ type : "streamable-http" ,
140+ url : "http://localhost:3000/mcp" ,
141+ note : "Test HTTP server"
142+ }
143+ }
144+ } , null , 2 ) ) ;
145+
146+ const stdioConfigPath = path . join ( TEMP_DIR , "stdio-config.json" ) ;
147+ fs . writeFileSync ( stdioConfigPath , JSON . stringify ( {
148+ mcpServers : {
149+ "test-stdio" : {
150+ type : "stdio" ,
151+ command : "npx" ,
152+ args : [ "@modelcontextprotocol/server-everything" ] ,
153+ env : {
154+ TEST_ENV : "test-value"
155+ }
156+ }
157+ }
158+ } , null , 2 ) ) ;
159+
160+ // Config without type field (backward compatibility)
161+ const legacyConfigPath = path . join ( TEMP_DIR , "legacy-config.json" ) ;
162+ fs . writeFileSync ( legacyConfigPath , JSON . stringify ( {
163+ mcpServers : {
164+ "test-legacy" : {
165+ command : "npx" ,
166+ args : [ "@modelcontextprotocol/server-everything" ] ,
167+ env : {
168+ LEGACY_ENV : "legacy-value"
169+ }
170+ }
171+ }
172+ } , null , 2 ) ) ;
173+
123174// Function to run a basic test
124175async function runBasicTest ( testName , ...args ) {
125176 const outputFile = path . join (
@@ -649,6 +700,56 @@ async function runTests() {
649700 "debug" ,
650701 ) ;
651702
703+ console . log (
704+ `\n${ colors . YELLOW } === Running Config Transport Type Tests ===${ colors . NC } ` ,
705+ ) ;
706+
707+ // Test 25: Config with stdio transport type
708+ await runBasicTest (
709+ "config_stdio_type" ,
710+ "--config" ,
711+ stdioConfigPath ,
712+ "--server" ,
713+ "test-stdio" ,
714+ "--cli" ,
715+ "--method" ,
716+ "tools/list" ,
717+ ) ;
718+
719+ // Test 26: Config with SSE transport type (should pass transport to client)
720+ await runBasicTest (
721+ "config_sse_type" ,
722+ "--config" ,
723+ sseConfigPath ,
724+ "--server" ,
725+ "test-sse" ,
726+ "echo" ,
727+ "test" ,
728+ ) ;
729+
730+ // Test 27: Config with streamable-http transport type
731+ await runBasicTest (
732+ "config_http_type" ,
733+ "--config" ,
734+ httpConfigPath ,
735+ "--server" ,
736+ "test-http" ,
737+ "echo" ,
738+ "test" ,
739+ ) ;
740+
741+ // Test 28: Legacy config without type field (backward compatibility)
742+ await runBasicTest (
743+ "config_legacy_no_type" ,
744+ "--config" ,
745+ legacyConfigPath ,
746+ "--server" ,
747+ "test-legacy" ,
748+ "--cli" ,
749+ "--method" ,
750+ "tools/list" ,
751+ ) ;
752+
652753 console . log (
653754 `\n${ colors . YELLOW } === Running HTTP Transport Tests ===${ colors . NC } ` ,
654755 ) ;
@@ -668,7 +769,7 @@ async function runTests() {
668769
669770 await new Promise ( ( resolve ) => setTimeout ( resolve , 3000 ) ) ;
670771
671- // Test 25 : HTTP transport inferred from URL ending with /mcp
772+ // Test 29 : HTTP transport inferred from URL ending with /mcp
672773 await runBasicTest (
673774 "http_transport_inferred" ,
674775 "http://127.0.0.1:3001/mcp" ,
@@ -677,7 +778,7 @@ async function runTests() {
677778 "tools/list" ,
678779 ) ;
679780
680- // Test 26 : HTTP transport with explicit --transport http flag
781+ // Test 30 : HTTP transport with explicit --transport http flag
681782 await runBasicTest (
682783 "http_transport_with_explicit_flag" ,
683784 "http://127.0.0.1:3001/mcp" ,
@@ -688,7 +789,7 @@ async function runTests() {
688789 "tools/list" ,
689790 ) ;
690791
691- // Test 27 : HTTP transport with suffix and --transport http flag
792+ // Test 31 : HTTP transport with suffix and --transport http flag
692793 await runBasicTest (
693794 "http_transport_with_explicit_flag_and_suffix" ,
694795 "http://127.0.0.1:3001/mcp" ,
@@ -699,7 +800,7 @@ async function runTests() {
699800 "tools/list" ,
700801 ) ;
701802
702- // Test 28 : SSE transport given to HTTP server (should fail)
803+ // Test 32 : SSE transport given to HTTP server (should fail)
703804 await runErrorTest (
704805 "sse_transport_given_to_http_server" ,
705806 "http://127.0.0.1:3001" ,
@@ -710,7 +811,7 @@ async function runTests() {
710811 "tools/list" ,
711812 ) ;
712813
713- // Test 29 : HTTP transport without URL (should fail)
814+ // Test 33 : HTTP transport without URL (should fail)
714815 await runErrorTest (
715816 "http_transport_without_url" ,
716817 "--transport" ,
@@ -720,7 +821,7 @@ async function runTests() {
720821 "tools/list" ,
721822 ) ;
722823
723- // Test 30 : SSE transport without URL (should fail)
824+ // Test 34 : SSE transport without URL (should fail)
724825 await runErrorTest (
725826 "sse_transport_without_url" ,
726827 "--transport" ,
0 commit comments