You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This sample demonstrates how to use the `AgentRegistry` client to discover agents and MCP servers registered in Google Cloud.
4
+
5
+
## Setup
6
+
7
+
1. Ensure you have Google Cloud credentials configured (e.g., `gcloud auth application-default login`).
8
+
2. Set the following environment variables:
9
+
10
+
```bash
11
+
export GOOGLE_CLOUD_PROJECT=your-project-id
12
+
export GOOGLE_CLOUD_LOCATION=global # or your specific region
13
+
```
14
+
15
+
3. 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:
16
+
17
+
```bash
18
+
python3 agent.py
19
+
```
20
+
21
+
Alternatively, use `gcloud` to list them:
22
+
23
+
```bash
24
+
# For agents
25
+
gcloud alpha agent-registry agents list --project=$GOOGLE_CLOUD_PROJECT --location=$GOOGLE_CLOUD_LOCATION
26
+
27
+
# For MCP servers
28
+
gcloud alpha agent-registry mcp-servers list --project=$GOOGLE_CLOUD_PROJECT --location=$GOOGLE_CLOUD_LOCATION
29
+
```
30
+
31
+
4. Replace `AGENT_NAME` and `MCP_SERVER_NAME`in`agent.py` with the last part of the resource names (e.g., if the name is `projects/.../agents/my-agent`, use `my-agent`).
32
+
33
+
## Running the Sample
34
+
35
+
Run the sample script to list available agents and MCP servers:
36
+
37
+
```bash
38
+
python3 agent.py
39
+
```
40
+
41
+
## How it Works
42
+
43
+
The sample uses `AgentRegistry` to:
44
+
- List registered agents using `list_agents()`.
45
+
- List registered MCP servers using `list_mcp_servers()`.
46
+
47
+
It also shows (in comments) how to:
48
+
- Get a `RemoteA2aAgent` instance using `get_remote_a2a_agent(name)`.
49
+
- Get an `McpToolset` instance using `get_mcp_toolset(name)`.
0 commit comments