Skip to content

Esmeralda: a governed multi-agent platform blueprint for Google Cloud

Esmeralda

Welcome to Esmeralda, an open-source reference blueprint for running AI agents and Model Context Protocol (MCP) tool servers in zero-trust production on Google Cloud: Google ADK and A2A agents on Agent Runtime (Gemini Enterprise Agent Platform, formerly Vertex AI Agent Engine), private MCP tool servers on Cloud Run, Agent Gateway (Preview), Agent Identity and Agent Registry for governed egress, Apigee token quotas for partners, optional Model Armor, and per-team token chargeback, all deployed with Terraform and Terragrunt.

Throughout the documentation, we follow a single real-world scenario (Garimpo's customer order support flow) from the front-door request down to the cloud foundation and developer SDK. Expand any section in the left sidebar (or in the Contents right below) to jump directly to a topic, or use the Next / Previous links at the bottom of each page.


Contents

1. Workloads, Catalog & Gateways (Layer 5)

Best for AI Engineers, Application Architects, and Product & Engineering Leaders.

2. Governance, Identity & AgentOps (Layer 4)

Best for CISOs, SecOps, Governance Leads, FinOps, and SRE / Platform Operators.

  • 2.0 Overview & Release Lifecycle — How six independent engineering tracks ship in parallel and promote immutable container digests (release/prd.yaml) from dev to prd.
  • 2.1 Zero-Trust Egress & The Central Agent Gateway — How Google's Central Agent Gateway (AGENT_TO_ANYWHERE), Agent Registry, per-target SPIFFE roles/iap.egressor bindings, and the internal Root CA govern every outbound packet (includes the Complete Technical Deep Dive & Reference).
  • 2.2 Capability-Based & Semantic Governance — Preventing the "Confused Deputy" — Division of responsibilities across Apigee X, GEAP Agent Identity & Auth Manager (3LO), and Central Agent Gateway; per-target IAP egress, a Semantic Governance (Natural Language Constraints, NLC) policy manifest (not enforced yet), and removable Apigee X partner modules.
  • 2.3 FinOps, Telemetry & Cross-Team Chargeback — Attributing every Gemini token across team boundaries via OpenTelemetry BaggageSpanProcessor, hub-and-spoke Cloud Logging sinks, curated [START HERE] BigQuery views (vw_monthly_agent_chargeback, vw_partner_apigee_chargeback, vw_request_level_telemetry, vw_security_audit_trail), and Golden Signals.
  • 2.4 Day-2 Operations with the esmeralda CLI & MCP Server — Operating and verifying environments safely with uv run esmeralda doctor/status/units/plan/apply/verify/logs/lock/catalog/guard and the read-only esmeralda mcp server.
  • 2.5 Usage Telemetry Contract — The esmeralda.usage JSON Schema (contracts/usage-event.schema.json) shared across all producers.
  • 2.6 Service Catalog & 2.7 Catalog Sources — Declarative teams, callers, targets, and snapshot-based external catalog sources.
3. Platform Foundations (Layers 1–3)

Best for Cloud Architects, NetOps, SecOps, and Infrastructure Engineers.

4. Esmeralda Library & CLI (esmeralda)

Best for Application Developers, Platform Engineers, and AI Coding Agents.

5. Multi-Cloud & Interoperability

Best for Cloud & Security Architects, Identity Teams, FinOps, and Platform Engineers.

  • 5.0 Why Multi-Cloud Agents — Why agents end up on more than one cloud, the four principles that carry across clouds, and how inbound and outbound cross-cloud traffic share one model.
  • 5.1 Identity Across Clouds — Workload identity federation, OIDC iss#sub verified at the gateway (the Apigee cross-cloud shared flow), SPIFFE federation, mTLS, federated callers in the catalog, and fail-closed enforcement.
  • 5.2 Cross-Cloud Connectivity & Protocols — The gateway per hop (Apigee best path, Envoy and direct alternatives, Agent Gateway for egress), public endpoints vs. HA VPN vs. Cross-Cloud Interconnect, and A2A and MCP as the interoperable protocols.
  • 5.3 Unified Observability & Chargeback — The esmeralda.usage record as the normalized schema, producers on other clouds (OTel GenAI span adapter, OpenTelemetry Collector), landing in BigQuery, and chargeback by verified team.
  • 5.4 Bringing an Agent from Another Cloud, End to End — A worked example: a synthetic payments partner's agent on another cloud calls order-ops-specialist, with its catalog entries, request flow, and usage records.
  • 5.5 Status & Roadmap — What is available on main, what is in open pull requests, and what is planned.
6. Integrations & Agent Factory

Best for Platform Engineers, AI Tooling Teams, and Engineering Leads.

  • 6.1 Governed Agent Factory (Scion Integration) — Two-plane governance for autonomous coding agents in Scion: team-owned factory agents with one identity each, Apigee llm-gateway OIDC proxy, Envoy MCP bridge, fail-closed GitHub triggers, human-in-the-loop Approved Commands, and private GKE Autopilot.
7. Reference & Contributing

Best for Contributors and AI Coding Agents.


1. Why Enterprise Agent Prototypes Stall

In almost every enterprise today, building a compelling AI agent demo takes a single afternoon. A developer wires an LLM prompt to a few Python helper functions on a laptop, runs a sample query, and the prototype works.

Then the team tries to take that prototype to production—and hits a wall:

  • Security & Egress Risk: How do we guarantee an autonomous agent can only call approved internal tools and partner APIs, without opening broad firewall holes or embedding static API keys?
  • Cross-Team Bottlenecks: If the Customer Experience (CX) team wants to reuse an order operations capability built by the AI Center of Excellence (AI CoE), how do they call it across GCP project boundaries without sharing databases or service accounts?
  • Coupled Release Cycles: If a backend team updates an order-management or refunds connector, why does the AI team have to re-evaluate and redeploy their entire reasoning engine?
  • Cost & Audit Blindness: When ten departments share foundation models and tools, how does FinOps attribute token spend and latency back to the exact business unit that triggered a request?

Most prototypes stall because teams try to solve application reasoning, tool integration, private networking, identity, and governance inside a single monolithic codebase or a single cloud project.

A Decoupled Layered Architecture for Multi-Track Parallelism

Esmeralda breaks this logjam by organizing the enterprise AI stack into six decoupled infrastructure layers (L0–L5) joined by four explicit contracts:

  1. Private DNS (*.esmeralda.internal) — Stable, human-readable hostnames that never change even if the underlying runtime or gateway adapter changes.
  2. Central Agent Registry — A deny-by-default catalog of every allowed MCP tool server (TOOL_SPEC) and A2A specialist agent (A2A_AGENT_CARD).
  3. Declarative Service Catalog (catalog in env.yaml) — A single source of truth declaring every internal service, its routing backend, its health probe, and which callers are authorized to invoke it.
  4. Portable Agent Manifest (agent.yaml) — A clean contract between Python agent code (apps/) and Cloud infrastructure (infrastructure/).

Because these boundaries are strict and stable, seven independent tracks and teams can build, test, and deploy in parallel without blocking one another:

Parallel Track Team What They Own & Evolve Independently What They Never Have to Touch
Track 1: Customer Experience CX Product Team User-facing orchestrator agents (support-assistant on Google ADK) in esm-<env>-cx-agents-<sfx>. Backend SQL/API code, VPC routing, or specialist agent internals.
Track 2: Reusable Domain AI AI CoE Team Domain specialist agents (order-ops-specialist) exposed over the A2A protocol in esm-<env>-ai-coe-agents-<sfx>. Customer UI channels, firewall rules, or load balancer certificates.
Track 3: Enterprise Tools Backend / MCP Teams Standalone FastMCP microservices (knowledge-base, orders, customers, refunds, notifications) on Cloud Run in esm-<env>-mcps-<sfx>. LLM prompts, model upgrades, or agent orchestration graphs.
Track 4: Ingress & API Mediation Gateway / Partner Team The private entry point (*.esmeralda.internal) using built-in direct routing or optional Envoy / Apigee adapters in esm-<env>-gateway-<sfx>. Python agent code or MCP business logic.
Track 5: Governance & FinOps Governance / FinOps Team Outbound policy (Central Agent Gateway), Model Armor templates, and BigQuery chargeback views in esm-<env>-governance-<sfx>. Individual service deployments or container Dockerfiles.
Track 6: Zero-Trust Security SecOps & Identity Team Cryptographic SPIFFE Agent Identity, Cloud KMS CMEK keys, Secret Manager, and the internal Root CA (layer-3-security). Application release schedules or route maps.
Track 7: Cloud Foundations Networking & Platform Team Shared VPC, Private Service Connect (PSC), DNS zones, and immutable CI/CD promotion pipelines (layer-0 to layer-2). Agent prompts, tool schemas, or A2A task stores.

2. Architecture at a Glance: Garimpo Order Support

To make every architectural concept concrete, we trace a single real-world request from start to finish: a support agent or external partner application asks Esmeralda,

"What is the status of order ORD-2026-4102?"

End-to-End System Topology

flowchart LR
    subgraph NS["1. North–South Front Door (Layer 5)"]
        Partner["External Partner / B2B App<br/>(API Key / OAuth + 3LO Token)"]
        Apigee["Apigee X Partner Front Door<br/>(partner.esmeralda.internal on the entry point)<br/>API Products • LLMTokenQuota • Metering"]
        Caller["Internal Support Agent / CLI<br/>(esmeralda query)"]
    end

    subgraph Agents["2. Agent Runtime & Cryptographic Identity (Layers 3 & 5)"]
        Orch["support-assistant<br/>(Google ADK • CX Project)<br/>SPIFFE Identity #1 (principal://)"]
        Spec["order-ops-specialist<br/>(A2A Protocol • AI CoE Project)<br/>SPIFFE Identity #2 + Auth Manager 3LO"]
        SQL[("Private Cloud SQL<br/>(A2A Task Store • CMEK)")]
    end

    subgraph Gov["3. East–West Zero-Trust Control Plane (Layer 4)"]
        AGW["GEAP Central Agent Gateway<br/>(Google-managed • PSC egress)<br/>• Agent Registry Allowlist<br/>• Per-Target IAP (roles/iap.egressor)<br/>• Model Armor (optional)"]
        Gemini["Gemini 3.7 Flash<br/>(Vertex AI API)"]
        FinOps["Central Telemetry & FinOps Hub<br/>(OTel Baggage • BigQuery Chargeback Views)"]
    end

    subgraph EastWest["4. Private Entry Point & MCP Tools (Layer 5)"]
        EP["Internal HTTPS Entry Point<br/>(*.esmeralda.internal • reserved VIP)<br/>Built-in direct routing (optional Envoy)"]
        KB["knowledge-base<br/>(Cloud Run FastMCP)"]
        Ord["orders<br/>(Cloud Run FastMCP)"]
        Cust["customers<br/>(Cloud Run FastMCP)"]
        Ref["refunds<br/>(Cloud Run FastMCP)"]
        Notify["notifications<br/>(Cloud Run FastMCP)"]
    end

    Partner -->|"HTTPS + x-api-key"| Apigee
    Apigee -->|"Curated route + quota check"| Orch
    Caller -->|"Vertex AI streamQuery"| Orch

    Orch -->|"All outbound egress"| AGW
    Spec -->|"All outbound egress"| AGW

    AGW -->|"Authorized model call"| Gemini
    AGW -->|"Per-target IAP verified"| EP

    EP -->|"A2A (PSC NEG)"| Spec
    EP -->|"MCP + 3LO Claims"| KB & Ord & Cust & Ref & Notify
    Spec -->|"IAM DB Auth"| SQL

    Orch -.->|"Log sink + caller baggage"| FinOps
    Spec -.->|"Log sink + caller baggage"| FinOps
    Apigee -.->|"ML-interaction analytics"| FinOps

The 60-Second Request Tour

sequenceDiagram
    autonumber
    actor User as Support Agent / Partner App
    participant Apigee as Apigee X<br/>(Optional Partner Front Door)
    participant Orch as support-assistant<br/>(CX Team, SPIFFE Identity #1)
    participant AGW as Central Agent Gateway<br/>(Per-target IAP + Model Armor, optional)
    participant Gemini as Gemini 3.7 Flash<br/>(Vertex AI API)
    participant EP as Entry Point<br/>(*.esmeralda.internal, direct)
    participant Spec as order-ops-specialist<br/>(AI CoE Team, SPIFFE Identity #2)
    participant MCP as MCP Tool Servers<br/>(Cloud Run FastMCP)
    participant FinOps as Central Governance<br/>(Log Sinks & BigQuery)

    User->>Apigee: "What is the status of order ORD-2026-4102?" (x-api-key / 3LO token)
    Apigee->>Orch: Verified partner request + LLMTokenQuota check
    Orch->>AGW: Reason about intent
    AGW->>Gemini: Authorized model call (SPIFFE identity check)
    Gemini-->>Orch: Delegate order lookup to order-ops-specialist

    Note over Orch,Spec: Act I — Governed Cross-Team A2A Delegation
    Orch->>AGW: A2A task to order-ops-specialist.esmeralda.internal
    AGW->>EP: Verify Agent Registry + per-target IAP (principal://) -> private PSC attachment
    EP->>Spec: Route by Host header (PSC NEG to Agent Runtime, path rewrite)

    Note over Spec,MCP: Act II — Governed MCP Tool Execution
    Spec->>AGW: Call get_order & get_shipment_status (https://<svc>.esmeralda.internal/mcp + ID token + 3LO claims)
    AGW->>EP: Verify per-target IAP (principal://) + Model Armor (optional) -> private PSC attachment
    EP->>MCP: Route by Host header (serverless NEG to Cloud Run, IAM + mcp_authz check)
    MCP-->>Spec: Order ORD-2026-4102 details & shipment tracking

    Spec-->>Orch: Structured order status summary
    Orch-->>Apigee: SSE stream + usageMetadata token counts
    Apigee-->>User: Complete order status summary for Camila Rocha
    Orch-)FinOps: Structured token & latency telemetry -> BigQuery chargeback
    Spec-)FinOps: Structured token & latency telemetry -> BigQuery chargeback
  1. The North–South Front Door (Apigee X or Direct SDK): External B2B partner apps enter through Apigee X (partner.esmeralda.internal), which validates API keys/OAuth tokens, blocks direct access to internal specialists, and enforces commercial <LLMTokenQuota> budgets. Internal callers can invoke the orchestrator directly via uv run esmeralda query.
  2. The Orchestrator Reasons (support-assistant): Running as a Bring-Your-Own-Container (BYOC) workload on Vertex AI Agent Runtime in the CX team's project with its own attested SPIFFE Agent Identity (principal://), the orchestrator consults Gemini, handles policy questions via knowledge-base, and delegates order operations to the AI CoE's order-ops-specialist.
  3. The East–West Trust Boundary Inspects (Central Agent Gateway): Every outbound packet passes through the Google-managed Central Agent Gateway (AGENT_TO_ANYWHERE), which verifies the caller's SPIFFE principal:// identity against per-target IAP egress grants (roles/iap.egressor), checks the Agent Registry, and, when enabled, runs Model Armor on unary MCP tool calls and agent cards (coverage). Tool arguments are not checked against the Semantic Governance (NLC) manifest: it is not enforced yet.
  4. The Private Front Door Routes (Entry Point): The gateway forwards the request over Private Service Connect to the internal HTTPS load balancer (entry point, *.esmeralda.internal), which presents a certificate signed by Esmeralda's internal Root CA and routes straight to the target engine or Cloud Run service (direct backend).
  5. The Specialist Calls MCP Tools (order-ops-specialist → Cloud Run): The specialist—using its own SPIFFE identity and Auth Manager 3LO user delegation—invokes orders, customers, refunds, and notifications over MCP (https://<svc>.esmeralda.internal/mcp).
  6. FinOps Closes the Loop (BigQuery & Cloud Monitoring): OpenTelemetry caller baggage (caller.project_id, caller.agent_name) and structured token telemetry flow into BigQuery (vw_monthly_agent_chargeback), attributing every token to the initiating team and agent.

3. Why We Designed It This Way: The 6 Layers & Key Decisions

Infrastructure is provisioned from the ground up in six decoupled layers using Terragrunt. Layer 0 is shared across environments; Layers 1 through 5 are instantiated identically per environment (dev, prd):

flowchart LR
    L0["<b>Layer 0 (Shared)</b><br/>CI/CD & Artifact Registry<br/>Build once, promote by digest"] --> L1["<b>Layer 1</b><br/>Projects & FinOps<br/>Isolated team projects"]
    L1 --> L2["<b>Layer 2</b><br/>Private Networking<br/>Shared VPC, PSC & DNS"]
    L2 --> L3["<b>Layer 3</b><br/>Security, IAM & PKI<br/>SPIFFE, CMEK & Root CA"]
    L3 --> L4["<b>Layer 4</b><br/>Governance Hub<br/>Agent Gateway & FinOps BQ"]
    L4 --> L5["<b>Layer 5</b><br/>Workloads & Catalog<br/>Agents, MCPs & Entry Point"]

Architectural Decisions at a Glance

Architectural Decision Why We Made It What We Avoided
Per-Team GCP Projects (L1) (cx-agents, ai-coe-agents, mcps, gateway, governance) Gives every engineering track its own IAM boundary, quota pool, and FinOps chargeback bucket. A "mega-project" where experimental agents share service accounts and blast radius with production tools.
Stable *.esmeralda.internal DNS + Internal Root CA (L2–L3) Decouples callers from dynamic Cloud Run URLs and Vertex AI engine resource IDs while maintaining full end-to-end TLS verification. Hardcoding run.app or aiplatform.googleapis.com resource IDs inside agent code or disabling TLS verification (verify=False).
Central Agent Gateway + Agent Registry (L4) Enforces a Google-managed, deny-by-default outbound allowlist for every agent based on cryptographic SPIFFE identity. Custom egress squid proxies, unmanaged NAT gateways, or agents calling arbitrary external URLs.
Built-In direct Entry Point with Optional Adapters (L5) Routes *.esmeralda.internal traffic natively via Google Cloud Load Balancing NEGs by default (zero proxy compute cost, end-to-end caller identity), while allowing teams to opt into Envoy or Apigee per host. Mandatory reverse-proxy hops that hide caller identity and add operational overhead when simple routing suffices.
Build Once, Promote by Digest (L0) Container images contain zero environment secrets or certificates; prd runs the exact SHA-256 image digest verified in dev. Rebuilding containers per environment or baking certificates into Docker images.

4. Section Guide & Quick Start

The documentation is organized into seven numbered sections (1.–7.): the first four follow Camila Rocha's request from the application surface down to the cloud foundation and developer tooling, the fifth takes it across clouds, the sixth covers external integrations such as the Scion governed agent factory, and the seventh collects reference material:

Section Focus Subsections Best For
1. Workloads, Catalog & Gateways The runtime workloads in Layer 5 and the declarative service catalog that connects them. • 1.1 Two Teams, Two Agents (ADK & A2A)
• 1.2 MCP Tool Servers
• 1.3 Private Front Door & Gateways
• 1.4 Apigee X Partner Gateway & Monetization
• 1.5 One Gateway per Hop
AI Engineers, Application Architects, Product & Engineering Leaders
2. Governance, Identity & AgentOps How Layer 4 governs every outbound call, inspects content, tracks FinOps costs, and powers day-2 operations. • 2.1 Central Agent Gateway & Private PKI
• 2.2 Capability & Semantic Governance
• 2.3 FinOps, Telemetry & Chargeback
• 2.4 Day-2 Operations (CLI & MCP)
• 2.5 Usage Telemetry Contract
• 2.6 Service Catalog & 2.7 Catalog Sources
SecOps, Governance Leads, FinOps, SRE / Platform Operators
3. Platform Foundations (Layers 1–3) The zero-trust landing zone (Layers 0–3) that makes Sections 1 and 2 possible. • 3.1 Projects & FinOps Isolation (Layer 1)
• 3.2 Private Networking, PSC & DNS (Layer 2)
• 3.3 Security, SPIFFE Identity & PKI (Layer 3)
Cloud Architects, NetOps, Infrastructure Engineers
4. Esmeralda Library & CLI The esmeralda Python runtime package, CLI, and read-only MCP server. • 4.1 Developer Usage Guide
• 4.2 Package & CLI Reference
All Developers & AI Coding Agents
5. Multi-Cloud & Interoperability Agents on other clouds calling Esmeralda (and back) with verified identity, governed paths, and one usage and chargeback view. • 5.1 Identity Across Clouds
• 5.2 Cross-Cloud Connectivity & Protocols
• 5.3 Unified Observability & Chargeback
• 5.4 Bringing an Agent from Another Cloud
• 5.5 Status & Roadmap
Cloud & Security Architects, Identity Teams, FinOps
6. Integrations & Agent Factory Governed autonomous coding agents using Scion with Esmeralda identities, gateways, and FinOps. • 6.1 Governed Agent Factory (Scion) Platform Engineers, AI Tooling Teams, Engineering Leads
7. Reference & Contributing Generated Make target reference and the contribution workflow. • 7.1 Make Targets
• 7.2 Contributing Guide
• 7.3 Code of Conduct
Contributors & AI Coding Agents

Try It Now with the esmeralda CLI

Every operation in Esmeralda is available through the esmeralda CLI (uv run esmeralda --help):

# 0. Configure the ESMERALDA_* variables once, outside the repository (never commit the copy),
#    then edit it: ESMERALDA_BILLING_ACCOUNT is required
mkdir -p ~/.config/esmeralda
cp -n infrastructure/esmeralda.env.example ~/.config/esmeralda/env && chmod 600 ~/.config/esmeralda/env

# 1. Check local tools, credentials, and environment configuration
uv run esmeralda doctor --env dev
uv run esmeralda status --env dev

# 2. Run Camila Rocha's order support query locally (--local-mcp starts and stops the local MCP servers)
uv run esmeralda query --agent-dir apps/agents/support-assistant --local-mcp \
  "What is the status of order ORD-2026-4102?"

# 3. Verify a deployed environment end-to-end (all catalog probes + live orchestrator query)
uv run esmeralda verify --env dev

Next: 1.0 Workloads, Catalog & Gateways — Overview.