Cloudflare MCP Servers

repository·main·Indexed 26 days ago

https://github.com/cloudflare/mcp-server-cloudflare

A collection of Model Context Protocol (MCP) servers enabling LLMs to interact with Cloudflare services using natural language. Includes servers for Audit Logs, Cloudflare Blog, Cloudflare One CASB, Developer Documentation, GraphQL API, and a unified Cloudflare API server (superseding legacy AutoRAG and Radar servers) to manage Workers, DNS, Observability, and more.

Tokens
37.1K
Snippets
41
Records
262
Agent score
87%

What's inside @cloudflare/mcp-server-cloudflare

  1. Overview of Cloudflare MCP Servers

    main

    Cloudflare provides several Model Context Protocol (MCP) servers that allow MCP clients (such as Cursor or Claude) to interact with Cloudflare services using natural language. These servers enable clients to read configurations, process information, and perform actions across various Cloudflare products like application development, security, and performance.

    All servers expose a stateless Streamable HTTP handler at /mcp or /sse. Modern requests share a request-scoped implementation without an MCP protocol session. Security and application state (OAuth, credentials, account selection, etc.) are managed at the application level.

  2. Overview of Cloudflare Blog MCP Server

    main
    The Cloudflare Blog MCP Server is a Model Context Protocol (MCP) server that allows clients to search and read content from the official Cloudflare Blog. It provides read-only access to public blog content and does not require authentication. The server uses a stateless SDK v2 handler via /mcp and /sse endpoints, supporting modern MCP requests without requiring a protocol session.
  3. Overview of Cloudflare One CASB MCP Server

    main
    The Cloudflare One CASB MCP Server is a Model Context Protocol (MCP) server that provides tools for inspecting Cloudflare One CASB integrations, assets, and asset categories. It supports authentication via Cloudflare OAuth and API tokens. The server is stateless and uses a request-scoped auth/account context for every request via /mcp and /sse URLs.
  4. Implement AI model evaluations with describeEval

    main

    Use describeEval from vitest-evals to create automated test suites that verify if an AI model correctly understands instructions and utilizes tools (functions, API calls, etc.).

    An evaluation suite is defined by an options object containing:

    • data: An async function returning an array of test cases. Each case includes an input (the instruction) and an expected (a description of the anticipated outcome).
    • task: An async function that executes the test logic. It should initialize the environment, run the task, perform assertions using expect, and return the promptOutput.
    • scorers: An array of functions (e.g., checkFactuality) that evaluate the promptOutput against the expected string.
    • threshold: A number (0-1) representing the minimum passing score.
    • timeout: Maximum time in milliseconds for a single test case.
  5. Structure an evaluation task function

    main

    The task(input) function is the core of an evaluation. It should follow these steps:

    1. Setup: Call a helper like initializeClient() to prepare the test environment and configure available tools.
    2. Execution: Call a helper like runTask(client, model, input) to send the instruction to the AI. This returns an object containing:
      • promptOutput: The textual response from the AI.
      • toolCalls: A list of tools invoked and the arguments passed to them.
    3. Assertions: Use expect to verify that the correct tools were called with the correct arguments (e.g., checking toolName and args).
    4. Return: Return the promptOutput so that the configured scorers can evaluate the text against the expected value.
    task: async (input) => {
    	const client = await initializeClient()
    	const { promptOutput, toolCalls } = await runTask(client, 'your-model', input)
    
    	// Assertions
    	const myToolCall = toolCalls.find((call) => call.toolName === 'my_tool')
    	expect(myToolCall).toBeDefined()
    	expect(myToolCall?.args).toEqual(
    		expect.objectContaining({
    			data: 'example',
    		})
    	)
    
    	return promptOutput
    }
  6. Connect to the Cloudflare Audit Logs MCP Server

    main

    To use the Cloudflare Audit Logs MCP Server, connect your MCP client directly to the provided URL. If your client requires authentication, you will be prompted to complete the Cloudflare OAuth flow in your browser. Once authorized, the audit log tools will be available for use.

    https://auditlogs.mcp.cloudflare.com/mcp
  7. Implement MCP Tool Type Validators

    main

    When creating Zod validators for MCP tool parameters that interact with the Cloudflare TypeScript SDK, follow these three core principles to ensure runtime safety, type safety, and LLM compatibility:

    1. Link to SDK Types: Use z.ZodType<SDKType> to create a compile-time dependency between your Zod schema and the underlying Cloudflare Node SDK types. This ensures that if the SDK changes, your validator will trigger a TypeScript error during compilation.
    2. Define Individual Field Validators: Do not group parameters into a single z.object({...}) schema. Instead, define a separate, named Zod schema for every individual field. This improves LLM understanding, allows for parameter reusability across different tools, and increases modularity.
    3. Use .describe() Extensively: Every Zod schema must include a .describe('...') call. This description is used to provide context to the LLM, helping it understand the purpose and constraints of each parameter.
  8. Migrate from AutoRAG MCP Server to Unified Cloudflare MCP Server

    main

    The Cloudflare AutoRAG MCP Server is deprecated. AutoRAG has been superseded by Cloudflare AI Search. All new work should use the unified Cloudflare MCP server, which provides access to AI Search and the full Cloudflare API via Code Mode (using search and execute tools).

    To migrate, update your MCP client configuration to use the unified server URL:

    {
    	"mcpServers": {
    		"cloudflare-api": {
    			"url": "https://mcp.cloudflare.com/mcp"
    		}
    	}
    }
  9. Connect to the Cloudflare Radar MCP server

    main

    You can connect your MCP client directly to the Cloudflare Radar MCP server via the hosted endpoint. If your client requires authentication, you will need to complete the Cloudflare OAuth flow in your browser to authorize the connection. Once authorized, the Radar tools will be available for use.

    https://radar.mcp.cloudflare.com/mcp
  10. Migrate to the unified Cloudflare MCP server

    main

    The standalone Cloudflare Radar MCP Server is deprecated. All Radar API functionality is now integrated into the unified Cloudflare MCP server. You should migrate to the unified server to access all Cloudflare API endpoints, including Radar, via the search and execute tools in Code Mode. The unified server supports both OAuth and Cloudflare API tokens.

    {
    	"mcpServers": {
    		"cloudflare-api": {
    			"url": "https://mcp.cloudflare.com/mcp"
    		}
    	}
    }