Cloudflare MCP

Cloudflare MCP

Enables interaction with the complete Cloudflare API using a codemode pattern that allows agents to search the OpenAPI spec and execute API calls via JavaScript. This approach minimizes token usage by keeping the massive specification on the server and only returning relevant results.

Category
Visit Server

README

cloudflare-mcp

A smol MCP server for the complete Cloudflare API.

Deploy to Cloudflare Workers

Uses codemode to avoid dumping too much context to your agent.

The Problem

The Cloudflare OpenAPI spec is 2.3 million tokens in JSON format. Even compressed to TypeScript endpoint summaries, it's still ~50k tokens. Traditional MCP servers that expose every endpoint as a tool, or include the full spec in tool descriptions, leak this entire context to the main agent on every request.

This server solves the problem by using code execution in a codemode pattern - the spec lives on the server, and only the results of queries are returned to the agent.

Tools

Two tools where the agent writes code to search the spec and execute API calls. Akin to ACI.dev's MCP server but with added codemode.

Tool Description
search Write JavaScript to query spec.paths and find endpoints
execute Write JavaScript to call cloudflare.request() with the discovered endpoints

Token usage: Only search results and API responses are returned. The 6MB spec stays on the server.

Agent                         MCP Server
  │                               │
  ├──search({code: "..."})───────►│ Execute code against spec.json
  │◄──[matching endpoints]────────│
  │                               │
  ├──execute({code: "..."})──────►│ Execute code against Cloudflare API
  │◄──[API response]──────────────│

Setup

Create API Token

Create a Cloudflare API token with the permissions you need.

Add to Claude Code

export CLOUDFLARE_API_TOKEN="your-token-here"

claude mcp add --transport http cloudflare-api https://cloudflare-mcp.mattzcarey.workers.dev/mcp \
  --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"

Usage

// 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;
  }`,
});

// 2. Execute API call
execute({
  code: `async () => {
    const response = await cloudflare.request({
      method: "GET",
      path: \`/accounts/\${accountId}/workers/scripts\`
    });
    return response.result;
  }`,
  account_id: "your-account-id",
});

Token Comparison

Content Tokens
Full OpenAPI spec (JSON) ~2,352,000
Endpoint summary (TypeScript) ~43,000
Typical search result ~500
API response varies

Architecture

src/
├── index.ts      # MCP server entry point
├── server.ts     # Search + Execute tools
├── executor.ts   # Isolated worker code execution
├── truncate.ts   # Response truncation (10k token limit)
└── data/
    ├── types.generated.ts  # Generated endpoint types
    ├── spec.json           # OpenAPI spec for search
    └── products.ts         # Product list

Code execution uses Cloudflare's Worker Loader API to run generated code in isolated workers, following the codemode pattern.

Development

npm i
npm run deploy

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured