Stop shadow MCP servers by making a gateway the only path between your agents and MCP servers: put agentgateway in front of the servers you approved, authorize every tool call, and default-deny egress so nothing reaches an unregistered server directly. A shadow server can still run, but your agents can’t reach company systems through it, and the MCP calls that do go out show up in the gateway’s metrics. This page is the stop. What shadow MCP is is the definition, and why shadow MCP servers are hard to track is the hub.
I work at Solo.io, which makes agentgateway.
Why doesn’t finding them stop them?
A scan is an inventory with a timestamp on it. It is stale the next time someone runs docker compose up, clones a repo that ships a .mcp.json, or signs into a personal connector. Finding shadow MCP servers in your environment is still the first control, because you cannot authorize a path you have not seen. It is not the control that keeps a new server from being used.
The durable control has to sit where agents cannot route around it. If the agent can reach an MCP server on its own, the gateway is a suggestion.
How do you put MCP on one path through agentgateway?
Use agentgateway in standalone mode or on Kubernetes. Federate only the servers you registered. Authorize each tool call. An unregistered server can still be running. The agent cannot reach it if every MCP hop goes through that gateway. Pin tool definitions so a registered server cannot quietly change what those tools do after you approved them.
How does standalone authorization work?
Standalone MCP authorization attaches CEL mcpAuthorization rules to a route or to an MCP backend. The policy runs against MCP method invocations such as tools/list and tools/call. If a tool is not allowed, the gateway filters it from the list response, so the client never sees it. This is documented behavior in the current standalone docs. I have not run a fresh harness for this page that proves an allowed call passes, a disallowed call is refused, and tools/list is filtered, so I am leaving that at Documented, not Tested.
A short rules example, copied from those docs:
mcp:
port: 3000
policies:
mcpAuthorization:
rules:
# Allow anyone to call 'echo'
- 'mcp.tool.name == "echo"'
# Only the test-user can call 'add'
- 'jwt.sub == "test-user" && mcp.tool.name == "add"'
targets:
- name: everything
stdio:
cmd: npx
args: ["@modelcontextprotocol/server-everything"]
You can also attach the same policy in routing-based config. The docs are the source for both forms.
How does Kubernetes tool access work?
On Kubernetes, an AgentgatewayPolicy validates the JWT and applies CEL rules for tool access. Tool access docs state that all tools are allowed by default until you attach a tool-access policy, so attach one. The following shape comes from those docs. It allows only one named tool, and it is not useful until you point targetRefs at your own backend:
apiVersion: agentgateway.dev/v1alpha1
kind: AgentgatewayPolicy
metadata:
name: mcp-tool-access
spec:
targetRefs:
- group: agentgateway.dev
kind: AgentgatewayBackend
name: approved-mcp-backend
backend:
mcp:
authorization:
action: Allow
policy:
matchExpressions:
- 'mcp.tool.name == "get_me"'
Support for the 2026-07-28 MCP spec revision landed in agentgateway v1.4.
How should you federate only what you approved?
On Kubernetes, virtual MCP can put several servers behind one endpoint by label selector, over Streamable HTTP only. SSE still needs a static backend. That is documented in the Kubernetes virtual MCP docs. The live multi-tenant MCP federation write-up uses Solo Enterprise, so treat that post as a Solo Enterprise result, not as an open-source default.
How do you know the policy actually denies?
Write a call you expect to fail, and run it. CEL policies can fail open silently (tested on Solo Enterprise): both forms can report healthy, and only a call you expected to refuse tells you which one you wrote. A denied call is the only proof.
How do you make egress enforce the gateway?
A gateway nobody has to use is a suggestion. Default-deny egress from agent namespaces with a Kubernetes NetworkPolicy, and allow only the gateway. That is Kubernetes behavior, not an agentgateway feature. On standalone hosts and VMs, use the same rule at the host or network firewall: agents can reach MCP servers only through the gateway you configured.
Decide on the address you resolved, not the hostname the workload typed. That is egress decided at CONNECT time. That demo used a Python CONNECT stand-in to show the pattern, not agentgateway.
Laptops are the gap. A developer on a machine with unrestricted egress can still reach a personal remote server, and no cluster NetworkPolicy will notice. See which MCP servers run on employee machines is that sweep.
Why can’t you allowlist MCP servers by name?
A name is a label. Anyone who can edit a config file can reuse a name you already approved.
Claude Code’s managed MCP controls key allowedMcpServers and deniedMcpServers on serverUrl or serverCommand, and say a serverName entry, in either list, is not a security control. Cursor’s enterprise MCP Allowlist keys on a command pattern for stdio servers and a URL pattern for remote servers. Those are client facts with sources, not a recommendation of one client over the other. The paths those clients write are on every MCP client’s config path.
How do you make this detectable, not just blocked?
In standalone mode, agentgateway’s mcp_requests_total metric is labeled by server, method, and tool, as documented in the standalone MCP observability docs. Alert on a server label you did not register. I am not claiming the same metric labels on Kubernetes here, because I did not re-confirm that on the Kubernetes metrics page for this draft.
Denied egress shows up in whatever logs your NetworkPolicy or firewall already writes. If those logs are off, the deny is silent.
The scanner gate in CI is the other detection point. python3 scanner/scan.py mcp.internal:8080 --fail-on-open exits 1 when any endpoint answers server/discover or initialize without credentials. That form is tested in the lab on the hub. In that lab, four open servers out of seven answered with no credentials at all. That is a demo number from the published scanner write-up, not a measurement of your network.
Why keep a registry of record?
The official MCP Registry lists public servers. It will not inventory your internal ones. Run a private MCP registry that implements the official API, and record owner, domain, and what each server can reach. The useful move is to register servers by business domain, not by whoever stood the process up. The registry is what the laptop sweep, the network scan, and the gateway metrics reconcile against. How to run an MCP registry of record is the fields and the loop that keeps the gateway, the allowlists, and the scans on the same list.
Why bind servers to identities, not labels?
A name, a serverInfo block, or a registry ID is a claim. Bind the gateway route to a workload identity and to audience-bound tokens, so “is this our server” is a verified credential. SPIFFE workload identity is the attested half of that.
Until that binding exists, the scanner and the metrics tell you the size of the gap. They do not close it.
What does “undetected” actually mean?
The search query that this page is built for asks how to stop shadow MCP servers from connecting to company systems undetected. The important word is the last one. A deny that never shows up in a log is a deny you cannot prove, and a server that never hits the gateway is a server you will not see in mcp_requests_total.
Three signals cover the common cases:
- A registered tool call appears in the gateway metrics, labeled by server and tool. That is expected traffic. You watch it for servers you did not register.
- A pod or host tries to reach an MCP URL that is not the gateway, and the NetworkPolicy or firewall denies it. That is the around-the-gateway case. You only see it if those deny logs are on.
- A laptop config sweep or a CI
--fail-on-opengate finds a server that never crossed your network. That is the case the gateway will not see on its own.
If you only deploy the gateway, and you do not log the denies or sweep the laptops, a personal remote server can still be in use and you will have no row that says so.
What order should you put this in?
- Stand up a registry of the servers you approve, even if it starts as a short list with an owner for each row.
- Put agentgateway in front of those servers, with CEL rules that do not allow every tool by default.
- Prove a denied call fails, including after a config change.
- Default-deny egress so agents cannot skip the gateway.
- Alert on unexpected server labels in the standalone MCP metrics, and on denied egress.
- Sweep laptop config files and vendor admin consoles for the servers that never enter the cluster.
Skip a step and the others leak. A registry without a gateway is a list. A gateway without egress is a suggestion. Egress without detection is a silent block. Detection without a laptop sweep misses the servers that never used your network.
If the gateway is already deployed and unauthorized shadow MCP traffic is still getting through, why your MCP gateway is not blocking shadow servers is the diagnosis of that setup. This page stays on building the controls.
What does this not cover?
Vendor-hosted connectors connect from the vendor’s cloud and never cross your network. On Claude Team and Enterprise, owners control which custom connectors exist. On individual plans you often cannot see them. A cluster NetworkPolicy will not notice a connector that never enters the cluster. Say that plainly to anyone who thinks a gateway and a firewall are enough.
The same limit applies to a developer laptop with a personal OAuth grant. The stop described here holds where you control the path. It does not hold where the call starts in a vendor’s cloud or on an unmanaged machine.