Skip to content
Help guide the future of agentgateway — Take the survey

MCP servers

Verified : Automated tests passed for: Kubernetes resources: The Kubernetes resources on this page were checked against their API schemas. End-to-end run: Every step ran in a fresh test environment and the results were checked.
Page as Markdown

Connect to an MCP server and try tools with agentgateway on Kubernetes.

Route to a Model Context Protocol (MCP) server through a static address. For more information, see the About MCP topic.

Before you begin

Install and set up an agentgateway proxy.

Static MCP server

Step 1: Deploy an MCP server

Deploy a Model Context Protocol (MCP) server that you want agentgateway to proxy traffic to. The following example sets up a simple MCP server with one tool, fetch, that retrieves the content of a website URL that you pass in.

Notice the following details about the Service:

  • appProtocol: agentgateway.dev/mcp: Only label-selector targets read this setting, so a static target does not require it. The example keeps it so that you can reuse the Service with label selectors. For more information, see Multiplex MCP servers.
  • agentgateway.dev/mcp-path annotation: Only label-selector targets read this annotation. A static target sets the transport and path in the static.protocol and static.path fields of the AgentgatewayBackend instead.
kubectl apply -f- <<EOF
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mcp-website-fetcher
spec:
  selector:
    matchLabels:
      app: mcp-website-fetcher
  template:
    metadata:
      labels:
        app: mcp-website-fetcher
    spec:
      containers:
      - name: mcp-website-fetcher
        image: ghcr.io/peterj/mcp-website-fetcher:main
        imagePullPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
  name: mcp-website-fetcher
  labels:
    app: mcp-website-fetcher
spec:
  selector:
    app: mcp-website-fetcher
  ports:
  - port: 80
    targetPort: 8000
    appProtocol: agentgateway.dev/mcp
EOF

Step 2: Create the backend for the MCP server

Create a AgentgatewayBackend that sets up the agentgateway target details for the MCP server.

kubectl apply -f- <<EOF
apiVersion: agentgateway.dev/v1alpha1
kind: AgentgatewayBackend
metadata:
  name: mcp-backend
spec:
  mcp:
    targets:
    - name: mcp-target
      static:
        host: mcp-website-fetcher.default.svc.cluster.local
        port: 80
        protocol: SSE   
EOF

Step 3: Route to the backend

Create an HTTPRoute resource that routes to the AgentgatewayBackend that you created in the previous step. Use a path match so that requests to /mcp go to the MCP backend and are not routed to an LLM or other backend.

kubectl apply -f- <<EOF
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: mcp
spec:
  parentRefs:
    - name: agentgateway-proxy
      namespace: agentgateway-system
  rules:
    - matches:
      - path:
          type: PathPrefix
          value: /mcp
      backendRefs:
      - name: mcp-backend
        group: agentgateway.dev
        kind: AgentgatewayBackend  
EOF

Step 4: Verify the connection

Use the MCP Inspector tool to verify that you can connect to your sample MCP server through agentgateway.

  1. Get the agentgateway address.

    • Cloud Provider LoadBalancer:
      export INGRESS_GW_ADDRESS=$(kubectl get gateway agentgateway-proxy -n agentgateway-system -o=jsonpath="{.status.addresses[0].value}")
      echo $INGRESS_GW_ADDRESS
    • Port-forward for local testing:
      kubectl port-forward deployment/agentgateway-proxy -n agentgateway-system 8080:80
  2. From the terminal, run the MCP Inspector. The MCP Inspector opens in your browser. If the browser does not open, open the URL that the command prints, including the MCP_INSPECTOR_API_TOKEN query parameter. The MCP Inspector requires Node.js 22.23.4 or a later 22.x release, 24.22.1 or a later 24.x release, or 26.12.1 or later. To check your version, run node -v.

    npx @modelcontextprotocol/inspector@2.17.0
  3. Add your agentgateway address as a server, and connect to it.

    1. Click Add Servers > + Add manually.
    2. Enter the following details, and click Add.
      • Server ID: Enter a name for the server, such as agentgateway.
      • Transport: Select streamable-http.
      • URL: Enter the agentgateway address, port, and the /mcp path. If your agentgateway proxy is exposed with a LoadBalancer server, use http://<lb-address>/mcp. In local test setups where you port-forwarded the agentgateway proxy on your local machine, use http://localhost:8080/mcp.
    3. On the agentgateway server card, click the toggle. Verify that the card shows Connected.
  4. From the menu bar, click Tools. From the list of tools, select the fetch tool.

  5. In the url field, enter a website URL, such as https://lipsum.com/, and click Execute Tool.

  6. Verify that the Results pane shows the fetched URL content.

Verify in the UI

You can also confirm that the proxy received your configuration in the read-only UI. In Kubernetes mode, the UI reflects the configuration that the agentgateway controller pushes to the proxy, so it is a quick way to check that your resources took effect.

  1. Forward port 15000 from the agentgateway-proxy deployment to your local machine.

    kubectl port-forward deployment/agentgateway-proxy -n agentgateway-system 15000
  2. While the port-forward is running, open http://localhost:15000/ui/ in your browser.

  3. From the Traffic menu, click Routes. Find your route, and click the view (eye) icon in its row to inspect the route and backend details.

Connect an IDE

After verifying connectivity with MCP Inspector, you can connect AI coding assistants such as Claude Code, Cursor, or VS Code to the MCP server through agentgateway. For configuration instructions, see MCP clients.

Cleanup

You can remove the resources that you created in this guide.
kubectl delete Deployment mcp-website-fetcher
kubectl delete Service mcp-website-fetcher
kubectl delete AgentgatewayBackend mcp-backend
kubectl delete HTTPRoute mcp
Was this page helpful?
Agentgateway assistant

Ask me anything about agentgateway configuration, features, or usage.

Note: AI-generated content might contain errors; please verify and test all returned information.

Tip: one topic per conversation gives the best results. Use the + button in the chat header to start a new conversation.

Switching topics? Starting a new conversation improves accuracy.
↑↓ navigate ↵ select esc dismiss

What could be improved?

Your feedback helps us improve assistant answers and identify docs gaps we should fix.

Need more help? Join us on Discord: https://discord.gg/y9efgEmppm

Want to use your own agent? Add the Solo MCP server to query our docs directly. Get started here: https://search.solo.io/.