Reuse downstream MCP sessions across tool calls#1435
Merged
Conversation
Contributor
Cloudflare previewTorn down — the PR is closed. |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
executor-marketing | c618b8f | Commit Preview URL Branch Preview URL |
Jul 20 2026, 06:17 AM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
executor-cloud | c618b8f | Jul 20 2026, 06:18 AM |
@executor-js/cli
@executor-js/config
@executor-js/execution
@executor-js/sdk
@executor-js/codemode-core
@executor-js/runtime-quickjs
@executor-js/plugin-file-secrets
@executor-js/plugin-graphql
@executor-js/plugin-keychain
@executor-js/plugin-mcp
@executor-js/plugin-onepassword
@executor-js/plugin-openapi
executor
commit: |
RhysSullivan
marked this pull request as ready for review
July 20, 2026 06:30
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Every MCP tool invocation dialed a fresh downstream connection and closed it after the call, so each call ran
initializeand got a newMcp-Session-Id. Downstream servers that key state by session (Render'sselect_workspace→list_logs, and similar) lose that state between calls: the first call succeeds, the next one lands in a brand-new session and fails.Observed in production against Render MCP (
select_workspaceok →list_logs/get_selected_workspacefailing whilelist_deploys— which takes an explicitserviceId— survives), and reproduced wire-level: two calls in one sandbox execution arrived at the fixture on two distinct session ids.Fix
Remote MCP invocations now lease connections from a per-plugin-instance pool:
tools/list_changedhandlers keep their current semantics.transportFailureflag onMcpInvocationError) close and drop it.closehook. stdio transports and endpoint probing/discovery remain strictly per-call.Tests
mcp-session-state.test.ts: a session-stateful MCP fixture (workspace-selection shape); asserts state set by call 1 is visible to call 2 and the fixture's request ledger saw exactly oneMcp-Session-Id. Failed before this change on selfhost and cloud; passes on both now.connection-pool.test.ts: sequential reuse (one session), concurrent leases (no serialization), transparent redial after server-side session loss, drop-on-failure.elicitation.test.tsextended: per-invoke elicitation handlers ride a reused session correctly (accept then decline over one session).mcp-catalog-sync(list_changed + unknown-tool healing) andpolicy-tool-approvale2e.Gates:
format:check,lint,typecheck, fullpackages/plugins/mcpsuite green.