mcp: improvements for 'stateless' streamable servers; 'distributed' mode

Several improvements for the stateless streamable mode, plus support for
a 'distributed' (or rather, distributable) version of the stateless
server.

- Add a 'Stateless' option to StreamableHTTPOptions and
  StreamableServerTransport, which controls stateless behavior.
  GetSessionID may still return a non-empty session ID.
- Audit validation of stateless mode to allow requests with a session
  id. Propagate this session ID to the temporary connection.
- Peek at requests to allow 'initialize' requests to go through to the
  session, so that version negotiation can occur (FIXME: add tests).

Fixes #284
For #148
This commit is contained in:
Rob Findley 2025-08-15 03:13:53 +00:00 • committed by Robert Findley
commit 98e67fdf62

View file

@ -40,8 +40,8 @@ type Transport interface {
type Connection interface {
// Read reads the next message to process off the connection.
//
// Read need not be safe for concurrent use: Read is called in a
// concurrency-safe manner by the JSON-RPC library.
// Connections must allow Read to be called concurrently with Close. In
// particular, calling Close should unblock a Read waiting for input.
Read(context.Context) (jsonrpc.Message, error)
// Write writes a new message to the connection.