Commit Graph

9 Commits

Author SHA1 Message Date
cliffhall
3adf59409c In sse.ts, /message endpoint, if transport isn't found for the given sessionId, output a "No transport found for sessionId" message. 2025-05-28 17:29:42 -04:00
cliffhall
2da9f33969 Remove or clause for sessionId where "none" is offered as an alternative.
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.
2025-05-28 16:31:21 -04:00
cliffhall
9ffacb78ab Be more verbose about unexpected GET /sse calls from already connected clients. 2025-05-28 11:14:03 -04:00
cliffhall
145f893108 Allow multiple connections to the everything server.
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.
2025-05-22 11:41:16 -04:00
cliffhall
26aa0f8091 * In src/everything/sse.ts
- add SIGINT handler that does cleanup, server.close, and process.exit
2025-05-15 14:32:42 -04:00
cliffhall
3894d236c0 * In src/everything/sse.ts and streamableHttp.ts
- Replace console.log with console.error throughout
* In src/everything/sse.ts
  - remove the process.exit() in the server.onclose handler so reconnections are possible
2025-05-15 14:13:15 -04:00
cliffhall
e30f30868f Update server-everything to use the latest version of the SDK
* In sse.ts & streamableHttp.ts
  - change console.log to console.error
2025-05-06 10:27:49 -04:00
cliffhall
f93911607b Update server-everything to allow choosing the transport on the command line.
# Run the default (stdio) server
```npx @modelcontextprotocol/server-everything```

# Or specify stdio explicitly
```npx @modelcontextprotocol/server-everything stdio```

# Run the SSE server
```npx @modelcontextprotocol/server-everything sse```

# Run the streamable HTTP server
```npx @modelcontextprotocol/server-everything streamableHttp```

* In src/everything/index.ts
  - refactor/extracted contents to stdio.ts
  - replaced with code that
    - Gets the single argument from the commandline as scriptName
    - switches on scriptName
    - imports the appropriate server script or outputs usage options
  - scripts run on import

* In src/everything/stdio.ts
  - added console log "Starting default (STDIO) server..."

* In src/everything/sse.ts
  - added console log "Starting SSE server..."

* In src/everything/streamableHttp.ts
  - added console log "Starting Streamable HTTP server..."

* This fixes #1594
2025-05-05 13:09:38 -04:00
Justin Spahr-Summers
37415258b9 Initial commit 2024-11-19 13:29:12 +00:00