The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(mcp): supports_parallel_tool_calls is per profile, not per server name
teknium19d39267def9b
diff --git a/tests/tools/test_mcp_multiplex_connection_keys.py b/tests/tools/test_mcp_multiplex_connection_keys.pyindex b7f80a13b98..869f59d5064 100644--- a/tests/tools/test_mcp_multiplex_connection_keys.py+++ b/tests/tools/test_mcp_multiplex_connection_keys.py@@ -220,3 +220,24 @@ def test_untrusted_adopter_of_a_full_profiles_connection_keeps_its_own_trust_gattwo_profiles("a")assert handlers._trust_gate_check("x", "t") is None and len(asked) == 1++def test_parallel_safe_opt_in_is_per_profile(two_profiles):+ """B's ``supports_parallel_tool_calls`` on its own same-named server never makes A's serial+ server's tool parallel-safe (the batch planner would run two A calls concurrently)."""+ from tools import mcp_tool_discovery as disc, mcp_tool_registration as reg++ cfg_a = {"url": "https://mcp.example/x", "headers": {"Authorization": "Bearer A"}}+ cfg_b = dict(cfg_a, headers={"Authorization": "Bearer B"}, supports_parallel_tool_calls=True)++ two_profiles("a")+ disc._select_new_servers({"x": cfg_a})+ srv_a = _server("x", cfg_a)+ disc._adopt_server("x", srv_a)+ srv_a._registered_tool_names = reg._register_server_tools("x", srv_a, cfg_a)++ two_profiles("b")+ disc._select_new_servers({"x": cfg_b})+ assert disc.is_mcp_tool_parallel_safe("mcp__x__t") is True++ two_profiles("a")+ assert disc.is_mcp_tool_parallel_safe("mcp__x__t") is Falsediff --git a/tools/mcp_tool.py b/tools/mcp_tool.pyindex c1ac8d83c20..0703f8b4966 100644--- a/tools/mcp_tool.py+++ b/tools/mcp_tool.py@@ -499,8 +499,8 @@ def _reset_server_error(server_name: str) -> None:_server_errors_all_application.pop(key, None)-# Raw server names opted into parallel tool calls (``foo-bar``/``foo_bar`` sanitize alike but-# must not share policy).+# Servers opted into parallel tool calls, keyed by the consuming profile's own key (``foo-bar``/+# ``foo_bar`` sanitize alike but must not share policy; neither do two profiles' same-named servers)._parallel_safe_servers: set = set()# registry tool name -> raw server name (the generated name is lossy; never re-parse it)._mcp_tool_server_names: Dict[str, str] = {}diff --git a/tools/mcp_tool_discovery.py b/tools/mcp_tool_discovery.pyindex d424b9b3661..8a0429c2a7d 100644--- a/tools/mcp_tool_discovery.py+++ b/tools/mcp_tool_discovery.py@@ -262,12 +262,15 @@ def _select_new_servers(servers: Dict[str, dict]) -> Dict[str, dict]:_core._server_connecting.add(keys[srv_name])_core._server_scope_keys[keys[srv_name]] = current_scope_core._server_connect_errors.pop(keys[srv_name], None)- # Track which servers opt-in to parallel tool calls (idempotent).+ # Track which servers opt-in to parallel tool calls (idempotent). Keyed by THIS profile's own+ # key: the opt-in is the calling profile's policy, so B's parallel-safe `x` never makes A's+ # same-named serial `x` (own connection or adopted) run two calls at once.for srv_name, srv_cfg in servers.items():+ own_key = _server_key(srv_name, current_scope, current=False)if _parse_boolish(srv_cfg.get("supports_parallel_tool_calls", False), default=False):- _core._parallel_safe_servers.add(srv_name)+ _core._parallel_safe_servers.add(own_key)else:- _core._parallel_safe_servers.discard(srv_name)+ _core._parallel_safe_servers.discard(own_key)for srv in stale_cached:_loop._signal_reconnect(srv)return new_servers@@ -527,7 +530,7 @@ def is_mcp_tool_parallel_safe(tool_name: str) -> bool:return Falsewith _core._lock:server_name = _core._mcp_tool_server_names.get(tool_name)- return bool(server_name and server_name in _core._parallel_safe_servers)+ return bool(server_name and _server_key(server_name) in _core._parallel_safe_servers)def get_mcp_status(configured: Optional[Dict[str, dict]] = None, *, include_runtime: bool = True) -> List[dict]: