modelcontextprotocol / modelcontextprotocol/typescript-sdk
SSEServerTransport doesn't seem to close properly
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 13.4k
- Forks
- 2.2k
- Avg merge
- 3d 15h
- Merged PRs (30d)
- 4
Description
Describe the bug
While reviewing the source code, I noticed that the close method is never actually called, which means res.end is never triggered:
https://github.com/modelcontextprotocol/typescript-sdk/blob/main/src/server/sse.ts
In multiple places, it seems like onclose is called directly when close should be used instead, to ensure proper cleanup.
To Reproduce
I created a minimal reproduction here:
https://github.com/nichtsam/transport-issue
Steps to reproduce the behavior:
npm run startnpx @modelcontextprotocol/inspector- connect to
http://localhost:3001/sse - disconnect
Expected behavior
res.end should be called via the close method to cleanly terminate the SSE connection.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/server/sse.ts and trace the SSEServerTransport close and onclose paths, focusing on where res.end should be reached. Run the reproduction with npm run start, then connect and disconnect using the MCP Inspector; done means the SSE response terminates cleanly through close and the observed cleanup matches the expected behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend, networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 67/100