Mcp Classifier Routing

Routes MCP requests by body-derived method and tool name

Category: Setup-dependent integration
Task: Routes MCP requests by body-derived method and tool name

Prerequisites: The external service, credentials, or certificates referenced by this configuration.

Run it: Use ghcr.io/praxis-proxy/ai:0.5.0 and follow the container quickstart to mount and start the configuration.

This configuration comes from the selected release. The example has not been run here; external services are not bundled.

Download the source file.

# MCP Classifier Routing
#
# Routes MCP requests by body-derived method and tool name.
# The `mcp` filter parses JSON-RPC bodies and promotes internal
# routing headers (x-praxis-mcp-*) for router matching. These
# internal headers are stripped before upstream by header hygiene.
#
# This example uses `missing: synthesize` so it works with real
# MCP clients that do not send Mcp-Method / Mcp-Name headers.
# Standard MCP headers are synthesized from body-derived values
# and forwarded to backends. Mismatched headers are still rejected.
#
# For non-MCP traffic (e.g. old SSE transport), set on_invalid:
# continue and header_validation.missing: ignore.

listeners:
  - name: mcp
    address: "127.0.0.1:8080"
    filter_chains: [mcp-routing]

filter_chains:
  - name: mcp-routing
    filters:
      - filter: mcp
        max_body_bytes: 65536
        on_invalid: reject
        header_validation:
          mismatch: reject
          missing: synthesize
        headers:
          method: x-praxis-mcp-method
          name: x-praxis-mcp-name
          kind: x-praxis-mcp-kind
          protocol_version: x-praxis-mcp-protocol-version
          session_present: x-praxis-mcp-session-present

      - filter: router
        routes:
          - path_prefix: "/"
            headers:
              x-praxis-mcp-name: "get_weather"
            cluster: "weather-tools"
          - path_prefix: "/"
            headers:
              x-praxis-mcp-name: "get_calendar"
            cluster: "calendar-tools"
          - path_prefix: "/"
            cluster: "default-mcp"

      - filter: load_balancer
        clusters:
          - name: "weather-tools"
            endpoints:
              - "127.0.0.1:9001"
          - name: "calendar-tools"
            endpoints:
              - "127.0.0.1:9002"
          - name: "default-mcp"
            endpoints:
              - "127.0.0.1:9003"

insecure_options:
  allow_private_endpoints: true # example proxies to local backends