You can build and deploy Model Context Protocol (MCP) ↗︎ servers on Cloudflare.
Model Context Protocol (MCP) ↗︎ is an open standard that connects AI systems with external applications. Think of MCP like a USB-C port for AI applications. Just as USB-C provides a standardized way to connect your devices to various accessories, MCP provides a standardized way to connect AI agents to different services.
- Agents: AI assistants (like Claude ↗︎ or Cursor ↗︎), AI agents, or applications that need to access external capabilities.
- MCP Clients: Clients embedded within agents that connect to MCP servers and invoke tools. Each MCP client instance has a single connection to an MCP server.
- MCP Servers: Applications that expose tools, prompts ↗︎, and resources ↗︎ that MCP clients can use.
The MCP standard supports two modes of operation:
- Remote MCP connections: MCP clients connect to MCP servers over the Internet, establishing a connection using Streamable HTTP, and authorizing the MCP client access to resources on the user's account using OAuth.
- Local MCP connections: MCP clients connect to MCP servers on the same machine, using stdio ↗︎ as a local transport method.
- Keep tool definitions out of the context window: MCP clients used to send every tool definition straight to the model, so a server with many tools filled the agent's context window. Newer clients use Code Mode instead: the model writes code that calls your tools and loads only the definitions it needs. You can apply the same pattern on the server, exposing a large API through a small search-and-execute interface. Refer to Code Mode for MCP servers ↗︎ and Build a Code Mode MCP server.
- Use granular authorization: Protect your server with OAuth, and give each operation its own scopes. When a token lacks a scope, return an
insufficientScope()challenge so the client asks the user to approve it (step-up authorization) instead of requesting every scope up front. Refer to Authorization. - Declare accurate input and output schemas: Strict MCP clients validate tool calls against
inputSchemaand tool results againstoutputSchema, and reject tools whose results do not match. Define both schemas for every tool, and returnstructuredContentthat matchesoutputSchema. Refer to Tools.
Go to the Getting Started guide to learn how to build and deploy your first remote MCP server to Cloudflare.