# Putting agentgateway in front of MCP doesn't restrict your agent

> On Kubernetes every tool stays open until you add a policy, and a deny rule with a broken expression silently lets every call through.

Original: https://fdetimes.net/en/tools/agentgateway-kubernetes-tool-authorization/

According to agentgateway's documentation, when the gateway runs on Kubernetes it gives agents access to every tool by default. Putting a gateway between an agent and an MCP server does not, by itself, restrict the agent. To do that, you have to create an AgentgatewayPolicy.

Who can call which tool is a question worth answering before you sit down for a security review with a client.

When you connect an agent to a client's CRM, ticketing system or database over MCP, you have to show who can call which tool and prove it with a test call. agentgateway can answer that question, provided you know what it does by default and how its rules can fail.

## A proxy built for agent protocols

The official repository describes agentgateway as an open-source proxy built on MCP and A2A that adds security, observability and governance to agent communication. Solo.io created the project, the Linux Foundation announced it was taking it on on August 25th 2025, and in 2026 it became the fourth project hosted by the Agentic AI Foundation (AAIF).

## Which stages does a request pass through?

The guardrails documentation sets out the order of processing. If MCP authentication or JWT authentication is configured, the gateway checks the client's token first, then evaluates target conditions, then runs the request-phase guardrail. For tools/call, the request-phase guardrail runs before the mcpAuthorization check.

For tools/list, the gateway filters the list after the upstream responds and before the response-phase guardrail. Tools denied by policy are stripped from the response, so the agent never sees them. If the agent calls such a tool anyway, the gateway answers as if the tool did not exist, with JSON-RPC error -32602.

This order determines where each kind of control belongs, as the example below shows.

## Example: a read-only support agent

The Kubernetes documentation has a compact example: a policy that lets the user alice call only get_me, with every other tool blocked. Carry that idea over to a hypothetical case. A client has an MCP server for its CRM with both lookup tools and tools that modify data, and the support team's agent may only read.

You write a policy made up solely of allow rules for the lookup tools. Once a policy contains allow rules, any request that matches none of them is denied. Shubham Katara tested this on the v1.2.x chart and wrote on kubesimplify that rules are combined with OR, so opening up another read tool means adding one more allow rule rather than editing the existing ones.

Do not write the syntax from scratch. Take the alice/get_me policy from the documentation for the version you are running as a template, and change only the user and the tool names.

Then test twice. Call tools/list to confirm only the lookup tools remain, then call a write tool directly to confirm you get -32602. Those two results are the evidence you take into the review.

Now say the client wants the agent to close tickets, but only tickets belonging to a particular team. Hoon Jo tested on v1.5.0, updated for v1.6.0, and wrote on kuberneteslab.dev that CEL at the authorization stage cannot see tool arguments. A policy that sets conditions on arguments therefore blocks every call.

Per-argument controls have to go through guardrails, which for tools/call run before mcpAuthorization. Make this clear in the design session, before the client assumes one more line of policy will do.

**Key point:** A gateway blocks only what you have written rules to block.

## Deny rules fail silently

The MCP authorization documentation is explicit: a deny rule whose expression cannot be evaluated blocks nothing. Aonan Guan flagged the same trap on the AAIF blog, with the same advice: when an evaluation error must result in a block, use allow or require.

The difference lies in which direction each kind of rule fails. If an allow expression is broken or written too narrowly, requests match no allow rule and are denied, so the mistake surfaces as an agent missing permissions. A deny rule with a broken expression does the opposite: the agent quietly keeps its access and nobody notices.

An allow-list is not safe by default either. An allow rule written too broadly still grants access, so testing with tools/list and tools/call remains mandatory. On a client site, start with a narrow allow-list and widen it gradually.

## Which version to pin?

Advisory GHSA-mvgg-jvj2-4frq, rated High with a CVSS score of 8.1, describes a stateful MCP session being reused across a different route. It affects only stateful configurations with multiple MCP backends on separate routes, and was fixed in v1.4.0.

The version to pin now is v1.8.1, the first patch release of v1.8.0. It fixes a bug in the v1.8.0 Helm chart that stopped Flux from deploying the CRDs. The release blog post advises anyone who has not yet upgraded to skip 1.8.0 and install 1.8.1 directly.

Before upgrading, read the v1.8.0 release notes, which list the security fixes and behavior changes. One change to watch: Bedrock now uses the native endpoint by default and needs different IAM permissions. If the client calls models through Bedrock, check the IAM permissions first, then record the running version in the handover documentation.

## What to learn first

Start with CEL. Policies are written in it, and a broken expression is precisely what renders a deny rule useless.

Next, learn the MCP tools/list and tools/call flows and the processing order above, so you know at which stage each control runs.

Finally, learn how JWT authentication works, so you can work with the client's identity team.

On the career side, experience with tool authorization for agents belongs on a CV in specific terms. A line such as "Designed allow-list policies for agent access to MCP servers, verified with tools/list and tools/call" is far more convincing than "experienced in AI security".

Clients will not ask whether you installed a gateway. They will ask whether the write tools are blocked, and the answer should be an allow rule plus a -32602 error you have seen with your own eyes.

**Try this week:**

- Deploy agentgateway v1.8.1 in front of a test MCP server, write a policy with a single allow rule for a read tool, then call tools/list to confirm the other tools have disappeared
- Call a blocked tool directly and confirm the gateway returns JSON-RPC error -32602, as if the tool did not exist
- Deliberately write a deny rule whose expression cannot be evaluated, confirm it blocks nothing, then rewrite it using allow or require

## Sources

- [agentgateway/agentgateway (GitHub)](https://github.com/agentgateway/agentgateway)

- [Linux Foundation Welcomes Agentgateway Project to Accelerate AI Agent Adoption While Maintaining Security, Observability and Governance](https://www.linuxfoundation.org/press/linux-foundation-welcomes-agentgateway-project-to-accelerate-ai-agent-adoption-while-maintaining-security-observability-and-governance)

- [agentgateway Joins AAIF as an Open Gateway for Agentic AI Infrastructure](https://aaif.io/blog/agentgateway-joins-aaif-as-an-open-gateway-for-agentic-ai-infrastructure)

- [Tool access](https://agentgateway.dev/docs/kubernetes/latest/documentation/mcp/tool-access/)

- [MCP authorization](https://agentgateway.dev/docs/standalone/latest/documentation/configuration/security/authorization/mcp-authz/)

- [About guardrails (agentgateway Kubernetes docs)](https://agentgateway.dev/docs/kubernetes/latest/documentation/mcp/guardrails/about/)

- [Controlling MCP Tools with agentgateway on Kubernetes (Part 1)](https://blog.kubesimplify.com/controlling-mcp-tools-with-agentgateway-on-kubernetes)

- [What changes when you put a gateway in front of MCP?](https://kuberneteslab.dev/en/blog/agentgateway-mcp-enforcement/)

- [Stateful MCP sessions can cross routes and overwrite the authorization policy](https://github.com/agentgateway/agentgateway/security/advisories/GHSA-mvgg-jvj2-4frq)

- [Agentgateway v1.8.1: Native Bedrock, Decisions Everywhere, and MCP Skills](https://agentgateway.dev/blog/2026-12-01-agentgateway-v1.8.1/)

- [Release v1.8.0 · agentgateway/agentgateway](https://github.com/agentgateway/agentgateway/releases/tag/v1.8.0)

- [Enterprise MCP gateway security in practice with agentgateway](https://aaif.io/blog/enterprise-mcp-gateway-security-in-practice-with-agentgateway)
