Skip to content

ACP: re-mount client MCP on session/load + mid-session teardown (Slice B of #7) #9

Closed

Description

@JAORMX

Follow-up to #7 (done in 4baf34a, which shipped Slice A: accept streaming-HTTP client MCP on session/new).

Deferred from #7 Slice A

  1. session/load re-mount. Today session/load hard-rejects any client mcpServers (fail-loud). A re-attaching editor that re-sends its streaming-HTTP servers on load should get them re-mounted into a per-session engine, same as session/new. ACP allows mcpServers on session/load. Needs a LoadSessionWithMCP symmetric to CreateSessionWithMCP, reusing the existing SessionEngineFactory seam — no persistence required (the editor re-sends the specs).
  2. Mid-session teardown. Per-session MCP connections currently close only on editor disconnect (closeTrackedSessions) or process exit (Service.Close). ACP has no per-session-end RPC, so a long-lived connection that opens many sessions holds their MCP connections until disconnect. Consider a finer teardown hook if a real need emerges. (Connection-lifetime teardown is correct for a typical interactive editor; this is a refinement.)

Out of scope (intentional, per #7)

  • Metadata-IP/link-local SSRF filtering — out under the local-editor trust model (see ADR 0001).

Context: docs/adr/0001-acp-adapter.md (Client streaming-HTTP MCP section), internal/adapter/server/service.go (SessionEngineFactory, CreateSessionWithMCP, CloseSession).

Activity

  1. JAORMX commented on Jun 1, 2026

    @JAORMX
    ContributorAuthor

    Shipped — closing as done (both slices of Slice B)

    1. session/load re-mount — 943ab7e

    Service.LoadSessionWithMCP, symmetric to CreateSessionWithMCP, reusing the existing SessionEngineFactory seam (no new seam, no proto change). Empty specs delegate to LoadSession (shared engine); with specs it loads/reopens first (so an unknown id fails fast with no wasted MCP connect), then builds + registers the per-session engine. handleSessionLoad switched from the blanket reject to the same partitionClientMCP + re-mount + trackSession flow as session/new — stdio/sse reject, SSRF allowlist, server cap, and connect timeout all apply identically. A re-load leak guard closes a prior per-session engine before replacing for the same id. fs/* on load deliberately stays osfs (separate deferred item).

    2. Mid-session teardown — 0c79b94

    Originally proposed for deferral on the premise that "ACP has no per-session-end RPC." That premise was wrong — ACP defines a first-class session/close request (capability-gated by agentCapabilities.sessionCapabilities.close, confirmed against the canonical schema). So we wired the real signal rather than a TTL/LRU heuristic. handleSessionClose cancels any in-flight run (spec-mandated "MUST cancel ongoing work"), untracks the session (so the disconnect path doesn't double-close), then runs Service.EndSession. It shares the EndSession teardown step with the #10 gRPC CloseSession RPC / HTTP DELETE, but is not behaviorally identical — only session/close cancels; the others leave cancel to a separate endpoint. Confined to the acp adapter — no new Service method, port, clock, or goroutine.

    No deferred items remain. Tests offline (mockllm + memfs); reviewed across spec + standards + security + architecture panels for each commit.

    Aside: while evaluating whether to adopt an ACP Go library vs the hand-rolled adapter, we found and fixed a separate transport bug — conn.go framed messages with LSP-style Content-Length headers, but ACP mandates newline-delimited JSON, so it couldn't interop with a real client (fixed in b7aef5a, with the loopback test blind-spot closed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions