@@ -120,6 +120,85 @@ 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 (
126+ sseConfigPath ,
127+ JSON . stringify (
128+ {
129+ mcpServers : {
130+ "test-sse" : {
131+ type : "sse" ,
132+ url : "http://localhost:3000/sse" ,
133+ note : "Test SSE server" ,
134+ } ,
135+ } ,
136+ } ,
137+ null ,
138+ 2 ,
139+ ) ,
140+ ) ;
141+
142+ const httpConfigPath = path . join ( TEMP_DIR , "http-config.json" ) ;
143+ fs . writeFileSync (
144+ httpConfigPath ,
145+ JSON . stringify (
146+ {
147+ mcpServers : {
148+ "test-http" : {
149+ type : "streamable-http" ,
150+ url : "http://localhost:3000/mcp" ,
151+ note : "Test HTTP server" ,
152+ } ,
153+ } ,
154+ } ,
155+ null ,
156+ 2 ,
157+ ) ,
158+ ) ;
159+
160+ const stdioConfigPath = path . join ( TEMP_DIR , "stdio-config.json" ) ;
161+ fs . writeFileSync (
162+ stdioConfigPath ,
163+ JSON . stringify (
164+ {
165+ mcpServers : {
166+ "test-stdio" : {
167+ type : "stdio" ,
168+ command : "npx" ,
169+ args : [ "@modelcontextprotocol/server-everything" ] ,
170+ env : {
171+ TEST_ENV : "test-value" ,
172+ } ,
173+ } ,
174+ } ,
175+ } ,
176+ null ,
177+ 2 ,
178+ ) ,
179+ ) ;
180+
181+ // Config without type field (backward compatibility)
182+ const legacyConfigPath = path . join ( TEMP_DIR , "legacy-config.json" ) ;
183+ fs . writeFileSync (
184+ legacyConfigPath ,
185+ JSON . stringify (
186+ {
187+ mcpServers : {
188+ "test-legacy" : {
189+ command : "npx" ,
190+ args : [ "@modelcontextprotocol/server-everything" ] ,
191+ env : {
192+ LEGACY_ENV : "legacy-value" ,
193+ } ,
194+ } ,
195+ } ,
196+ } ,
197+ null ,
198+ 2 ,
199+ ) ,
200+ ) ;
201+
123202// Function to run a basic test
124203async function runBasicTest ( testName , ...args ) {
125204 const outputFile = path . join (
@@ -649,6 +728,56 @@ async function runTests() {
649728 "debug" ,
650729 ) ;
651730
731+ console . log (
732+ `\n${ colors . YELLOW } === Running Config Transport Type Tests ===${ colors . NC } ` ,
733+ ) ;
734+
735+ // Test 25: Config with stdio transport type
736+ await runBasicTest (
737+ "config_stdio_type" ,
738+ "--config" ,
739+ stdioConfigPath ,
740+ "--server" ,
741+ "test-stdio" ,
742+ "--cli" ,
743+ "--method" ,
744+ "tools/list" ,
745+ ) ;
746+
747+ // Test 26: Config with SSE transport type (should pass transport to client)
748+ await runBasicTest (
749+ "config_sse_type" ,
750+ "--config" ,
751+ sseConfigPath ,
752+ "--server" ,
753+ "test-sse" ,
754+ "echo" ,
755+ "test" ,
756+ ) ;
757+
758+ // Test 27: Config with streamable-http transport type
759+ await runBasicTest (
760+ "config_http_type" ,
761+ "--config" ,
762+ httpConfigPath ,
763+ "--server" ,
764+ "test-http" ,
765+ "echo" ,
766+ "test" ,
767+ ) ;
768+
769+ // Test 28: Legacy config without type field (backward compatibility)
770+ await runBasicTest (
771+ "config_legacy_no_type" ,
772+ "--config" ,
773+ legacyConfigPath ,
774+ "--server" ,
775+ "test-legacy" ,
776+ "--cli" ,
777+ "--method" ,
778+ "tools/list" ,
779+ ) ;
780+
652781 console . log (
653782 `\n${ colors . YELLOW } === Running HTTP Transport Tests ===${ colors . NC } ` ,
654783 ) ;
@@ -668,7 +797,7 @@ async function runTests() {
668797
669798 await new Promise ( ( resolve ) => setTimeout ( resolve , 3000 ) ) ;
670799
671- // Test 25 : HTTP transport inferred from URL ending with /mcp
800+ // Test 29 : HTTP transport inferred from URL ending with /mcp
672801 await runBasicTest (
673802 "http_transport_inferred" ,
674803 "http://127.0.0.1:3001/mcp" ,
@@ -677,7 +806,7 @@ async function runTests() {
677806 "tools/list" ,
678807 ) ;
679808
680- // Test 26 : HTTP transport with explicit --transport http flag
809+ // Test 30 : HTTP transport with explicit --transport http flag
681810 await runBasicTest (
682811 "http_transport_with_explicit_flag" ,
683812 "http://127.0.0.1:3001/mcp" ,
@@ -688,7 +817,7 @@ async function runTests() {
688817 "tools/list" ,
689818 ) ;
690819
691- // Test 27 : HTTP transport with suffix and --transport http flag
820+ // Test 31 : HTTP transport with suffix and --transport http flag
692821 await runBasicTest (
693822 "http_transport_with_explicit_flag_and_suffix" ,
694823 "http://127.0.0.1:3001/mcp" ,
@@ -699,7 +828,7 @@ async function runTests() {
699828 "tools/list" ,
700829 ) ;
701830
702- // Test 28 : SSE transport given to HTTP server (should fail)
831+ // Test 32 : SSE transport given to HTTP server (should fail)
703832 await runErrorTest (
704833 "sse_transport_given_to_http_server" ,
705834 "http://127.0.0.1:3001" ,
@@ -710,7 +839,7 @@ async function runTests() {
710839 "tools/list" ,
711840 ) ;
712841
713- // Test 29 : HTTP transport without URL (should fail)
842+ // Test 33 : HTTP transport without URL (should fail)
714843 await runErrorTest (
715844 "http_transport_without_url" ,
716845 "--transport" ,
@@ -720,7 +849,7 @@ async function runTests() {
720849 "tools/list" ,
721850 ) ;
722851
723- // Test 30 : SSE transport without URL (should fail)
852+ // Test 34 : SSE transport without URL (should fail)
724853 await runErrorTest (
725854 "sse_transport_without_url" ,
726855 "--transport" ,
0 commit comments