Skip to content

mcp: tolerate 404 on subscriptions/listen in stateless mode - #1193

Open
smlx wants to merge 1 commit into
modelcontextprotocol:mainfrom
smlx:github-mcp-fix
Open

mcp: tolerate 404 on subscriptions/listen in stateless mode#1193
smlx wants to merge 1 commit into
modelcontextprotocol:mainfrom
smlx:github-mcp-fix

Conversation

@smlx

@smlx smlx commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

When connecting to remote stateless servers (such as GitHub's MCP server), optional streams like subscriptions/listen may be rejected by middleware with a plain-text HTTP 404 before reaching a JSON-RPC handler.

Previously, checkResponse misclassified these 404s as lost stateful sessions (ErrSessionMissing) and tore down the transport connection because the error didn't wrap jsonrpc2.ErrRejected.

This change aligns with the MCP 2026-07-28 Streamable HTTP specification:

  1. Conditionally check for an active session ID before returning ErrSessionMissing, since a 404 on a stateless connection cannot mean a session was lost.

  2. Wrap subscriptions/listen failures with ErrRejected (matching server/discover) so the jsonrpc2 layer doesn't permanently break the transport when encountering non-compliant plain-text 404s.


I have manually tested this change against GitHub's hosted MCP server and confirmed that it fixes github/github-mcp-server#3129

When connecting to remote stateless servers (such as GitHub's MCP
server), optional streams like subscriptions/listen may be rejected by
middleware with a plain-text HTTP 404 before reaching a JSON-RPC
handler.

Previously, checkResponse misclassified these 404s as lost stateful
sessions (ErrSessionMissing) and tore down the transport connection
because the error didn't wrap jsonrpc2.ErrRejected.

This change aligns with the MCP 2026-07-28 Streamable HTTP specification:

1. Conditionally check for an active session ID before returning
   ErrSessionMissing, since a 404 on a stateless connection cannot mean
   a session was lost.

2. Wrap subscriptions/listen failures with ErrRejected (matching
   server/discover) so the jsonrpc2 layer doesn't permanently break the
   transport when encountering non-compliant plain-text 404s.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remote MCP calls to the Copilot-hosted GitHub MCP server fail (crush)

2 participants