-
Notifications
You must be signed in to change notification settings - Fork 772
SSEServerTransport doesn't seem to close properly #321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Would you mind please adding some of the symptoms you noticed because of this issue? I'm trying to debug some issues on an MCP server and suspect it could be related to something like this. Thanks! |
The core issue is that these responses never properly close, so they occupy memory until timeout. This can build up and create memory pressure. Not sure if there's any obvious symptoms. |
Running into this as well. import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
const client = new Client(
{
name: "mcp-typescript-client",
version: "1.0.0",
},
{
capabilities: {},
}
);
const transport = new SSEClientTransport(
new URL(
".../sse"
)
);
async function main() {
await client.connect(transport);
// ... do stuff with client
// these don't seem to do anything - the connection stays open indefinitely
await client.transport?.close();
await client.close();
}
main(); |
It could be two things, one is that the transport itself doesn't close properly, You're using the client part so I'm not sure if it's the same, but I'm guessing it is. |
Describe the bug
While reviewing the source code, I noticed that the
close
method is never actually called, which meansres.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 whenclose
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 start
npx @modelcontextprotocol/inspector
http://localhost:3001/sse
Expected behavior
res.end
should be called via theclose
method to cleanly terminate the SSE connection.The text was updated successfully, but these errors were encountered: