Keep MCP tool calls bound to their thread (#36355)

## Why

Threads can configure the same MCP server name with different runtimes. Tool calls
must use the runtime associated with the thread that issued the call.

## What changed

- Route MCP readiness checks and call preparation through the invoking session.
- Add regression coverage that alternates calls between two threads and verifies
  that each thread continues using its own MCP server process and configuration.

GitOrigin-RevId: 5735f7b29a579f545351385ab01a575e35ead01e
This commit is contained in:
jif authored and copyberry committed 2026-07-31 16:12:46 +00:00
1 parent 35eab50501
commit c4f2746c43
4 files changed
+169 -14

No files matched your search

+1 -4
View File
@@ -170,11 +170,8 @@ impl McpHandler {
impl CoreToolRuntime for McpHandler {
fn wait_until_ready<'a>(&'a self, session: &'a Arc<Session>) -> Option<BoxFuture<'a, ()>> {
Some(Box::pin(async move {
session.refresh_mcp_if_dirty().await;
session
.services
.mcp_runtime
.wait_for_server_startup(&self.tool_info.server_name)
.wait_for_mcp_server(&self.tool_info.server_name)
.await;
}))
}