Skip to content

Conversation

@pull
Copy link

@pull pull bot commented May 29, 2025

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.1)

Can you help keep this open source service alive? 💖 Please sponsor : )

cliffhall and others added 9 commits May 22, 2025 11:41
For both sse and streamableHttp, a server instance needs to be created for each transport. Otherwise, when a new client connects and its new transport is connected to the single server, the previous transport is overwritten in the server instance and can no longer communicate.

* In sse.ts
  - remove global server, cleanup, and transport vars
  - add transports map
  - in sse GET handler,
    - check for sessionId, there shouldn't be one, so comment "Reconnecting?" and do nothing if present
    - if sessionId not present
      - create new server and transport instance
      - connect server to transport
      - add transport to transports map
      - in server.onclose, delete the transport from the transports map and call cleanup
  - in /message POST handler
    - get the sessionId from the request
    - get the transport from the map by sessionId
    - handle the message if the transport was found

* In streamableHttp.ts
  - remove the global server and cleanup vars
  - change transports var to Map
  - in /mcp POST handler
    - when creating a new session
      - create a server instance
      - in server.onclose, delete the transport from the transports map and call cleanup
  - remove the calls to cleanup and server.close in the SIGINT handler, because the transport is closed and its onclose handler closes the server.
…ive.

 In the first case (line 16) we already know that req.query.sessionId is set to something. I

 n the second (line 40), it doesn't matter because if it doesn't map to a transport no further action is taken.
…sessionId, output a "No transport found for sessionId" message.
…nnection-support

Everything server multiple connection support
…sion of the now removed Github server and is breaking CI.
@pull pull bot added the ⤵️ pull label May 29, 2025
@pull pull bot merged commit ed101d0 into threatcode:main May 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants