@@ -75,7 +75,7 @@ describe("MCP Server", () => {
7575 const transport = new SSEClientTransport ( new URL ( url ) , { } ) ;
7676
7777 const client = new Client (
78- { name : "stress -client" , version : "1.0.0" } ,
78+ { name : "sse -client" , version : "1.0.0" } ,
7979 { capabilities : { } } ,
8080 ) ;
8181
@@ -159,4 +159,66 @@ describe("MCP Server", () => {
159159
160160 await killAsync ( child ) ;
161161 } ) ;
162+
163+ it ( "sse with multiple clients" , async ( ) => {
164+ const child = await spawnAsync ( "ts-node" , [ "./src/index.ts" , "-t" , "sse" ] ) ;
165+
166+ const url = "http://localhost:1122/sse" ;
167+
168+ const transport1 = new SSEClientTransport ( new URL ( url ) , { } ) ;
169+ const client1 = new Client (
170+ { name : "sse-client-1" , version : "1.0.0" } ,
171+ { capabilities : { } } ,
172+ ) ;
173+
174+ const transport2 = new SSEClientTransport ( new URL ( url ) , { } ) ;
175+ const client2 = new Client (
176+ { name : "sse-client-2" , version : "1.0.0" } ,
177+ { capabilities : { } } ,
178+ ) ;
179+
180+ await Promise . all ( [
181+ client1 . connect ( transport1 ) ,
182+ client2 . connect ( transport2 ) ,
183+ ] ) ;
184+
185+ expect ( ( await client1 . listTools ( ) ) . tools . length ) . toBe (
186+ ( await client2 . listTools ( ) ) . tools . length ,
187+ ) ;
188+
189+ await killAsync ( child ) ;
190+ } ) ;
191+
192+ it ( "streamable with multiple clients" , async ( ) => {
193+ const child = await spawnAsync ( "ts-node" , [
194+ "./src/index.ts" ,
195+ "-t" ,
196+ "streamable" ,
197+ ] ) ;
198+
199+ const url = "http://localhost:1122/mcp" ;
200+
201+ const transport1 = new StreamableHTTPClientTransport ( new URL ( url ) , { } ) ;
202+ const client1 = new Client (
203+ { name : "streamable-client-1" , version : "1.0.0" } ,
204+ { capabilities : { } } ,
205+ ) ;
206+
207+ const transport2 = new StreamableHTTPClientTransport ( new URL ( url ) , { } ) ;
208+ const client2 = new Client (
209+ { name : "streamable-client-2" , version : "1.0.0" } ,
210+ { capabilities : { } } ,
211+ ) ;
212+
213+ await Promise . all ( [
214+ client1 . connect ( transport1 ) ,
215+ client2 . connect ( transport2 ) ,
216+ ] ) ;
217+
218+ expect ( ( await client1 . listTools ( ) ) . tools . length ) . toBe (
219+ ( await client2 . listTools ( ) ) . tools . length ,
220+ ) ;
221+
222+ await killAsync ( child ) ;
223+ } ) ;
162224} ) ;
0 commit comments