MCP logical sessions vs transport (MCP-Session-Id)¶
Historical behavior (superseded for MCP tools)¶
Previously, Plasm bound one execute session (prompt_hash, session_id) per MCP transport session (Streamable HTTP MCP-Session-Id / SDK session id). Tool state (plasm_context → plasm), short artifact refs plasm://r/{n}, and trace roots were all keyed by that transport handle.
That model breaks when:
- Multiple agent instances or windows share one MCP connection.
- The same agent needs several independent symbol spaces / execute sessions over one transport.
- Horizontal scaling requires resuming work without sticky transport affinity.
Current model¶
-
Transport session — Still the Streamable HTTP / SDK session: used for auth, connection lifecycle, and correlation only (which physical MCP connection issued a call).
-
Logical session — The canonical Plasm session for prompts, execute
(prompt_hash, session_id), monotonice#/m#/p#, run artifacts, and trace root identity: intent— Host-chosen stable string for the agent context (window, subagent, or other boundary the host defines); MCP JSON field onplasm_context; used for idempotent opens. The server does not infer this from the MCP transport. See MCP session reuse.- Canonical id — Server-minted UUID (
logical_session_idinternally): global stable identifier for archives, traces, and cross-replica correlation (when backed by shared storage). logical_session_ref— Per MCP transport slot string (s0,s1, …) returned byplasm_context, analogous to run artifact indexr/{n}but naming the logical session. Agents pass this ref toplasmand see it in short run URIs.-
Paginated list continuations — Opaque handles are
s0_pg1,s0_pg2, … (slot + sequence): usepage(s0_pgN)from tool results, not plainpage(pgN). -
Flow —
plasm_contextfirst withintentand non-emptyseeds, then mostlyplasmwithlogical_session_ref. Short run URIs useplasm://session/{logical_session_ref}/r/{n}; canonicalplasm://execute/.../run/{uuid}remains accepted onresources/read. Legacyplasm://r/{n}remains accepted for older run links that were created without a logical id. Thoseplasm://…URIs are MCPresources/readidentifiers, not strings you pass back into theplasmtool as Plasm path expressions.
In-process vs scaled deployments¶
Today, logical session metadata and execute bindings are still in-memory in plasm-agent. Surviving process restart or moving to another replica requires a shared logical session repository (out of scope for this document’s implementation phase); the types and IDs are chosen so that repository can be added without changing the client contract.
Related code¶
- MCP handler:
crates/plasm-agent-core/src/mcp_server.rs - Logical session registry:
crates/plasm-agent-core/src/session_identity.rs - Trace correlation:
docs/mcp-trace-correlation.md - Incremental DOMAIN:
docs/incremental-domain-prompts.md - Session reuse and
SessionReuseKey:docs/mcp-session-reuse.md