Skip to content

SSE stream disconnected: TypeError: terminated #1211

Closed

Description

@whynixx

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

Image

cursor version 1.4.3

Image

Activity

  1. KKonstantinov commented on Dec 4, 2025

    @KKonstantinov
    Contributor

    Hello, could you test this with the latest SDK version? There were a couple of bug fixes lately related to connection & closing.

  2. whynixx commented on Dec 8, 2025

    @whynixx
    Author

    Hello, could you test this with the latest SDK version? There were a couple of bug fixes lately related to connection & closing.

    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?

    Image

    package.json

    {
    "name": "ts-mcp",
    "version": "1.0.0",
    "description": "",
    "license": "ISC",
    "author": "",
    "type": "commonjs",
    "main": "index.js",
    "scripts": {
    "test": "echo "Error: no test specified" && exit 1"
    },
    "dependencies": {
    "@modelcontextprotocol/sdk": "^1.24.3",
    "axios": "^1.13.2",
    "express": "^5.1.0",
    "fastify": "^5.6.2",
    "fastmcp": "^3.24.0",
    "kafkajs": "^2.2.4",
    "zod": "^4.1.13"
    },
    "devDependencies": {
    "@types/express": "^5.0.5"
    }
    }

  3. added
    ready for workEnough information for someone to start working on
    P2Moderate issues affecting some users, edge cases, potentially valuable feature
    on Dec 8, 2025
  4. added a commit that references this issue on Dec 29, 2025
    193a1f9
  5. newmanwang commented on Jan 2, 2026

    @newmanwang

    I encountered the same issue while using playwright-mcp as a standalone MCP server.

    Image
  6. ManojShivva commented on Mar 5, 2026

    @ManojShivva

    Hello team, what's the status on this issue? When can I expect a release that has a fix for this issue?

  7. added a commit that references this issue on Mar 31, 2026
    31beb5b
  8. mattzcarey commented on Jul 23, 2026

    @mattzcarey
    Member

    we have this and have fixed this with https://github.com/cloudflare/agents will open a pr for this

  9. felixweinberger commented on Oct 5, 2026

    @felixweinberger
    Contributor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Moderate issues affecting some users, edge cases, potentially valuable featurebugSomething isn't workingready for workEnough information for someone to start working on

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions