How affinidi/affinidi-labs-tgw-get-started works
Purpose and Scope
This is an evaluation/learning repository for Affinidi Agent Gateway (the Rust-hosted product itself is external). It supplies runnable protocol endpoints, clients, identity/delegation demos, observability setup, and cross-organization labs. The gateway is the control boundary: it inspects A2A/MCP traffic, applies configured routing, identity, authentication and policies, then forwards to local or cloud agents.
Baseline A2A Flow
The local A2A echo agent and interactive client establish the simplest agent-to-agent path. The server exposes an agent card, health endpoint, and messaging endpoint; a client can call it directly or through a gateway A2A surface.
• a2a/a2a_server.py
• a2a/a2a_client.py
• a2a/run.sh
Baseline MCP Flow
The MCP sample is a JSON-RPC tool server with calculator and mock weather capabilities. Its client initializes the MCP session, discovers tools, and invokes them. Gateway configuration replaces the direct server URL with a governed MCP route, making the gateway responsible for ingress controls and upstream forwarding.
• mcp/mcp_server.py
• mcp/mcp_client.py
• mcp/enable-auth.md
Cloud Agent and REST Adapters
A separate A2A agent definition can be tested locally and deployed to Google Cloud Vertex AI Agent Engine; its client continues to use Vertex management APIs while A2A messaging can traverse the gateway. A REST server also acts as an MCP proxy, demonstrating protocol/API integration rather than a standalone agent.
• a2a-vertex-agent/agent.py
• a2a-vertex-agent/deploy.py
• rest-api/api_server.py
Agent Identity and Trust
The multi-agent identity lab publishes Personal and Finance A2A agents with identity-extension declarations. When an Agent Gateway surface enables identity, it issues did:webvh-based signed verifiable presentations and injects them into agent-card and message responses. Cross-org examples model two gateway configurations connected through trust/policy controls, with Rego policies defining admission, routing, acknowledgment, and user-scope behavior.
• a2a-agent-identity/agents.py
• a2a-agent-identity/identity-extension.json
• use-cases/secure-agent-communication/gateway-config/policies/
OAuth Delegation Chat Surface
auth0-mcp-surface is a full browser-facing reference surface: static Astro frontend calls a FastAPI backend, which serves the built UI and mediates MCP requests. Google OAuth supplies caller context; Agent Gateway validates that context and delegates Auth0 credentials to the protected upstream MCP service, including consent-oriented flows. Docker Compose supports a single-container deployment, while development can use separate frontend/backend processes.
• auth0-mcp-surface/backend/main.py
• auth0-mcp-surface/frontend/src/pages/chat.astro
• auth0-mcp-surface/docker-compose.yml
Cross-Organization Portal Scenario
The secure-agent-communication lab has Python agents plus a Next.js portal for interactive direct and gateway-mediated A2A communication. Portal API routes handle Microsoft/Entra authentication, outgoing chat, and incoming messages. Gateway JSON surfaces and Rego policies are externalized so organizations can independently configure trust and transit rules.
• use-cases/secure-agent-communication/agent/agent.py
• use-cases/secure-agent-communication/portal/src/app/api/chat/route.ts
• use-cases/secure-agent-communication/gateway-config/
Operations and External Boundaries
Python 3.10+ is the main sample runtime; TypeScript runs Astro and Next.js UIs; Docker runs observability and chat-surface deployments. Public reachability is supplied by ngrok or GitHub Codespaces port forwarding for local upstreams. Prometheus directly scrapes the external gateway metrics endpoint, while Grafana provisions dashboards from that data. Other material external services are Affinidi Developer Portal/Agent Gateway, Google Cloud Vertex AI and Gemini, Google OAuth, Auth0 OAuth, Microsoft Entra, and Copilot Studio Direct Line.
• gateway-prometheus-integration/docker-compose.yml
• gateway-prometheus-integration/prometheus.yml.template
• use-cases/copilot-studio-agent-communication/gateway-config/
Main entry points: main.py OAuth chat backend · mcp_server.py MCP tool server · a2a_client.py A2A interactive client · mcp_client.py MCP client
Components 22
Protocol samples
- A2A interactive client
a2a/a2a_client.py - A2A echo agent · Serves agent card, health, and messaging.
a2a/a2a_server.py - MCP client · Initializes sessions, discovers tools, and invokes them.
mcp/mcp_client.py - MCP tool server · Provides calculator and mock weather tools.
mcp/mcp_server.py
Cloud and adapters
- Vertex A2A agent
a2a-vertex-agent/agent.py - Vertex deployment
a2a-vertex-agent/deploy.py - Vertex AI Agent Engine
- REST-to-MCP proxy · Demonstrates protocol/API integration.
rest-api/api_server.py
Identity and cross-org
- Personal and Finance agents · Publish identity-extension declarations.
a2a-agent-identity/agents.py - Identity extension
a2a-agent-identity/identity-extension.json - Cross-org agents
use-cases/secure-agent-communication/agent/agent.py - Cross-org portal API · Handles Entra-authenticated chat and incoming messages.
use-cases/secure-agent-communication/portal/src/app/api/chat/route.ts - Cross-org gateway surfaces · Organizations configure independent trust and transit surfaces.
- Trust and routing policies · Controls admission, routing, acknowledgments, and user scope.
OAuth delegation surface
- OAuth chat frontend
auth0-mcp-surface/frontend/src/pages/chat.astro - OAuth chat backend · Serves the UI and mediates MCP requests.
auth0-mcp-surface/backend/main.py - Chat surface deployment · Supports single-container deployment.
auth0-mcp-surface/docker-compose.yml - Google OAuth and Auth0 · Google supplies caller context; Auth0 credentials are delegated upstream.
Operations
- Prometheus and Grafana · Prometheus scrapes gateway metrics and Grafana visualizes them.
gateway-prometheus-integration/docker-compose.yml - Prometheus scrape config
gateway-prometheus-integration/prometheus.yml.template - Copilot gateway surfaces
Other components
- Affinidi Agent Gateway · Enforces routing, auth, identity, and policy before forwarding traffic.
Connections 24
- A2A interactive client → A2A echo agent: direct A2A
- A2A interactive client → Affinidi Agent Gateway: governed A2A
- Affinidi Agent Gateway → A2A echo agent: forwards A2A
- MCP client → MCP tool server: direct MCP
- MCP client → Affinidi Agent Gateway: governed MCP
- Affinidi Agent Gateway → MCP tool server: forwards MCP
- Vertex deployment → Vertex AI Agent Engine: deploys
- Vertex AI Agent Engine → Vertex A2A agent: hosts
- Affinidi Agent Gateway → Vertex AI Agent Engine: routes A2A messaging
- REST-to-MCP proxy → MCP tool server: proxies MCP
- Personal and Finance agents → Identity extension: declares
- Affinidi Agent Gateway → Personal and Finance agents: issues identity presentations
- Cross-org portal API → Affinidi Agent Gateway: gateway-mediated chat
- Cross-org gateway surfaces → Affinidi Agent Gateway: configures surfaces
- Trust and routing policies → Cross-org gateway surfaces: governs
- Affinidi Agent Gateway → Cross-org agents: routes cross-org A2A
- OAuth chat frontend → OAuth chat backend: browser requests
- OAuth chat backend → Google OAuth and Auth0: obtains caller context
- OAuth chat backend → Affinidi Agent Gateway: mediates MCP
- Affinidi Agent Gateway → Google OAuth and Auth0: validates and delegates OAuth
- Chat surface deployment → OAuth chat backend: deploys
- Prometheus scrape config → Prometheus and Grafana: configures scrape
- Prometheus and Grafana → Affinidi Agent Gateway: scrapes metrics
- Copilot gateway surfaces → Affinidi Agent Gateway: configures Direct Line routes