Skip to content

The agent that grows with you

fix(mcp): ssl_verify and strict_redirect_headers are part of the shared connection's identity

John Paul Solivaff0eab89385e
diff --git a/tests/tools/test_mcp_multiplex_connection_keys.py b/tests/tools/test_mcp_multiplex_connection_keys.py
index 7112c4b2e3f..d962a6da7fa 100644
--- a/tests/tools/test_mcp_multiplex_connection_keys.py
+++ b/tests/tools/test_mcp_multiplex_connection_keys.py
@@ -152,6 +152,26 @@ def test_same_named_server_with_other_mtls_identity_is_a_separate_connection(two
assert "x" in disc._select_new_servers({"x": cfg_b})
[email protected]("policy", [{"ssl_verify": False}, {"strict_redirect_headers": True}])
+def test_cross_profile_share_refuses_on_connection_policy_differences(two_profiles, policy):
+ """``ssl_verify`` and ``strict_redirect_headers`` shape the live connection: a profile must
+ never inherit another profile's TLS-verification or redirect-header policy through adoption."""
+ from tools import mcp_tool_discovery as disc
+ from tools import mcp_tool_registration as reg
+
+ cfg_a = {"url": "https://mcp.example/x", **policy}
+ cfg_b = {"url": "https://mcp.example/x"}
+
+ 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")
+ assert reg.register_connected_into_current_scope({"x": cfg_b}) == 0
+ 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 core
from tools import mcp_tool_discovery as disc, mcp_tool_lifecycle as lifecycle
diff --git a/tools/mcp_tool_registration.py b/tools/mcp_tool_registration.py
index 33dad5c36de..7d16a735a44 100644
--- a/tools/mcp_tool_registration.py
+++ b/tools/mcp_tool_registration.py
@@ -411,17 +411,19 @@ def _register_server_tools(name: str, server: "MCPServerTask", config: dict) ->
def _connection_identity(config: dict) -> tuple:
"""What makes one live connection reusable for another profile: the route fingerprint PLUS
- everything that authenticates it (``config_fingerprint`` deliberately excludes credentials so
- the schema cache survives a token rotation). Two profiles pointing at the same URL with different
- headers/env/auth/client certificates are two identities; borrowing across them would call tools
- as the other user."""
+ everything that authenticates or secures it (``config_fingerprint`` deliberately excludes
+ credentials so the schema cache survives a token rotation). Two profiles pointing at the same URL
+ with different headers/env/auth/client certificates/TLS policy are two identities; borrowing
+ across them would call tools as the other user, or under the other profile's ``ssl_verify`` /
+ ``strict_redirect_headers``."""
from tools.mcp_schema_cache import config_fingerprint
def _frozen(value):
return json.dumps(value or {}, sort_keys=True, default=str)
return (config_fingerprint(config), _frozen(config.get("env")), _frozen(config.get("headers")),
- _auth_type(config), _frozen(config.get("client_cert")), _frozen(config.get("client_key")))
+ _auth_type(config), _frozen(config.get("client_cert")), _frozen(config.get("client_key")),
+ config.get("ssl_verify", True), bool(config.get("strict_redirect_headers")))
def _auth_type(config: dict) -> str: