The client capabilities declared at initialize (stateful) or carried in the request's _meta (stateless draft). Empty when unknown (legacy stateless): a handler that needs a client capability then errors.
In-flight cancellation tokens keyed by this connection's request ids. Scoping the registry to the ConnectionState keeps a cancellation for one session's request id from touching another session's identically-numbered request.
Whether an initialize request has been processed for this connection (stateful). Distinct from initialized (the post-handshake notification): this guards against a second initialize re-negotiating the session.
Whether the client has sent notifications/initialized for this connection (stateful). The lifecycle gate (opt-in via requireInitialized) serves non-ping requests only once this is set.
The minimum log level the client asked for via logging/setLevel (stateful) or the per-request _meta log level (stateless draft).
The protocol version negotiated for this connection (stateful) or the effective version for the current request (stateless). This is the single version concept: the server->client push/notification path is driven by each open listener's own SubscriptionFilter, not by a separate connection-level version (subscriptions/listen is an ordinary request and is not special-cased).
The resource URIs this connection has subscribed to (stateful only).
The per-connection (or per-session) mutable state for a single MCP peer.
This is the designated home for the mutable per-peer state that would otherwise leak across concurrently-served connections that share one server instance. A McpServer itself holds only immutable registration data, declared capabilities, the serverInfo, and the chosen ServerMode; per-peer state lives here.
Ownership by mode: - stateful: exactly one ConnectionState per session, owned by the transport's SessionManager keyed by Mcp-Session-Id. - stateless: the transport builds a transient ConnectionState per request (from the draft _meta, or from the MCP-Protocol-Version header / default plus empty capabilities for the legacy path) and discards it; nothing is stored across calls. - stdio: a single implicit ConnectionState for the process.