cloudflare

How Cloudflare detects MCP traffic and helps secure it (opens in new tab)

AI agents change the risk model for resource permissions because they make nondeterministic decisions and can repeat actions at machine speed. A mistaken judgment that a human might quickly catch can become thousands of harmful operations before anyone notices. Cloudflare’s new Cloudflare One capabilities aim to detect MCP traffic, identify its users and servers, and enforce approved routes through MCP Server Portals.

Why AI Agents Require New Controls

  • Traditional permissions assumed users would apply judgment and act at a limited human pace.
  • AI agents can invoke tools repeatedly and indefinitely.
  • A single incorrect decision can rapidly propagate across databases, SaaS systems, or infrastructure.
  • MCP makes it easy to connect clients such as Claude Code, Codex, Cursor, OpenCode, and VS Code to approved or unapproved tools.
  • Direct MCP traffic can resemble ordinary HTTPS because MCP does not require a standard hostname or /mcp path.

Anatomy of an MCP Tool Call

An MCP request appears differently at three points:

  • Client: The agent decides to invoke a tool and supplies arguments.
  • Network: The request is transmitted as an HTTP transaction containing JSON-RPC.
  • Server: The server authenticates, validates, and dispatches the request to a tool handler.

Useful protocol signals include:

  • Destination hostname and path
  • Authorization credentials
  • MCP-Protocol-Version
  • Mcp-Method
  • Mcp-Name
  • JSON-RPC request id
  • Tool arguments in params

The tool name indicates the intended operation, while the arguments may contain sensitive data such as source code, customer information, search queries, or infrastructure-changing instructions. Responses can also contain sensitive results, making both request prevention and response inspection valuable.

Controls Inside the MCP Client

Client hooks can intervene after the model selects a tool but before the request is serialized.

  • Enforce server allowlists
  • Require confirmation for sensitive operations
  • Remove sensitive data from arguments
  • Support local stdio MCP servers that never generate network traffic

The main limitation is operational: organizations must implement controls across every client employees use. Client telemetry also cannot provide a complete inventory unless the organization manages all relevant clients and devices.

Controls at the Network Boundary

A secure web gateway with TLS decryption can inspect remote MCP traffic independently of the client.

  • Associate requests with users and devices
  • Inspect destinations and MCP protocol headers
  • Detect direct connections outside approved MCP Portals
  • Block unauthorized traffic before it reaches the server
  • Use data loss prevention scanning to inspect JSON-RPC methods and arguments

Network controls provide the broadest visibility into remote MCP usage, but they cannot see local stdio calls or traffic that bypasses managed network paths.

Controls at the MCP Server

The server has the deepest execution context because it knows the authenticated caller, parsed message, resolved tool, and validated arguments.

Server-side middleware can:

  • Authorize users for specific tools
  • Apply rate limits
  • Inspect arguments
  • Log outcomes
  • Block requests before tool execution

Cloudflare’s WriteGuard applies this approach to internal MCP servers by assigning tools risk tiers and enabled or disabled states. It can allow reads, attach attribution and audit events to approved writes, or block critical actions before their handlers run. Because enforcement occurs on the server, users cannot bypass it by changing clients or disabling local hooks.

Layered MCP Security

Each control point has a different strength:

  • Client controls: Earliest intervention and support for local MCP, but limited coverage.
  • Network controls: Broadest visibility into remote traffic and unmanaged MCP connections.
  • Server controls: Richest context and final prevention point before execution.

A layered strategy can protect sensitive data before it leaves a device, identify shadow MCP usage, require trusted Portal-based access, and prevent unauthorized tools from executing.