@@ -120,6 +120,57 @@ try {
120
120
const invalidConfigPath = path . join ( TEMP_DIR , "invalid-config.json" ) ;
121
121
fs . writeFileSync ( invalidConfigPath , '{\n "mcpServers": {\n "invalid": {' ) ;
122
122
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
+
123
174
// Function to run a basic test
124
175
async function runBasicTest ( testName , ...args ) {
125
176
const outputFile = path . join (
@@ -649,6 +700,56 @@ async function runTests() {
649
700
"debug" ,
650
701
) ;
651
702
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
+
652
753
console . log (
653
754
`\n${ colors . YELLOW } === Running HTTP Transport Tests ===${ colors . NC } ` ,
654
755
) ;
@@ -668,7 +769,7 @@ async function runTests() {
668
769
669
770
await new Promise ( ( resolve ) => setTimeout ( resolve , 3000 ) ) ;
670
771
671
- // Test 25 : HTTP transport inferred from URL ending with /mcp
772
+ // Test 29 : HTTP transport inferred from URL ending with /mcp
672
773
await runBasicTest (
673
774
"http_transport_inferred" ,
674
775
"http://127.0.0.1:3001/mcp" ,
@@ -677,7 +778,7 @@ async function runTests() {
677
778
"tools/list" ,
678
779
) ;
679
780
680
- // Test 26 : HTTP transport with explicit --transport http flag
781
+ // Test 30 : HTTP transport with explicit --transport http flag
681
782
await runBasicTest (
682
783
"http_transport_with_explicit_flag" ,
683
784
"http://127.0.0.1:3001/mcp" ,
@@ -688,7 +789,7 @@ async function runTests() {
688
789
"tools/list" ,
689
790
) ;
690
791
691
- // Test 27 : HTTP transport with suffix and --transport http flag
792
+ // Test 31 : HTTP transport with suffix and --transport http flag
692
793
await runBasicTest (
693
794
"http_transport_with_explicit_flag_and_suffix" ,
694
795
"http://127.0.0.1:3001/mcp" ,
@@ -699,7 +800,7 @@ async function runTests() {
699
800
"tools/list" ,
700
801
) ;
701
802
702
- // Test 28 : SSE transport given to HTTP server (should fail)
803
+ // Test 32 : SSE transport given to HTTP server (should fail)
703
804
await runErrorTest (
704
805
"sse_transport_given_to_http_server" ,
705
806
"http://127.0.0.1:3001" ,
@@ -710,7 +811,7 @@ async function runTests() {
710
811
"tools/list" ,
711
812
) ;
712
813
713
- // Test 29 : HTTP transport without URL (should fail)
814
+ // Test 33 : HTTP transport without URL (should fail)
714
815
await runErrorTest (
715
816
"http_transport_without_url" ,
716
817
"--transport" ,
@@ -720,7 +821,7 @@ async function runTests() {
720
821
"tools/list" ,
721
822
) ;
722
823
723
- // Test 30 : SSE transport without URL (should fail)
824
+ // Test 34 : SSE transport without URL (should fail)
724
825
await runErrorTest (
725
826
"sse_transport_without_url" ,
726
827
"--transport" ,
0 commit comments