Skip to content

The agent that grows with you

fix(mcp): refuse adoption with one sentinel when the adopter cannot resolve an identity

kshitijk4poorbe3274fcb02a
diff --git a/tests/gateway/test_multiplex_mcp_discovery.py b/tests/gateway/test_multiplex_mcp_discovery.py
index c67052174cf..c229152ff26 100644
--- a/tests/gateway/test_multiplex_mcp_discovery.py
+++ b/tests/gateway/test_multiplex_mcp_discovery.py
@@ -266,15 +266,16 @@ def test_shared_server_tools_are_callable_and_removed_on_non_owner_reload(
inputSchema={"type": "object", "properties": {}},
annotations=None,
)
+ shared_cfg = {"url": "https://default.example/mcp"} # connectable: the adopter resolves its identity
server = SimpleNamespace(
name="shared",
session=object(),
_tools=[tool],
tool_timeout=30,
_registered_tool_names=[],
- _config={},
+ _config=dict(shared_cfg),
initialize_result=None,
- _resolved_identity=_mcp_registration._adopter_identity_digest("shared", {}),
+ _resolved_identity=_mcp_registration._adopter_identity_digest("shared", shared_cfg),
)
owner_tool_name = "mcp__shared__echo"
registry.register(
@@ -304,7 +305,7 @@ def test_shared_server_tools_are_callable_and_removed_on_non_owner_reload(
try:
monkeypatch.setattr(mcp_tool, "_ensure_mcp_sdk", lambda: True)
monkeypatch.setattr(_mcp_config, "_filter_suspicious_mcp_servers", lambda servers: servers)
- assert _mcp_discovery.register_mcp_servers({"shared": {}})
+ assert _mcp_discovery.register_mcp_servers({"shared": dict(shared_cfg)})
tool_names = registry.get_tool_names_for_toolset("mcp-shared")
assert tool_names
assert callable(registry.get_entry(tool_names[0]).handler)
diff --git a/tools/mcp_tool_registration.py b/tools/mcp_tool_registration.py
index b538e0fa352..4fbb79afc84 100644
--- a/tools/mcp_tool_registration.py
+++ b/tools/mcp_tool_registration.py
@@ -442,15 +442,16 @@ def _adopter_identity_digest(server_name: str, config: dict) -> str | None:
default cwd; an HTTP connection's URL and headers after a ``server_json`` live endpoint and
``identity_header`` (``value_from: profile``). The transport publishes the digest of the very
inputs each attempt connects with; an adopter recomputes it here. A resolver failure refuses
- adoption for this server only (None), never discovery for the whole scope."""
+ adoption for this server only, never discovery for the whole scope. None is the one refuse
+ sentinel: no connectable config, no live endpoint, or a resolver failure."""
from tools.mcp_tool_transport import LiveEndpointUnavailable, _connect_inputs
if "url" not in config and not config.get("command"): # the transport refuses it before resolving
- return ""
+ return None
try:
inputs, _ = _connect_inputs(server_name, config)
except LiveEndpointUnavailable: # the transport cannot connect either; never equal to a live one
- return ""
+ return None
except Exception as exc: # fail closed for this server; the others still adopt
logger.warning("MCP server '%s': cannot resolve this profile's connection identity (%s); "
"not adopting another profile's connection", server_name, exc)