Skip to main content
Backends define where agentgateway forwards matched traffic. They appear inside routes as inline configurations. agentgateway supports four backend types: mcp, host (plain HTTP/A2A), and named backend references defined at the top-level backends list.

Backend types

Each entry in routes[].backends must be exactly one of:

MCP backend

The mcp backend type proxies traffic to one or more MCP (Model Context Protocol) servers. Multiple targets are aggregated: the gateway exposes all tools, resources, and prompts as a single unified MCP server to clients.
When multiple targets are configured, each tool name is prefixed with <target-name>_ to avoid collisions between servers.

MCP target fields

string
required
A unique name for this MCP target. Used to prefix tool names when multiple targets are aggregated (e.g., weather_get_forecast).
object
Per-target policies (header modification, backend TLS, authentication, etc.). These merge with and can override route-level policies for this specific target.

Stdio transport

Agentgateway spawns a local process and communicates over its standard input/output. Use this for MCP servers distributed as CLI tools.
string
required
The command to execute. The process is started when the first client connects.
string[]
Arguments to pass to the command.
object
Environment variables to set for the spawned process. Key-value string pairs.

HTTP/SSE transport

Agentgateway connects to an already-running MCP server over HTTP. Two sub-types are supported: SSE transport (sse) — connects to an MCP server using the legacy Server-Sent Events transport.
string
required
Hostname or IP address of the MCP server.
number
Port of the MCP server.
string
URL path prefix, e.g. /sse.
Streamable HTTP transport (mcp) — connects to an MCP server using the modern streamable HTTP transport.
string
required
Hostname or IP address of the MCP server.
number
Port of the MCP server.
string
URL path prefix, e.g. /mcp.

OpenAPI transport

Agentgateway converts an OpenAPI specification into MCP tools, enabling any REST API to be used by AI agents over the MCP protocol.
string
required
Hostname of the REST API.
number
Port of the REST API.
string
Base path for the API.
object
required
The OpenAPI schema to use. Provide either a file path or a url.

HTTP / A2A backend

Use host to forward traffic to any HTTP service or A2A (Agent-to-Agent) endpoint. This is the simplest backend type and requires only a hostname and optional port.
string
required
The upstream hostname or host:port address to forward requests to.Examples: 127.0.0.1:8080, backend.internal:9000, localhost:9999.
plain HTTP

A2A traffic

For A2A (Agent-to-Agent protocol) traffic, use host combined with the a2a: {} route policy. The policy enables A2A-specific processing, telemetry, and tracing.
a2a/config.yaml

Top-level named backends

The top-level backends list defines named backend resources that can be referenced by routes using backend: <name>.
string
required
A unique name for this backend. Referenced from routes as backend: <name>.
string
The upstream hostname or host:port.
object
Policies attached to this backend (TLS, auth, health, HTTP settings, etc.). These apply whenever this backend is referenced from any route.

Backend TLS (backendTLS)

Configure TLS for connections agentgateway makes to the upstream backend.
object
Send TLS to the backend.

Backend auth (backendAuth)

Authenticate agentgateway to upstream services. Exactly one auth variant must be set.
Pass the incoming request’s Authorization header directly to the backend without modification.
Attach a static key as the Authorization header on every upstream request. The key value can be an inline string or loaded from a file.
inline key
key from file
Obtain a GCP identity or access token from the instance metadata service (or a service account) and attach it to upstream requests.
  • typeidentityToken or accessToken.
  • audience — Audience for the token. Defaults to the backend host when omitted.
Sign upstream requests using AWS Signature Version 4.
Obtain an Azure access token and attach it to upstream requests. Supports explicit service principal credentials, managed identity, workload identity, and developer implicit credentials.
client secret (service principal)
managed identity
workload identity
developer implicit (local dev)

Complete examples

MCP backend with API key auth and TLS

A2A backend with CORS

OpenAPI backend


AI backend

The ai backend proxies traffic to an LLM provider. It enables AI-specific policies like prompt guard and prompt enrichment, and exposes LLM-specific telemetry (token counts, model used, streaming status).

Supported providers

Authenticate using backendAuth.key set to your OPENAI_API_KEY environment variable:

AI backend fields

string
required
A unique name for this AI backend instance. Used in telemetry and logging.
object
required
The LLM provider configuration. Exactly one provider must be specified: openAI, gemini, anthropic, vertex, bedrock, or azureOpenAI.

AI-specific policies

When using an ai backend, the following additional policies are available: See the Prompt Guard guide for configuration details.

AWS backend

The aws backend type handles AWS-native integrations such as AWS Bedrock AgentCore.
AWS backends use IAM/SigV4 authentication by default. Configure backendAuth.aws with explicit credentials, or rely on the instance’s IAM role for implicit authentication.