Skip to content

[SEP-2575][SEP-2567] 2026-06 stateless support: stdio + InMemory transports#2132

Draft
felixweinberger wants to merge 3 commits into
fweinberger/v2-http-statelessfrom
fweinberger/v2-pipe-transports
Draft

[SEP-2575][SEP-2567] 2026-06 stateless support: stdio + InMemory transports#2132
felixweinberger wants to merge 3 commits into
fweinberger/v2-http-statelessfrom
fweinberger/v2-pipe-transports

Conversation

@felixweinberger
Copy link
Copy Markdown
Contributor

@felixweinberger felixweinberger commented May 20, 2026

2026-06 stateless stack (v2-stateless label):

# PR
1 #2128 tasks-delete (mechanical)
2 #2129 schema-sync (mechanical)
3 #2130 Dispatcher extraction (zero-Δ refactor)
4 #2131 HTTP-stateless (the substantive review)
5 #2132 stdio/InMemory transports (additive)
6 #2133 docs + changeset
7 #2134 LegacyServer/LegacyClient extraction

Extends 2026-06 stateless support to stdio + InMemory transports. Additive: StreamDriver (client-side correlation for pipe transports), serverStatelessRouter (server-side per-message router), sendAndReceive impls. Migrates 189 connection-model tests to LegacyTestClient.

Motivation and Context

Same SEPs over non-HTTP transports.

How Has This Been Tested?

pnpm test:all (1367). InMemory acceptance scenarios + zeroChangeConsumer (same handler under both protocols).

Breaking Changes

None.

Types of changes

  • New feature

Checklist

  • My code follows the repository's style guidelines
  • New and existing tests pass locally

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 20, 2026

⚠️ No Changeset found

Latest commit: 32ef72b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 20, 2026

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/@modelcontextprotocol/client@2132

@modelcontextprotocol/server

npm i https://pkg.pr.new/@modelcontextprotocol/server@2132

@modelcontextprotocol/express

npm i https://pkg.pr.new/@modelcontextprotocol/express@2132

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/@modelcontextprotocol/fastify@2132

@modelcontextprotocol/hono

npm i https://pkg.pr.new/@modelcontextprotocol/hono@2132

@modelcontextprotocol/node

npm i https://pkg.pr.new/@modelcontextprotocol/node@2132

commit: 32ef72b

NEW core/shared/streamDriver.ts: minimal request->response correlator for
pipe-shaped client transports (one _pending map keyed by RequestId AND
String(id) for _meta.subscriptionId routing). sendAndReceive yields
notifications then one response (or indefinite for subscriptions/listen);
break/return() sends notifications/cancelled. Send-failure -> synthetic
error response (no hang). onMessage routes; close() ends all pending.

InMemoryTransport: composes StreamDriver. send() routes via _receive()
(driver claims first, falls through to onmessage). close() closes driver.

StdioClientTransport: composes StreamDriver. processReadBuffer routes to
driver when protocolVersion is unset or stateless. setProtocolVersion()
gates back to onmessage for legacy.

Satisfies: 2575-R12 (client sendAndReceive contract, pipe transports)
…outers

NEW core/shared/serverStatelessRouter.ts: routeServerStateless() —
per-message branch on isStatelessRequest to StatelessHandlers
{dispatch,listen}; notifications/cancelled aborts matching _inflight
controller.

stdio + InMemory server-side: receive paths route via
routeServerStateless; close() aborts all in-flight.

stdio + InMemory client-side: sendAndReceive threads opts?.signal to
StreamDriver.

Satisfies: 2567-R1 (pipe), 2567-R2
Migrate existing connection-model tests to LegacyTestClient (client.test,
server.test, mcp.test, elicitation.test, stateManagementStreamableHttp,
taskResumability) — they exercise server-to-client RPCs / oninitialized
which require the legacy initialize path.

statelessAcceptance.test.ts: add 'Client over InMemory' describe block
(auto-probe, legacy negotiate, subscribe demux, MRTR auto-resume).

NEW zeroChangeConsumer.test.ts: InMemory describe.each over Server/McpServer
ctors + MRTR hardening (accumulate, max-rounds, requestSampling).
@felixweinberger felixweinberger force-pushed the fweinberger/v2-http-stateless branch from dd9e762 to af76de4 Compare May 20, 2026 17:32
@felixweinberger felixweinberger force-pushed the fweinberger/v2-pipe-transports branch 2 times, most recently from 7995ab3 to 32ef72b Compare May 20, 2026 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v2-stateless 2026-06 SDK: Protocol decomposition + SEP alignment (request-first / stateless)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant