Basic Example
This example shows how to use the agentgateway to proxy requests to the everything tool.
Running the example
cargo run -- -f examples/basic/config.yaml
Let's look at the config to understand what's going on.
binds:
- port: 3000
listeners:
- routes:
- backends:
- mcp: ...
We have a few concepts to understand here:
bindsrepresent each port our server listens on. In this case, we will listen on port 3000.listenerscan contain groups of resources. For our simple case here, we just have 1 listener.routescan associate advanced routing functionality and traffic policies with traffic. In this case, we just match all traffic and do not apply any policies.backendscontains where the traffic is finally sent to. In this case, we have 1 backend of typemcp.
For the MCP backend, we can connect to MCP servers over HTTP or Stdio. Additionally, we can connect to multiple MCP servers, and expose them all as one aggregated server. In this example, we will connect to one server over Stdio.
targets:
- name: everything
stdio:
cmd: npx
args: ["@modelcontextprotocol/server-everything"]
Tip
If you don't have
npx, you can also run with docker:stdio: cmd: docker args: ["run", "--rm", "-i", "mcp/everything"]
When clients connect to the gateway, the cmd will be executed to serve the traffic.
Now that we have the gateway running, we can use the mcpinspector to try it out.
npx @modelcontextprotocol/inspector
Once the inspector is running, it will present the port that it's running on, and then you can navigate to it in your browser.
Agentgatway supports both SSE (served under /sse) and streamable HTTP (served under /mcp).
Once you're connected, you can navigate to the tools tab and see the available tools.
Let's try out one of the tools, like everything:echo.
That worked! The gateway was able to proxy the request to the everything tool and return the response.


