home / mcp / cloudflare mcp server
Provides access to Cloudflare API endpoints via codemode MCP server with a dedicated HTTP endpoint.
Configuration
View docs{
"mcpServers": {
"mattzcarey-cloudflare-mcp": {
"url": "https://cloudflare-mcp.mattzcarey.workers.dev/mcp",
"headers": {
"CLOUDFLARE_API_TOKEN": "YOUR_TOKEN"
}
}
}
}You have a compact MCP server that lets you query the complete Cloudflare API using codemode. It keeps the full Cloudflare OpenAPI spec on the server and only returns the results you need, helping you avoid exposing massive context to the agent while still giving you flexible access to Cloudflare endpoints.
Use this MCP server with your MCP client to locate endpoints in the Cloudflare API and then perform API calls. You authenticate with a Cloudflare API token, connect to the MCP URL, and leverage the two built-in tools to search for endpoints and execute API requests.
Steps you will follow - Add the MCP server to your client using your token - Search for relevant Cloudflare endpoints - Execute API calls against the discovered endpoints and view responses
Code-assisted workflow you can run in your client environment includes two key blocks. First, search for endpoints. Then, execute a chosen API call against Cloudflare.
// 1. Search for endpoints
search({
code: `async () => {
const results = [];
for (const [path, methods] of Object.entries(spec.paths)) {
for (const [method, op] of Object.entries(methods)) {
if (op.tags?.some(t => t.toLowerCase() === 'workers')) {
results.push({ method: method.toUpperCase(), path, summary: op.summary });
}
}
}
return results;
}`,
});Prerequisites: you need Node.js and npm installed on your system.
Install dependencies and deploy the MCP server codebase locally if you want to run a local instance, or use the provided remote server for Cloudflare API access.
Install dependencies and deploy locally (example flow seen in the source):
npm i
npm run deployConfiguration and tokens - Create a Cloudflare API token with the permissions you need. - Set the token in your environment when configuring your MCP client.
Connection details - HTTP MCP URL you will connect to is: https://cloudflare-mcp.mattzcarey.workers.dev/mcp - You will typically add an Authorization header with your token when configuring the client.
Security and usage tips - The server keeps the Cloudflare OpenAPI spec on the server and only returns results you request, reducing context leakage. - Protect your API token and only grant the minimal permissions needed for your tasks.
Write JavaScript code to query spec.paths and identify endpoints, returning a list of matching operations.
Write JavaScript code to call cloudflare.request() with the discovered endpoints and return the API response.