The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(mcp): isolate mTLS connection identities
KoNit-Kbbe40894057b
diff --git a/tests/tools/test_mcp_multiplex_connection_keys.py b/tests/tools/test_mcp_multiplex_connection_keys.pyindex 8a2b36bf542..31b96ecacf9 100644--- a/tests/tools/test_mcp_multiplex_connection_keys.py+++ b/tests/tools/test_mcp_multiplex_connection_keys.py@@ -109,6 +109,31 @@ def test_oauth_server_is_not_adopted_across_profiles(two_profiles):assert "x" in disc._select_new_servers({"x": dict(cfg)})+def test_same_named_server_with_other_mtls_identity_is_a_separate_connection(two_profiles):+ from tools import mcp_tool_discovery as disc+ from tools import mcp_tool_registration as reg++ cfg_a = {+ "url": "https://mcp.example/x",+ "client_cert": "/certs/profile-a.pem",+ "client_key": "/certs/profile-a.key",+ }+ cfg_b = {+ "url": "https://mcp.example/x",+ "client_cert": "/certs/profile-b.pem",+ "client_key": "/certs/profile-b.key",+ }++ two_profiles("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")+ reg.register_connected_into_current_scope({"x": cfg_b})+ assert "x" in disc._select_new_servers({"x": cfg_b})++def test_owner_reload_reregisters_profiles_that_adopted_its_connection(two_profiles):import tools.mcp_tool as corefrom tools import mcp_tool_discovery as disc, mcp_tool_lifecycle as lifecyclediff --git a/tools/mcp_tool_registration.py b/tools/mcp_tool_registration.pyindex aff3544dfae..cf98054e82d 100644--- a/tools/mcp_tool_registration.py+++ b/tools/mcp_tool_registration.py@@ -403,14 +403,16 @@ def _connection_identity(config: dict) -> tuple:"""What makes one live connection reusable for another profile: the route fingerprint PLUSeverything that authenticates it (``config_fingerprint`` deliberately excludes credentials sothe schema cache survives a token rotation). Two profiles pointing at the same URL with different- headers/env/auth are two identities; borrowing across them would call tools as the other user."""+ headers/env/auth/client certificates are two identities; borrowing across them would call tools+ as the other user."""from tools.mcp_schema_cache import config_fingerprintdef _frozen(value):return json.dumps(value or {}, sort_keys=True, default=str)return (config_fingerprint(config), _frozen(config.get("env")), _frozen(config.get("headers")),- (config.get("auth") or "").lower().strip())+ (config.get("auth") or "").lower().strip(), _frozen(config.get("client_cert")),+ _frozen(config.get("client_key")))def _same_server_route(server: Any, config: dict, *, cross_profile: bool = False) -> bool: