Installation
copilot plugin marketplace add samueltauil/skills-hub
copilot plugin install agent-platform-agent-registry@skills-hub
Works with GitHub Copilot CLI and VS Code (enable chat.plugins.enabled).
Plugin agent-platform-agent-registry v1.0.0 follows the Agent Plugins spec.
gh skills-hub install agent-platform-agent-registry Don't have the extension? Run gh extension install samueltauil/skills-hub first.
Download and extract to your repository:
.github/skills/agent-platform-agent-registry/ Extract the ZIP to .github/skills/ in your repo. The folder name must match agent-platform-agent-registry for Copilot to auto-discover it.
Skill Files (7)
SKILL.md 33.3 KB
---
name: agent-platform-agent-registry
description: >-
Manages Google Cloud Agent Registry (agentregistry.googleapis.com) resources
using gcloud CLI and Kubernetes manifests, including agents, MCP servers,
endpoints, services, bindings, AI applications, skills and skill revisions,
resource-level IAM policies, Cloud Run and GKE automatic workload
registration, Cloud Resource Manager management boundaries, 5-endpoint Quick
Add for Agent Gateway, and Python ADK integration. Use when registering,
discovering, searching, filtering, or governing agents, MCP servers,
endpoints, skills, AI applications, or management boundaries in Google Cloud
Agent Registry. Don't use for the preview AI Platform Skill Registry Python
scripts (use agent-platform-skill-registry), deploying raw Vertex AI Agent
Engine code (use agent-platform-deploy), or runtime trace debugging (use
agent-platform-troubleshooting).
metadata:
version: "1.0.0"
category: AiAndMachineLearning
---
<!-- disableFinding(LINE_OVER_80) -->
# Google Cloud Agent Registry
Interact with Google Cloud Agent Registry using `gcloud agent-registry` (`agents`, `mcp-servers`, `services`, `endpoints`, `bindings`, `skills`, `findings`, `publishers`, `ai-applications`, `operations`), `gcloud beta run` (`--functional-type` and `--identity-type` for automatic registration of Cloud Run services and jobs), Kubernetes manifests and [scripts/annotate_gke.py](scripts/annotate_gke.py) (GKE automatic registration), `gcloud resource-manager` (`boundary-configs`, `capability-configs`, `boundaries`, and `tags bindings` for management boundaries), and Python ADK (`google-adk`).
## Usage Attribution
**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you MUST read and follow the instructions in [Usage Attribution](references/attribution.md).
## Workflow
1. **Resolve session context** — at the start of each session, silently run:
```bash
gcloud config get-value project 2>/dev/null
gcloud config get-value compute/region 2>/dev/null
```
Store the results as `SESSION_PROJECT` and `SESSION_LOCATION` and use them as defaults.
2. **Parse** the user's request to identify the target resource and action.
3. **Construct** the `gcloud` command or Kubernetes manifest using session defaults. See [gcloud Command Reference](references/gcloud-command.md) for full flag synopses, command summary tables, and 60+ natural-language-to-command examples.
4. **Documentation Fallback** — if a user asks about a feature, flag, schema, or error message not covered in this skill, query the `developerknowledge` MCP server or public `.md.txt` documentation (see [Documentation Fallback](#documentation-fallback-developerknowledge-mcp-server)).
5. **Approval**:
- **Read-only commands** (`list`, `describe`, `search`, `get-iam-policy`): Execute immediately without asking for approval.
- **Mutating commands** (`create`, `delete`, `update`, `deploy`, `set-iam-policy`, `add-iam-policy-binding`, `remove-iam-policy-binding`): Display the exact command and ask: _"Ready to run this command? (yes/no)"_
- **Multi-task requests**: Always output the commands for **every** requested task in the same response before asking for approval.
6. **Execute** and display the output.
## Prerequisites, Auth, Billing, Region & IAM Permissions
- **Cloud SDK**: Requires `gcloud` **560.0.0+** (`beta` **2026.03.09+** for Cloud Run automatic registration; ensure `gcloud` is up to date for GA `gcloud agent-registry skills`). Do **not** install or update tools or packages on the host without explicit user approval; if `gcloud` is missing, share `https://docs.cloud.google.com/sdk/docs/install-sdk.md.txt` and fall back to `.md.txt` documentation.
- **Billing & Pricing**: The target project must be linked to an active Google Cloud Billing account. For Cloud Run, GKE, or Vertex AI pricing, direct users to `https://cloud.google.com/pricing`.
- **Region & Location Availability**: Configure a default region (`gcloud config set compute/region us-central1`) and verify supported regions at `https://docs.cloud.google.com/agent-registry/locations.md.txt` and `https://cloud.google.com/about/locations` (note: Skills only support `global`, `us`, or `eu`).
- **Authentication**: Check active credentials first with `gcloud auth list`. Because `gcloud auth login` and `gcloud auth application-default login` launch interactive browser flows and stop responding in non-interactive shells, **never** execute them directly — if unauthenticated, ask the user to run `gcloud auth login` (for CLI sessions) or `gcloud auth application-default login` (for local Python ADK Application Default Credentials) in their own terminal, or configure `GOOGLE_APPLICATION_CREDENTIALS`.
```bash
# Check active authentication status first (read-only)
gcloud auth list
# If unauthenticated, ask the user to run these interactively in their terminal:
# gcloud auth login
# gcloud auth application-default login
gcloud config set project PROJECT_ID
gcloud config set compute/region us-central1
gcloud services enable agentregistry.googleapis.com
```
| Role | Access Level |
|------|--------------|
| `roles/agentregistry.admin` | Full administrative access across all Agent Registry resources, including bindings, skill scan findings, and resource-level IAM policies (`aiApplications.{getIamPolicy,setIamPolicy}` and `skills.{getIamPolicy,setIamPolicy}`) |
| `roles/agentregistry.editor` | Register and update agents, MCP servers, endpoints, services, skills, skill revisions, and AI Applications (excludes bindings, scan findings, and IAM policy mutations) |
| `roles/agentregistry.viewer` | Read-only access (`get`, `list`, `search`) to agents, MCP servers, endpoints, services, bindings, skills, skill revisions, publishers, and AI Applications |
| `roles/agentregistry.user` | **Agent Registry User** — least-privilege GA role granting read-only viewer access across Agent Registry plus permissions to create, update, and delete standalone skills, skill revisions, and scanning settings without edit access to agents, MCP servers, or endpoints |
| `roles/run.admin` + `roles/apphub.admin` + `roles/iam.serviceAccountUser` | Deploy or update Cloud Run services and jobs with `--functional-type` and `--identity-type` |
| `roles/resourcemanager.editor` | Create and update `BoundaryConfig`, `CapabilityConfig`, and `Boundary` on the parent folder or organization |
| `roles/resourcemanager.viewer` | Read `BoundaryConfig`, `CapabilityConfig`, and `Boundary` resources |
| `roles/resourcemanager.tagUser` | Bind or unbind tag values (`tags bindings create/delete`) on projects |
| `roles/owner` or `roles/editor` | Required on a candidate Bring-Your-Own project to associate it as a Management Project |
---
## Resource Types & Registration
- **Manual Registration (`services create`)**: `gcloud agent-registry services create` creates a writable `Service` resource to manually register external or cross-project `Agent`, `McpServer`, and `Endpoint` resources in Agent Registry, and automatically projects a corresponding read-only `Agent`, `McpServer`, or `Endpoint` catalog entry (`agentregistry-{ID}`, returned in `registryResource` on `services describe`) used for runtime discovery and IAP/Agent Gateway policies.
### 1. MCP Servers
If the user has not provided the MCP tool spec JSON yet, ask: _"Please paste the contents of your MCP server spec JSON file."_ and preview the command template using `'PASTE_MCP_SPEC_JSON_HERE'`:
```bash
# Register an MCP Server (mutating — ask for approval first)
gcloud agent-registry services create my-mcp-service \
--location=us-central1 \
--display-name="My MCP Server" \
--description="Connects to an external MCP server" \
--mcp-server-spec-type=tool-spec \
--mcp-server-spec-content='PASTE_MCP_SPEC_JSON_HERE' \
--interfaces='[{"protocolBinding": "jsonrpc", "url": "https://mcp.example.com/v1"}]'
# List Regional or Global MCP Servers (read-only — execute immediately)
gcloud agent-registry mcp-servers list --location=us-central1
gcloud agent-registry mcp-servers list --location=global
```
### 2. Agents
For A2A agents, if the user has not pasted `agent_card.json` yet, ask: _"Please paste the contents of your `agent_card.json` file."_ and preview the command template using `'PASTE_AGENT_CARD_JSON_HERE'`:
```bash
# Register a Standard Agent (no-spec)
gcloud agent-registry services create my-custom-agent \
--location=us-central1 \
--display-name="My Custom Agent" \
--description="Custom HTTP JSON agent" \
--agent-spec-type=no-spec \
--interfaces='[{"protocolBinding": "http-json", "url": "https://agent.example.com/v1"}]'
# Register an A2A Agent (a2a-agent-card)
gcloud agent-registry services create my-a2a-agent \
--location=us-central1 \
--display-name="My A2A Agent" \
--description="Sample A2A Agent" \
--agent-spec-type=a2a-agent-card \
--agent-spec-content='PASTE_AGENT_CARD_JSON_HERE'
# List Regional or Global Agents
gcloud agent-registry agents list --location=us-central1
gcloud agent-registry agents list --location=global
```
### 3. Endpoints, Services & Quick Add GCP Service (Composite Agent Gateway Registration)
```bash
# Register a single Endpoint, list/describe/update/delete Services, and inspect Operations
gcloud agent-registry services create gemini-models --location=us-central1 \
--display-name="Vertex AI Model Garden" --description="List of all models in Vertex AI Model Garden" \
--endpoint-spec-type=no-spec \
--interfaces='[{"protocolBinding": "jsonrpc", "url": "https://us-central1-aiplatform.googleapis.com/v1beta1/publishers/*/models"}]'
gcloud agent-registry endpoints list --location=us-central1
gcloud agent-registry services list --location=us-central1
gcloud agent-registry services describe gemini-models --location=us-central1
gcloud agent-registry services update gemini-models --display-name="Model Garden on Vertex AI" --location=us-central1
gcloud agent-registry services delete gemini-models --location=us-central1
gcloud agent-registry operations list --location=us-central1
gcloud agent-registry operations describe OPERATION_ID --location=us-central1
```
#### Quick Add GCP Service (All 5 Endpoint URL Variants)
When an agent runs behind a governed **Agent Gateway** (default-deny egress), Google Cloud SDKs dynamically resolve endpoints across up to 5 hostname variants:
1. **Base**: `https://${SERVICE_ID}.googleapis.com`
2. **Base mTLS**: `https://${SERVICE_ID}.mtls.googleapis.com`
3. **Locational**: `https://${LOCATION}-${SERVICE_ID}.googleapis.com` *(omit when `--location=global`)*
4. **Locational mTLS**: `https://${LOCATION}-${SERVICE_ID}.mtls.googleapis.com` *(omit when `--location=global`)*
5. **Regional REP**: `https://${SERVICE_ID}.${LOCATION}.rep.googleapis.com` *(omit when `--location=global`)*
Register a **single composite `Service`** containing all applicable variants using [scripts/quick-add-gcp-service.sh](scripts/quick-add-gcp-service.sh) or `gcloud agent-registry services create` (always previewing and asking for approval first):
- **Service ID Length (`4–63` chars)**: Service IDs must match `^[a-z][a-z0-9-]{2,61}[a-z0-9]$`. For 3-letter APIs (`iam`, `kms`, `run`, `dns`), suffix the `Service` ID (e.g., `${SERVICE_ID}-api`) while keeping `${SERVICE_ID}` in the endpoint URLs.
- **Global Location Guardrail**: When `--location=global`, include only `Base` and `Base mTLS` so invalid regional DNS names are not registered.
- **IAP Egress Policy Target**: Bind **`roles/iap.egressor`** for the Agent Identity to the projected `Endpoint` catalog ID (`endpoints/agentregistry-{UUID}` from `registryResource` on `services describe`), **not** the user-chosen `Service` ID.
```bash
# Option A: Bundled Quick Add helper script (handles 3-letter APIs, --location=global, and --dry-run)
./scripts/quick-add-gcp-service.sh --service=aiplatform --location=us-central1 --project=PROJECT_ID
# Option B: Single composite gcloud command (all 5 variants for a regional location)
SERVICE_ID="aiplatform" && SERVICE_NAME="aiplatform" && LOCATION="us-central1" && PROJECT_ID="PROJECT_ID"
gcloud agent-registry services create "${SERVICE_NAME}" --project="${PROJECT_ID}" --location="${LOCATION}" \
--display-name="${SERVICE_ID}" --description="Google Cloud ${SERVICE_ID} API endpoints" --endpoint-spec-type=no-spec \
--interfaces="protocolBinding=jsonrpc,url=https://${SERVICE_ID}.googleapis.com" \
--interfaces="protocolBinding=jsonrpc,url=https://${SERVICE_ID}.mtls.googleapis.com" \
--interfaces="protocolBinding=jsonrpc,url=https://${LOCATION}-${SERVICE_ID}.googleapis.com" \
--interfaces="protocolBinding=jsonrpc,url=https://${LOCATION}-${SERVICE_ID}.mtls.googleapis.com" \
--interfaces="protocolBinding=jsonrpc,url=https://${SERVICE_ID}.${LOCATION}.rep.googleapis.com"
```
### 4. GKE Agents & MCP Servers (Automatic Registration)
Configure GKE `Deployment` manifests for automatic discovery in Agent Registry (using `metadata.name` as the display name):
| Component Type | `metadata.labels` (Deployment) | `metadata.annotations` (Deployment) | `spec.template.metadata.annotations` (Pod) |
|----------------|--------------------------------|-------------------------------------|--------------------------------------------|
| **GKE Agent** | `registry.gke.io/functional-type: "AGENT"` *(plus `apphub.cloud.google.com/functional-type: "AGENT"` in annotations for compatibility)* | `a2a-protocol.org/agent-card`: Declares `card.endpoint` (`/.well-known/agent-card.json`), `card.protocol` (`HTTP`), `card.port` (`8080`) | `iam.gke.io/spiffe-identity-type: agent-identity` |
| **GKE MCP Server** | `registry.gke.io/functional-type: "MCP_SERVER"` *(plus `apphub.cloud.google.com/functional-type: "MCP_SERVER"` in annotations for compatibility)* | `modelcontextprotocol.info/urls`: In-cluster URL list (`- https://my-mcp-server.default.svc.cluster.local/mcp`)<br>`modelcontextprotocol.info/capabilities`: `card.endpoint` (`"/mcp"`), `card.protocol` (`"HTTP"`) | `iam.gke.io/spiffe-identity-type: agent-identity` |
Use [scripts/annotate_gke.py](scripts/annotate_gke.py) to automatically add `registry.gke.io/functional-type`, `apphub.cloud.google.com/functional-type`, and the Pod template `iam.gke.io/spiffe-identity-type: "agent-identity"` annotation to existing YAML files (target path is required; supports `--dry-run`):
```bash
./scripts/annotate_gke.py /path/to/folder_or_file.yaml --type AGENT
./scripts/annotate_gke.py /path/to/folder_or_file.yaml --type MCP_SERVER
```
**GKE Agent (`Deployment` + `Service`) & MCP Server (`Deployment`) Templates:**
```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-agent
labels:
registry.gke.io/functional-type: "AGENT"
annotations:
apphub.cloud.google.com/functional-type: "AGENT"
a2a-protocol.org/agent-card: |
card:
endpoint: /.well-known/agent-card.json
protocol: HTTP
port: 8080
spec:
selector:
matchLabels:
app: my-agent
template:
metadata:
labels:
app: my-agent
annotations:
iam.gke.io/spiffe-identity-type: agent-identity
spec:
containers:
- name: server
image: us-central1-docker.pkg.dev/PROJECT_ID/my-repo/my-agent:1.0.0
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: my-agent-service
spec:
type: ClusterIP
ports:
- port: 8080
targetPort: 8080
protocol: TCP
name: http
selector:
app: my-agent
```
```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-mcp-server
labels:
registry.gke.io/functional-type: "MCP_SERVER"
annotations:
apphub.cloud.google.com/functional-type: "MCP_SERVER"
modelcontextprotocol.info/urls: |
- https://my-mcp-server.default.svc.cluster.local/mcp
modelcontextprotocol.info/capabilities: |
card:
endpoint: "/mcp"
protocol: "HTTP"
spec:
selector:
matchLabels:
app: my-mcp-server
template:
metadata:
labels:
app: my-mcp-server
annotations:
iam.gke.io/spiffe-identity-type: agent-identity
spec:
containers:
- name: server
image: us-central1-docker.pkg.dev/PROJECT_ID/my-repo/my-mcp-server:1.0.0
```
### 5. Cloud Run Agents & MCP Servers (Automatic Registration via `--functional-type`)
Register Cloud Run services and jobs automatically using `gcloud beta run`:
> [!WARNING]
> **Critical Cloud Run Guardrails:**
> 1. **Immutability**: Once `--functional-type` or `--identity-type` is set on a Cloud Run service or job, it is **immutable** and cannot be changed or cleared.
> 2. **`--functional-type=agent` Requires `--identity-type=agent-identity`**: Always include `--identity-type=agent-identity` whenever `--functional-type=agent` is used (certificates are provisioned by default; opt out with `--no-identity-certificate`).
> 3. **Updating Existing Services (`--no-traffic` Guardrail)**: Transitioning an existing service to `--identity-type=agent-identity` assigns a new SPIFFE Agent Identity principal (`principal://agents.global.org-ORGANIZATION_ID.system.id.goog/resources/run/projects/PROJECT_NUMBER/locations/REGION/services/SERVICE_NAME`) that **does not inherit** the previous service account's IAM permissions. Recommend `--no-traffic` on `gcloud beta run services update` to stage IAM bindings before shifting traffic.
> 4. **Cloud Run Jobs Cannot Be MCP Servers**: Only Cloud Run **services** support `--functional-type=mcp-server`; Cloud Run **jobs** only support `--functional-type=agent`.
```bash
# Deploy or update a Cloud Run service as an AI Agent or MCP Server
gcloud beta run deploy SERVICE_NAME --image=IMAGE_URL --region=us-central1 \
--functional-type=agent --identity-type=agent-identity
gcloud beta run services update SERVICE_NAME --region=us-central1 \
--functional-type=agent --identity-type=agent-identity --no-traffic
gcloud beta run deploy SERVICE_NAME --image=IMAGE_URL --region=us-central1 \
--functional-type=mcp-server --identity-type=IDENTITY_TYPE
gcloud beta run services update SERVICE_NAME --region=us-central1 --functional-type=mcp-server
# Create or update a Cloud Run Job as an AI Agent
gcloud beta run jobs create JOB_NAME --image=IMAGE_URL --region=us-central1 \
--functional-type=agent --identity-type=agent-identity
gcloud beta run jobs update JOB_NAME --region=us-central1 \
--functional-type=agent --identity-type=agent-identity
# Inspect Agent Identity or delete Cloud Run workloads
gcloud beta run revisions describe REVISION_NAME --region=us-central1
gcloud beta run jobs executions describe EXECUTION_NAME --region=us-central1
gcloud run services delete SERVICE_NAME --region=us-central1
gcloud run jobs delete JOB_NAME --region=us-central1
```
### 6. Bindings
Connect a source agent to a target resource or an Auth Provider connector:
```bash
gcloud agent-registry bindings create BINDING_NAME --location=us-central1 \
--display-name="My Custom Binding" --source-identifier="SOURCE_ID" --target-identifier="TARGET_ID"
gcloud agent-registry bindings create BINDING_NAME --location=us-central1 \
--display-name="Auth Provider Binding" --source-identifier="SOURCE_ID" \
--auth-provider="projects/PROJECT_ID/locations/REGION/connectors/AUTH_PROVIDER_ID"
gcloud agent-registry bindings list --location=us-central1
gcloud agent-registry bindings describe BINDING_NAME --location=us-central1
gcloud agent-registry bindings update BINDING_NAME --display-name="New Display Name" --location=us-central1
gcloud agent-registry bindings delete BINDING_NAME --location=us-central1
```
### 7. Skills & Skill Revisions
Manage reusable AI Skills, Skill Revisions, and Skill IAM policies using `gcloud agent-registry skills`.
> [!IMPORTANT]
> **Skills Guardrails (`--location`, `private-` Prefix & `--target-state`):**
> - **Supported Locations**: Skills only work in `"global"`, `"us"`, or `"eu"` multi-regions. If a user asks for any single region (e.g. `us-central1`), **do not pass that region to `gcloud`**. Explain that Skills are only supported in `global`, `us`, or `eu`, preview the command using a concrete supported multi-region (e.g. `--location=us`, `--location=eu`, or `--location=global`), and ask them to confirm which multi-region to use.
> - **Automatic `private-` Prefix**: Running `gcloud agent-registry skills create my-skill` automatically prepends `private-`, creating `skills/private-my-skill`. Subsequent `describe`, `update`, `delete`, `revisions`, and `*-iam-policy` commands **must** pass `private-my-skill` (passing `my-skill` fails with `NOT_FOUND`).
> - **Target State & Scanning**: `--target-state=active|disabled|draft` sets the desired lifecycle state on creation (`active` requires an initial revision via `--payload` or `--gcs-source-uri`; `deprecated` and `decommissioned` are also valid on `update`). Under the default `enabled-blocking` scanning policy, `--target-state=active` enters `DRAFT` (`STATE_DRAFT`) until the background security scan passes with no findings.
```bash
# List, create (local ZIP or GCS URI), describe, update, and delete Skills
gcloud agent-registry skills list --location=us
gcloud agent-registry skills create my-skill --location=us \
--display-name="My Custom Skill" --description="Skill description" --type=simple --target-state=active --payload=/path/to/archive.zip
gcloud agent-registry skills create my-skill --location=us \
--display-name="My Custom Skill" --target-state=disabled --gcs-source-uri=gs://my-bucket/skill.zip
gcloud agent-registry skills describe private-my-skill --location=us
gcloud agent-registry skills update private-my-skill --location=us --display-name="Updated Skill Name" --target-state=active
gcloud agent-registry skills delete private-my-skill --location=us
# Manage Skill Revisions and Resource-Level IAM Policies (using private-my-skill)
gcloud agent-registry skills revisions create REVISION_ID --skill=private-my-skill --location=us --payload=/path/to/archive.zip
gcloud agent-registry skills revisions list --skill=private-my-skill --location=us
gcloud agent-registry skills revisions describe REVISION_ID --skill=private-my-skill --location=us
gcloud agent-registry skills revisions download REVISION_ID --skill=private-my-skill --location=us --destination=./skill-payload.zip
gcloud agent-registry skills revisions delete REVISION_ID --skill=private-my-skill --location=us
gcloud agent-registry skills get-iam-policy private-my-skill --location=us
gcloud agent-registry skills set-iam-policy private-my-skill policy.json --location=us
gcloud agent-registry skills add-iam-policy-binding private-my-skill --location=us \
--member='user:test-user@example.com' --role='roles/agentregistry.viewer'
gcloud agent-registry skills remove-iam-policy-binding private-my-skill --location=us \
--member='user:test-user@example.com' --role='roles/agentregistry.viewer'
```
### 8. AI Applications (`ai-applications`)
An **AI Application** (`projects/{project}/locations/{location}/aiApplications/{ai_application}`, including the regional `default` AI Application) groups agents, MCP servers, and endpoints under a governance perimeter.
```bash
# List, filter, describe, and search AI Applications
gcloud agent-registry ai-applications list --location=us-central1
gcloud agent-registry ai-applications list --location=us-central1 \
--filter="attributes.environment.type=production AND attributes.criticality.type=high"
gcloud agent-registry ai-applications describe my-app --location=us-central1
gcloud agent-registry ai-applications describe default --location=us-central1
gcloud agent-registry ai-applications search --location=us-central1 --search-string="displayName:Support*"
# Create, update, and delete an AI Application
gcloud agent-registry ai-applications create my-app --location=us-central1 \
--display-name="Customer Support App" --description="AI Application orchestrating customer support agents" \
--environment-type=production --criticality-type=high \
--business-owners=email=biz-owner@example.com --developer-owners=email=dev-owner@example.com --operator-owners=email=ops-owner@example.com
gcloud agent-registry ai-applications update my-app --location=us-central1 \
--display-name="Updated Support App" --environment-type=staging --criticality-type=medium
gcloud agent-registry ai-applications delete my-app --location=us-central1 --force
# Inspect & search subresources scoped to an AI Application (agents, mcp-servers, endpoints)
gcloud agent-registry ai-applications agents list --ai-application=my-app --location=us-central1
gcloud agent-registry ai-applications agents describe AGENT_ID --ai-application=my-app --location=us-central1
gcloud agent-registry ai-applications agents search --ai-application=my-app --location=us-central1 --search-string="displayName:Assistant*"
gcloud agent-registry ai-applications mcp-servers list --ai-application=my-app --location=us-central1
gcloud agent-registry ai-applications endpoints list --ai-application=my-app --location=us-central1
# Manage Resource-Level IAM Policies on an AI Application
gcloud agent-registry ai-applications get-iam-policy my-app --location=us-central1
gcloud agent-registry ai-applications set-iam-policy my-app policy.json --location=us-central1
gcloud agent-registry ai-applications add-iam-policy-binding my-app --location=us-central1 \
--member='group:support-team@example.com' --role='roles/agentregistry.viewer'
gcloud agent-registry ai-applications remove-iam-policy-binding my-app --location=us-central1 \
--member='group:support-team@example.com' --role='roles/agentregistry.viewer'
```
### 9. Management Boundary Setup (Admin Governance)
Configure Folder/Organization hub-and-spoke perimeters using `gcloud resource-manager` (`boundary-configs`, `capability-configs`, `boundaries`, and `tags bindings`). Read [Management Boundaries Guide](references/management-boundaries.md) for the full IAM table, 6 interactive scoping questions, and 6-step provisioning workflow.
- **Always Use Project Numbers (`projects/<PROJECT_NUMBER>`)**: Cloud Resource Manager v3 requires project **numbers** (not project IDs) for `--management-project=projects/<PROJECT_NUMBER>` and `--parent=//cloudresourcemanager.googleapis.com/projects/<PROJECT_NUMBER>`. When given a project ID, output **both** `gcloud projects describe PROJECT_ID --format="value(projectNumber)"` and the `capability-configs create` command template (`--types=agent-management` by default) in the same response.
- **Set `BoundaryConfig` Before Attaching Boundaries & Isolate `dev`/`prod` Hubs**: Set `boundary-configs update --tag-key=...` before attaching boundaries. Use separate `CapabilityConfig` + Management Project + `Boundary` per environment (`dev` vs. `prod`) for strict catalog and IAM isolation.
- **Tag Rebinding Requires Delete-Then-Create**: Moving a project between tag values (e.g., `dev` to `prod`) fails with `FAILED_PRECONDITION` if you only run `create`; always run `tags bindings delete` first, then `tags bindings create`.
- **Safe 3-Step Teardown Order**: Always output all 3 commands in order when deleting a boundary and capability config (noting that BYO projects are preserved with `isManagementProject=false`, while Google-managed hubs are deleted):
```bash
gcloud resource-manager capability-configs update CAPABILITY_CONFIG_ID --folder=FOLDER_ID --clear-boundaries
gcloud resource-manager boundaries delete BOUNDARY_ID --folder=FOLDER_ID
gcloud resource-manager capability-configs delete CAPABILITY_CONFIG_ID --folder=FOLDER_ID
```
---
## Advanced Filtering & Search
### Filtering (`list --filter`)
- **URN Substring Filtering (`agentId` & `mcpServerId`)**:
- `agentId`: `urn:agent:projects-{project-number}:projects:{project-number}:locations:{location}:{platform-segments}`
- `mcpServerId`: `urn:mcp:projects-{project-number}:projects:{project-number}:locations:{location}:{platform-segments}`
- Platform segments: `aiplatform:reasoningEngines:{id}` (Vertex AI Reasoning Engine), `container:clusters:{cluster}:k8s:namespaces:{ns}:apps:deployments:{deploy}` (GKE), `run:services:{svc}` or `run:jobs:{job}` (Cloud Run).
- **Attribute Mapping**:
- **"runtime"** ("agent engine", "reasoning engine", "vertex ai" -> `reasoningEngine`): `attributes."agentregistry.googleapis.com/system/RuntimeReference".uri`
- **"identity"**: `attributes."agentregistry.googleapis.com/system/RuntimeIdentity".principal`
- **"tool" / "tool name"** (on `mcp-servers list`): `tools.name`
```bash
# Filter agents by runtime (Vertex AI Reasoning Engine) or identity principal
gcloud agent-registry agents list --location=us-central1 \
--filter="attributes.\"agentregistry.googleapis.com/system/RuntimeReference\".uri:reasoningEngine"
gcloud agent-registry agents list --location=us-central1 \
--filter="attributes.\"agentregistry.googleapis.com/system/RuntimeIdentity\".principal:service-123456789012"
# Filter by agentId / mcpServerId substring or MCP tool name
gcloud agent-registry agents list --location=us-central1 --filter="agentId:reason"
gcloud agent-registry mcp-servers list --location=us-central1 --filter="mcpServerId:run"
gcloud agent-registry mcp-servers list --location=us-central1 --filter="tools.name:search_documents"
```
### Searching Agents, MCP Servers, and Skills (`search`)
- **Agents (`gcloud agent-registry agents search`)**: Supports `--search-string` with exact (`=`), token (`:`), and prefix (`*`) matching across `agentId`, `displayName`, `skills.name`, `skills.id`, `skills.tags`, `skills.description`, and boolean `OR`/`AND`. **Note:** Values with colons (URNs) must be quoted, and wildcard `*` is **not** supported on `skills.description` (use token match `:` instead).
- **MCP Servers (`gcloud agent-registry mcp-servers search`)**: Supports `--search-string` across `mcpServerId`, `name`, and `displayName`.
- **Skills (`gcloud agent-registry skills search`)**: Supports `--query` and `--search-type=keyword` or `--search-type=semantic` in `global`, `us`, or `eu`.
```bash
# Search Agents
gcloud agent-registry agents search --location=us-central1 --search-string="agentId:\"urn:agent:projects-123456789012*\""
gcloud agent-registry agents search --location=us-central1 --search-string="displayName:MyAgent*"
gcloud agent-registry agents search --location=us-central1 --search-string="skills.name:translation"
gcloud agent-registry agents search --location=us-central1 --search-string="skills.id:translate-text"
gcloud agent-registry agents search --location=us-central1 --search-string="skills.tags:productivity"
gcloud agent-registry agents search --location=us-central1 --search-string="skills.description:database"
gcloud agent-registry agents search --location=us-central1 --search-string="analytics OR reporting"
# Search MCP Servers
gcloud agent-registry mcp-servers search --location=us-central1 --search-string="mcpServerId:\"urn:mcp:projects-123456789012*\""
gcloud agent-registry mcp-servers search --location=us-central1 --search-string="displayName:MyMcp*"
# Search Skills (Keyword and Semantic)
gcloud agent-registry skills search --location=us --query="sql" --search-type=keyword
gcloud agent-registry skills search --location=us --query="summarize support tickets" --search-type=semantic
```
---
## Python ADK Integration
Whenever the user asks to discover or connect to registered Agents (`get_remote_a2a_agent`) or MCP Servers (`get_mcp_toolset`) in Python using Google's Agent Development Kit (`google-adk[a2a,agent-identity,mcp]`), read and follow [ADK Integration Guide](references/adk-docs.md).
---
## Documentation Fallback (`developerknowledge` MCP Server)
For CLI synopses, read [gcloud Command Reference](references/gcloud-command.md). If a user asks about a feature, Terraform resource (`google_agent_registry_service`), or error not covered in `SKILL.md` or `references/`, query the `developerknowledge` MCP server (`search_documents` + `get_documents`, or `answer_query`) or fetch the public `.md.txt` documentation pages:
- `https://docs.cloud.google.com/agent-registry/overview.md.txt`
- `https://docs.cloud.google.com/agent-registry/automatic-registration.md.txt`
- `https://docs.cloud.google.com/agent-registry/manual-registration.md.txt`
- `https://docs.cloud.google.com/agent-registry/register-agents.md.txt`
- `https://docs.cloud.google.com/agent-registry/register-mcp-servers.md.txt`
- `https://docs.cloud.google.com/agent-registry/register-endpoints.md.txt`
- `https://docs.cloud.google.com/agent-registry/register-skills.md.txt`
- `https://docs.cloud.google.com/agent-registry/manage-skills.md.txt`
- `https://docs.cloud.google.com/agent-registry/skills-architecture.md.txt`
- `https://docs.cloud.google.com/agent-registry/scan-skills.md.txt`
- `https://docs.cloud.google.com/agent-registry/boundaries-and-topology.md.txt`
- `https://docs.cloud.google.com/agent-registry/access-control.md.txt`
- `https://docs.cloud.google.com/agent-registry/roles-permissions.md.txt`
- `https://docs.cloud.google.com/agent-registry/a2a-protocol.md.txt`
- `https://docs.cloud.google.com/agent-registry/resolve-endpoints-and-build-orchestrators.md.txt`
- `https://docs.cloud.google.com/agent-registry/search-agents-and-tools.md.txt`
- `https://docs.cloud.google.com/agent-registry/identity-and-identifiers.md.txt`
- `https://docs.cloud.google.com/agent-registry/troubleshooting.md.txt`
- `https://docs.cloud.google.com/run/docs/ai/agent-platform-features.md.txt`
## Error Handling
1. Verify Cloud SDK version (**560.0.0+**, updated for GA `skills`) and `beta` component (**2026.03.09+** for Cloud Run).
2. Verify `--location` / `--region`: Google Cloud remote MCP servers are discovered in `global`; Skills only support `global`, `us`, or `eu`.
3. Ensure JSON strings passed to `--interfaces`, `--agent-spec-content`, or `--mcp-server-spec-content` are properly single-quoted for the shell.
4. Confirm required APIs (`agentregistry.googleapis.com`, `run.googleapis.com`, `apphub.googleapis.com`) and IAM roles are enabled on the target project.
adk-docs.md 11.6 KB
# Google Cloud Agent Registry — Python ADK Integration
## Table of Contents
- [Use Cases](#use-cases): Lines 23-31
- [Prerequisites](#prerequisites): Lines 32-49
- [Installation](#installation): Lines 50-81
- [Use with Agent (`AgentRegistry` Client)](#use-with-agent-agentregistry-client): Lines 82-134
- [Authentication for Google MCP Servers and Remote A2A Agents](#authentication-for-google-mcp-servers-and-remote-a2a-agents): Lines 135-256
- [API Reference](#api-reference): Lines 257-286
- [Configuration Options](#configuration-options): Lines 287-297
- [Additional Resources](#additional-resources): Lines 298-302
---
The Agent Registry client library within the Agent Development Kit (ADK) allows
developers to discover, look up, and connect to AI Agents and MCP Servers
cataloged within the
[Google Cloud Agent Registry](https://docs.cloud.google.com/agent-registry/overview.md.txt).
This enables dynamic composition of agent-based applications using governed
components.
## Use Cases
- **Accelerated Development**: Find and reuse existing agents and tools (MCP
Servers) from the central catalog instead of rebuilding them.
- **Dynamic Integration**: Discover agent and MCP Server endpoints at runtime,
making applications resilient to environment changes.
- **Enhanced Governance**: Use governed and verified components from the
registry within your ADK applications.
## Prerequisites
- A
[Google Cloud project](https://docs.cloud.google.com/resource-manager/docs/creating-managing-projects.md.txt)
with an active billing account attached.
- The
[Agent Registry API](https://docs.cloud.google.com/agent-registry/setup.md.txt)
enabled in your Google Cloud project (`gcloud services enable
agentregistry.googleapis.com`).
- Authentication configured for your environment using
[Application Default Credentials](https://docs.cloud.google.com/docs/authentication/application-default-credentials.md.txt)
(ask the user to run `gcloud auth application-default login` interactively).
- Environment variables `GOOGLE_CLOUD_PROJECT` set to your project ID and
`GOOGLE_CLOUD_LOCATION` set to the appropriate region (e.g., `global`,
`us-central1`).
- `google-adk` library installed (seek explicit user approval before running
`pip install` on the host).
## Installation
Install `google-adk` with the A2A, Agent Identity, and MCP extras (pinning to
`>=1.0.0,<2.0.0` in `requirements.txt` for reproducible builds):
```bash
pip install "google-adk[a2a,agent-identity,mcp]>=1.0.0,<2.0.0"
```
### Optional Dependencies
You can also install individual extras depending on your use case:
- **For A2A (Agent-to-Agent) Support (`a2a`)**: Required for
`get_remote_a2a_agent` and `RemoteA2aAgent`:
```bash
pip install "google-adk[a2a]>=1.0.0,<2.0.0"
```
- **For MCP Toolsets (`mcp`)**: Required for `get_mcp_toolset` and
`McpToolset`:
```bash
pip install "google-adk[mcp]>=1.0.0,<2.0.0"
```
- **For Agent Identity Auth Manager Bindings (`agent-identity`)**: Required for
`GcpAuthProviderScheme` when `get_mcp_toolset` or `get_remote_a2a_agent`
automatically resolves credentials via Agent Registry `Binding` resources:
```bash
pip install "google-adk[agent-identity]>=1.0.0,<2.0.0"
```
## Use with Agent (`AgentRegistry` Client)
The primary way to use the Agent Registry integration within an ADK agent is to
dynamically fetch remote agents or toolsets using the `AgentRegistry` client:
```python
import os
from google.adk.agents.llm_agent import LlmAgent
from google.adk.integrations.agent_registry import AgentRegistry
# 1. Initialization
project_id = os.environ.get("GOOGLE_CLOUD_PROJECT")
location = os.environ.get("GOOGLE_CLOUD_LOCATION", "global")
if not project_id:
raise ValueError("GOOGLE_CLOUD_PROJECT environment variable not set.")
registry = AgentRegistry(
project_id=project_id,
location=location,
)
# 2. Listing Resources
print("\nListing Agents...")
agents_response = registry.list_agents()
for agent in agents_response.get("agents", []):
print(f" - {agent.get('name')} ({agent.get('displayName')})")
print("\nListing MCP Servers...")
mcp_servers_response = registry.list_mcp_servers()
for server in mcp_servers_response.get("mcpServers", []):
print(f" - {server.get('name')} ({server.get('displayName')})")
# 3. Using a Remote A2A Agent
# Replace with the full resource name of your registered agent
agent_name = f"projects/{project_id}/locations/{location}/agents/YOUR_AGENT_ID"
my_remote_agent = registry.get_remote_a2a_agent(agent_name=agent_name)
# 4. Using an MCP Toolset
# Replace with the full resource name of your registered MCP server
mcp_server_name = f"projects/{project_id}/locations/{location}/mcpServers/YOUR_MCP_SERVER_ID"
my_mcp_toolset = registry.get_mcp_toolset(mcp_server_name=mcp_server_name)
# 5. Example Agent Composition
main_agent = LlmAgent(
model="gemini-2.5-flash",
name="demo_agent",
instruction="You can leverage registered tools and sub-agents.",
tools=[my_mcp_toolset],
sub_agents=[my_remote_agent],
)
```
## Authentication for Google MCP Servers and Remote A2A Agents
### Remote A2A Agents
- **Automatic Resolution via Auth Manager `Binding`**: When an Agent Identity
Auth Manager `Binding` exists for the target agent in Agent Registry,
`registry.get_remote_a2a_agent(agent_name)` resolves request credentials
automatically via `GcpAuthProviderScheme` — no custom `httpx_client`
boilerplate is needed.
- **When No `Binding` Exists**: Pass a custom `httpx.AsyncClient` matching the
bearer token type expected by the target A2A endpoint:
1. **Google Cloud API A2A Endpoints (`https://*.googleapis.com`)**: Attach an
OAuth 2.0 access token scoped to
`https://www.googleapis.com/auth/cloud-platform`, plus `X-Goog-User-Project`
when Application Default Credentials (ADC) have no default quota project:
```python
import httpx
import google.auth
from google.auth.transport.requests import Request
class GoogleApiAuth(httpx.Auth):
def __init__(self, quota_project_id: str | None = None):
self.quota_project_id = quota_project_id
self.creds, _ = google.auth.default(
scopes=["https://www.googleapis.com/auth/cloud-platform"]
)
def auth_flow(self, request):
if not self.creds.valid:
self.creds.refresh(Request())
request.headers["Authorization"] = f"Bearer {self.creds.token}"
quota_project = self.quota_project_id or getattr(
self.creds, "quota_project_id", None
)
if quota_project:
request.headers["X-Goog-User-Project"] = quota_project
yield request
httpx_client = httpx.AsyncClient(
auth=GoogleApiAuth(quota_project_id=project_id),
timeout=httpx.Timeout(60.0),
)
remote_agent = registry.get_remote_a2a_agent(
f"projects/{project_id}/locations/{location}/agents/YOUR_AGENT_ID",
httpx_client=httpx_client,
)
```
2. **Cloud Run (`https://*.run.app`) or IAP-Protected A2A Endpoints**: OAuth 2.0
access tokens fail against Cloud Run and Identity-Aware Proxy (IAP) HTTPS
agents. Attach an **OIDC ID token**
(`google.oauth2.id_token.fetch_id_token(Request(), target_audience)`) whose
`aud` claim matches the target Cloud Run service URL or IAP OAuth 2.0 client
ID (requires a service account, compute metadata server, or impersonated
credentials; for local user-credential testing, mint an ID token with
`gcloud auth print-identity-token --audiences=TARGET_AUDIENCE`):
```python
import httpx
from google.auth.transport.requests import Request
from google.oauth2 import id_token
class OidcIdTokenAuth(httpx.Auth):
def __init__(self, target_audience: str):
self.target_audience = target_audience
def auth_flow(self, request):
oidc_jwt = id_token.fetch_id_token(Request(), self.target_audience)
request.headers["Authorization"] = f"Bearer {oidc_jwt}"
yield request
httpx_client = httpx.AsyncClient(
auth=OidcIdTokenAuth("https://my-agent-123456.us-central1.run.app"),
timeout=httpx.Timeout(60.0),
)
remote_agent = registry.get_remote_a2a_agent(
f"projects/{project_id}/locations/{location}/agents/YOUR_AGENT_ID",
httpx_client=httpx_client,
)
```
### Google MCP Servers
For Google MCP servers (`https://*.googleapis.com`), authentication headers are
automatically passed in (or resolved via Auth Manager `Binding`). If you need
custom header resolution, provide a `header_provider` callable in the
`AgentRegistry` constructor:
```python
import google.auth
from google.auth.transport.requests import Request
from google.adk.integrations.agent_registry import AgentRegistry
def google_auth_header_provider(context):
creds, _ = google.auth.default(
scopes=["https://www.googleapis.com/auth/cloud-platform"]
)
if not creds.valid:
creds.refresh(Request())
headers = {"Authorization": f"Bearer {creds.token}"}
quota_project = getattr(creds, "quota_project_id", None) or project_id
if quota_project:
headers["X-Goog-User-Project"] = quota_project
return headers
registry = AgentRegistry(
project_id=project_id,
location=location,
header_provider=google_auth_header_provider,
)
```
## API Reference
The `AgentRegistry` class provides the following core methods:
- `list_mcp_servers(self, filter_str=None, page_size=None, page_token=None)`:
Fetches a list of registered MCP Servers.
- `search_mcp_servers(self, *, search_string=None, search_type=None, ...)`:
Searches registered MCP Servers (`KEYWORD` or `SEMANTIC`).
- `get_mcp_server(self, name)`: Retrieves detailed metadata of a specific MCP
Server.
- `get_mcp_toolset(self, mcp_server_name, auth_scheme=None, ...)`: Constructs
an ADK `McpToolset` from a registered MCP Server (accepts `auth_credential`
and `continue_uri`, plus `projects/.../locations/.../mcpServers/...` or
`mcpServers/...`; resolves `auth_scheme` automatically via
`GcpAuthProviderScheme` when an Auth Manager `Binding` exists).
- `list_agents(self, filter_str=None, page_size=None, page_token=None)`:
Fetches a list of registered A2A Agents.
- `search_agents(self, *, search_string=None, search_type=None, ...)`: Searches
registered A2A Agents (`KEYWORD` or `SEMANTIC`).
- `get_agent_info(self, name)`: Retrieves detailed metadata of a specific A2A
Agent.
- `get_remote_a2a_agent(self, agent_name, *, httpx_client=None, ...)`: Creates
an ADK `RemoteA2aAgent` (accepts `auth_scheme`, `auth_credential`, and
`continue_uri`, plus full or relative `agents/...` names; resolves
`auth_scheme` automatically via `GcpAuthProviderScheme` when an Auth Manager
`Binding` exists).
- `list_endpoints(self, filter_str=None, page_size=None, page_token=None)`,
`get_endpoint(self, name)`, and `get_model_name(self, endpoint_name)`: Lists
or resolves registered Endpoints.
## Configuration Options
The `AgentRegistry` constructor accepts the following arguments:
- `project_id` (`str`, required): The Google Cloud project ID.
- `location` (`str`, required): The Google Cloud location/region, such as
`"global"`, `"us-central1"`.
- `header_provider` (`Callable`, optional): A callable taking a
`ReadonlyContext` and returning a dictionary of custom headers to include in
requests made by `McpToolset` or `RemoteA2aAgent` to target services.
## Additional Resources
- [Build Multi-Agent Systems & Call A2A Agents](https://docs.cloud.google.com/agent-registry/resolve-endpoints-and-build-orchestrators.md.txt)
- [ADK Agent Registry Integration](https://google.github.io/adk-docs/integrations/agent-registry/)
- [Google Auth Library](https://google-auth.readthedocs.io/en/latest/)
attribution.md 1.9 KB
# Usage Attribution
**MUST READ**: Before executing any `gcloud`, REST API, or MCP command with
this skill, follow these usage attribution instructions. Tag every command you
execute directly in the terminal so usage can be attributed. The tag identifies
only the skill and its version; it carries no user data.
- **`gcloud` CLI Commands**: Prefix every `gcloud` invocation, whatever the
subcommand, with the metrics environment variable. Set it inline on each
command because shell state may not persist between commands:
```bash
CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:agent-platform-agent-registry)" \
gcloud <command> [flags]
```
Do not use `gcloud config set` for this: it would persist beyond the current
task and mislabel unrelated usage.
- **Direct HTTP, REST, and MCP Requests**: On direct HTTP calls to Google
Cloud APIs (for example with `curl`) or HTTP requests to a remote MCP
server, include
`agent-skills/1.0 (skill:agent-platform-agent-registry)` in the
`User-Agent` header. If a `User-Agent` header is already specified, append
this string to the end of it rather than overwriting existing `User-Agent`
data — the collection pipeline parses the `agent-skills/<version>` and
`skill:<name>` tokens, so any rewording breaks attribution:
```
User-Agent: <existing_user_agent> agent-skills/1.0 (skill:agent-platform-agent-registry)
```
- **Constraint for Generated Code**: The tracking prefix is strictly for
commands you execute directly in the terminal. Do NOT include this tracking
prefix in generated scripts, Terraform templates, or code provided to the
user for their own repositories.
- **User Opt-Out**: If the user asks to disable or remove tracking or
attribution tags, omit the `CLOUDSDK_METRICS_REQUEST_ATTRIBUTION` variable
and custom `User-Agent` suffix from all commands.
gcloud-command.md 31.4 KB
# `gcloud agent-registry` & Related CLI Command Reference
## Table of Contents
- [Main Command: `gcloud agent-registry`](#main-command-gcloud-agent-registry): Lines 31-75
- [Subcommands](#subcommands): Lines 79-485
- [`agents`](#agents): Lines 81-123
- [`bindings`](#bindings): Lines 125-149
- [`endpoints`](#endpoints): Lines 151-166
- [`findings`](#findings): Lines 168-177
- [`mcp-servers`](#mcp-servers): Lines 179-216
- [`operations`](#operations): Lines 218-226
- [`publishers`](#publishers): Lines 228-237
- [`services`](#services): Lines 239-263
- [`skills`](#skills): Lines 267-385
- [`ai-applications`](#ai-applications): Lines 389-485
- [Cloud Resource Manager: Management Boundary Commands](#cloud-resource-manager-management-boundary-commands): Lines 489-538
- [`boundary-configs`](#boundary-configs): Lines 491-502
- [`capability-configs`](#capability-configs): Lines 504-525
- [`boundaries`](#boundaries): Lines 527-538
- [Cloud Run: Agent Registry Automatic Registration Flags (`gcloud beta run`)](#cloud-run-agent-registry-automatic-registration-flags-gcloud-beta-run): Lines 542-582
- [Command Summary & Flag Reference Tables](#command-summary-flag-reference-tables): Lines 586-639
- [Natural Language to Command Examples](#natural-language-to-command-examples): Lines 643-711
---
Documentation for `gcloud agent-registry` (GA), `gcloud resource-manager`
(Management Boundaries), and `gcloud beta run` (Cloud Run automatic
registration).
## Main Command: `gcloud agent-registry`
```text
NAME
gcloud agent-registry - manage Agent Registry resources
SYNOPSIS
gcloud agent-registry GROUP [GCLOUD_WIDE_FLAG ...]
DESCRIPTION
Manage Agent Registry resources.
GROUPS
GROUP is one of the following:
agents
Manage Agent resources.
ai-applications
Manage Ai Application resources.
bindings
Manage Binding resources.
endpoints
Manage Endpoint resources.
findings
Manage Finding resources.
mcp-servers
Manage Mcp Server resources.
operations
Manage Operation resources.
publishers
Manage Publisher resources.
services
Manage Service resources.
skills
Manage Skill resources.
```
---
## Subcommands
### `agents`
```text
NAME
gcloud agent-registry agents - manage Agent resources
SYNOPSIS
gcloud agent-registry agents COMMAND [GCLOUD_WIDE_FLAG ...]
COMMANDS
describe
Describe agents.
list
List agents.
search
Search agents.
```
#### `agents search`
```text
SYNOPSIS
gcloud agent-registry agents search --location=LOCATION
[--search-string=SEARCH_STRING] [--search-type=SEARCH_TYPE]
[GCLOUD_WIDE_FLAG ...]
REQUIRED FLAGS
--location=LOCATION
ID of the location or fully qualified identifier for the location.
OPTIONAL FLAGS
--search-string=SEARCH_STRING
Search criteria used to select the Agents to return.
Search expressions can be used to restrict results based upon skills,
agentId, description, name, displayName, and trust, where the operators
=, :, NOT, AND, and OR can be used along with the suffix wildcard *.
Note: Wildcard * is NOT supported on skills.description (use token match :).
--search-type=SEARCH_TYPE
The type of search. If set, must be set to keyword.
```
### `bindings`
```text
NAME
gcloud agent-registry bindings - manage Binding resources
SYNOPSIS
gcloud agent-registry bindings COMMAND [GCLOUD_WIDE_FLAG ...]
COMMANDS
create
Create bindings.
delete
Delete bindings.
describe
Describe bindings.
list
List bindings.
update
Update bindings.
```
### `endpoints`
```text
NAME
gcloud agent-registry endpoints - manage Endpoint resources
SYNOPSIS
gcloud agent-registry endpoints COMMAND [GCLOUD_WIDE_FLAG ...]
COMMANDS
describe
Describe endpoints.
list
List endpoints.
```
### `findings`
```text
NAME
gcloud agent-registry findings - manage Finding resources
SYNOPSIS
gcloud agent-registry findings (list | describe) --location=LOCATION
[--filter=EXPRESSION] [GCLOUD_WIDE_FLAG ...]
```
### `mcp-servers`
```text
NAME
gcloud agent-registry mcp-servers - manage Mcp Server resources
SYNOPSIS
gcloud agent-registry mcp-servers COMMAND [GCLOUD_WIDE_FLAG ...]
COMMANDS
describe
Describe mcpServers.
list
List mcpServers.
search
Search mcpServers.
```
#### `mcp-servers search`
```text
SYNOPSIS
gcloud agent-registry mcp-servers search --location=LOCATION
[--search-string=SEARCH_STRING] [--search-type=SEARCH_TYPE]
[GCLOUD_WIDE_FLAG ...]
REQUIRED FLAGS
--location=LOCATION
ID of the location or fully qualified identifier for the location.
OPTIONAL FLAGS
--search-string=SEARCH_STRING
Search expressions can be used to restrict results based upon
mcpServerId, name, and displayName, where the operators =, :, NOT, AND,
and OR can be used along with the suffix wildcard symbol *.
```
### `operations`
```text
NAME
gcloud agent-registry operations - manage Operation resources
SYNOPSIS
gcloud agent-registry operations (list | describe) [GCLOUD_WIDE_FLAG ...]
```
### `publishers`
```text
NAME
gcloud agent-registry publishers - manage Publisher resources
SYNOPSIS
gcloud agent-registry publishers (list | describe) --location=LOCATION
[GCLOUD_WIDE_FLAG ...]
```
### `services`
```text
NAME
gcloud agent-registry services - manage Service resources
SYNOPSIS
gcloud agent-registry services COMMAND [GCLOUD_WIDE_FLAG ...]
COMMANDS
create
Create services (projects read-only Agent, McpServer, or Endpoint catalog entries: agentregistry-{ID}).
delete
Delete services.
describe
Describe services (includes registryResource showing the projected agentregistry-{ID} resource name).
list
List services.
update
Update services.
```
---
### `skills`
```text
NAME
gcloud agent-registry skills - manage Skill resources
SYNOPSIS
gcloud agent-registry skills GROUP | COMMAND [GCLOUD_WIDE_FLAG ...]
GROUPS
revisions
Manage Skill Revision resources.
COMMANDS
add-iam-policy-binding
Add IAM policy binding for a skill.
create
Create skills.
delete
Delete skills.
describe
Describe skills.
get-iam-policy
Get the IAM policy for a skill.
list
List skills.
remove-iam-policy-binding
Remove IAM policy binding from a skill.
search
Search skills.
set-iam-policy
Set the IAM policy for a skill.
update
Update skills.
```
#### `skills create`
```text
SYNOPSIS
gcloud agent-registry skills create SKILL [--async]
[--default-revision=DEFAULT_REVISION] [--description=DESCRIPTION]
[--display-name=DISPLAY_NAME] [--location=LOCATION]
[--publisher=PUBLISHER] [--request-id=REQUEST_ID]
[--scanning-policy=SCANNING_POLICY] [--target-state=TARGET_STATE]
[--type=TYPE]
[--initial-revision-name=INITIAL_REVISION_NAME --payload=PAYLOAD
| [--gcs-source-uri=GCS_SOURCE_URI
: --gcs-source-generation=GCS_SOURCE_GENERATION]]
[GCLOUD_WIDE_FLAG ...]
NOTES
- Supported locations: global, us, and eu only.
- Automatic 'private-' prefix: Running 'skills create my-skill' creates
'skills/private-my-skill'. Subsequent describe, update, delete,
revisions, and *-iam-policy commands must pass 'private-my-skill'.
- Target state & scanning: --target-state accepts active, disabled, or
draft on create ('active' requires an initial revision via --payload or
--gcs-source-uri; deprecated and decommissioned are also accepted on
update). Under the default 'enabled-blocking' scanning policy,
'--target-state=active' enters DRAFT until the security scan completes
with no findings.
- Cloud Storage source: When passing --gcs-source-uri, grant
'storage.objects.get' on the bucket to the Agent Registry service agent
('service-PROJECT_NUMBER@gcp-sa-agentregistry.iam.gserviceaccount.com').
```
#### `skills search`
```text
SYNOPSIS
gcloud agent-registry skills search --location=LOCATION
[--query=QUERY] [--search-type=SEARCH_TYPE] [--filter=EXPRESSION]
[--limit=LIMIT] [--page-size=PAGE_SIZE] [--sort-by=[FIELD,...]]
[GCLOUD_WIDE_FLAG ...]
```
#### `skills revisions`
```text
SYNOPSIS
gcloud agent-registry skills revisions (create | delete | describe | list)
--skill=SKILL --location=LOCATION [GCLOUD_WIDE_FLAG ...]
gcloud agent-registry skills revisions download
(REVISION : --location=LOCATION --skill=SKILL)
--destination=DESTINATION [--allow-overwrite] [GCLOUD_WIDE_FLAG ...]
```
#### `skills` Resource-Level IAM Commands
```text
SYNOPSIS
gcloud agent-registry skills get-iam-policy (SKILL : --location=LOCATION)
[--filter=EXPRESSION] [--limit=LIMIT] [--page-size=PAGE_SIZE]
[--sort-by=[FIELD,...]] [GCLOUD_WIDE_FLAG ...]
gcloud agent-registry skills set-iam-policy (SKILL : --location=LOCATION)
POLICY_FILE [GCLOUD_WIDE_FLAG ...]
gcloud agent-registry skills add-iam-policy-binding
(SKILL : --location=LOCATION) --member=PRINCIPAL --role=ROLE
[--condition=[KEY=VALUE,...] | --condition-from-file=PATH_TO_FILE]
[GCLOUD_WIDE_FLAG ...]
gcloud agent-registry skills remove-iam-policy-binding
(SKILL : --location=LOCATION) --member=PRINCIPAL --role=ROLE
[--all | --condition=[KEY=VALUE,...]
| --condition-from-file=PATH_TO_FILE] [GCLOUD_WIDE_FLAG ...]
```
---
### `ai-applications`
```text
NAME
gcloud agent-registry ai-applications - manage Ai Application resources
SYNOPSIS
gcloud agent-registry ai-applications GROUP | COMMAND [GCLOUD_WIDE_FLAG ...]
GROUPS
agents
Manage Agent resources scoped to an AI Application.
endpoints
Manage Endpoint resources scoped to an AI Application.
mcp-servers
Manage Mcp Server resources scoped to an AI Application.
COMMANDS
add-iam-policy-binding
create
delete
describe
get-iam-policy
list
remove-iam-policy-binding
search
set-iam-policy
update
```
#### `ai-applications` CRUD & IAM Commands
```text
SYNOPSIS
gcloud agent-registry ai-applications list --location=LOCATION
[--filter=EXPRESSION] [--limit=LIMIT] [--page-size=PAGE_SIZE]
[--sort-by=[FIELD,...]] [GCLOUD_WIDE_FLAG ...]
gcloud agent-registry ai-applications describe
(AI_APPLICATION : --location=LOCATION) [GCLOUD_WIDE_FLAG ...]
gcloud agent-registry ai-applications search --location=LOCATION
[--search-string=SEARCH_STRING] [--filter=EXPRESSION]
[--limit=LIMIT] [--page-size=PAGE_SIZE] [GCLOUD_WIDE_FLAG ...]
gcloud agent-registry ai-applications create
(AI_APPLICATION : --location=LOCATION) [--async]
[--description=DESCRIPTION] [--display-name=DISPLAY_NAME]
[--environment-type=ENVIRONMENT_TYPE]
[--criticality-type=CRITICALITY_TYPE]
[--business-owners=[email=EMAIL,...]]
[--developer-owners=[email=EMAIL,...]]
[--operator-owners=[email=EMAIL,...]]
[--labels=[KEY=VALUE,...]] [--members=[MEMBERS,...]]
[--request-id=REQUEST_ID] [GCLOUD_WIDE_FLAG ...]
gcloud agent-registry ai-applications update
(AI_APPLICATION : --location=LOCATION) [--async]
[--description=DESCRIPTION] [--display-name=DISPLAY_NAME]
[--environment-type=ENVIRONMENT_TYPE]
[--criticality-type=CRITICALITY_TYPE]
[--labels=[KEY=VALUE,...]] [--members=[MEMBERS,...]]
[--request-id=REQUEST_ID] [GCLOUD_WIDE_FLAG ...]
gcloud agent-registry ai-applications delete
(AI_APPLICATION : --location=LOCATION) [--async] [--etag=ETAG]
[--force] [--request-id=REQUEST_ID] [GCLOUD_WIDE_FLAG ...]
gcloud agent-registry ai-applications get-iam-policy
(AI_APPLICATION : --location=LOCATION) [GCLOUD_WIDE_FLAG ...]
gcloud agent-registry ai-applications set-iam-policy
(AI_APPLICATION : --location=LOCATION) POLICY_FILE [GCLOUD_WIDE_FLAG ...]
gcloud agent-registry ai-applications add-iam-policy-binding
(AI_APPLICATION : --location=LOCATION) --member=PRINCIPAL --role=ROLE
[--condition=[KEY=VALUE,...] | --condition-from-file=PATH_TO_FILE]
[GCLOUD_WIDE_FLAG ...]
gcloud agent-registry ai-applications remove-iam-policy-binding
(AI_APPLICATION : --location=LOCATION) --member=PRINCIPAL --role=ROLE
[--all | --condition=[KEY=VALUE,...]
| --condition-from-file=PATH_TO_FILE] [GCLOUD_WIDE_FLAG ...]
```
#### `ai-applications` Subgroups (`agents`, `mcp-servers`, `endpoints`)
```text
SYNOPSIS
gcloud agent-registry ai-applications (agents | mcp-servers | endpoints)
(list | describe | search)
--ai-application=AI_APPLICATION --location=LOCATION
[--search-string=SEARCH_STRING] [--filter=EXPRESSION]
[GCLOUD_WIDE_FLAG ...]
```
---
## Cloud Resource Manager: Management Boundary Commands
### `boundary-configs`
```text
SYNOPSIS
gcloud resource-manager boundary-configs describe
(--folder=FOLDER_ID | --organization=ORGANIZATION_ID)
gcloud resource-manager boundary-configs update
(--clear-tag-key | --tag-key=TAG_KEY)
(--folder=FOLDER_ID | --organization=ORGANIZATION_ID) [--async]
[--etag=ETAG] [GCLOUD_WIDE_FLAG ...]
```
### `capability-configs`
```text
SYNOPSIS
gcloud resource-manager capability-configs create
(CAPABILITY_CONFIG
: --folder=FOLDER --organization=ORGANIZATION --project=PROJECT)
--types=[TYPES,...] [--async] [--boundaries=[BOUNDARIES,...]]
[--display-name=DISPLAY_NAME] [--management-project=MANAGEMENT_PROJECT]
[GCLOUD_WIDE_FLAG ...]
gcloud resource-manager capability-configs update
(CAPABILITY_CONFIG
: --folder=FOLDER --organization=ORGANIZATION --project=PROJECT)
[--async] [--display-name=DISPLAY_NAME] [--etag=ETAG]
[--types=[TYPES,...]]
[--boundaries=[BOUNDARIES,...] | --clear-boundaries]
[GCLOUD_WIDE_FLAG ...]
gcloud resource-manager capability-configs (list | describe | delete)
(--folder=FOLDER | --organization=ORGANIZATION | --project=PROJECT)
```
### `boundaries`
```text
SYNOPSIS
gcloud resource-manager boundaries create
(BOUNDARY : --folder=FOLDER --organization=ORGANIZATION) [--async]
[--display-name=DISPLAY_NAME] [--tag-key=TAG_KEY]
[--tag-value=TAG_VALUE] [GCLOUD_WIDE_FLAG ...]
gcloud resource-manager boundaries (list | describe | update | delete)
(--folder=FOLDER | --organization=ORGANIZATION)
```
---
## Cloud Run: Agent Registry Automatic Registration Flags (`gcloud beta run`)
```text
SYNOPSIS
gcloud beta run deploy [[SERVICE] --namespace=NAMESPACE]
[--image=IMAGE_URL | --source=SOURCE] [--region=REGION]
[--functional-type=FUNCTIONAL_TYPE] [--identity-type=IDENTITY_TYPE]
[--[no-]identity-certificate] [GCLOUD_WIDE_FLAG ...]
gcloud beta run services update [SERVICE] [--region=REGION]
[--functional-type=FUNCTIONAL_TYPE] [--identity-type=IDENTITY_TYPE]
[--[no-]identity-certificate] [--no-traffic] [GCLOUD_WIDE_FLAG ...]
gcloud beta run jobs (create | deploy | update) [JOB] [--image=IMAGE_URL]
[--region=REGION] [--functional-type=agent]
[--identity-type=agent-identity] [--[no-]identity-certificate]
[GCLOUD_WIDE_FLAG ...]
gcloud beta run revisions describe REVISION_NAME [--region=REGION]
gcloud beta run jobs executions describe EXECUTION_NAME [--region=REGION]
FLAGS
--functional-type=FUNCTIONAL_TYPE
Specifies the function of the resource for automatic registration in
Agent Registry (sets annotation apphub.cloud.google.com/functional-type).
Once configured on a resource, this property is immutable and cannot be
changed or cleared.
- Services support: agent, mcp-server
- Jobs support: agent only
--identity-type=IDENTITY_TYPE
Configures the type of identity assigned to the resource. Once set,
this property is immutable and cannot be changed or unset.
- agent-identity: Assigns a SPIFFE agent identity (required when --functional-type=agent)
- service-account: Uses a standard Google Cloud service account (default for mcp-server)
--[no-]identity-certificate
Enables automatic provisioning of identity certificates from the trust
domain into the container environment (enabled by default when
--identity-type=agent-identity). Use --no-identity-certificate to opt out.
```
---
## Command Summary & Flag Reference Tables
All `gcloud agent-registry` commands support `--location` (required) and
`--project` (optional). Cloud Run commands (`gcloud beta run`) use `--region`
(or `--project`). Cloud Resource Manager boundary governance commands (`gcloud
resource-manager`) are scoped to `--folder` or `--organization`.
| Group | Commands | CLI Track |
|-------|----------|-----------|
| `agents` | `list`, `describe`, `search` | GA (`gcloud agent-registry agents`) |
| `mcp-servers` | `list`, `describe`, `search` | GA (`gcloud agent-registry mcp-servers`) |
| `endpoints` | `list`, `describe` | GA (`gcloud agent-registry endpoints`) |
| `services` | `create`, `list`, `describe`, `update`, `delete` | GA (`gcloud agent-registry services`) |
| `bindings` | `create`, `list`, `describe`, `update`, `delete` | GA (`gcloud agent-registry bindings`) |
| `operations` | `list`, `describe` | GA (`gcloud agent-registry operations`) |
| `skills` | `create`, `list`, `describe`, `update`, `delete`, `search`, `get-iam-policy`, `set-iam-policy`, `add-iam-policy-binding`, `remove-iam-policy-binding` | GA (`gcloud agent-registry skills`) |
| `skills revisions` | `create`, `list`, `describe`, `delete`, `download` | GA (`gcloud agent-registry skills revisions`) |
| `findings` | `list`, `describe` | GA (`gcloud agent-registry findings`) |
| `publishers` | `list`, `describe` | GA (`gcloud agent-registry publishers`) |
| `ai-applications` | `list`, `describe`, `search`, `create`, `update`, `delete`, `get-iam-policy`, `set-iam-policy`, `add-iam-policy-binding`, `remove-iam-policy-binding` | GA (`gcloud agent-registry ai-applications`) |
| `ai-applications agents` | `list`, `describe`, `search` | GA (`gcloud agent-registry ai-applications agents`) |
| `ai-applications mcp-servers` | `list`, `describe`, `search` | GA (`gcloud agent-registry ai-applications mcp-servers`) |
| `ai-applications endpoints` | `list`, `describe`, `search` | GA (`gcloud agent-registry ai-applications endpoints`) |
| `run` (`deploy`, `services update`, `jobs`) | `deploy`, `services update`, `multi-region-services update`, `jobs create`, `jobs deploy`, `jobs update`, `revisions describe`, `jobs executions describe` | Beta (`gcloud beta run` with `--functional-type` & `--identity-type`) |
| `boundary-configs` | `describe`, `update` | GA (`gcloud resource-manager boundary-configs`) |
| `capability-configs` | `create`, `list`, `describe`, `update`, `delete` | GA (`gcloud resource-manager capability-configs`) |
| `boundaries` | `create`, `list`, `describe`, `update`, `delete` | GA (`gcloud resource-manager boundaries`) |
| `tags bindings` | `create`, `list`, `delete` | GA (`gcloud resource-manager tags bindings`) |
### Service Creation Flags (`gcloud agent-registry services create`)
Service IDs must be 4–63 characters (`^[a-z][a-z0-9-]{2,61}[a-z0-9]$`; suffix
3-letter GCP APIs such as `iam` -> `iam-api`). Downstream IAP egress policies
(`roles/iap.egressor`) bind to the projected `Endpoint` catalog ID
(`agentregistry-{UUID}`), not the `Service` ID.
| Flag | Description |
|------|-------------|
| `--display-name` | Human-readable name (up to 63 chars) |
| `--description` | Brief summary of the service |
| `--interfaces` | Repeated `protocolBinding=...,url=...` flags or JSON array of protocol bindings and URLs (supports composite multi-URL endpoints) |
| `--mcp-server-spec-type` | Type: `no-spec`, `tool-spec` |
| `--mcp-server-spec-content` | JSON content of the MCP tool spec |
| `--agent-spec-type` | Type: `no-spec`, `a2a-agent-card` |
| `--agent-spec-content` | JSON content for `a2a-agent-card` |
| `--endpoint-spec-type` | Type: `no-spec` |
### Cloud Run Automatic Registration Flags (`gcloud beta run`)
| Flag | Values | Description |
|------|--------|-------------|
| `--functional-type` | `agent`, `mcp-server` | Declares the workload's function for automatic registration in Agent Registry (sets `apphub.cloud.google.com/functional-type`). **Immutable once set.** Cloud Run jobs only support `agent`. |
| `--identity-type` | `agent-identity`, `service-account` | Configures the identity assigned to the Cloud Run resource. **Required as `agent-identity` when `--functional-type=agent`. Immutable once set.** |
| `--[no-]identity-certificate` | Boolean | Enabled by default when `--identity-type=agent-identity`. Pass `--no-identity-certificate` to opt out of automatic SPIFFE certificate provisioning. |
---
## Natural Language to Command Examples
| User says | Command |
|-----------|---------|
| "List my MCP servers" | `gcloud agent-registry mcp-servers list --location=us-central1` |
| "Configure this GKE deployment as an agent" | `./scripts/annotate_gke.py /path/to/folder_or_file.yaml --type AGENT` |
| "Make my deployments in this folder MCP Servers" | `./scripts/annotate_gke.py /path/to/folder_or_file.yaml --type MCP_SERVER` |
| "Show me a GKE manifest for an MCP server in Agent Registry" | Provide `Deployment` YAML with `registry.gke.io/functional-type: "MCP_SERVER"`, `modelcontextprotocol.info/urls`, `modelcontextprotocol.info/capabilities`, and `iam.gke.io/spiffe-identity-type: agent-identity` |
| "Show me a GKE manifest for an A2A agent in Agent Registry" | Provide `Deployment` + `Service` YAML with `registry.gke.io/functional-type: "AGENT"`, `a2a-protocol.org/agent-card`, and `iam.gke.io/spiffe-identity-type: agent-identity` |
| "Deploy a Cloud Run service my-agent as an agent in us-central1" | `gcloud beta run deploy my-agent --image=IMAGE_URL --region=us-central1 --functional-type=agent --identity-type=agent-identity` |
| "Register my existing Cloud Run service my-agent as an agent" | `gcloud beta run services update my-agent --region=us-central1 --functional-type=agent --identity-type=agent-identity --no-traffic` |
| "Deploy a Cloud Run service my-mcp as an MCP server" | `gcloud beta run deploy my-mcp --image=IMAGE_URL --region=us-central1 --functional-type=mcp-server` |
| "Update existing Cloud Run service my-mcp to register as an MCP server" | `gcloud beta run services update my-mcp --region=us-central1 --functional-type=mcp-server` |
| "Create a Cloud Run job my-agent-job registered as an agent" | `gcloud beta run jobs create my-agent-job --image=IMAGE_URL --region=us-central1 --functional-type=agent --identity-type=agent-identity` |
| "View the assigned agent identity for Cloud Run revision my-agent-00001" | `gcloud beta run revisions describe my-agent-00001 --region=us-central1` |
| "Show me information on agent X" | `gcloud agent-registry agents describe X --location=us-central1` |
| "Register a new MCP server my-mcp-service with this spec..." | `gcloud agent-registry services create my-mcp-service ... --mcp-server-spec-content='...'` |
| "Check status of operation Y" | `gcloud agent-registry operations describe Y --location=us-central1` |
| "List all registered services" | `gcloud agent-registry services list --location=us-central1` |
| "Delete registered service Z" | `gcloud agent-registry services delete Z --location=us-central1` |
| "Show all agents where the runtime is reasoningEngine" | `gcloud agent-registry agents list --location=us-central1 --filter="attributes.\"agentregistry.googleapis.com/system/RuntimeReference\".uri:reasoningEngine"` |
| "Show agents with identity containing 'service-123456789012'" | `gcloud agent-registry agents list --location=us-central1 --filter="attributes.\"agentregistry.googleapis.com/system/RuntimeIdentity\".principal:service-123456789012"` |
| "Create a new A2A agent called my-a2a" | `gcloud agent-registry services create my-a2a --agent-spec-type=a2a-agent-card ...` |
| "Show me all MCP servers where the runtime is my-runtime" | `gcloud agent-registry mcp-servers list --location=us-central1 --filter="attributes.\"agentregistry.googleapis.com/system/RuntimeReference\".uri:my-runtime"` |
| "List all global agents" | `gcloud agent-registry agents list --location=global` |
| "List global MCP servers" | `gcloud agent-registry mcp-servers list --location=global` |
| "Change display name of gemini-models to 'Vertex AI Model Garden'" | `gcloud agent-registry services update gemini-models --display-name="..." --location=us-central1` |
| "Quickly add the aiplatform GCP service in us-central1 (composite 5-URL service)" | `./scripts/quick-add-gcp-service.sh --service=aiplatform --location=us-central1` |
| "Quick add storage API endpoints for Agent Gateway in us-central1" | `./scripts/quick-add-gcp-service.sh --service=storage --location=us-central1` |
| "Which agents in us-central1 are based on reasoning engine?" | `gcloud agent-registry agents list --location=us-central1 --filter="attributes.\"agentregistry.googleapis.com/system/RuntimeReference\".uri:reasoningEngine"` |
| "List all vertex ai agents" | `gcloud agent-registry agents list --location=us-central1 --filter="attributes.\"agentregistry.googleapis.com/system/RuntimeReference\".uri:reasoningEngine"` |
| "Show agents with agent engine runtime" | `gcloud agent-registry agents list --location=us-central1 --filter="attributes.\"agentregistry.googleapis.com/system/RuntimeReference\".uri:reasoningEngine"` |
| "Which MCP Server has a tool named search_documents?" | `gcloud agent-registry mcp-servers list --location=us-central1 --filter="tools.name:search_documents"` |
| "Find all servers with the get_document tool" | `gcloud agent-registry mcp-servers list --location=us-central1 --filter="tools.name:get_document"` |
| "Search for all reasoning engine agents by agent ID" | `gcloud agent-registry agents list --location=us-central1 --filter="agentId:reason"` |
| "Search for Cloud Run MCP servers by MCP Server ID" | `gcloud agent-registry mcp-servers list --location=us-central1 --filter="mcpServerId:run"` |
| "Search for agents by skill name translation" | `gcloud agent-registry agents search --location=us-central1 --search-string="skills.name:translation"` |
| "Search for agents with display name starting with MyAgent" | `gcloud agent-registry agents search --location=us-central1 --search-string="displayName:MyAgent*"` |
| "Search for MCP servers starting with display name MyMcp" | `gcloud agent-registry mcp-servers search --location=us-central1 --search-string="displayName:MyMcp*"` |
| "Create a binding between agent A and server B" | `gcloud agent-registry bindings create my-binding --source-identifier="URN_A" --target-identifier="URN_B" --location=us-central1` |
| "List all bindings" | `gcloud agent-registry bindings list --location=us-central1` |
| "Show details for binding X" | `gcloud agent-registry bindings describe X --location=us-central1` |
| "Delete binding Y" | `gcloud agent-registry bindings delete Y --location=us-central1` |
| "List all skills" | `gcloud agent-registry skills list --location=us` |
| "Create a skill named my-skill from /path/to/archive.zip" | `gcloud agent-registry skills create my-skill --location=us --display-name="My Skill" --target-state=active --payload=/path/to/archive.zip` *(creates `skills/private-my-skill`)* |
| "Show details of custom skill my-skill" | `gcloud agent-registry skills describe private-my-skill --location=us` |
| "Upload a new revision v2 for custom skill my-skill" | `gcloud agent-registry skills revisions create v2 --skill=private-my-skill --location=us --payload=/path/to/archive.zip` |
| "List security scan findings in us" | `gcloud agent-registry findings list --location=us` |
| "Search skills matching query" | `gcloud agent-registry skills search --location=us --query="QUERY"` |
| "Get IAM policy on custom skill my-skill" | `gcloud agent-registry skills get-iam-policy private-my-skill --location=us` |
| "Grant user alice@example.com viewer role on custom skill my-skill" | `gcloud agent-registry skills add-iam-policy-binding private-my-skill --location=us --member="user:alice@example.com" --role="roles/agentregistry.viewer"` |
| "Set IAM policy on custom skill my-skill from policy.yaml" | `gcloud agent-registry skills set-iam-policy private-my-skill policy.yaml --location=us` |
| "List all AI applications" | `gcloud agent-registry ai-applications list --location=us-central1` |
| "Describe the default AI application" | `gcloud agent-registry ai-applications describe default --location=us-central1` |
| "Search AI applications with display name Customer*" | `gcloud agent-registry ai-applications search --location=us-central1 --search-string="displayName:Customer*"` |
| "List agents under the default AI application" | `gcloud agent-registry ai-applications agents list --ai-application=default --location=us-central1` |
| "List MCP servers under AI application my-ai-app" | `gcloud agent-registry ai-applications mcp-servers list --ai-application=my-ai-app --location=us-central1` |
| "Get IAM policy for AI application my-ai-app" | `gcloud agent-registry ai-applications get-iam-policy my-ai-app --location=us-central1` |
| "Grant group ai-team@example.com viewer access on AI application my-ai-app" | `gcloud agent-registry ai-applications add-iam-policy-binding my-ai-app --location=us-central1 --member="group:ai-team@example.com" --role="roles/agentregistry.viewer"` |
| "Set IAM policy on AI application my-ai-app from policy.yaml" | `gcloud agent-registry ai-applications set-iam-policy my-ai-app policy.yaml --location=us-central1` |
| "Configure folder 111111111111 boundary config to use environment tag" | `gcloud resource-manager boundary-configs update --folder=111111111111 --tag-key="222222222222/environment"` |
| "Create a capability config for agent management on folder 111111111111" | `gcloud resource-manager capability-configs create agent-governance --folder=111111111111 --display-name="Agent Governance Capability" --types=agent-management --management-project=projects/123456789012` |
| "Create a dev boundary under folder 111111111111 for environment=dev" | `gcloud resource-manager boundaries create agents-dev --folder=111111111111 --display-name="Agent Dev Boundary" --tag-key="222222222222/environment" --tag-value="dev"` |
| "Associate boundary agents-dev with capability config agent-governance" | `gcloud resource-manager capability-configs update agent-governance --folder=111111111111 --boundaries=folders/111111111111/boundaries/agents-dev` |
| "Bind tag environment=dev to project 333333333333" | `gcloud resource-manager tags bindings create --tag-value=222222222222/environment/dev --parent=//cloudresourcemanager.googleapis.com/projects/333333333333` |
| "List all boundaries under folder 111111111111" | `gcloud resource-manager boundaries list --folder=111111111111` |
| "List all capability configs under folder 111111111111" | `gcloud resource-manager capability-configs list --folder=111111111111` |
| "Filter aggregated agents in management project by spoke project number 333333333333" | `gcloud agent-registry agents list --project=MANAGEMENT_PROJECT_ID --location=us-central1 --filter="agentId:333333333333"` |
| "Search aggregated agents by skill tag productivity" | `gcloud agent-registry agents search --project=MANAGEMENT_PROJECT_ID --location=us-central1 --search-string="skills.tags:productivity"` |
management-boundaries.md 17.8 KB
# Management Boundary Setup (Admin Governance)
## Table of Contents
- [Resource Model Overview](#resource-model-overview): Lines 21-29
- [Required IAM Roles & Permissions for Boundary Setup](#required-iam-roles-permissions-for-boundary-setup): Lines 30-55
- [Interactive Scoping Questions for Admins](#interactive-scoping-questions-for-admins): Lines 56-95
- [Best Practices & Architectural Guardrails](#best-practices-architectural-guardrails): Lines 96-152
- [Step-by-Step Boundary Provisioning Workflow](#step-by-step-boundary-provisioning-workflow): Lines 153-280
- [Safe Teardown Sequence](#safe-teardown-sequence): Lines 281-302
---
Agent Registry administrators use Cloud Resource Manager (`BoundaryConfig`,
`CapabilityConfig`, `Boundary`, and Tag Bindings) to configure hub-and-spoke
governance perimeters across a Google Cloud Folder or Organization. When member
(spoke) projects match a boundary's tag filter, Agent Registry automatically
discovers runtime agents and MCP servers deployed across those member projects
and aggregates them into the designated Management Project (hub) catalog.
## Resource Model Overview
| Resource | CLI Command Group | Purpose |
|----------|-------------------|---------|
| **`BoundaryConfig`** | `gcloud resource-manager boundary-configs` | Singleton resource on a Folder or Organization node (`folders/{id}/boundaryConfig` or `organizations/{id}/boundaryConfig`) that specifies the single partitioning `tagKey` (e.g., `222222222222/environment`) used by all boundaries under that node. |
| **`CapabilityConfig`** | `gcloud resource-manager capability-configs` | Designates a Management Project (hub) under the Folder or Organization, enables `--types=agent-management` (or `agent-management,app-management`), and associates one or more `Boundary` resources. |
| **`Boundary`** | `gcloud resource-manager boundaries` | Logical perimeter under a Folder or Organization that selects child projects matching a specific tag value (`--tag-key` and `--tag-value`) and links to a `CapabilityConfig`. |
| **Tag Bindings** | `gcloud resource-manager tags bindings` | Enrolls the Management Project and Member (Spoke) Projects into a boundary perimeter by binding the corresponding tag value (e.g., `222222222222/environment/dev`). |
## Required IAM Roles & Permissions for Boundary Setup
Before running boundary provisioning commands, verify that the administrator
holds the required IAM roles on the appropriate hierarchy nodes:
| Role | Where to Grant (Target Resource) | Underlying Permissions | Purpose |
|------|----------------------------------|------------------------|---------|
| **`roles/resourcemanager.editor`** *(Resource Manager Editor)* | **Parent Folder or Organization** (`folders/FOLDER_ID` or `organizations/ORG_ID`) | • `resourcemanager.capabilityConfigs.{create,get,update,delete,list}`<br>• `resourcemanager.boundaries.{create,get,update,delete,list,associateToCapabilityConfig}`<br>• `resourcemanager.boundaryConfigs.{get,update}`<br>• `resourcemanager.boundaryMembers.{get,list}` | Create, update, link, and delete `CapabilityConfig`, `Boundary`, and singleton `BoundaryConfig` resources under the folder/org. *(Note: There is no dedicated curated `boundaryAdmin` role; these permissions ship inside `roles/resourcemanager.editor` or a Custom Role.)* |
| **`roles/resourcemanager.viewer`** *(Resource Manager Viewer)* | **Parent Folder or Organization** (`folders/FOLDER_ID` or `organizations/ORG_ID`) | • `resourcemanager.capabilityConfigs.{get,list}`<br>• `resourcemanager.boundaries.{get,list}`<br>• `resourcemanager.boundaryConfigs.get`<br>• `resourcemanager.boundaryMembers.{get,list}` | Read-only inspection of boundary configurations, capability configs, boundaries, and effective boundary members. |
| **`roles/owner`** or **`roles/editor`** *(Project Owner / Editor)* | **Candidate Bring-Your-Own Management Project** (`projects/PROJECT_NUMBER`) | • `resourcemanager.projects.associateToCapabilityConfig` | Required on an existing project when designating it as a Management Project via `--management-project=projects/<PROJECT_NUMBER>` on `capability-configs create`. (Not needed if Cloud Resource Manager auto-provisions a Google-managed project.) |
| **`roles/resourcemanager.tagUser`** *(Tag User)* | **Both the Tag Value AND each Target Project** (Hub + Member Spoke Projects) | • `resourcemanager.tagValues.use`<br>• `resourcemanager.tagValueBindings.{create,delete}` | Required to attach or detach environment/perimeter tag bindings (`gcloud resource-manager tags bindings create/delete`) on projects. *(Creating new Tag Keys/Values requires `roles/resourcemanager.tagAdmin` on the Organization.)* |
| **`roles/agentregistry.admin`** / **`roles/agentregistry.viewer`** | **Management Project (Hub)** (`projects/MGMT_PROJECT_ID`) | • `agentregistry.*` | `roles/agentregistry.admin` to centrally register `Services` and `Bindings` on the hub; `roles/agentregistry.viewer` to query (`list`, `describe`, `search`) the aggregated agent, MCP server, and skill catalog across the boundary. |
> **Custom Role & IAM Notes:**
> - All `resourcemanager.capabilityConfigs.*`, `resourcemanager.boundaries.*`,
> and `resourcemanager.boundaryConfigs.*` permissions support **IAM Custom
> Roles** and **IAM Deny** policies (`create` and `list` are checked as
> `parents_only` on the Folder or Organization).
> - The permission resource noun for the singleton `boundaryConfig` is plural
> (`resourcemanager.boundaryConfigs.get` and
> `resourcemanager.boundaryConfigs.update`).
> - Attaching a `Boundary` to a `CapabilityConfig` (`capability-configs update
> --boundaries=...`) checks both `resourcemanager.capabilityConfigs.update`
> and `resourcemanager.boundaries.associateToCapabilityConfig` on the parent
> node.
## Interactive Scoping Questions for Admins
When an administrator asks to set up a Management Boundary or
`CapabilityConfig` (or asks what information you need and what best practices
to follow), **always present all 6 scoping questions and all best practices
below in a single response** (skipping only details they have already provided)
before constructing mutating commands:
1. **Parent Hierarchy Node (Folder vs. Organization)**:
_"Which Folder ID (`--folder=FOLDER_ID`) or Organization ID
(`--organization=ORG_ID`) will anchor the boundary and management
project(s)?"_
*(Note: A `CapabilityConfig`, its Management Project, and all associated
`Boundary` resources must share the exact same parent node.)*
2. **Perimeter Partitioning & Tag Key Strategy**:
_"How do you want to partition projects under this node? Do you want
multiple isolated perimeters using an Organization Tag Key (for example,
`<ORG_ID>/environment` with values like `dev` and `prod`, or partitioning by
business unit), or a single catch-all boundary covering all child
projects?"_
3. **Catalog & IAM Isolation (`1 Hub per Perimeter` vs. `Shared Hub`)**:
_"If you have multiple perimeters (such as `dev` and `prod`), do you want
**strict catalog and IAM isolation** with a dedicated Management Project and
`CapabilityConfig` per perimeter (recommended so `prod` agents never appear
in `dev` queries and vice versa), or should multiple boundaries roll up into
a single shared Management Project?"_
4. **Management Project Selection (Bring-Your-Own vs. Google-Managed)**:
_"Do you want to designate existing project(s) under that parent node as
your Management Project(s)
(`--management-project=projects/<PROJECT_NUMBER>`), or have Cloud Resource
Manager auto-provision a new Google-managed Management Project (by omitting
`--management-project`)?"_
5. **Capability Types (`agent-management` vs. Shared with App Hub)**:
_"Should the `CapabilityConfig` enable `agent-management` only, or both
`agent-management,app-management` (to share the Management Project with App
Hub)?"_
6. **Member (Spoke) Projects**:
_"Which project IDs or project numbers should be enrolled into each boundary
perimeter via tag bindings?"_
## Best Practices & Architectural Guardrails
Always share relevant best practices with the administrator as you guide them
through setup:
- **Set `BoundaryConfig` Tag Key Before Attaching Boundaries**: Configure the
partitioning `tagKey` (`gcloud resource-manager boundary-configs update`)
*before* creating and attaching boundaries. Once any boundary under the node
is attached to a `CapabilityConfig`, Cloud Resource Manager locks `tagKey` on
that node (requiring all boundaries to be detached before `tagKey` can be
changed). If `tagKey` is left unset, the node supports at most one
filter-less boundary that matches every child project under the node.
- **Use Separate `CapabilityConfig` + Management Project for Strict `dev`/`prod`
Isolation**: Every boundary attached to the same `CapabilityConfig` merges
its discovered agents and MCP servers into one Management Project catalog.
There is no `--boundary` filter on `gcloud agent-registry` queries, and
granting `roles/agentregistry.viewer` on a Management Project exposes assets
from all boundaries attached to it. To guarantee zero cross-perimeter leakage
between environments (e.g., `dev` vs. `prod`), create a separate
`CapabilityConfig`, Management Project, and `Boundary` for each environment.
- **Always Use Project Numbers (`projects/<PROJECT_NUMBER>`)**: Cloud Resource
Manager v3 requires project **numbers** (not project IDs) for
`--management-project=projects/<PROJECT_NUMBER>` on `capability-configs
create` and `--parent=//cloudresourcemanager.googleapis.com/projects/<PROJECT_NUMBER>`
on `tags bindings create`. Whenever a user provides a project ID for
`--management-project`, always output **both** the lookup command below
**and** the complete `gcloud resource-manager capability-configs create`
command template using `--management-project=projects/<PROJECT_NUMBER>`
(defaulting `--types=agent-management` when not specified) in the same
response:
```bash
gcloud projects describe PROJECT_ID --format="value(projectNumber)"
```
- **Tag Binding Updates Require Delete-Then-Create**: Whenever a user asks to
move a project from one boundary/tag value to another (e.g., `dev` to
`prod`), always explicitly warn them that GCP Tags allow at most one value
per tag key on a resource (`tags bindings create` does not overwrite an
existing binding and fails with `FAILED_PRECONDITION` if another value under
the same tag key is already bound), and then provide the `tags bindings
delete` followed by `tags bindings create` commands. Tag changes take ~2–7
minutes to fully propagate.
- **Resource ID & Display Name Constraints**: `capability_config_id` and
`boundary_id` must be 6–30 lowercase ASCII letters, digits, or hyphens, must
start with a letter, and cannot end with a hyphen. `--display-name` must be
4–30 characters.
- **Centralize Manual Registrations in the Hub (Spoke Governance)**: Automatic
runtime discovery (e.g., Vertex AI Agent Engine / Reasoning Engine and GKE
agents/MCP servers) works across spoke member projects even when
`agentregistry.googleapis.com` is disabled on the spoke projects. However,
user-defined `Services` (`gcloud agent-registry services create`) and
`Bindings` created locally in a spoke project stay isolated to that spoke and
**do not roll up** to the Management Project. Register third-party MCP
servers, custom agents, endpoints, and bindings centrally in the Management
Project, and consider disabling `agentregistry.googleapis.com` (or
restricting `services.*` and `bindings.*` write permissions via IAM Deny /
Org Policy `gcp.restrictServiceUsage`) on spoke workload projects.
## Step-by-Step Boundary Provisioning Workflow
Below is the canonical end-to-end setup workflow (modeling a folder
`111111111111` in organization `222222222222` partitioned by tag key
`222222222222/environment` into isolated `dev` and `prod` management
perimeters):
**Step 1: Configure Folder/Org `BoundaryConfig` and Bind Tags to Projects**
```bash
# 1a. Inspect current BoundaryConfig on the folder (or --organization=ORG_ID)
gcloud resource-manager boundary-configs describe --folder=111111111111
# 1b. Configure folder BoundaryConfig with the organization environment tag key
gcloud resource-manager boundary-configs update \
--folder=111111111111 \
--tag-key="222222222222/environment"
# 1c. Bind environment=dev to the dev management hub and dev spoke projects (using project numbers)
for pnum in 123456789012 333333333333 444444444444; do
gcloud resource-manager tags bindings create \
--tag-value=222222222222/environment/dev \
--parent=//cloudresourcemanager.googleapis.com/projects/$pnum
done
# 1d. Bind environment=prod to the prod management hub and prod spoke projects (using project numbers)
for pnum in 555555555555 666666666666 777777777777; do
gcloud resource-manager tags bindings create \
--tag-value=222222222222/environment/prod \
--parent=//cloudresourcemanager.googleapis.com/projects/$pnum
done
```
**Step 2: Create `CapabilityConfig` Resources (Designate Management Projects)**
```bash
# Create folder-scoped CapabilityConfig for the dev management project
gcloud resource-manager capability-configs create agent-governance \
--folder=111111111111 \
--display-name="Agent Governance Capability" \
--types=agent-management \
--management-project=projects/123456789012
# Create folder-scoped CapabilityConfig for the prod management project
gcloud resource-manager capability-configs create agent-governance-prod \
--folder=111111111111 \
--display-name="Agent Governance Capability" \
--types=agent-management \
--management-project=projects/555555555555
```
**Step 3: Create `Boundary` Resources**
```bash
# Create dev and prod Boundaries on the parent folder
gcloud resource-manager boundaries create agents-dev \
--folder=111111111111 \
--display-name="Agent Dev Boundary" \
--tag-key="222222222222/environment" \
--tag-value="dev"
gcloud resource-manager boundaries create agents-prod \
--folder=111111111111 \
--display-name="Agent Prod Boundary" \
--tag-key="222222222222/environment" \
--tag-value="prod"
```
**Step 4: Associate Each `Boundary` with Its `CapabilityConfig`**
```bash
# Associate agents-dev boundary with the dev CapabilityConfig
gcloud resource-manager capability-configs update agent-governance \
--folder=111111111111 \
--boundaries=folders/111111111111/boundaries/agents-dev
# Associate agents-prod boundary with the prod CapabilityConfig
gcloud resource-manager capability-configs update agent-governance-prod \
--folder=111111111111 \
--boundaries=folders/111111111111/boundaries/agents-prod
```
**Step 5: Verify Cross-Project Rollup, Filtering, and Search on the Hub**
```bash
# List all discovered agents aggregated across member projects in the boundary
gcloud agent-registry agents list --project=MANAGEMENT_PROJECT_ID --location=us-central1
# Filter aggregated agents by runtime (Vertex AI Reasoning Engine) across all member projects
gcloud agent-registry agents list --project=MANAGEMENT_PROJECT_ID --location=us-central1 \
--filter='attributes."agentregistry.googleapis.com/system/RuntimeReference".uri:reasoningEngine'
# Narrow aggregated agents to a specific spoke project number via agentId or RuntimeIdentity
gcloud agent-registry agents list --project=MANAGEMENT_PROJECT_ID --location=us-central1 \
--filter="agentId:333333333333"
gcloud agent-registry agents list --project=MANAGEMENT_PROJECT_ID --location=us-central1 \
--filter='attributes."agentregistry.googleapis.com/system/RuntimeIdentity".principal:service-444444444444'
# Search aggregated agents across spoke projects by displayName prefix, spoke URN prefix, or A2A skills
gcloud agent-registry agents search --project=MANAGEMENT_PROJECT_ID --location=us-central1 \
--search-string="displayName:MyAgent*"
gcloud agent-registry agents search --project=MANAGEMENT_PROJECT_ID --location=us-central1 \
--search-string='agentId:"urn:agent:projects-444444444444*"'
gcloud agent-registry agents search --project=MANAGEMENT_PROJECT_ID --location=us-central1 \
--search-string="skills.tags:productivity"
```
**Step 6: Audit or Reassign Projects Between Boundaries**
```bash
# List and describe CapabilityConfigs and Boundaries under a folder
gcloud resource-manager capability-configs list --folder=111111111111
gcloud resource-manager capability-configs describe agent-governance --folder=111111111111
gcloud resource-manager boundaries list --folder=111111111111
gcloud resource-manager boundaries describe agents-dev --folder=111111111111
# Audit all Agent Registry management projects across the organization
gcloud projects list \
--filter="isManagementProject=true" \
--format="table(projectId, projectNumber, parent.id, configuredCapabilities)"
# Move a member project from dev to prod (delete old binding first, then create new binding)
gcloud resource-manager tags bindings delete \
--tag-value=222222222222/environment/dev \
--parent=//cloudresourcemanager.googleapis.com/projects/333333333333
gcloud resource-manager tags bindings create \
--tag-value=222222222222/environment/prod \
--parent=//cloudresourcemanager.googleapis.com/projects/333333333333
```
## Safe Teardown Sequence
Cloud Resource Manager blocks deleting an attached `Boundary` or a
`CapabilityConfig` with attached boundaries. Whenever a user asks to delete or
tear down a boundary and capability config, **always output the complete
3-command `gcloud` teardown sequence in order**, and explicitly note that
deleting a `CapabilityConfig` preserves a Bring-Your-Own (BYO) project
(`isManagementProject` reverts to `false`), whereas a Google-managed Management
Project is deleted:
```bash
# 1. Detach boundaries from the CapabilityConfig
gcloud resource-manager capability-configs update agent-governance \
--folder=111111111111 \
--clear-boundaries
# 2. Delete the Boundary
gcloud resource-manager boundaries delete agents-dev --folder=111111111111
# 3. Delete the CapabilityConfig
gcloud resource-manager capability-configs delete agent-governance --folder=111111111111
```
annotate_gke.py 18.8 KB
#!/usr/bin/env python3
"""Configures GKE Deployment YAML files for Agent Registry discovery."""
import argparse
from collections.abc import Sequence
import os
import re
import sys
_YAML_DOC_BOUNDARY_RE = re.compile(r"^(?:---|\.\.\.)(?:\s*(?:#.*)?)?$")
def _strip_yaml_comment(line: str) -> str:
"""Returns `line` with any trailing unquoted YAML `#` comment removed."""
in_single = False
in_double = False
idx = 0
length = len(line)
while idx < length:
ch = line[idx]
if in_single:
if ch == "'":
if idx + 1 < length and line[idx + 1] == "'":
idx += 2
continue
in_single = False
elif in_double:
if ch == "\\" and idx + 1 < length:
idx += 2
continue
if ch == '"':
in_double = False
else:
if ch == "'":
in_single = True
elif ch == '"':
in_double = True
elif ch == "#" and (idx == 0 or line[idx - 1].isspace()):
return line[:idx]
idx += 1
return line
def _find_unquoted_colon(text: str) -> int:
"""Finds the index of the first unquoted YAML mapping `:` separator, or -1."""
in_single = False
in_double = False
brace_depth = 0
bracket_depth = 0
idx = 0
length = len(text)
while idx < length:
ch = text[idx]
if in_single:
if ch == "'":
if idx + 1 < length and text[idx + 1] == "'":
idx += 2
continue
in_single = False
elif in_double:
if ch == "\\" and idx + 1 < length:
idx += 2
continue
if ch == '"':
in_double = False
else:
if ch == "'":
in_single = True
elif ch == '"':
in_double = True
elif ch == "{":
brace_depth += 1
elif ch == "}":
brace_depth -= 1
elif ch == "[":
bracket_depth += 1
elif ch == "]":
bracket_depth -= 1
elif (
ch == ":"
and brace_depth == 0
and bracket_depth == 0
and (idx + 1 == length or text[idx + 1].isspace())
):
return idx
idx += 1
return -1
def _split_flow_map_entries(inner: str) -> list[str]:
"""Splits the interior of a YAML `{k: v, ...}` flow mapping into entries."""
if not inner.strip():
return []
entries: list[str] = []
start = 0
in_single = False
in_double = False
brace_depth = 0
bracket_depth = 0
idx = 0
length = len(inner)
while idx < length:
ch = inner[idx]
if in_single:
if ch == "'":
if idx + 1 < length and inner[idx + 1] == "'":
idx += 2
continue
in_single = False
elif in_double:
if ch == "\\" and idx + 1 < length:
idx += 2
continue
if ch == '"':
in_double = False
else:
if ch == "'":
in_single = True
elif ch == '"':
in_double = True
elif ch == "{":
brace_depth += 1
elif ch == "}":
brace_depth -= 1
elif ch == "[":
bracket_depth += 1
elif ch == "]":
bracket_depth -= 1
elif ch == "," and brace_depth == 0 and bracket_depth == 0:
piece = inner[start:idx].strip()
if piece:
entries.append(piece)
start = idx + 1
idx += 1
if in_single or in_double or brace_depth != 0 or bracket_depth != 0:
raise ValueError(f"Unbalanced YAML flow mapping: {{{inner}}}")
tail = inner[start:].strip()
if tail:
entries.append(tail)
normalized: list[str] = []
for entry in entries:
colon_idx = _find_unquoted_colon(entry)
if colon_idx < 0:
raise ValueError(f"Invalid YAML flow mapping entry: {entry!r}")
key_str = entry[:colon_idx].strip()
val_str = entry[colon_idx + 1 :].strip()
normalized.append(f"{key_str}: {val_str}" if val_str else f"{key_str}:")
return normalized
def _expand_flow_map_line(line: str) -> list[str]:
"""Expands a single-line `key: {...}` flow mapping recursively into block lines."""
indent = len(line) - len(line.lstrip())
code_part = _strip_yaml_comment(line).strip()
colon_idx = _find_unquoted_colon(code_part)
if colon_idx < 0:
return [line]
key_part = code_part[:colon_idx].strip()
val_part = code_part[colon_idx + 1 :].strip()
if not val_part.startswith("{"):
return [line]
if not val_part.endswith("}"):
raise ValueError(
f"Multi-line flow mapping on '{key_part}:' is not supported; convert it"
" to block YAML first."
)
entries = _split_flow_map_entries(val_part[1:-1])
expanded = [" " * indent + f"{key_part}:"]
for entry in entries:
child_line = " " * (indent + 2) + entry
expanded.extend(_expand_flow_map_line(child_line))
return expanded
def _key_matches_mapping_line(code_part: str, key_name: str) -> bool:
"""Returns True if `code_part` declares mapping key `key_name:`."""
if code_part == f"{key_name}:":
return True
colon_idx = _find_unquoted_colon(code_part)
if colon_idx < 0:
return False
parsed_key = code_part[:colon_idx].strip().strip("\"'")
if parsed_key != key_name:
return False
val_part = code_part[colon_idx + 1 :].strip()
return not val_part or val_part.startswith("{")
def _upsert_metadata_map_key(
meta_lines: Sequence[str],
metadata_indent: int,
map_name: str,
key: str,
value: str,
) -> list[str]:
"""Ensures `map_name.<key>: "<value>"` exists in a metadata block."""
meta_lines = list(meta_lines)
child_indent = metadata_indent + 2
for line in meta_lines:
stripped = line.strip()
if not stripped or stripped.startswith("#"):
continue
indent = len(line) - len(line.lstrip())
if indent > metadata_indent:
child_indent = indent
break
map_idx = None
map_indent = child_indent
for idx, line in enumerate(meta_lines):
stripped = line.strip()
if not stripped or stripped.startswith("#"):
continue
indent = len(line) - len(line.lstrip())
code_part = _strip_yaml_comment(line).strip()
if indent == child_indent and _key_matches_mapping_line(
code_part, map_name
):
map_idx = idx
map_indent = indent
expanded = _expand_flow_map_line(meta_lines[idx])
meta_lines = meta_lines[:idx] + expanded + meta_lines[idx + 1 :]
break
if map_idx is not None:
# Find the end of the map_name block and its direct child indentation
end_idx = len(meta_lines)
entry_indent = None
for j in range(map_idx + 1, len(meta_lines)):
stripped = meta_lines[j].strip()
if not stripped or stripped.startswith("#"):
continue
indent = len(meta_lines[j]) - len(meta_lines[j].lstrip())
if indent <= map_indent:
end_idx = j
break
if entry_indent is None:
entry_indent = indent
if entry_indent is None:
entry_indent = map_indent + 2
# Check if key already exists as a direct child in the block
for j in range(map_idx + 1, end_idx):
stripped = meta_lines[j].strip()
if not stripped or stripped.startswith("#"):
continue
indent = len(meta_lines[j]) - len(meta_lines[j].lstrip())
code_part = _strip_yaml_comment(meta_lines[j]).strip()
colon_idx = _find_unquoted_colon(code_part)
if (
indent == entry_indent
and colon_idx >= 0
and code_part[:colon_idx].strip().strip("\"'") == key
):
current_val = code_part[colon_idx + 1 :].strip().strip("\"'")
if current_val != value:
print(
f"Warning: Updating existing {key} from '{current_val}' to"
f" '{value}'"
)
meta_lines[j] = " " * indent + f'{key}: "{value}"'
else:
print(f"Info: {key} '{value}' already exists. Skipping update.")
return meta_lines
# Key not found inside existing map_name block; insert right after map_name:
new_line = " " * entry_indent + f'{key}: "{value}"'
return meta_lines[: map_idx + 1] + [new_line] + meta_lines[map_idx + 1 :]
# map_name block does not exist; insert before trailing comments/blank lines
insert_idx = 0
for j in range(len(meta_lines) - 1, -1, -1):
stripped = meta_lines[j].strip()
if stripped and not stripped.startswith("#"):
insert_idx = j + 1
break
new_block = [
" " * child_indent + f"{map_name}:",
" " * (child_indent + 2) + f'{key}: "{value}"',
]
return meta_lines[:insert_idx] + new_block + meta_lines[insert_idx:]
def _is_top_level_deployment_line(line: str) -> bool:
"""Returns True if line is a top-level `kind: Deployment` declaration."""
if len(line) - len(line.lstrip()) != 0:
return False
code_part = _strip_yaml_comment(line).strip()
return code_part in (
"kind: Deployment",
'kind: "Deployment"',
"kind: 'Deployment'",
)
def _find_and_expand_child_block(
lines: list[str],
start_idx: int,
end_idx: int,
parent_indent: int,
key_name: str,
) -> tuple[list[str], tuple[int, int, int] | None]:
"""Finds (and expands if inline `{...}`) a direct child mapping block.
Args:
lines: Document lines to search.
start_idx: Inclusive start line index of the parent block body.
end_idx: Exclusive end line index of the parent block body.
parent_indent: Indentation of the parent mapping key (-1 for document root).
key_name: Mapping key name to find (e.g., 'metadata', 'spec', 'template').
Returns:
A pair `(updated_lines, (block_start_idx, block_end_idx, block_indent))` if
found, or `(lines, None)` if the key does not exist as a direct child.
"""
child_indent = 0 if parent_indent < 0 else parent_indent + 2
if parent_indent >= 0:
for idx in range(start_idx, end_idx):
stripped = lines[idx].strip()
if not stripped or stripped.startswith("#"):
continue
indent = len(lines[idx]) - len(lines[idx].lstrip())
if indent > parent_indent:
child_indent = indent
break
for idx in range(start_idx, end_idx):
stripped = lines[idx].strip()
if not stripped or stripped.startswith("#"):
continue
indent = len(lines[idx]) - len(lines[idx].lstrip())
code_part = _strip_yaml_comment(lines[idx]).strip()
if indent == child_indent and _key_matches_mapping_line(
code_part, key_name
):
expanded = _expand_flow_map_line(lines[idx])
delta = len(expanded) - 1
updated_lines = lines[:idx] + expanded + lines[idx + 1 :]
new_end_idx = end_idx + delta
block_end = new_end_idx
for j in range(idx + 1, new_end_idx):
j_stripped = updated_lines[j].strip()
if not j_stripped or j_stripped.startswith("#"):
continue
j_indent = len(updated_lines[j]) - len(updated_lines[j].lstrip())
if j_indent <= indent:
block_end = j
break
return updated_lines, (idx, block_end, indent)
return lines, None
def _process_single_doc(
doc_lines: Sequence[str], functional_type: str
) -> list[str]:
"""Processes a single YAML document's lines."""
is_deployment = any(_is_top_level_deployment_line(line) for line in doc_lines)
if not is_deployment:
return list(doc_lines)
doc_lines = list(doc_lines)
doc_lines, meta_block = _find_and_expand_child_block(
doc_lines, 0, len(doc_lines), -1, "metadata"
)
if meta_block is not None:
meta_start, meta_end, metadata_indent = meta_block
meta_body = doc_lines[meta_start + 1 : meta_end]
meta_body = _upsert_metadata_map_key(
meta_body,
metadata_indent,
"labels",
"registry.gke.io/functional-type",
functional_type,
)
meta_body = _upsert_metadata_map_key(
meta_body,
metadata_indent,
"annotations",
"apphub.cloud.google.com/functional-type",
functional_type,
)
doc_lines = doc_lines[: meta_start + 1] + meta_body + doc_lines[meta_end:]
else:
kind_idx = next(
idx
for idx, line in enumerate(doc_lines)
if _is_top_level_deployment_line(line)
)
new_top_meta = [
"metadata:",
" labels:",
f' registry.gke.io/functional-type: "{functional_type}"',
" annotations:",
f' apphub.cloud.google.com/functional-type: "{functional_type}"',
]
doc_lines = (
doc_lines[: kind_idx + 1] + new_top_meta + doc_lines[kind_idx + 1 :]
)
doc_lines, spec_block = _find_and_expand_child_block(
doc_lines, 0, len(doc_lines), -1, "spec"
)
if spec_block is not None:
spec_start, spec_end, spec_indent = spec_block
doc_lines, template_block = _find_and_expand_child_block(
doc_lines, spec_start + 1, spec_end, spec_indent, "template"
)
if template_block is not None:
template_start, template_end, template_indent = template_block
doc_lines, pod_meta_block = _find_and_expand_child_block(
doc_lines,
template_start + 1,
template_end,
template_indent,
"metadata",
)
if pod_meta_block is not None:
pod_meta_start, pod_meta_end, pod_meta_indent = pod_meta_block
pod_meta_body = doc_lines[pod_meta_start + 1 : pod_meta_end]
pod_meta_body = _upsert_metadata_map_key(
pod_meta_body,
pod_meta_indent,
"annotations",
"iam.gke.io/spiffe-identity-type",
"agent-identity",
)
doc_lines = (
doc_lines[: pod_meta_start + 1]
+ pod_meta_body
+ doc_lines[pod_meta_end:]
)
else:
template_child_indent = template_indent + 2
for idx in range(template_start + 1, template_end):
stripped = doc_lines[idx].strip()
if not stripped or stripped.startswith("#"):
continue
indent = len(doc_lines[idx]) - len(doc_lines[idx].lstrip())
if indent > template_indent:
template_child_indent = indent
break
new_pod_meta = [
" " * template_child_indent + "metadata:",
" " * (template_child_indent + 2) + "annotations:",
" " * (template_child_indent + 4)
+ 'iam.gke.io/spiffe-identity-type: "agent-identity"',
]
doc_lines = (
doc_lines[: template_start + 1]
+ new_pod_meta
+ doc_lines[template_start + 1 :]
)
return doc_lines
def process_yaml(content: str, functional_type: str) -> str:
"""Updates all Deployment documents in a multi-document YAML string.
Args:
content: Raw YAML string containing one or more Kubernetes documents.
functional_type: Functional type to set ('AGENT' or 'MCP_SERVER').
Returns:
The updated YAML string.
"""
lines = content.split("\n")
result_lines: list[str] = []
current_doc: list[str] = []
for line in lines:
if _YAML_DOC_BOUNDARY_RE.match(line):
if current_doc:
result_lines.extend(_process_single_doc(current_doc, functional_type))
current_doc = []
result_lines.append(line)
else:
current_doc.append(line)
if current_doc:
result_lines.extend(_process_single_doc(current_doc, functional_type))
return "\n".join(result_lines)
def process_file(
filepath: str, functional_type: str, dry_run: bool = False
) -> bool:
"""Processes a single YAML file and writes changes unless dry_run is True.
Args:
filepath: Path to the YAML file on disk.
functional_type: Functional type to set ('AGENT' or 'MCP_SERVER').
dry_run: If True, previews changes without writing to disk.
Returns:
True if the file was processed without errors, False otherwise.
"""
try:
with open(filepath, "r", encoding="utf-8") as f:
content = f.read()
has_deployment = any(
_is_top_level_deployment_line(line) for line in content.splitlines()
)
if has_deployment:
updated_content = process_yaml(content, functional_type)
if content != updated_content:
if dry_run:
print(f"[DRY RUN] Would update {filepath}")
else:
with open(filepath, "w", encoding="utf-8") as f:
f.write(updated_content)
print(f"Successfully updated {filepath}")
else:
print(
f"No changes needed for {filepath} (Labels/annotations already"
" exist)"
)
else:
print(f"Skipping {filepath} (no Deployment found)")
return True
except (OSError, ValueError) as e:
print(f"Error processing {filepath}: {e}", file=sys.stderr)
return False
def process_directory(
directory: str, functional_type: str, dry_run: bool = False
) -> None:
"""Recursively processes all .yaml and .yml files in a directory.
Args:
directory: Root directory path to scan.
functional_type: Functional type to set ('AGENT' or 'MCP_SERVER').
dry_run: If True, previews changes without writing to disk.
"""
if not os.path.isdir(directory):
print(f"Error: Directory '{directory}' does not exist.", file=sys.stderr)
sys.exit(1)
all_ok = True
for root, dirnames, files in os.walk(directory):
dirnames[:] = sorted(
d for d in dirnames if not d.startswith(".") and d != "node_modules"
)
for file in sorted(files):
if file.endswith(".yaml") or file.endswith(".yml"):
filepath = os.path.join(root, file)
print(f"Processing {filepath}...")
if not process_file(filepath, functional_type, dry_run=dry_run):
all_ok = False
if not all_ok:
sys.exit(1)
def main() -> None:
"""CLI entrypoint for annotating GKE Deployment manifests."""
parser = argparse.ArgumentParser(
description=(
"Configure GKE Deployment YAML files for Agent Registry automatic"
" discovery (sets registry.gke.io/functional-type label,"
" apphub.cloud.google.com/functional-type annotation, and Pod"
" template iam.gke.io/spiffe-identity-type annotation)."
)
)
parser.add_argument(
"path",
help="YAML file or directory of YAML files to process",
)
parser.add_argument(
"--type",
"-t",
choices=["AGENT", "MCP_SERVER"],
required=True,
help="The functional type to set (AGENT or MCP_SERVER)",
)
parser.add_argument(
"--dry-run",
action="store_true",
help="Preview changes without modifying files on disk",
)
args = parser.parse_args()
path = os.path.abspath(args.path)
if not os.path.exists(path):
print(f"Error: Path '{path}' does not exist.", file=sys.stderr)
sys.exit(1)
print(f"Setting functional type: {args.type}")
if os.path.isfile(path):
if path.endswith(".yaml") or path.endswith(".yml"):
print(f"Processing file: {path}")
if not process_file(path, args.type, dry_run=args.dry_run):
sys.exit(1)
else:
print(f"Error: File '{path}' is not a YAML file.", file=sys.stderr)
sys.exit(1)
elif os.path.isdir(path):
print(f"Scanning directory: {path}")
process_directory(path, args.type, dry_run=args.dry_run)
else:
print(
f"Error: Path '{path}' is neither a regular file nor a directory.",
file=sys.stderr,
)
sys.exit(1)
if __name__ == "__main__":
main()
quick-add-gcp-service.sh 8.0 KB
#!/bin/bash
# quick-add-gcp-service.sh - Registers a single composite Service in Agent
# Registry containing all applicable Google Cloud API endpoint URL variants
# (Base, Base mTLS, and for non-global locations: Locational, Locational mTLS,
# and Regional REP) for a Governed Target GCP Service behind Agent Gateway.
set -euo pipefail
readonly DEFAULT_ATTRIBUTION="agent-skills/1.0 (skill:agent-platform-agent-registry)"
PROJECT=""
LOCATION=""
SERVICE_ID=""
SERVICE_NAME=""
DRY_RUN=0
NO_ATTRIBUTION=0
usage() {
cat <<EOF
Usage: $0 --service=SERVICE_ID [--service-name=RESOURCE_ID] [--location=LOCATION] [--project=PROJECT_ID] [--no-attribution] [--dry-run]
Registers a single composite Service in Agent Registry containing the Google
Cloud API endpoint URL variants for a Governed Target Service (e.g.,
aiplatform, discoveryengine, storage, iam, kms):
1. Base: https://<SERVICE_ID>.googleapis.com
2. Base mTLS: https://<SERVICE_ID>.mtls.googleapis.com
3. Locational: https://<LOCATION>-<SERVICE_ID>.googleapis.com (omitted when --location=global)
4. Locational mTLS: https://<LOCATION>-<SERVICE_ID>.mtls.googleapis.com (omitted when --location=global)
5. Regional REP: https://<SERVICE_ID>.<LOCATION>.rep.googleapis.com (omitted when --location=global)
Options:
--service=SERVICE_ID GCP service short name (e.g., aiplatform, storage, iam, kms)
--service-name=RESOURCE_ID Agent Registry Service ID (4-63 chars; defaults to SERVICE_ID,
or <SERVICE_ID>-api when SERVICE_ID is shorter than 4 chars)
--location=LOCATION Target GCP region, multi-region, or 'global' (defaults to gcloud compute/region or us-central1)
--project=PROJECT_ID Target GCP project ID (defaults to gcloud config project)
--no-attribution Omit CLOUDSDK_METRICS_REQUEST_ATTRIBUTION when running gcloud
--dry-run Print the composite gcloud command without executing it
--help, -h Show this help message
EOF
}
require_flag_value() {
local flag="$1"
if [[ $# -lt 2 || -z "${2:-}" || "${2:-}" == -* ]]; then
echo "Error: Missing value for ${flag}" >&2
usage >&2
exit 1
fi
}
require_nonempty_eq_value() {
local raw="$1"
local val="${raw#*=}"
if [[ -z "${val}" ]]; then
echo "Error: Empty value for ${raw%%=*}" >&2
usage >&2
exit 1
fi
}
resolve_effective_attribution() {
if (( NO_ATTRIBUTION == 1 )); then
printf ''
elif [[ -v CLOUDSDK_METRICS_REQUEST_ATTRIBUTION ]]; then
printf '%s' "${CLOUDSDK_METRICS_REQUEST_ATTRIBUTION}"
else
printf '%s' "${DEFAULT_ATTRIBUTION}"
fi
}
run_gcloud() {
local effective_attr
effective_attr="$(resolve_effective_attribution)"
if [[ -z "${effective_attr}" ]]; then
gcloud "$@"
else
CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="${effective_attr}" gcloud "$@"
fi
}
while [[ $# -gt 0 ]]; do
case "$1" in
--service=*)
require_nonempty_eq_value "$1"
SERVICE_ID="${1#*=}"
shift
;;
--service)
require_flag_value "$@"
SERVICE_ID="$2"
shift 2
;;
--service-name=*)
require_nonempty_eq_value "$1"
SERVICE_NAME="${1#*=}"
shift
;;
--service-name)
require_flag_value "$@"
SERVICE_NAME="$2"
shift 2
;;
--location=*)
require_nonempty_eq_value "$1"
LOCATION="${1#*=}"
shift
;;
--location)
require_flag_value "$@"
LOCATION="$2"
shift 2
;;
--project=*)
require_nonempty_eq_value "$1"
PROJECT="${1#*=}"
shift
;;
--project)
require_flag_value "$@"
PROJECT="$2"
shift 2
;;
--no-attribution)
NO_ATTRIBUTION=1
shift
;;
--dry-run)
DRY_RUN=1
shift
;;
--help|-h)
usage
exit 0
;;
-*)
echo "Error: Unknown flag $1" >&2
usage >&2
exit 1
;;
*)
if [[ -z "${SERVICE_ID}" ]]; then
SERVICE_ID="$1"
else
echo "Error: Unexpected argument '$1'" >&2
usage >&2
exit 1
fi
shift
;;
esac
done
# Strip .googleapis.com suffix if provided
SERVICE_ID="${SERVICE_ID%.googleapis.com}"
if [[ -z "${SERVICE_ID}" ]]; then
echo "Error: Service ID is required. Use --service=SERVICE_ID (e.g., --service=aiplatform)." >&2
usage >&2
exit 1
fi
if [[ ! "${SERVICE_ID}" =~ ^[a-z][a-z0-9-]*[a-z0-9]$ ]]; then
echo "Error: Invalid GCP service short name '${SERVICE_ID}'. Expected lowercase letters, digits, or hyphens (e.g., aiplatform, storage, iam)." >&2
exit 1
fi
if [[ -z "${SERVICE_NAME}" ]]; then
if (( ${#SERVICE_ID} < 4 )); then
SERVICE_NAME="${SERVICE_ID}-api"
else
SERVICE_NAME="${SERVICE_ID}"
fi
fi
if [[ ! "${SERVICE_NAME}" =~ ^[a-z][a-z0-9-]{2,61}[a-z0-9]$ ]]; then
echo "Error: Agent Registry Service ID '${SERVICE_NAME}' must be 4-63 characters matching ^[a-z][a-z0-9-]{2,61}[a-z0-9]$. Pass --service-name=RESOURCE_ID." >&2
exit 1
fi
if [[ -z "${PROJECT}" || "${PROJECT}" == "(unset)" ]]; then
PROJECT=$(run_gcloud config get-value project 2>/dev/null || true)
fi
if [[ -z "${PROJECT}" || "${PROJECT}" == "(unset)" ]]; then
echo "Error: Project not set. Use --project=PROJECT_ID." >&2
usage >&2
exit 1
fi
if [[ ! "${PROJECT}" =~ ^[a-z0-9][a-z0-9.:-]*[a-z0-9]$ ]]; then
echo "Error: Invalid GCP project identifier '${PROJECT}'." >&2
exit 1
fi
if [[ -z "${LOCATION}" || "${LOCATION}" == "(unset)" ]]; then
LOCATION=$(run_gcloud config get-value compute/region 2>/dev/null || true)
fi
if [[ -z "${LOCATION}" || "${LOCATION}" == "(unset)" ]]; then
LOCATION="us-central1"
fi
if [[ ! "${LOCATION}" =~ ^[a-z][a-z0-9-]*[a-z0-9]$ ]]; then
echo "Error: Invalid location '${LOCATION}'. Expected lowercase 'global', multi-region ('us', 'eu'), or region (e.g., 'us-central1')." >&2
exit 1
fi
interfaces_flags=(
"--interfaces=protocolBinding=jsonrpc,url=https://${SERVICE_ID}.googleapis.com"
"--interfaces=protocolBinding=jsonrpc,url=https://${SERVICE_ID}.mtls.googleapis.com"
)
if [[ "${LOCATION}" != "global" ]]; then
interfaces_flags+=(
"--interfaces=protocolBinding=jsonrpc,url=https://${LOCATION}-${SERVICE_ID}.googleapis.com"
"--interfaces=protocolBinding=jsonrpc,url=https://${LOCATION}-${SERVICE_ID}.mtls.googleapis.com"
"--interfaces=protocolBinding=jsonrpc,url=https://${SERVICE_ID}.${LOCATION}.rep.googleapis.com"
)
fi
gcloud_args=(
agent-registry services create "${SERVICE_NAME}"
"--project=${PROJECT}"
"--location=${LOCATION}"
"--display-name=${SERVICE_ID}"
"--description=Google Cloud ${SERVICE_ID} API endpoints"
"--endpoint-spec-type=no-spec"
"${interfaces_flags[@]}"
)
format_shell_arg() {
local arg="$1"
if [[ "${arg}" =~ ^[A-Za-z0-9_./:=,+-]+$ ]]; then
printf '%s' "${arg}"
elif [[ ! "${arg}" =~ [\"\$\\\!\`] ]]; then
printf '"%s"' "${arg}"
else
printf "'%s'" "${arg//\'/\'\\\'\'}"
fi
}
if (( DRY_RUN == 1 )); then
echo "[DRY RUN] Would register composite Service '${SERVICE_NAME}' (${#interfaces_flags[@]} endpoint URL variants for '${SERVICE_ID}') in project '${PROJECT}' (${LOCATION}):"
cmd_parts=()
effective_attr="$(resolve_effective_attribution)"
if [[ -n "${effective_attr}" ]]; then
cmd_parts+=("CLOUDSDK_METRICS_REQUEST_ATTRIBUTION=$(format_shell_arg "${effective_attr}")")
fi
cmd_parts+=("gcloud")
for arg in "${gcloud_args[@]}"; do
cmd_parts+=("$(format_shell_arg "${arg}")")
done
printf '%s\n' "${cmd_parts[*]}"
else
echo "Registering composite Service '${SERVICE_NAME}' (${#interfaces_flags[@]} endpoint URL variants for '${SERVICE_ID}') in project '${PROJECT}' (${LOCATION})..."
run_gcloud "${gcloud_args[@]}"
echo "Successfully registered composite Service '${SERVICE_NAME}' for '${SERVICE_ID}' in '${LOCATION}'."
fi
echo "Reminder: Bind 'roles/iap.egressor' for the Agent Identity to the projected Endpoint catalog ID ('endpoints/agentregistry-<UUID>' from 'registryResource' in 'gcloud agent-registry services describe ${SERVICE_NAME} --project=${PROJECT} --location=${LOCATION}'), not to the Service ID '${SERVICE_NAME}'."
License (Apache-2.0)
View full license text
Licensed under the Apache License, Version 2.0. See https://github.com/google/skills/blob/main/LICENSE