Core concepts
Before configuring an MCP proxy, it helps to understand the four top-level objects in a gateway config:binds— the ports the gateway listens onlisteners— groups of routing rules per bindroutes— traffic matching rules and attached policiesbackends— where traffic is ultimately forwarded
backend of type mcp holds one or more targets. Each target is an upstream MCP server the gateway connects to over Stdio or HTTP.
Connecting to a stdio MCP server
The simplest setup proxies a single MCP server launched as a child process via Stdio.config.yaml
cmd is executed as a child process. The gateway handles the full MCP session lifecycle and forwards tool calls, resource reads, and prompt requests to that process.
Connecting to an HTTP/SSE MCP server
To proxy a remote MCP server already running over HTTP, use themcp transport in the target definition:
host field accepts the full base URL of the remote MCP server’s streamable HTTP endpoint.
When proxying remote MCP servers over TLS, add
backendTLS: {} to the route’s policies block to enable TLS verification for the upstream connection.Multiplexing multiple MCP backends
Agentgateway can multiplex multiple MCP servers into a single endpoint. Clients connect once and see all tools, resources, and prompts from every upstream server as if they came from one server. This centralizes client configuration — when you add or remove MCP servers, only the gateway config changes, not every client.config.yaml
<name>_ to avoid collisions across servers. For example, the echo tool from the everything server is exposed as everything_echo.
Tool aggregation
Tools from all backends are merged and presented as a single tool list to clients.
Resource aggregation
Resources from all backends are namespaced and aggregated into one resource list.
Prompt aggregation
Prompts from all backends are collected and served from the single endpoint.
Collision prevention
Tool and resource names are prefixed with the target name to prevent conflicts.
Transport: SSE vs. streamable HTTP
Agentgateway exposes two MCP transport endpoints on each bind:| Endpoint | Transport | Description |
|---|---|---|
/sse | Server-Sent Events | Legacy SSE-based MCP transport |
/mcp | Streamable HTTP | Modern HTTP-based MCP transport (preferred) |
Testing with MCP Inspector
Launch MCP Inspector
In a separate terminal, start the inspector:The inspector prints the URL it’s running on. Open that URL in your browser.
Connect to the gateway
In the inspector UI:
- Set Transport to
Streamable HTTP - Set URL to
http://localhost:3000/mcp
http://localhost:3000/sse instead.Full config reference
Stdio target
Stdio target
cmd and args define the process that is spawned per client connection.HTTP target
HTTP target
host is the full URL to the upstream MCP server’s streamable HTTP endpoint.CORS policy
CORS policy
Mcp-Session-Id response header must be exposed for stateful MCP sessions to work correctly with browser-based clients.