Skip to main content
Resource / Definition

What is MCP gateway bypass?

Local stdio servers, direct remote URLs, personal tokens, and unmanaged clients all route around the gateway. Which control layer closes each path, and which paths stay open.

Scroll for definition
Nolan Sullivan headshotBy Nolan Sullivan, Founding Growth Engineer
Published
Definition

MCP gateway bypass

MCP gateway bypass is any route by which an AI agent reaches a Model Context Protocol (MCP) server, or the API behind it, without passing through the organization’s MCP gateway. The gateway’s authentication, tool policy, and audit log apply only to requests it receives, so a call that takes another route carries none of them.


Agent securityDefinitionSpeakeasy

An MCP gateway is the policy point between agents and tools. It authenticates the caller, decides which tools they may use, and logs every call. All of that assumes the call arrives. Connecting an agent to a server takes one line of client configuration, and Cloudflare describes how it usually happens: an employee finds a server in a repository, a product guide, or a message from a colleague and adds it to their MCP client directly. Nothing about that connection passes the gateway, and the gateway has no record that it exists.

A gateway governs the traffic it receives, so preventing MCP gateway bypass means making every other route fail, and each route is closed by a different layer. Two of those layers live in the gateway. The others live on the network, on the device, and at the upstream provider, and one route stays open whatever you deploy: a device the organization doesn’t manage.

How is MCP gateway bypass different from shadow MCP?

Shadow MCP is a connection to an MCP server the organization has not approved. The OWASP MCP Top 10 catalogs it as MCP09:2025 Shadow MCP Servers. Gateway bypass is the wider set. It includes every shadow MCP connection, and it also includes connections to approved servers that skip the gateway placed in front of them.

Cloudflare makes the same split in its August 2026 post on MCP detection. It calls the second case portal bypass: an approved server sits behind an MCP Portal, and an employee connects to its upstream URL anyway, skipping the Portal’s access policy, tool catalog, data loss prevention, and audit trail. Cloudflare’s conclusion is that shadow MCP needs a network control, while portal bypass needs that network control plus an origin that can reject direct requests.

Approving a server therefore doesn’t close the bypass. An organization can put every approved server behind a gateway and still find calls to those servers going direct, because the old client configuration still works. Shadow AI is the broader category again, covering models, agents, skills, and MCP servers used outside the security perimeter. This article covers only the routes around the MCP gateway.

Why can’t the gateway stop bypass by itself?

The gateway is a server, so it can refuse a request it receives but has no view of a request sent somewhere else. Three of the four bypass paths never produce a request to the gateway.

The local stdio path is the clearest case. The MCP transports specification defines stdio as a transport where the client launches the server as a subprocess and exchanges messages over standard input and output. A server configured that way runs entirely on the developer’s machine. If it calls an API, that call is ordinary HTTPS from the laptop to the API, with nothing in it that says MCP.

Direct remote connections and personal tokens are the same problem one step out. The request goes from the client to a server or API the gateway doesn’t front, so the gateway’s policy never runs. Unmanaged clients are the exception, because they do connect to the gateway. That makes them the one path a gateway can close at the point of connection.

Deploying a gateway gives approved use a governed path. The other layers make the ungoverned paths fail, or at least show up somewhere a security team can see them.

How do agents route around an MCP gateway?

Each path looks different in practice and leaves different evidence:

Bypass pathWhat it looks likeWhat the gateway seesLayer that closes it
Local stdio serverA client config entry that runs a command such as npx some-mcp-serverNothingClient hooks and device-level discovery
Direct remote URLA server URL pasted into a client, either an unapproved server or the upstream address of an approved oneNothingNetwork egress policy, plus an origin that rejects direct requests
Personal tokenA personal access token or API key in a client config or environment variableNothingCredential custody at the gateway, plus provider token policy
Unmanaged clientAn unreviewed MCP client, or a client switched to a personal account that dropped the organization’s plugins and hooksAn authorization from an unfamiliar client, which it may admitClient admission at the gateway, plus device enrollment
Four bypass paths and the layer that closes eachThe governed path runs from an MCP client through the MCP gateway to MCP servers. Three bypass paths skip the gateway, so it sees nothing. 1, a local stdio server: the client runs the server as a local command on the device; closed by client hooks and device-level discovery. 2, a direct remote URL: the client calls an unapproved server, or an approved server's upstream address, directly; closed by network egress policy, plus an origin that rejects direct requests. 3, a personal token: the client uses a personal access token or API key to reach the service; closed by credential custody at the gateway, plus provider token policy. A fourth path reaches the gateway: 4, an unmanaged client sends an authorization from an unfamiliar client, which the gateway may admit; closed by client admission at the gateway, plus device enrollment.MCP GATEWAY BYPASSFour bypass paths and the layer that closes eachGOVERNED PATHMCP CLIENTMCP GATEWAYMCP SERVERSBYPASS PATHSLOCAL STDIO SERVERThe client runs the server as a localcommand on the device. The gateway seesnothing.CLOSED BYClient hooks and device-level discoveryDIRECT REMOTE URLThe client calls an unapproved server, oran approved server's upstream address,directly. The gateway sees nothing.CLOSED BYNetwork egress policy, plus an origin thatrejects direct requestsPERSONAL TOKENThe client uses a personal access token orAPI key to reach the service. The gatewaysees nothing.CLOSED BYCredential custody at the gateway, plusprovider token policyUNMANAGED CLIENTThe gateway receives an authorization froman unfamiliar client, which it may admit.CLOSED BYClient admission at the gateway, plusdevice enrollmentFour bypass paths and the layer that closes eachThe governed path runs from an MCP client through the MCP gateway to MCP servers. Three bypass paths skip the gateway, so it sees nothing. 1, a local stdio server: the client runs the server as a local command on the device; closed by client hooks and device-level discovery. 2, a direct remote URL: the client calls an unapproved server, or an approved server's upstream address, directly; closed by network egress policy, plus an origin that rejects direct requests. 3, a personal token: the client uses a personal access token or API key to reach the service; closed by credential custody at the gateway, plus provider token policy. A fourth path reaches the gateway: 4, an unmanaged client sends an authorization from an unfamiliar client, which the gateway may admit; closed by client admission at the gateway, plus device enrollment.MCP GATEWAY BYPASSFour bypass paths and thelayer that closes eachGOVERNED PATHMCP CLIENTMCP GATEWAYMCP SERVERSBYPASS PATHSLOCAL STDIO SERVERRUNS ON THE DEVICE, AROUND THE GATEWAYThe client runs the server as a localcommand on the device. The gateway seesnothing.CLOSED BYClient hooks and device-level discoveryDIRECT REMOTE URLCLIENT TO SERVERS, AROUND THE GATEWAYThe client calls an unapproved server, oran approved server's upstream address,directly. The gateway sees nothing.CLOSED BYNetwork egress policy, plus an origin thatrejects direct requestsPERSONAL TOKENCLIENT TO SERVERS, AROUND THE GATEWAYThe client uses a personal access token orAPI key to reach the service. The gatewaysees nothing.CLOSED BYCredential custody at the gateway, plusprovider token policyUNMANAGED CLIENTCLIENT TO GATEWAYThe gateway receives an authorization froman unfamiliar client, which it may admit.CLOSED BYClient admission at the gateway, plusdevice enrollment

The personal-token path outlives the others. A user who connected a server directly last quarter may still hold the token. Removing the server from their client config doesn’t revoke it, and the shadow MCP guide makes the same point about closing findings: a config entry removed without addressing the credential leaves the connection easy to restore.

The unmanaged-client path has a quieter version that falls under configuration drift, which Speakeasy’s device agent documentation calls the most common bypass on developer laptops. A user switches their AI agent to a personal account and silently loses the organization’s plugins, telemetry, and guardrails. The client is the same one the organization approved, but its configuration is not.

How do you prevent MCP gateway bypass?

Five control layers cover the four paths: network egress, the origin server, credential custody, client admission, and device-level discovery. None covers every path, and each has a documented blind spot.

Network egress: block direct MCP traffic on managed paths

A secure web gateway sees HTTP traffic after it leaves the client, which makes it the widest view of remote MCP connections from managed devices. Cloudflare Gateway now classifies TLS-inspected requests as MCP when they carry the MCP-Protocol-Version header, and exposes that as a beta Is MCP selector in HTTP policies. Combined with a Traffic Source selector that marks requests proxied by an MCP Portal, one rule blocks MCP traffic that didn’t come through the Portal:

experimental.is_mcp == true and not traffic.onramp in ("mcp_portal")
Action: Block

Docker documents the same two-layer pattern for its sandboxes. Its MCP access policies govern only server registration and requests handled by Docker’s MCP gateway. A direct connection from inside a sandbox to a remote MCP server is outbound sandbox traffic, so Docker’s guidance is to block the server in MCP policy and block its network destination in network policy.

Egress control has three limits, and Cloudflare states all of them. Detection requires TLS decryption. Local stdio servers, off-network connections, and traffic exempted from inspection stay outside the view. And legacy MCP clients send their first initialize request without the protocol header, so the first request to a previously unknown endpoint may not be classified. An egress rule is therefore a control for managed devices on managed networks, and the rest of the stack has to assume it can be absent.

The origin: make direct requests fail at the server

An egress rule stops the request on the way out. A locked-down origin stops it on arrival, which also covers devices the egress proxy never sees. Cloudflare’s MCP server portal documentation is direct about why this layer is needed: users blocked by a portal’s Access policy can still connect to the server, and bypass that policy, by using its direct URL, unless Access is configured as the server’s OAuth provider.

For MCP servers the organization runs, the strongest origin control is to give the server no address anyone else can reach. An MCP tunnel lets the gateway reach a server inside a private network over an outbound-only connection, with no inbound port open. The server can also check that a request came through the gateway. Speakeasy’s private tunneled servers receive a short-lived signed JWT in an X-Speakeasy-Identity header on each forwarded request, which the server can verify and reject when absent.

Private networking on the client side is a separate decision with its own costs. A private MCP gateway takes the gateway’s own listener off the public internet, so only devices on the private network can reach it. That narrows who can reach the gateway, and it means hosted agents such as remote connectors in ChatGPT or Claude can’t reach it at all. On Speakeasy, private network access runs over a Tailscale tailnet, requires an Enterprise organization, and is set per server as public only, public and private, or private only. The private MCP gateway guide covers when that trade is worth making. Speakeasy runs as a managed gateway by default, and self-hosting is available for Enterprise customers (talk to our team).

For third-party SaaS servers, the origin belongs to the vendor, and the organization’s options depend on what the vendor exposes.

Credential custody: keep the token in the gateway

A direct connection to a SaaS MCP server works only if the user can authenticate to it. If the upstream credential lives in the gateway and never reaches the user, a direct connection has nothing to authenticate with. This is the cheapest layer to deploy, because it needs no software on any device.

The MCP security best practices already forbid token passthrough, where a server accepts a client’s token and forwards it upstream. Gateways implement the custody side in different ways. Kong’s AI MCP OAuth2 plugin, part of AI Gateway Enterprise, validates that each token was issued for the target MCP server and doesn’t forward client access tokens upstream by default. IBM’s ContextForge stores per-user OAuth tokens encrypted, keyed by gateway and user, and keeps header passthrough off unless an operator enables it.

Speakeasy’s gateway holds upstream credentials one of two ways: a token per user, obtained through the upstream’s OAuth flow, encrypted at rest and refreshed by the platform, or one shared credential per remote server, either a static key or an OAuth client credentials token. With Enterprise Managed Auth through Okta, the platform exchanges each person’s Okta identity for the downstream token, so there’s no per-service connect step and removing a person in Okta stops new access to every server that uses it.

Custody stops new tokens from reaching users. It does nothing about tokens users already hold or can still create, and that half belongs to the provider. GitHub, for example, lets an organization restrict access by personal access tokens and enable OAuth app access restrictions, so members can’t authorize unapproved OAuth apps against organization resources. A provider without equivalent controls leaves the personal-token path open, and the remaining options are rotation and detection.

Client admission: refuse unreviewed clients at the gateway

Client admission is the one bypass control that runs inside the gateway at connection time. The OAuth handshake is where the gateway learns which client is connecting, and with Client ID Metadata Documents (CIMD) the client’s ID is an HTTPS URL on its vendor’s domain. That URL is the same on every install, so the gateway can allowlist it, block it, and search for it.

Speakeasy exposes this as a per-server Client access setting with three options. Verified clients admits a catalog of client documents Speakeasy has checked plus any URLs the organization adds, Any client admits any valid document, and Off admits no CIMD client. Separately, Shadow AI records a decision per AI tool that enrolled devices report, and a tool marked Blocked is refused when it authenticates, on every MCP server in the organization.

Admission has real gaps, and the documentation states each one. Dynamic Client Registration (DCR) stays open to every client whatever the Client access setting says, and a Shadow AI block takes effect only for callers that present a CIMD client ID. CIMD verifies that a document belongs to its vendor, and doesn’t prove that the program on a user’s machine is genuine. Admission also gates new authorizations, not existing sessions, so cutting off a client that is already connected takes a revocation. And admission only covers clients that connect to the gateway, which none of the other three bypass paths do.

Device-level discovery: see what runs on the laptop

The device is the only place that can see a local stdio server. Cloudflare’s post lays out the trade clearly: a hook inside the MCP client runs before the request is serialized, can deny a server not on an allowlist, and covers stdio servers that never produce network traffic, but the controls have to be reproduced in every client employees use.

Two kinds of device software do this work. Hooks in the coding agent see each tool call, its server, and its arguments, which is how agent hooks catch calls to servers the gateway doesn’t host. A device agent installed through MDM inventories the AI tools on a machine and keeps the organization’s client configuration in place. Speakeasy’s device agent reapplies that configuration every 60 seconds, which is what closes the personal-account case above. It is in beta and enabled per organization. Docker takes a sandbox-side approach to the same problem: its MCP access policies can refuse registration of host-run stdio servers outright.

Discovery depends on enrollment, and Speakeasy’s Shadow AI documentation puts it in one line: a tool on an unenrolled machine appears nowhere. Shadow MCP detection has the same property, since sessions from an uninstrumented client produce no traffic to scan.

Which bypass paths can’t be closed?

Four gaps stay at least partly open whatever an organization deploys.

  • Unmanaged devices. A personal laptop with no device agent, no hooks, and no managed proxy is invisible to three of the four layers. On that device, the organization’s only levers are credentials it holds centrally and restrictions it sets at each provider.
  • Providers without token controls. If an upstream service lets any user mint an API key and offers admins no way to restrict it, a user can always reach that service directly. Custody at the gateway removes the convenient token but not the ability to create one.
  • Off-network traffic. An egress rule covers traffic that passes the proxy. A device on a home network without the proxy client running sends direct MCP traffic the rule never evaluates.
  • Tools without an MCP client. Some agents call APIs directly and never speak MCP. Speakeasy’s Shadow AI page notes that a decision about such a tool is recorded and never enforced, because there’s no MCP authentication for the gateway to refuse.

The strongest argument against investing here follows from this list. A determined person with a shell and an API key can always reach the API, and the shadow MCP guide warns that enforcing a policy before a workable alternative exists can push teams toward the bypass it’s meant to stop. Both points are correct, and they argue for a narrower goal: on managed devices with organization credentials, the direct path fails, and everywhere else, a direct connection shows up in an inventory with an owner.

In what order should you roll out bypass controls?

Ranked from least to most effort, with the path each step closes:

  1. Move upstream credentials into the gateway, and restrict personal tokens at providers that allow it. No endpoint software, and it closes the personal-token path for every provider whose credentials move. This is realistic for every organization.
  2. Turn on client admission. Set servers to admit verified clients, and record approve or block decisions for the AI tools you already know about. It closes part of the unmanaged-client path, for clients that publish a CIMD document.
  3. Run discovery in flag mode. Deploy hooks and the device agent, and let a flag-only policy build the inventory of stdio and direct remote servers before anything is blocked. Speakeasy’s shadow MCP allow and block lists guide describes this sequence, including the choice between a block-all and an allow-all posture.
  4. Lock down the origins you own. Move internal MCP servers behind tunnels, and have them verify the gateway’s signed identity header. Add private network access for the gateway endpoint if your clients all run on enrolled devices.
  5. Block direct MCP traffic at the egress proxy. This needs TLS inspection and a managed proxy on every device, which many organizations already run and many don’t. If you don’t have one, this step is a network rollout before it is a policy.

Each step makes the next one less disruptive. Credentials in the gateway mean a blocked direct connection has a governed alternative waiting, and an inventory built in flag mode means the first blocking policy is based on observed traffic instead of guesses.

A note on Speakeasy

Speakeasy runs a managed MCP gateway as part of the AI Control Plane. Of the layers above, it covers credential custody, client admission, and origin lockdown for internal servers through tunnels, and it pairs those with device-side discovery. Shadow AI is generally available under Guardrails for every organization. It lists the harnesses, assistants, and local models that enrolled devices report, and lets an admin approve or block each tool at the gateway. A blocked tool is refused when it authenticates, on every MCP server in the organization.

The limits are the ones described above. Enforcement needs the tool to publish a client ID metadata document. A tool with no MCP client gets a recorded decision and no enforcement. And a device that isn’t enrolled doesn’t appear. Blocking direct MCP traffic on the network is a job for a secure web gateway, such as Cloudflare’s, alongside the gateway.

If you’re mapping which of these paths are open in your organization today, we’d be interested to hear how you’re approaching it. Talk to us.

Frequently asked questions

What is MCP gateway bypass?

MCP gateway bypass is any route by which an AI agent reaches a Model Context Protocol (MCP) server, or the API behind it, without passing through the organization's MCP gateway. The gateway's authentication, tool policy, and audit log apply only to requests it receives, so a call that takes another route carries none of them.

How is MCP gateway bypass different from shadow MCP?

Shadow MCP is a connection to an MCP server the organization has not approved. MCP gateway bypass is the broader set. It includes shadow MCP, and it also includes direct connections to approved servers that skip the gateway in front of them. Cloudflare draws the same line between shadow MCP and what it calls portal bypass, and notes that the two need different controls.

What are the main ways agents bypass an MCP gateway?

There are four common paths. An agent can launch a local stdio MCP server as a subprocess, connect directly to a remote MCP server URL, call the upstream service with a personal token the user holds, or connect through an MCP client the organization never reviewed or configured. Each path is closed by a different control layer.

Can an MCP gateway prevent bypass on its own?

No. An MCP gateway governs the requests that reach it, so it cannot block a local stdio server or a direct connection to a remote server. The gateway can close two paths itself: it can hold upstream credentials so users have no token to take elsewhere, and it can refuse unreviewed MCP clients at authentication. Network egress controls and device-level discovery close the rest.

How do you stop local stdio MCP servers from bypassing the gateway?

A local stdio server runs as a subprocess of the MCP client and sends no MCP traffic over the network, so a gateway or a network proxy never sees it. The control point is the client itself: hooks inside the coding agent can see and deny calls to servers that the gateway does not host, and a device agent can report and correct client configuration. Both require the device to be enrolled.

How do you block direct connections to remote MCP servers?

Use a network egress control on managed devices that can recognize MCP traffic and block requests that did not come through the approved gateway. Cloudflare Gateway, for example, offers an Is MCP selector and a Traffic Source selector for this. The control only applies to TLS-inspected traffic on managed network paths, so pair it with an origin that rejects requests that did not arrive through the gateway.

How do personal access tokens enable MCP gateway bypass?

A user who holds a working token for an upstream service can use it from any MCP client, script, or server, and none of those calls touch the gateway. Moving credential custody to the gateway removes that token from the user. Restricting personal tokens at the provider, where the provider supports it, stops tokens created outside the gateway from reaching organization data.

What is MCP client admission?

MCP client admission is the gateway's decision about which MCP clients may start an OAuth authorization. With Client ID Metadata Documents (CIMD), a client identifies itself by an HTTPS URL on its vendor's domain, which gives the gateway a stable identity to allowlist or block. Admission controls which clients reach the gateway; it does not see clients that never connect to the gateway.

Does network egress filtering stop MCP gateway bypass?

It stops part of it. A secure web gateway with TLS inspection can identify remote MCP traffic from managed devices and block direct connections. It cannot see local stdio servers, traffic from devices that are off the managed network, or traffic exempt from inspection, and some legacy MCP clients send their first request without the protocol header that detection relies on.

Can you prevent MCP gateway bypass on unmanaged devices?

Not reliably. Device-level discovery, client hooks, and egress filtering all depend on the device being enrolled or its traffic passing a managed proxy. On an unmanaged device, the remaining controls are the ones the organization holds centrally: keeping upstream credentials in the gateway and restricting personal tokens and unapproved OAuth apps at each provider that allows it.

What should you roll out first to prevent MCP gateway bypass?

Start with credential custody, because it needs no endpoint software and closes the personal-token path for every provider whose credentials move into the gateway. Then turn on client admission, then run discovery in a flag-only mode to build an inventory, and add egress blocking last, since it needs TLS inspection and a managed proxy on every device.

Do agents bypass the gateway on purpose?

Cloudflare describes the typical case: an employee finds a server in a repository, a product guide, or a colleague's message and adds it to their client without checking whether it is approved. Controls that make the governed path the default and make the direct path fail on managed devices handle that case. A determined person on an unmanaged device is a different problem and needs provider-side controls.

Does a private MCP gateway prevent bypass?

A private MCP gateway keeps the gateway's own listener off the public internet, which narrows who can reach the gateway. It does not stop an agent from reaching other servers directly. Private networking helps prevent bypass at the origin, when internal MCP servers are reachable only through the gateway, for example over an outbound-only tunnel, so a direct request has nowhere to go. On Speakeasy, private network access for the gateway endpoint runs over a Tailscale tailnet and requires an Enterprise organization.

Does Speakeasy prevent MCP gateway bypass?

Speakeasy is a managed MCP gateway. Its Shadow AI feature, generally available under Guardrails for every organization, lets admins approve or block each AI tool that enrolled devices report, and blocked tools are refused when they authenticate on every MCP server in the organization. Enforcement needs the tool to publish a client ID metadata document, and devices that are not enrolled are not visible.

AI everywhere.

Control here.