mcp: the streamable client does not start a new session after a 404, which the 2025-11-25 transport requires

Abierto
#1,299 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@zero-abd ya está trabajando en esto.

Desde el 26/9/2026.

  • #1300 de @zero-abd — abierto

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Necesita aclaración
Estado de actividad
Activo
Stack tecnológico
go
Área
api, networking

Línea de trabajo

Start with mcp/streamable.go, especially checkResponse and the ErrSessionMissing branch, then read the terminal-error documentation in mcp/streamable_client.go. Compare the two recovery shapes described in the issue and resolve the required client behavior and application hook or documentation scope. Done means the SDK's handling of a 404 session loss is explicitly chosen and conforms to the 2025-11-25 transport requirement.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

P2

The clause. The 2025-11-25 streamable HTTP transport, Session Management, item 4: "When a client receives HTTP 404 in response to a request containing an MCP-Session-Id, it MUST start a new session by sending a new InitializeRequest without a session ID attached." Item 3 is the other half: a server "MAY terminate the session at any time, after which it MUST respond to requests containing that session ID with HTTP 404 Not Found."

What the client does. streamableClientConn treats that 404 as terminal. checkResponse returns ErrSessionMissing for a 404 on a request carrying a session ID (mcp/streamable.go, the "Only a stateful connection with a known session ID can experience ErrSessionMissing" branch, unchanged on main since v1.8.0), the connection fails, and every later call on the ClientSession returns that error. The package doc in mcp/streamable_client.go lists it under "Terminal (breaks the connection)". Nothing in the client sends the new InitializeRequest the clause requires; an application has to notice ErrSessionMissing, drop the session and call Client.Connect again. #715 exposed the error so an application could do that, which is useful, but nothing in the documentation tells an application that the specification makes it mandatory, so a client built on the SDK is non-conformant by default.

Why it matters in practice. A server that restarts, evicts an idle stateful session or refuses a session ID it does not recognise answers 404 and relies on the client's MUST to recover. With the Go client, a long-lived ClientSession outlives any of those and stays broken, so every call after it fails with "session not found" while the server is healthy. I maintain an MCP server whose stateful HTTP mode answers an unknown or foreign session ID with 404 for exactly this reason, and its recovery depends on the client.

Two shapes, and I would like your view before writing either.

  1. The client re-initializes on its own: on ErrSessionMissing, the ClientSession runs the handshake again with the same ClientOptions, takes the new session ID and retries the failed request once. That meets the MUST with no application code. What it cannot restore by itself is state the old session carried (resource subscriptions, the logging level), so it would need a hook, for example a callback on ClientOptions, that tells the application it is talking to a new session.
  2. It stays terminal, and the SDK documents on Client.Connect and ClientSession that ErrSessionMissing means the specification requires a new session, perhaps with a helper or an example that does the reconnect, so each application does not reinvent it.

Related: #715 (exposing the error), #683 (terminal errors being too strict), and #579, which is about HTTP error details rather than this.

Lenguaje dominante
Go
Estrellas
5.4k
Forks
623
Merge medio
22 h 10 min
PR fusionados (30 d)
30

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de modelcontextprotocol/go-sdk

Todos los issues de modelcontextprotocol/go-sdk

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.