@@ -120,6 +120,85 @@ 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 (
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
+
123
202
// Function to run a basic test
124
203
async function runBasicTest ( testName , ...args ) {
125
204
const outputFile = path . join (
@@ -649,6 +728,56 @@ async function runTests() {
649
728
"debug" ,
650
729
) ;
651
730
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
+
652
781
console . log (
653
782
`\n${ colors . YELLOW } === Running HTTP Transport Tests ===${ colors . NC } ` ,
654
783
) ;
@@ -668,7 +797,7 @@ async function runTests() {
668
797
669
798
await new Promise ( ( resolve ) => setTimeout ( resolve , 3000 ) ) ;
670
799
671
- // Test 25 : HTTP transport inferred from URL ending with /mcp
800
+ // Test 29 : HTTP transport inferred from URL ending with /mcp
672
801
await runBasicTest (
673
802
"http_transport_inferred" ,
674
803
"http://127.0.0.1:3001/mcp" ,
@@ -677,7 +806,7 @@ async function runTests() {
677
806
"tools/list" ,
678
807
) ;
679
808
680
- // Test 26 : HTTP transport with explicit --transport http flag
809
+ // Test 30 : HTTP transport with explicit --transport http flag
681
810
await runBasicTest (
682
811
"http_transport_with_explicit_flag" ,
683
812
"http://127.0.0.1:3001/mcp" ,
@@ -688,7 +817,7 @@ async function runTests() {
688
817
"tools/list" ,
689
818
) ;
690
819
691
- // Test 27 : HTTP transport with suffix and --transport http flag
820
+ // Test 31 : HTTP transport with suffix and --transport http flag
692
821
await runBasicTest (
693
822
"http_transport_with_explicit_flag_and_suffix" ,
694
823
"http://127.0.0.1:3001/mcp" ,
@@ -699,7 +828,7 @@ async function runTests() {
699
828
"tools/list" ,
700
829
) ;
701
830
702
- // Test 28 : SSE transport given to HTTP server (should fail)
831
+ // Test 32 : SSE transport given to HTTP server (should fail)
703
832
await runErrorTest (
704
833
"sse_transport_given_to_http_server" ,
705
834
"http://127.0.0.1:3001" ,
@@ -710,7 +839,7 @@ async function runTests() {
710
839
"tools/list" ,
711
840
) ;
712
841
713
- // Test 29 : HTTP transport without URL (should fail)
842
+ // Test 33 : HTTP transport without URL (should fail)
714
843
await runErrorTest (
715
844
"http_transport_without_url" ,
716
845
"--transport" ,
@@ -720,7 +849,7 @@ async function runTests() {
720
849
"tools/list" ,
721
850
) ;
722
851
723
- // Test 30 : SSE transport without URL (should fail)
852
+ // Test 34 : SSE transport without URL (should fail)
724
853
await runErrorTest (
725
854
"sse_transport_without_url" ,
726
855
"--transport" ,
0 commit comments