The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(mcp): drive OAuth profile isolation through register_mcp_servers()
kshitijk4poor527bfe3cc0c0
diff --git a/tests/tools/test_mcp_multiplex_connection_keys.py b/tests/tools/test_mcp_multiplex_connection_keys.pyindex 31b96ecacf9..b77699635ed 100644--- a/tests/tools/test_mcp_multiplex_connection_keys.py+++ b/tests/tools/test_mcp_multiplex_connection_keys.py@@ -90,23 +90,38 @@ def test_same_named_server_with_other_credentials_is_a_separate_connection(two_pdef test_oauth_server_is_not_adopted_across_profiles(two_profiles):+ import tools.mcp_tool as corefrom tools import mcp_tool_discovery as discfrom tools import mcp_tool_registration as regfrom tools.registry import registrycfg = {"url": "https://mcp.example/x", "auth": "oauth"}- two_profiles("a")+ scope_a = two_profiles("a")srv_a = _server("x", cfg)disc._adopt_server("x", srv_a)srv_a._registered_tool_names = reg._register_server_tools("x", srv_a, cfg)assert reg.register_connected_into_current_scope({"x": dict(cfg)}) == 0assert registry.get_tool_names_for_toolset("mcp-x") == ["mcp__x__t"]- two_profiles("b")+ scope_b = two_profiles("b")assert reg.register_connected_into_current_scope({"x": dict(cfg)}) == 0assert registry.get_tool_names_for_toolset("mcp-x") == []- assert "x" in disc._select_new_servers({"x": dict(cfg)})++ # Driven through the public entry point, B must open its own connection (its own OAuth+ # token) rather than adopt A's session.+ connected = []++ def fake_pass(new_servers):+ for name, config in new_servers.items():+ connected.append(_server(name, config))+ disc._adopt_server(name, connected[-1])++ with patch.object(disc, "_run_discovery_pass", fake_pass), \+ patch.object(disc._loop, "_ensure_mcp_loop", lambda: None):+ disc.register_mcp_servers({"x": dict(cfg)})+ assert connected and core._servers[(scope_b, "x")] is connected[0]+ assert core._servers[(scope_a, "x")] is srv_adef test_same_named_server_with_other_mtls_identity_is_a_separate_connection(two_profiles):