This article discusses Cloudflare's approach to identifying and securing Model Context Protocol (MCP) traffic generated by AI agents. It highlights the architectural challenge of controlling AI agent access to tools and data, focusing on detection mechanisms at the client, network, and server layers to prevent unauthorized actions and data exfiltration.
Read original on Cloudflare BlogThe rise of AI agents introduces new security and system design challenges, as these agents operate at machine speed with non-deterministic decision-making. Traditional human-centric access controls are insufficient. The Model Context Protocol (MCP) facilitates AI agent interaction with various tools and APIs, requiring robust mechanisms to monitor and control these interactions.
An MCP tool call evolves through three main stages: within the client, on the network, and at the server. Each stage exposes different signals and presents unique opportunities for security controls. On the network, an MCP call is typically an HTTP transaction carrying a JSON-RPC message. Key signals include the destination hostname, authorization headers, and custom MCP headers (e.g., `MCP-Protocol-Version`, `Mcp-Method`, `Mcp-Name`) that identify the protocol version, operation, and tool being invoked.
Holistic Security Strategy
A comprehensive security strategy for AI agent interactions requires a combination of these control points. Client-side controls can stop sensitive data from leaving the device, network-level controls detect unmanaged traffic, and server-side controls enforce authorization and prevent unauthorized operations.
Initially, MCP traffic detection relied on basic URL patterns. However, modern MCP specifications, particularly 2026-07-28, mandate the inclusion of `MCP-Protocol-Version`, `Mcp-Method`, and `Mcp-Name` headers on HTTP requests. These explicit protocol signals enable network infrastructure like Cloudflare Gateway to reliably classify MCP traffic, distinguish between approved and unapproved connections (shadow MCP), and enforce policies like Portal-only access to trusted MCP servers.