google-agents-cli-publish
Registers deployed agents in Gemini Enterprise and Agent Registry. Use when the user wants to publish the agent to Gemini Enterprise (the Console's Gemini app), register it over A2A from its agent card, or list, update or remove agents and MCP servers in Agent Registry.
Warnings for the author
- 1 "metadata" entries are ignored: expected short text keys and values
- Listed once through the skills extension, as skills/google-agents-cli-publish/SKILL.md: this copy is identical.
Publish to Gemini Enterprise and Agent Registry
Run agents-cli info first: it prints the language and deployment target the sections below key off.
Before checking the prerequisites, read the framework's skill for this stage: the skill the project's guidance file (CLAUDE.md, GEMINI.md or AGENTS.md) names. On ADK, call the Skill tool with google-agents-cli-adk-code and read its references/adk-publish.md. No Skill tool: read its SKILL.md directly (../<skill-name>/ for a bundled skill, .agents/skills/<skill-name>/ for an extension's).
Optional, after a deploy: agents-cli publish gemini registers the agent with a Gemini Enterprise app (the Console now calls it a Gemini app). publish gemini-enterprise still works as a hidden alias. agents-cli publish gemini --help lists every flag and its env var. Not deployed yet: call the Skill tool with google-agents-cli-deploy.
Done when publish prints the registered agent and the user confirms it answers in the Gemini Enterprise app.
Prerequisites
- The agent is deployed and reachable.
- The Gemini Enterprise app exists. Create it in the Console;
agents-cli publish gemini --listshows the apps in the project. - The agent is text-based. Live and voice agents have no A2A card and the app has no live transport.
- On Agent Runtime,
deployment_metadata.jsonfromagents-cli deployis in the project. - Your account has Discovery Engine Editor on the project that hosts the app.
Agent Runtime
agents-cli publish gemini \
--gemini-app-id projects/123456/locations/global/collections/default_collection/engines/my-app
The command reads the runtime ID from deployment_metadata.json and picks the registration type from the metadata. Override with --registration-type or --agent-runtime-id. Without metadata, non-interactive mode needs --registration-type.
On Agent Runtime the default type is adk: the Gemini app calls the engine through :streamQuery, with no agent card. It works only for a framework that declares the ADK runtime contract. Before you choose between adk and a2a, check the framework's skill: it says which one the agent supports there and which to prefer (on ADK, adk-publish.md prefers adk).
Cloud Run and GKE: A2A
Every scaffolded agent serves A2A, and A2A is the only registration type on Cloud Run and GKE. Pass the card URL; display name and description default to the card's name and description, and --display-name and --description override them.
agents-cli publish gemini \
--agent-card-url https://my-service-abc123.us-east1.run.app/a2a/app/.well-known/agent-card.json \
--gemini-app-id projects/123456/locations/global/collections/default_collection/engines/my-app
The card path depends on the language, whatever the framework:
- Python, TypeScript:
/a2a/{app_name}/.well-known/agent-card.json - Go, Java, Kotlin:
/.well-known/agent-card.json
On Cloud Run, first grant roles/run.servicesInvoker on the service to service-PROJECT_NUMBER@gcp-sa-discoveryengine.iam.gserviceaccount.com.
On Agent Runtime, --registration-type a2a without --agent-card-url builds the card URL from the metadata. The card sits behind the /api passthrough: .../reasoningEngines/v1/{resource}/api/<card path>.
An agent that needs OAuth user consent passes --authorization-id projects/PROJECT_NUMBER/locations/global/authorizations/AUTH_ID.
In CI/CD
The command is non-interactive by default, so pass values as flags or env vars (GEMINI_APP_ID, AGENT_RUNTIME_ID, GEMINI_DISPLAY_NAME, GEMINI_DESCRIPTION, AGENT_CARD_URL, REGISTRATION_TYPE):
export GEMINI_APP_ID="projects/123456/locations/global/collections/default_collection/engines/my-app"
export GEMINI_DISPLAY_NAME="Production Agent"
agents-cli publish gemini
-i prompts for missing values instead: it lists the apps and offers the runtime ID from metadata. Re-running updates the existing registration in place.
Agent Registry
Agent Registry (Preview) is the project-wide catalog of agents and MCP servers, separate from any Gemini Enterprise app. Agent Runtime agents register automatically on deploy; for A2A projects deploy also stores the served agent card on the engine, so the entry lists as an A2A agent with the card's skills. Manage entries with gcloud agent-registry (needs roles/agentregistry.editor; see its --help). Change an endpoint or metadata on the Service resource, not the Agent. An external MCP server's spec is its tools/list response (max 10 KB; no us or eu multi-region). To remove an auto-registered agent, delete the runtime agent, but ask the user first: that deletes the deployment and its managed sessions.
Terraform: google_agent_registry_service with an mcp_server_spec block. Docs: manage agents, register MCP servers.
Troubleshooting
| Symptom | Fix |
|---|---|
| "Session not found" after registering | Python projects on google-cloud-aiplatform 1.128.0 or older: upgrade it, redeploy, re-register |
--registration-type is required | No deployment_metadata.json: pass --registration-type |
| "Gemini app ID is required" | Pass --gemini-app-id or set GEMINI_APP_ID |
| HTTP 403 | Discovery Engine Editor on the app's project; on Cloud Run, the run.servicesInvoker grant above |
| "Could not fetch agent card" | Check the agent runs and the URL is right; for Cloud Run, gcloud auth login. A Live agent has no card and can't be published |
Files of this skill
This skill has no supporting files.