fix(agent_registry): source MCP destination ID from RuntimeReference.uri - #7197
Open
chelsealong wants to merge 1 commit into
Open
chelsealong wants to merge 1 commit into
chelsealong wants to merge 1 commit into
Conversation
get_mcp_toolset() stamped gcp.mcp.server.destination.id on tools using mcpServerId, a urn:mcp:... value. The Agent Platform Topology view's connection matcher resolves against the App Hub resource-name URI form instead, which the Agent Registry API returns in the same response under attributes["agentregistry.googleapis.com/system/RuntimeReference"]["uri"]. Since the two never matched, no topology connection was ever drawn for an MCP server reached through AgentRegistry. Prefer RuntimeReference.uri for the destination span attribute, falling back to mcpServerId when the attribute is absent. mcpServerId is left unchanged everywhere else (e.g. IAM binding resolution), which still expects the urn form. Fixes google#7196
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
Problem:
AgentRegistry.get_mcp_toolset()stamps thegcp.mcp.server.destination.idspan attribute (used by the Agent Platform Topology view to draw a
connection from an agent to the MCP server it calls) from the Agent
Registry API's
mcpServerIdfield, aurn:mcp:...value. The Topologyview's connection matcher resolves against the App Hub resource-name URI
form instead (
//agentregistry.googleapis.com/projects/<number>/locations/ <region>/services/<name>), which the same API response already returns,unused, under
attributes["agentregistry.googleapis.com/system/RuntimeReference"]["uri"].Because the two identifier forms never match, no topology connection is
ever drawn for an MCP server reached through
AgentRegistry/AgentRegistrySingleMcpToolset, regardless of correct registration.Solution:
In
get_mcp_toolset(), sourcedestination_resource_idfromattributes["agentregistry.googleapis.com/system/RuntimeReference"]["uri"]when present, falling back to
mcpServerIdonly if that attribute isabsent.
mcpServerIditself is left untouched everywhere else in the file(e.g.
_resolve_auth_provider_scheme, which matches it against IAMbinding targets and still expects the urn form) — this is a one-field,
single-call-site change.
Testing Plan
Unit Tests:
Added
test_get_mcp_toolset_prefers_runtime_reference_uritotests/unittests/integrations/agent_registry/test_agent_registry.py,which mocks an MCP server response containing both
mcpServerIdandattributes["agentregistry.googleapis.com/system/RuntimeReference"]["uri"]and asserts the tool's
custom_metadata[GCP_MCP_SERVER_DESTINATION_ID]is the
RuntimeReference.urivalue, notmcpServerId.Confirmed the new test fails without the fix (reverting only
agent_registry.pyviagit stash) with:Full suite for the touched module, with the fix applied:
pre-commit run --files src/google/adk/integrations/agent_registry/agent_registry.py tests/unittests/integrations/agent_registry/test_agent_registry.pypasses (ruff, isort, pyink, addlicense, compliance checks, codespell).
Manual End-to-End (E2E) Tests:
Not performed — this requires a live Google Cloud Agent Registry
deployment with a registered MCP server and OTLP export to
telemetry.googleapis.com, which is unavailable in this environment.Covered instead by the unit test above, which reproduces the exact
API response shape from the issue report (both
mcpServerIdandRuntimeReference.uripresent) and asserts the observable output(
custom_metadata[GCP_MCP_SERVER_DESTINATION_ID]).Checklist
Additional context
This change was written with AI assistance (Claude Code), with all
changes reviewed and verified by the human account opening this PR.
Fixes #7196