Repository navigation
SSE stream disconnected: TypeError: terminated #1211
Description
I got an error "SSE stream disconnected: TypeError: terminated" every 5 minutes with the server connection on the cline or cursor, does anyone know why?
ts code:
`import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
import express from 'express';
import * as z from 'zod/v4';
const app = express();
app.use(express.json());
// Create the MCP server once (can be reused across requests)
const server = new McpServer({
name: 'example-server',
version: '1.0.0'
});
// Set up your tools, resources, and prompts
server.registerTool(
'echo',
{
title: 'Echo',
description: 'echo',
inputSchema: { name: z.string() },
},
async ({ name }) => {
return { content: [{ type: 'text', text: `Hello ${name}` }] };
}
);
app.post('/mcp', async (req, res) => {
try {
const transport = new StreamableHTTPServerTransport({
sessionIdGenerator: undefined,
enableJsonResponse: true
});
res.on('close', () => {
transport.close();
});
await server.connect(transport);
await transport.handleRequest(req, res, req.body);
} catch (error) {
console.error('Error handling MCP request:', error);
if (!res.headersSent) {
res.status(500).json({
jsonrpc: '2.0',
error: {
code: -32603,
message: 'Internal server error'
},
id: null
});
}
}
});
// Reusable handler for GET and DELETE requests
const handleSessionRequest = async (req: express.Request, res: express.Response) => {
const transport = new StreamableHTTPServerTransport({
sessionIdGenerator: undefined,
enableJsonResponse: true
});
await transport.handleRequest(req, res);
};
// Handle GET requests for server-to-client notifications via SSE
app.get('/mcp', handleSessionRequest);
const port = parseInt(process.env.PORT || '3000');
app.listen(port, () => {
console.log(MCP Server running on http://localhost:${port}/mcp);
}).on('error', error => {
console.error('Server error:', error);
process.exit(1);
});
mcp setting:"demo": {
"disabled": false,
"timeout": 1800,
"type": "streamableHttp",
"url": "http://localhost:3000/mcp"
}`
cline version 3.38.3
cursor version 1.4.3

Activity
KKonstantinov commentedon Dec 4, 2025
Hello, could you test this with the latest SDK version? There were a couple of bug fixes lately related to connection & closing.
whynixx commentedon Dec 8, 2025
I tried the latest version 1.24.3, but it still doesn't work. This seems like a recurring problem to me, has anyone else encountered it?
package.json
fix(client): handle graceful SSE stream termination without error rep…
newmanwang commentedon Jan 2, 2026
I encountered the same issue while using playwright-mcp as a standalone MCP server.
ManojShivva commentedon Mar 5, 2026
Hello team, what's the status on this issue? When can I expect a release that has a fix for this issue?
fix(client): suppress onerror when SSE disconnect will be handled by …
QRM7-012: file new ticket; close QRM7-011 as superseded
mattzcarey commentedon Jul 23, 2026
we have this and have fixed this with https://github.com/cloudflare/agents will open a pr for this
felixweinberger commentedon Oct 5, 2026
Fixed by default keep-alive on Streamable HTTP event streams: #2541 in 2.0.0, and #2538 with #2547 in 1.30.0. Upgrading to 1.30.0 or to v2 fixes it. Closing.