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 thesession.load 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 thesession.load field in the initialize response:
session.load is omitted or null, 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). User, agent, and thought messages can each be replayed as message updates with full content arrays or as chunks.
For example, a user message from the conversation history:
messageId for each replayed message. user_message, agent_message, and agent_thought updates are upserts keyed by messageId; their content arrays replace the whole message content, while chunk updates with the same messageId append content.
Clients apply replayed message updates and chunks in the order they are received. If a message update with content arrives after chunks for the same messageId, it replaces the content accumulated from those chunks. If chunks arrive after a message update, they append to that update’s current content. Message updates that omit content can update _meta or future fields without changing the current content.
When all the conversation entries have been reported to the Client, the Agent MUST respond to the original session/load request.
Resuming Sessions
Agents that advertisesession.resume allow Clients to reconnect to an existing session without replaying the conversation history.
Checking Support
Before attempting to resume a session, Clients MUST verify that the Agent supports this capability by checking for thesession.resume field in the initialize response:
session.resume is not present, the Agent does not support resuming sessions and Clients MUST NOT attempt to call session/resume.
Resuming a Session
To resume an existing session without replaying prior messages, Clients MUST call thesession/resume method with:
- The Session ID to resume
- MCP servers to connect to
- The working directory
session/load, the Agent MUST NOT replay the conversation history via session/update notifications before responding. Instead, it restores the session context, reconnects to the requested MCP servers, and returns once the session is ready to continue.
Closing Active Sessions
Agents that advertisesession.close allow Clients to tell the Agent to cancel any ongoing work for a session and free any resources associated with that active session.
Checking Support
Before attempting to close a session, Clients MUST verify that the Agent supports this capability by checking thesession.close field in the initialize response:
session.close is not present, the Agent does not support closing sessions and Clients MUST NOT attempt to call session/close.
Closing a Session
To close an active session, Clients MUST call thesession/close method with the session ID:
The ID of the active session to close.
session/cancel had been called, then free the resources associated with the session.
On success, the Agent responds with an empty result object:
Additional Workspace Roots
Agents that advertisesession.additionalDirectories allow Clients
to include additionalDirectories on supported session lifecycle requests to
expand the session’s effective workspace root set. Supported stable lifecycle
requests include session/new, session/load, and session/resume.
additionalDirectories has the following behavior:
cwdremains the primary working directory and the base for relative paths- each
additionalDirectoriesentry MUST be an absolute path - omitting the field or providing an empty array activates no additional roots for the resulting session
- on
session/loadandsession/resume, Clients must send the full intended additional-root list again; that list may differ from any previous or reported list as long as the requestcwdmatches the session’scwd, and omitting the field or providing an empty array does not restore stored roots implicitly
additionalDirectories when the Agent advertises session.additionalDirectories.
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 thesession.loadcapability) - Resume previous sessions via
session/resume(if the Agent supports thesession.resumecapability) - Close active sessions via
session/close(if the Agent supports thesession.closecapability)
Working Directory
Thecwd (current working directory) parameter establishes the primary 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
- MUST remain the base for relative-path resolution
- MUST be part of the session’s effective root set
session.additionalDirectories is in use, the session’s effective root set is [cwd, ...additionalDirectories]. This root set 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. Agents advertise supported transports during initialization usingsession.mcp.stdio, session.mcp.http, and any extension-specific transport capabilities.
Transport Types
Every MCP server object has atype discriminator that identifies its transport. Custom implementation-specific transport types MUST begin with _; unknown non-underscore transport types are reserved for future ACP variants.
Stdio Transport
When the Agent supportssession.mcp.stdio, Clients can specify MCP servers configurations using the stdio transport.
Must be
"stdio" to indicate stdio transportA 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 supportssession.mcp.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
Checking Transport Support
Before using stdio or HTTP transports, Clients MUST verify the Agent’s capabilities during initialization:session.mcp.stdio is omitted or null, the Agent does not support stdio transport.
If session.mcp.http is omitted or null, the Agent does not support HTTP transport.
Supplying {} means the Agent supports the corresponding 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.