Creating a Session
Clients create a new session by calling thesession/new
method with:
- The working directory for the session
- A list of MCP servers the Agent should connect to
Loading Sessions
Agents that support theloadSession
capability allow Clients to resume previous conversations. This feature enables persistence across restarts and sharing sessions between different Client instances.
Checking Support
Before attempting to load a session, Clients MUST verify that the Agent supports this capability by checking theloadSession
field in the initialize
response:
loadSession
is false
or not present, the Agent does not support loading sessions and Clients MUST NOT attempt to call session/load
.
Loading a Session
To load an existing session, Clients MUST call thesession/load
method with:
- The Session ID to resume
- MCP servers to connect to
- The working directory
session/update
notifications (like session/prompt
).
For example, a user message from the conversation history:
session/load
request.
Session ID
The session ID returned bysession/new
is a unique identifier for the conversation context.
Clients use this ID to:
- Send prompt requests via
session/prompt
- Cancel ongoing operations via
session/cancel
- Load previous sessions via
session/load
(if the Agent supports theloadSession
capability)
Working Directory
Thecwd
(current working directory) parameter establishes the file system context for the session. This directory:
- MUST be an absolute path
- MUST be used for the session regardless of where the Agent subprocess was spawned
- SHOULD serve as a boundary for tool operations on the file system
MCP Servers
The Model Context Protocol (MCP) allows Agents to access external tools and data sources. When creating a session, Clients MAY include connection details for MCP servers that the Agent should connect to. MCP servers can be connected to using different transports. All Agents MUST support the stdio transport, while HTTP and SSE transports are optional capabilities that can be checked during initialization. While they are not required to by the spec, new Agents SHOULD support the HTTP transport to ensure compatibility with modern MCP servers.Transport Types
Stdio Transport
All Agents MUST support connecting to MCP servers via stdio (standard input/output). This is the default transport mechanism.A human-readable identifier for the server
The absolute path to the MCP server executable
Command-line arguments to pass to the server
Environment variables to set when launching the server
HTTP Transport
When the Agent supportsmcpCapabilities.http
, Clients can specify MCP servers configurations using the HTTP transport.
Must be
"http"
to indicate HTTP transportA human-readable identifier for the server
The URL of the MCP server
HTTP headers to include in requests to the server
SSE Transport
When the Agent supportsmcpCapabilities.sse
, Clients can specify MCP servers configurations using the SSE transport.
This transport was deprecated by the MCP spec.
Must be
"sse"
to indicate SSE transportA human-readable identifier for the server
The URL of the SSE endpoint
HTTP headers to include when establishing the SSE connection
Checking Transport Support
Before using HTTP or SSE transports, Clients MUST verify the Agent’s capabilities during initialization:mcpCapabilities.http
is false
or not present, the Agent does not support HTTP transport.
If mcpCapabilities.sse
is false
or not present, the Agent does not support SSE transport.
Agents SHOULD connect to all MCP servers specified by the Client.
Clients MAY use this ability to provide tools directly to the underlying language model by including their own MCP server.