ec2b666284
Continuous Integration / Pre-commit Linter (push) Waiting to run
Continuous Integration / Mypy Check (Python 3.10) (push) Waiting to run
Continuous Integration / Mypy Check (Python 3.11) (push) Waiting to run
Continuous Integration / Mypy Check (Python 3.12) (push) Waiting to run
Continuous Integration / Mypy Check (Python 3.13) (push) Waiting to run
Continuous Integration / Unit Tests (Python 3.10) (push) Waiting to run
Continuous Integration / Unit Tests (Python 3.11) (push) Waiting to run
Continuous Integration / Unit Tests (Python 3.12) (push) Waiting to run
Continuous Integration / Unit Tests (Python 3.13) (push) Waiting to run
Continuous Integration / Unit Tests (Python 3.14) (push) Waiting to run
Continuous Integration / A2A v0.3 Tests (Python 3.10) (push) Waiting to run
Continuous Integration / A2A v0.3 Tests (Python 3.11) (push) Waiting to run
Continuous Integration / A2A v0.3 Tests (Python 3.12) (push) Waiting to run
Continuous Integration / A2A v0.3 Tests (Python 3.13) (push) Waiting to run
Continuous Integration / A2A v0.3 Tests (Python 3.14) (push) Waiting to run
Copybara PR Handler / close-imported-pr (push) Waiting to run
1.7 KiB
1.7 KiB
Agent Registry Sample
This sample demonstrates how to use the AgentRegistry client to discover agents and MCP servers registered in Google Cloud.
Setup
- Ensure you have Google Cloud credentials configured (e.g.,
gcloud auth application-default login). - Set the following environment variables:
export GOOGLE_CLOUD_PROJECT=your-project-id
export GOOGLE_CLOUD_LOCATION=global # or your specific region
-
Obtain the full resource names for the agents and MCP servers you want to use. You can do this by running the sample script once to list them:
python3 agent.pyAlternatively, use
gcloudto list them:# For agents gcloud alpha agent-registry agents list --project=$GOOGLE_CLOUD_PROJECT --location=$GOOGLE_CLOUD_LOCATION # For MCP servers gcloud alpha agent-registry mcp-servers list --project=$GOOGLE_CLOUD_PROJECT --location=$GOOGLE_CLOUD_LOCATION -
Replace
AGENT_NAMEandMCP_SERVER_NAMEinagent.pywith the last part of the resource names (e.g., if the name isprojects/.../agents/my-agent, usemy-agent).
Running the Sample
Run the sample script to list available agents and MCP servers:
python3 agent.py
How it Works
The sample uses AgentRegistry to:
- List registered agents using
list_agents(). - List registered MCP servers using
list_mcp_servers(). - Search registered agents using
search_agents(search_string). - Search registered MCP servers using
search_mcp_servers(search_string).
It also shows (in comments) how to:
- Get a
RemoteA2aAgentinstance usingget_remote_a2a_agent(name). - Get an
McpToolsetinstance usingget_mcp_toolset(name).