AgentFixFind a fix
MCPOpen issueUpdated Aug 20, 2026

MCP SSE stream disconnects with TypeError: terminated

Diagnose MCP Streamable HTTP or SSE connections that repeatedly disconnect with TypeError: terminated.

Exact error

Match the message before using the fix

SSE stream disconnected: TypeError: terminatedTypeError: terminatedMCP stream disconnected every 5 minutes

Quick answer

Start here

`TypeError: terminated` says the HTTP/SSE connection closed below the MCP tool layer; it does not identify which hop closed it. Record the interval, correlate client, server, and proxy logs, and test the endpoint directly on the same network path. A repeatable five-minute boundary points toward an idle/lifetime timer, but the upstream issue remains open and no universal timeout setting or one-command fix is confirmed.

Diagnosis

Why it happens

  • The client receives a terminated Fetch/SSE stream after the connection has already been established.
  • A reverse proxy, load balancer, client, server response-close handler, or network device can end the stream at a stable lifetime or idle threshold.
  • Server transport lifecycle mistakes can look identical to infrastructure timeouts; the exact message alone cannot assign the cause.

Safest first

Fixes, in order

01

Measure the disconnect interval and failing hop

Applies when: Every recurring SSE or Streamable HTTP termination

A stable boundary is useful evidence, but it must be matched with logs from both ends.

  1. Record the connection-open and disconnect timestamps from the MCP client.
  2. Collect the matching server request and response-close timestamps.
  3. List every proxy, tunnel, load balancer, or gateway between the client and server.
  4. Repeat the test twice and compare the intervals before changing configuration.

Expected: You can identify whether the server closed first, the client cancelled first, or an intermediate hop ended an otherwise live stream.

02

Test the MCP endpoint without the intermediary

Applies when: When a proxy or tunnel sits between the client and server

A direct local or same-network test separates application lifecycle behavior from infrastructure policy.

  1. Use the same MCP client and transport type against the server's direct test endpoint when safe and available.
  2. Keep the server build and request path unchanged.
  3. Compare the direct connection lifetime with the proxied connection lifetime.
  4. Restore the production route after the bounded test.

Expected: Only the proxied route terminates at the fixed boundary, or the same failure follows the server and rules the proxy out.

03

Review server transport lifecycle per request and session

Applies when: Custom TypeScript SDK servers that create or close transports in request handlers

The upstream example constructs transports in HTTP handlers; incorrect reuse or close handling can terminate SSE independently of network timeouts.

  1. Compare the server implementation with the current official SDK Streamable HTTP example for the same stateless or stateful mode.
  2. Confirm GET, POST, and DELETE routes share session state only when the selected mode requires it.
  3. Log response `close`, transport `close`, and server exceptions with a session identifier.
  4. Change one lifecycle branch at a time and rerun the measured connection test.

Expected: The stream remains connected for the intended lifetime or the logs identify the exact component initiating close.

Verification

Prove the fix worked

  1. Maintain the connection beyond the previous repeated failure interval.
  2. Call a harmless MCP tool before and after that boundary.
  3. Confirm client and server logs show one continuous healthy session without an unexplained termination.

Escalation

If it still fails

  • Do not increase every timeout blindly; first identify which component owns the observed boundary.
  • Capture SDK version, client, transport type, endpoint path, proxy chain, exact interval, and both-side close logs.
  • If the connection never opens and returns 404, diagnose endpoint/transport mismatch instead of this established-stream termination.

Scope

Environment and version notes

  • The primary report used the MCP TypeScript SDK with Cline 3.38.3 and Cursor 1.4.3.
  • The issue remained open on August 20, 2026; npm reported @modelcontextprotocol/sdk 1.30.0 as current.
  • Sources rechecked August 20, 2026.

Evidence

Sources

Source labels describe the evidence available on the checked date. A closed issue is not automatically a shipped fix.