Repository navigation
[MCP caching]: pool MCP backends in thread manager - #15258
jgershen-oai wants to merge 2 commits into
Conversation
2eb5d61 to
a97ee12
Compare
1b23646 to
4a4b5d1
Compare
15a0803 to
05c88b6
Compare
| store_mode: OAuthCredentialsStoreMode, | ||
| auth_entries: HashMap<String, McpAuthStatusEntry>, | ||
| tx_event: Sender<Event>, | ||
| initial_sandbox_state: SandboxState, |
There was a problem hiding this comment.
Is all sandboxing stuff purely for codex/sandbox-state/update? If so the shell mcp is going to get removed today/tomorrow so we can shed the sandboxing complexity.
| impl SharedMcpBackendCacheKey { | ||
| pub(crate) fn new( | ||
| mcp_servers: &HashMap<String, McpServerConfig>, | ||
| store_mode: OAuthCredentialsStoreMode, |
There was a problem hiding this comment.
Does this ever change mid session?
| pub(crate) struct SessionServices { | ||
| pub(crate) mcp_connection_manager: Arc<RwLock<McpConnectionManager>>, | ||
| pub(crate) mcp_startup_cancellation_token: Mutex<CancellationToken>, | ||
| pub(crate) shared_mcp_backend_pool: Option<Arc<SharedMcpBackendPool>>, |
There was a problem hiding this comment.
Having both mcp_manager and shared_mcp_backend_pool here feels like bad API that leaks implementation details.
| let (mcp_connection_manager, cancel_token) = async { | ||
| match sess.services.shared_mcp_backend_pool.as_ref() { | ||
| Some(shared_mcp_backend_pool) => { | ||
| McpConnectionManager::new_with_pool( |
There was a problem hiding this comment.
this logic shouldn't be in codex. Pooling decisions should be hidden by McpConnectionManager or SharedMcpBackendPool
|
|
||
| impl SharedMcpBackendCacheKey { | ||
| pub(crate) fn new( | ||
| mcp_servers: &HashMap<String, McpServerConfig>, |
There was a problem hiding this comment.
I'd expect a key to be per server not per group of them, what am I missing?
|
|
||
| struct SharedMcpBackendLeaseInner { | ||
| backend: Arc<SharedMcpBackend>, | ||
| cancel_token: CancellationToken, |
There was a problem hiding this comment.
this is the startup cancellation, right? how do you drop the lease/free the server?
|
Closing this pull request because it has had no updates for more than 14 days. If you plan to continue working on it, feel free to reopen or open a new PR. |
Depends on #15256.
Summary
This is the PR that actually makes MCP backend reuse happen across loaded threads.
ThreadManager-owned pool of shared MCP backends for enabledStdioMCP serversStreamableHttpMCPs, includingcodex_apps, per-thread/localWhy
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_appsinto a shared HTTP bottleneck or introducing cross-thread elicitation routing.Testing