What is MCP session?
An MCP session is a single stateful connection between a client and server, from the initialize handshake to disconnect, over which negotiated capabilities, context, and requests persist.
An MCP session is the unit of a client-server relationship in the Model Context Protocol: it begins with the initialization handshake, where the two sides negotiate protocol version and capabilities, and lasts until the connection ends. Because MCP is stateful, the session is where shared context lives, the agreed feature set, the list of available tools and resources, any subscriptions to change notifications, and the back-and-forth of requests, responses, and notifications all belong to one session. How a session is anchored depends on the transport. For a local stdio server, the session is simply the lifetime of the subprocess. For a remote server using Streamable HTTP, the session can span multiple HTTP requests, so the server issues a session identifier (the Mcp-Session-Id header) on initialization that the client echoes on subsequent calls, letting the server tie otherwise independent HTTP requests back to the same logical session and its state. A session can be resumed or must be re-established depending on the implementation, and ending it cleans up server-side state. Understanding sessions matters because everything stateful in MCP, from negotiated capabilities to streamed responses, is scoped to one.