MCP Gateway Not Blocking Shadow Servers?

Part of: MCP

Why an MCP gateway is not blocking shadow MCP server traffic: traffic that skips it, allow-by-default rules, a 200 that is a block, and stale sessions.

An MCP gateway usually is not blocking shadow server traffic because that traffic never goes through it: a stdio server runs on a laptop, or an agent calls a remote MCP URL directly, and no egress rule forces it to the gateway. When the traffic does reach agentgateway, the usual causes are policy that allows by default: no rules or deny-only rules allow everything else, Kubernetes allows every tool until a tool-access policy attaches, and a denied tool call can come back as HTTP 200.

I work at Solo.io, which makes agentgateway.

This page is the diagnosis of a gateway that is already in place. Why shadow MCP servers are hard to track is the hub. What an MCP gateway is is the definition. If you still need to set up the controls from scratch, start there.

Authorization behavior below is from the current 1.7.x docs, re-checked November 15, 2026. Nothing here is a harness result.

Is the shadow traffic going through the gateway at all?

Check this first, every time. In standalone agentgateway, every MCP request is logged with mcp.target and mcp.method.name, and the mcp_requests_total metric carries a server label, as documented in the standalone MCP observability docs. If the shadow server never appears there, no gateway policy can block it. If you are not sure the endpoint is MCP, check whether it is an MCP server at all.

Three common ways around the gateway:

  • A stdio MCP server is a child process on the laptop. It never touches your network, so it never reaches a gateway on that network.
  • An agent calls a remote MCP URL directly, skipping the gateway endpoint you configured.
  • A vendor-hosted connector connects from the vendor’s cloud and never crosses your network.

The fix is to make the gateway the only path. On Kubernetes, default-deny egress for agent namespaces with a NetworkPolicy that allows only the gateway. That is Kubernetes behavior, not an agentgateway feature. On standalone hosts, use the same rule at the host or network firewall, or run agentgateway as a CONNECT egress proxy (v1.6.0, tested on that page). Why proxy-variable sandboxes fail is the case for authorizing the resolved destination at CONNECT time. Laptops and vendor-hosted connectors stay the gap.

Egress controls only work when the MCP server’s traffic is forced through the gateway.

Does your policy allow anything it does not mention?

Start with standalone HTTP authorization, as documented in the HTTP authorization docs. Rules are evaluated in this order:

  1. If there are no rules, the request is allowed.
  2. If any deny rule matches, the request is denied.
  3. If any require rule does not match, the request is denied.
  4. If any allow rule matches, the request is allowed.
  5. If no rule matched: with no allow rules, the request is allowed (denylist semantics). With allow rules configured, the request is denied (allowlist semantics).

A CEL expression that cannot be evaluated is treated as false. A deny expression that errors does not match, so it fails open. A require expression that is false or errors denies the request, so it fails closed.

Network authorization uses the same rule types. The network doc adds that a rule referencing an unset variable never matches, so a require rule then rejects the connection and a deny rule lets it through.

Write shadow control as an allowlist: allow rules for the approved targets and tools, never a deny list of names you happen to know. Standalone MCP authorization can attach mcpAuthorization at the route or the MCP backend, and can match on mcp.tool.target. These authorization rules are copied from that doc:

mcp:
  port: 3000
  policies:
    mcpAuthorization:
      rules:
      # Allow anyone to access tools on the public-tools target
      - 'mcp.tool.target == "public-tools"'
      # Only authenticated admins can access tools on the admin-tools target
      - 'mcp.tool.target == "admin-tools" && has(jwt.sub) && "admin" in jwt.roles'
  targets:
  - name: public-tools
    stdio:
      cmd: npx
      args: ["@modelcontextprotocol/server-everything"]
  - name: admin-tools
    stdio:
      cmd: npx
      args: ["@mycompany/admin-server"]

On Kubernetes, the tool access docs state that “By default, all tool access is allowed” until you attach an AgentgatewayPolicy with CEL rules to the AgentgatewayBackend. Check that the policy’s targetRefs point at the backend you think they do. I am not stating what status the policy reports when those refs match nothing, because I have not checked that in a harness.

Is a broad allow rule matching first?

Rules are OR’ed: any allow that matches lets the call through. The Kubernetes tool access doc’s own example is a rule of only jwt.sub == "alice", which shows Alice every tool on the server. The comment on the documented policy says “Any of these conditions will allow access (OR logic)”.

The same OR shape shows up in matchExpressions on CEL authorization gotchas, tested there on Solo Enterprise for agentgateway v2026.8.2: two expressions that were meant to combine can each allow the request on their own.

This is the documented Kubernetes shape for attaching a tighter tool-access policy, copied from those docs. Point targetRefs at your own backend, and write the expression you actually want:

apiVersion: agentgateway.dev/v1alpha1
kind: AgentgatewayPolicy
metadata:
  name: jwt-rbac
  namespace: agentgateway-system
spec:
  targetRefs:
    - group: agentgateway.dev
      kind: AgentgatewayBackend
      name: github-mcp-backend
  backend:
    mcp:
      authorization:
        action: Allow
        policy:
          # Any of these conditions will allow access (OR logic)
          matchExpressions:
            - 'jwt.sub == "alice" && mcp.tool.name == "get_me"'

Are you blocking by name?

A server name, a target name, and serverInfo are labels someone chose. The MCP spec says serverInfo is self-reported and should not be used for security decisions.

mcpAuthorization can see mcp.tool.name and mcp.tool.target, but mcp.tool.arguments is not set in those rules. Decisions on arguments need a route-level authorization policy, which the standalone MCP authorization doc says can read mcp.tool.arguments.

On the client, Claude Code’s managed MCP allowlist matches on serverUrl or serverCommand. Its docs treat serverName as a user-assigned label, and say a serverName entry in either list is not a security control. That is a client fact, not a ranking.

Did a label selector let the shadow server in?

This is Kubernetes only. Virtual MCP and dynamic MCP select Services by label, and the Service needs appProtocol: agentgateway.dev/mcp. The virtual MCP docs warn that label selectors currently support only Streamable HTTP; SSE still needs a static backend.

So anyone who can create a Service with that label, in a place the selector matches, can add a server to the federation. That is the documented design, not a bug. I have not tested the selector’s namespace scope, so I am not stating which namespaces that covers.

The tighter option is static backends for the servers in a registry of record.

Restrict who may create or label Services in the namespaces your selector uses, with Kubernetes RBAC.

Is the block happening but looking like success?

Three documented reasons a working block looks like nothing happened:

  • A tools/call denied by an MCP guardrail (ExtMCP or a CEL processor) or a rate limit returns HTTP 200 with result.isError set to true, as stated in the spec compatibility docs. A dashboard that counts non-200s shows zero blocks.
  • mcpAuthorization filters tools out of list responses, so the client sees fewer tools, not an error.
  • In agentgateway v1.7.0 (tagged 2026-10-27), error responses sent to clients no longer include internal details such as CEL expressions or upstream error text. The notes show a client error that used to include the CEL expression, including a “no such key” failure, and now returns only “policy failed”. The full error is still logged, and status codes are unchanged. The same release’s changelog includes a fix that distinguishes authorization denials in logs. Read the gateway log, not only the client error.

Did the policy change reach sessions that were already open?

The v1.7.0 release notes fixed MCP conditional targets being evaluated only when a session was initialized, and resumed sessions keeping outdated settings after a configuration change. I have not reproduced the pre-1.7.0 behavior, so the documented fix is the claim: if you are on an earlier version, do not assume a policy change applies to a session that was already open. Upgrade to v1.7.0, and test with a new session.

A related breaking change in the same notes: standalone now always encrypts MCP sessions, so pre-upgrade encrypted sessions are rejected and clients have to establish new sessions.

How do you prove the gateway blocks it now?

These are the checks to run. I have not run them as a harness for this page, so this section lists what to look for and makes no claim about results.

  • Call a tool you did not allow. You expect it missing from tools/list, and refused on tools/call.
  • Call an unregistered target. You expect it not routable through the gateway.
  • From an agent pod, call an MCP URL that is not the gateway. You expect egress to refuse it.

Since v1.7.0, agentgateway records the x-claude-code-session-id header as request.agent.session in logs and CEL, which the release notes document. When a blocked call shows up, that field can tell you which coding session made it, not only which user.

Egress controls only work when the MCP server’s traffic is forced through the gateway. A denied tool on the gateway path does not prove a direct call is blocked.

Frequently asked questions

Why is my MCP gateway not blocking unauthorized shadow MCP server traffic?

Usually because the traffic never reaches the gateway. A stdio server runs on the laptop, or an agent calls a remote MCP URL directly, and nothing forces it through the gateway. If the traffic does pass through, check for policy that allows by default: no rules, deny-only rules, or a Kubernetes backend with no tool-access policy attached.

Is an MCP gateway enough to secure AI agents?

Only for traffic that goes through it. A gateway can authorize every tool call it sees, but it cannot see stdio servers on a laptop or calls that go around it. Pair it with default-deny egress, an allowlist by URL and command, and a registry of the servers you approved.

Does agentgateway allow all MCP tools by default?

On Kubernetes, yes: all tool access is allowed until you attach a policy with CEL rules. In standalone mode, a policy with no rules allows the request, and a policy with only deny rules allows everything it does not deny.

Why does a blocked MCP tool call return HTTP 200?

When agentgateway denies a tools/call through an MCP guardrail or a rate limit, it returns a normal JSON-RPC result marked isError, so the client can show it as a failed tool call. Count those results, not HTTP errors, to see blocks.

Disagree or have a war story? Reply on X