Skip to content

Pool stdio MCP connections between tool calls - #1861

Merged
RhysSullivan merged 1 commit into
mainfrom
stdio-mcp-pooling
Aug 30, 2026
Merged

Pool stdio MCP connections between tool calls#1861
RhysSullivan merged 1 commit into
mainfrom
stdio-mcp-pooling

Conversation

@RhysSullivan

@RhysSullivan RhysSullivan commented Aug 30, 2026

Copy link
Copy Markdown
Collaborator

Every tool call on a stdio MCP integration spawned a fresh child process, ran the full MCP handshake, called one tool, and tore the child down. Measured with @modelcontextprotocol/server-everything on the local daemon: 875–897ms on every call of a no-op echo, flat. This is the desktop/local host only — cloud disables stdio — and it is the dominant per-call overhead for anyone running npx-launched servers.

Plain stdio now joins the existing connection pool that remote and app-server connections already use: same five-minute idle window, same hashed identity key, same drop-on-transport-failure semantics. Identity separates on command, args, cwd, secret env, credential values, template, owner, and connection, and plain stdio never shares a session with the app-server bridge. Per-call elicitation handlers were already rebound on each pooled use, so reuse changes no elicitation behavior.

Opt-out: spawnPerCall: true in the stdio config (also accepted by the add-server API) restores fresh-process-per-call for servers that depend on it. The app-server bridge ignores the flag — its approvals are session state.

Measured on this branch, same server and tool:

before after
stdio echo, first call ~880ms 585ms (spawn + handshake, then parked)
stdio echo, subsequent calls 875–897ms each 3.5–8ms
pooled children during a burst n/a exactly 1
children after server shutdown 0 (pool closes with the plugin)

New tests pin the poolability predicate (default on, opt-out honored, bridge always pooled) and the stdio key separation properties (secret env, command/args/cwd, bridge-vs-plain, owner).

Codex plugin compatibility (checked against #1837/#1858/#1859): curated plugins ride the app-server bridge and were pooled before this change — no behavior change. Scanned cache plugins spawn their own MCP server binary and now pool like any stdio server; their tests pass and none rely on fresh-process semantics. One noted shift: after a plugin update moves the versioned cache dir, a parked child keeps serving until the idle window or a transport failure drops it, so the "command missing" health signal appears on the next fresh dial rather than on the very next call.

@github-actions

github-actions Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Cloudflare preview

Torn down — the PR is closed.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
executor-marketing 5632b28 Commit Preview URL

Branch Preview URL
Aug 30 2026, 12:11 AM

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
executor-cloud 5632b28 Aug 30 2026, 12:12 AM

@pkg-pr-new

pkg-pr-new Bot commented Aug 30, 2026

Copy link
Copy Markdown

Open in StackBlitz

@executor-js/cli

npm i https://pkg.pr.new/@executor-js/cli@1861

@executor-js/config

npm i https://pkg.pr.new/@executor-js/config@1861

@executor-js/execution

npm i https://pkg.pr.new/@executor-js/execution@1861

@executor-js/sdk

npm i https://pkg.pr.new/@executor-js/sdk@1861

@executor-js/codemode-core

npm i https://pkg.pr.new/@executor-js/codemode-core@1861

@executor-js/runtime-quickjs

npm i https://pkg.pr.new/@executor-js/runtime-quickjs@1861

@executor-js/plugin-file-secrets

npm i https://pkg.pr.new/@executor-js/plugin-file-secrets@1861

@executor-js/plugin-graphql

npm i https://pkg.pr.new/@executor-js/plugin-graphql@1861

@executor-js/plugin-keychain

npm i https://pkg.pr.new/@executor-js/plugin-keychain@1861

@executor-js/plugin-mcp

npm i https://pkg.pr.new/@executor-js/plugin-mcp@1861

@executor-js/plugin-onepassword

npm i https://pkg.pr.new/@executor-js/plugin-onepassword@1861

@executor-js/plugin-openapi

npm i https://pkg.pr.new/@executor-js/plugin-openapi@1861

executor

npm i https://pkg.pr.new/executor@1861

commit: 5632b28

@RhysSullivan
RhysSullivan marked this pull request as ready for review August 30, 2026 00:43
@RhysSullivan
RhysSullivan merged commit 4d4ad7c into main Aug 30, 2026
43 of 44 checks passed
@RhysSullivan RhysSullivan mentioned this pull request Aug 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant