Skip to content

[MCP caching]: pool MCP backends in thread manager#15258

Open
jgershen-oai wants to merge 2 commits intocodex/jgershen-mcp-backend-session-boundaryfrom
codex/jgershen-mcp-threadmanager-pool
Open

[MCP caching]: pool MCP backends in thread manager#15258
jgershen-oai wants to merge 2 commits intocodex/jgershen-mcp-backend-session-boundaryfrom
codex/jgershen-mcp-threadmanager-pool

Conversation

@jgershen-oai
Copy link
Collaborator

@jgershen-oai jgershen-oai commented Mar 20, 2026

Depends on #15256.

Summary

This is the PR that actually makes MCP backend reuse happen across loaded threads.

  • add a ThreadManager-owned pool of shared MCP backends for enabled Stdio MCP servers
  • keep StreamableHttp MCPs, including codex_apps, per-thread/local
  • force-rebuild the pooled stdio half on refresh, and reacquire it when sandbox state changes
  • add stdio-focused app-server lifecycle coverage for unsubscribe, archive, and archive -> unarchive -> resume

Why

The concrete bug here is duplicate local MCP processes when multiple loaded threads use the same stdio MCP configuration. Pooling only stdio backends fixes that without turning codex_apps into a shared HTTP bottleneck or introducing cross-thread elicitation routing.

Testing

  • cargo check -p codex-core
  • cargo test -p codex-core mcp_connection_manager::tests::
  • cargo test -p codex-core pooled_new_turn_keeps_local_mcp_startup_token_when_sandbox_state_changes
  • cargo test -p codex-app-server thread_mcp_pool
  • cargo test -p codex-app-server mcp_server_elicitation

@jgershen-oai jgershen-oai changed the title feat(core): pool MCP backends in thread manager [MCP caching]: pool MCP backends in thread manager Mar 20, 2026
@etraut-openai etraut-openai added the oai PRs contributed by OpenAI employees label Mar 20, 2026
@jgershen-oai jgershen-oai force-pushed the codex/jgershen-mcp-threadmanager-pool branch from 2eb5d61 to a97ee12 Compare March 20, 2026 07:11
@jgershen-oai jgershen-oai force-pushed the codex/jgershen-mcp-elicitation-router branch from 1b23646 to 4a4b5d1 Compare March 20, 2026 07:11
@jgershen-oai jgershen-oai marked this pull request as ready for review March 20, 2026 07:41
@jgershen-oai jgershen-oai requested a review from pakrym-oai March 20, 2026 07:41
@jgershen-oai jgershen-oai changed the base branch from codex/jgershen-mcp-elicitation-router to codex/jgershen-mcp-backend-session-boundary March 20, 2026 18:53
@jgershen-oai jgershen-oai force-pushed the codex/jgershen-mcp-threadmanager-pool branch from 15a0803 to 05c88b6 Compare March 20, 2026 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

oai PRs contributed by OpenAI employees

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants