Skip to content

Move MCP session execution behind the Runtime #18

Description

@ethan-huo

Objective

Move all MCP connection creation, reuse, execution, notification attribution, and cancellation adaptation behind the MCP Runtime session pool.

Scope

  • Resolve server declarations and credentials inside the Runtime; the CLI no longer sends server config or headers.
  • Execute one active MCP request per server key through the Call signal.
  • Pass RequestOptions.signal alongside timeout and progress options.
  • Preserve stdio child and Streamable HTTP session reuse after Call cancellation.
  • Treat cancelled-request late responses as diagnostics rather than session corruption.
  • Preserve retained-session rejection, 401 eviction, notification buffering, and idle cleanup behavior where compatible with the accepted spec.

Non-goals

  • Concurrent upstream requests on one session.
  • Authentication initiation.
  • Real remote MCP acceptance tests.

TDD acceptance

  • Start with failing session-pool tests using deterministic local fixtures.
  • Cover cancellation respected, ignored, racing, late, and completion-before-disconnect for stdio and Streamable HTTP.
  • A second Call succeeds on the same connection/session before and after a late response.
  • Cancellation never evicts a healthy session.
  • A 401 follows credential-invalid/session-eviction policy and returns reauth-required; it does not start authentication.
  • Existing notification buffering and retained-session cases remain green.

Verification

  • Focused session/cancellation integration tests.
  • Existing daemon and notification suites.
  • Full test suite, typecheck, formatter check, and git diff --check.

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