Routes

Routes

Routes are the entry points for traffic to your agentgateway. They are configured on listeners and are used to route traffic to backends.

You can use the built-in agentgateway UI or a configuration file to create, update, and delete routes.

Before you begin

  1. Install the agentgateway binary.
  2. Set up a listener.

Create routes

Set up a route on your listener.

  1. Start your agentgateway.

    agentgateway 
  2. Open the agentgateway route UI.

  3. Click Add Route and configure a route such as follows:

    • Name: An optional name for the route.
    • Rule Name: An optional name for the matching rules of the route.
    • Target Listener: Select the listener that you previously created. The Route Type is automatically determined based on the listener protocol.
    • Hostnames: Add the hostnames that the route serves traffic on.
    • Path Match Type: Select the type of path matching that you want to use, such as Path Prefix, and then configure its details. For more options, see the Request matching guide.
    • Headers: Optional header configuration, such as the authorization header.
    • HTTP Methods: Optional HTTP methods to allow, such as GET, POST, PUT.
    • Query Parameters: Optional query parameters to allow, such as version=v1.
    • Click Add HTTP Route to continue.
  1. Download a configuration file that contains your route configuration.

    curl -L https://raw.githubusercontent.com/agentgateway/agentgateway/refs/heads/main/examples/basic/config.yaml -o config.yaml
  2. Review the configuration file. The example sets up an HTTP listener on port 3000 that matches on all hosts. For more options, see the Request matching guide.

    cat config.yaml
    binds:
    - port: 3000
      listeners:
      - routes:
        - policies:
            cors:
              allowOrigins:
                - "*"
              allowHeaders:
                - mcp-protocol-version
                - content-type
                - cache-control
          backends:
          - mcp:
              targets:
              - name: everything
                stdio:
                  cmd: npx
                  args: ["@modelcontextprotocol/server-everything"]
  3. Run the agentgateway.

    agentgateway -f config.yaml
  4. Open the agentgateway listener UI and verify that your route is added successfully.

Delete routes

Remove agentgateway routes by using the UI or deleting the configuration file.

Remove agentgateway routes with the UI.

  1. Run the agentgateway from which you want to remove a route.

    agentgateway -f config.yaml
  2. Open the agentgateway route UI and find the route that you want to remove.

  3. Click the trash icon to remove the route.

Update the configuration file to remove the route.

  1. Remove the route from your configuration file.

  2. Apply the updated configuration file to your agentgateway.

    agentgateway -f config.yaml

Next steps

After you create routes, you might want to apply policies to them.