cloudflare/mcp
MCP server for the Cloudflare API
What it solves
This project provides a token-efficient way for AI agents to interact with the vast Cloudflare API, which contains over 2,500 endpoints. Traditional Model Context Protocol (MCP) servers typically expose every endpoint as a separate tool, which would consume millions of tokens of context window space. This server reduces that overhead from millions of tokens to approximately 1,000 tokens.
How it works
Instead of listing every API endpoint as a tool, the server uses a "Code Mode" pattern. The AI agent does not receive the full API specification; instead, it uses three primary tools:
docs: Searches Cloudflare's developer documentation.search: Allows the agent to write JavaScript code to query the API specification on the server side to find the correct endpoints.execute: Allows the agent to write JavaScript to call the discovered Cloudflare API endpoints.
The server executes this code in isolated Workers using the Dynamic Worker Loader API.
Who it’s for
Developers and AI agent users who want to automate Cloudflare services (such as Workers, KV, R2, D1, Pages, and DNS) using an LLM-powered agent without exhausting the agent's context window.
Highlights
- Extreme Token Efficiency: Reduces context usage from ~2 million tokens (raw OpenAPI spec) to ~1k tokens.
Code ModeSupport: Shifts the logic of API discovery and execution to server-side JavaScript execution.- Broad API Coverage: Supports nearly all Cloudflare products, including GraphQL Analytics API.
- Flexible Authentication: Supports both OAuth and API tokens.
- Optional Native Mode: Can be disabled via query parameter to return to traditional MCP tool registration if required.
Related
- Dispatch
- Project
- Project
- Project
- Project