mcp: do not call DELETE for sessionless & doc adjustments (#960)

This commit is contained in:
Maciej Kisiel 2026-05-15 21:47:34 +02:00 • committed by GitHub
commit 1253d17add
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -40,8 +40,12 @@ components:
# Sessions
The client maintains a session with the server, identified by a session ID
(Mcp-Session-Id header):
The client optionally maintains a session with the server, identified by a
session ID (Mcp-Session-Id header). Sessionless servers (those that never
send Mcp-Session-Id) are fully supported; the client simply omits the
header from subsequent requests and skips the DELETE on close.
When a session is present:
- Session ID is received from the server after initialization
- Client includes the session ID in all subsequent requests
@ -162,6 +166,7 @@ The client must handle two response formats from POST requests:
- DELETE: Terminate the session
- Used by [streamableClientConn.Close]
- Skipped if session is already known to be gone ([ErrSessionMissing])
or if no session was established (sessionless server)
# Error Handling
@ -176,7 +181,7 @@ Errors are categorized and handled differently:
- 404 Not Found: Session terminated by server ([ErrSessionMissing])
- Message decode errors: Protocol violation
- Context cancellation: Client closed connection
- Mismatched session IDs: Protocol error
- Mismatched session IDs: Protocol error (only relevant for servers that use sessions)
- See issue #683: our terminal errors are too strict.
Terminal errors are stored via [streamableClientConn.fail] and returned by
@ -211,7 +216,7 @@ This header (set by [streamableClientConn.setMCPHeaders]):
State management:
- [streamableClientConn.incoming]: Buffered channel for received messages
- [streamableClientConn.sessionID]: Server-assigned session identifier
- [streamableClientConn.sessionID]: Server-assigned session identifier (empty for sessionless servers)
- [streamableClientConn.initializedResult]: Cached for protocol version header
- [streamableClientConn.failed]: Channel closed on terminal error
- [streamableClientConn.done]: Channel closed on graceful shutdown