### Install Project Dependencies Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/CONTRIBUTING.md Run this command to install all necessary project dependencies using pnpm. ```bash pnpm install ``` -------------------------------- ### Start Local Development Server Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/apps/workers-builds/CONTRIBUTING.md Run this command to start the local development server for the MCP server. ```bash pnpm dev ``` -------------------------------- ### Start Local Development Server Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/apps/browser-rendering/CONTRIBUTING.md Run this command in your project root to start the local development server using Wrangler. ```bash npx wrangler dev ``` -------------------------------- ### Run MCP Server Locally Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/apps/docs-autorag/README.md Use this command to start the MCP server for local development. Connect to `http://localhost:8976/mcp` for remote MCP connections. ```bash pnpm run start ``` -------------------------------- ### Test Remote Server with Inspector Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/apps/browser-rendering/CONTRIBUTING.md Launch the MCP Inspector tool from your terminal to test the deployed remote server. This command installs and runs the latest version of the Inspector. ```bash npx @modelcontextprotocol/inspector@latest ``` -------------------------------- ### get_origin_details Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/apps/radar/README.md Gets details for a specific cloud provider. ```APIDOC ## get_origin_details ### Description Retrieves detailed information about a specific cloud provider. ### Method GET ### Endpoint /radar/cloud-observatory/origins/{slug} ### Parameters #### Path Parameters - **slug** (string) - Required - The unique slug identifier for the cloud provider (e.g., "aws", "gcp"). ### Response #### Success Response (200) - **name** (string) - The name of the cloud provider. - **slug** (string) - A unique identifier for the cloud provider. - **description** (string) - A description of the cloud provider. - **regions** (array) - A list of regions offered by the provider. ### Response Example { "name": "Amazon Web Services", "slug": "aws", "description": "Amazon Web Services (AWS) is a cloud computing platform.", "regions": ["us-east-1", "eu-west-1"] } ``` -------------------------------- ### get_internet_services_ranking Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/apps/radar/README.md Gets top Internet services. ```APIDOC ## get_internet_services_ranking ### Description Retrieves a ranked list of top Internet services based on various metrics. ### Method GET ### Endpoint /radar/internet-services/ranking ### Parameters #### Query Parameters - **limit** (integer) - Optional - The maximum number of services to return. - **offset** (integer) - Optional - The offset for pagination. ### Response #### Success Response (200) - **service_name** (string) - The name of the internet service. - **rank** (integer) - The rank of the service. - **score** (number) - The score used for ranking. ### Response Example { "data": [ { "service_name": "Web Browsing", "rank": 1, "score": 99.0 } ] } ``` -------------------------------- ### Setup Cloudflare OAuth 2.1 + PKCE Flow with Hono Source: https://context7.com/cloudflare/mcp-server-cloudflare/llms.txt The `createAuthHandlers` function sets up Hono routes for the full Cloudflare OAuth 2.1 PKCE flow, including authorization and callback endpoints. It's designed to be used as the `defaultHandler` in OAuth-enabled MCP applications. ```typescript // packages/mcp-common/src/cloudflare-oauth-handler.ts import OAuthProvider from '@cloudflare/workers-oauth-provider' import { createAuthHandlers, handleTokenExchangeCallback } from '@repo/mcp-common/src/cloudflare-oauth-handler' import { MetricsTracker } from 'packages/mcp-observability/src' const metrics = new MetricsTracker(env.MCP_METRICS, { name: 'my-server', version: '0.1.0' }) const RequiredScopes = { 'account:read': 'See your account info such as account details, analytics, and memberships.', 'workers:read': 'Read access to Workers scripts.', } export default { fetch: async (req: Request, env: Env, ctx: ExecutionContext) => { return new OAuthProvider({ apiHandlers: { '/mcp': MyMCPAgent.serve('/mcp'), '/sse': MyMCPAgent.serveSSE('/sse'), }, defaultHandler: createAuthHandlers({ scopes: RequiredScopes, metrics }), authorizeEndpoint: '/oauth/authorize', tokenEndpoint: '/token', tokenExchangeCallback: (options) => handleTokenExchangeCallback(options, env.CLOUDFLARE_CLIENT_ID, env.CLOUDFLARE_CLIENT_SECRET), accessTokenTTL: 3600, refreshTokenTTL: 2592000, clientRegistrationEndpoint: '/register', }).fetch(req, env, ctx) }, } ``` -------------------------------- ### Register Cloudflare Documentation Search Tools Source: https://context7.com/cloudflare/mcp-server-cloudflare/llms.txt Registers tools for semantic vector search over Cloudflare developer documentation. Use to find relevant documentation chunks or fetch the Pages-to-Workers migration guide. ```typescript // packages/mcp-common/src/tools/docs-vectorize.tools.ts import { registerDocsTools } from '@repo/mcp-common/src/tools/docs-vectorize.tools' registerDocsTools(server, { AI: env.AI, VECTORIZE: env.VECTORIZE }) ``` ```typescript // search_cloudflare_documentation — LLM: "How do I use Durable Objects?" // Args: { query: "Durable Objects usage and lifecycle" } // Returns XML of 10 chunks: // // https://developers.cloudflare.com/durable-objects/ // Durable Objects // Durable Objects provide low-latency coordination and consistent storage... // ``` ```typescript // migrate_pages_to_workers_guide — No args. // Fetches and returns the full Pages-to-Workers migration guide from developers.cloudflare.com ``` -------------------------------- ### R2 Bucket Management Tools Source: https://context7.com/cloudflare/mcp-server-cloudflare/llms.txt Facilitates management of Cloudflare R2 object storage buckets, supporting list operations with cursor pagination and filtering, as well as create, get, and delete operations. ```typescript import { registerR2BucketTools } from '@repo/mcp-common/src/tools/r2_bucket.tools' registerR2BucketTools(agent) ``` -------------------------------- ### get_tld_details Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/apps/radar/README.md Gets detailed information about a specific TLD. ```APIDOC ## get_tld_details ### Description Gets detailed information about a specific TLD. ### Method GET (assumed) ### Endpoint /radar/tlds/{tld} (assumed) ### Parameters #### Path Parameters - **tld** (string) - Required - The top-level domain to get details for. ### Request Example ```json { "example": "No example provided" } ``` ### Response #### Success Response (200) - **data** (object) - Detailed information about the TLD. ### Response Example ```json { "example": "No example provided" } ``` ``` -------------------------------- ### get_bot_details Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/apps/radar/README.md Gets detailed information about a specific bot by slug. ```APIDOC ## get_bot_details ### Description Retrieves detailed information about a specific bot using its unique slug. ### Method GET ### Endpoint /radar/bots/{slug} ### Parameters #### Path Parameters - **slug** (string) - Required - The unique slug identifier for the bot. ### Response #### Success Response (200) - **slug** (string) - The unique identifier for the bot. - **name** (string) - The name of the bot. - **operator** (string) - The operator of the bot. - **category** (string) - The category of the bot. - **description** (string) - A detailed description of the bot. - **user_agent** (string) - The typical User-Agent string used by the bot. ### Response Example { "slug": "googlebot", "name": "Googlebot", "operator": "Google", "category": "Search Engine", "description": "Google's web crawling bot.", "user_agent": "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" } ``` -------------------------------- ### get_bgp_top_ases_by_prefixes Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/apps/radar/README.md Gets top ASes ordered by announced prefix count - shows which networks have the largest routing footprint. ```APIDOC ## get_bgp_top_ases_by_prefixes ### Description Gets top ASes ordered by announced prefix count, indicating networks with the largest routing footprint. ### Method GET ### Endpoint /radar/bgp/top-ases-by-prefixes ### Parameters #### Query Parameters - **limit** (integer) - Optional - The maximum number of ASes to return. - **name** (string) - Optional - Filter by AS name. - **asn** (integer) - Optional - Filter by AS number. ### Response #### Success Response (200) - **asn** (integer) - The Autonomous System Number. - **name** (string) - The name of the Autonomous System. - **prefixes** (integer) - The count of announced prefixes. ### Response Example { "data": [ { "asn": 13335, "name": "CLOUDFLARENET", "prefixes": 10000 } ] } ``` -------------------------------- ### Hyperdrive Configuration Management Tools Source: https://context7.com/cloudflare/mcp-server-cloudflare/llms.txt Tools for managing Cloudflare Hyperdrive configurations, including list, get, delete, and edit (PATCH) operations. The create operation is intentionally disabled. ```typescript import { registerHyperdriveTools } from '@repo/mcp-common/src/tools/hyperdrive.tools' registerHyperdriveTools(agent) ``` -------------------------------- ### Local Development Environment Variables Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/apps/browser-rendering/CONTRIBUTING.md Configure your local development environment by creating a `.dev.vars` file. Use Cloudflare client credentials or a development API token for authentication. ```bash CLOUDFLARE_CLIENT_ID=your_development_cloudflare_client_id CLOUDFLARE_CLIENT_SECRET=your_development_cloudflare_client_secret ``` ```bash DEV_DISABLE_OAUTH=true # This is your global api token DEV_CLOUDFLARE_API_TOKEN=your_development_api_token ``` -------------------------------- ### get_domain_rank_details Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/apps/radar/README.md Gets domain rank details. ```APIDOC ## get_domain_rank_details ### Description Retrieves detailed ranking information for a specific domain. ### Method GET ### Endpoint /radar/domains/ranking/details ### Parameters #### Query Parameters - **domain** (string) - Required - The domain name to get details for. ### Response #### Success Response (200) - **domain** (string) - The domain name. - **rank** (integer) - The current rank of the domain. - **score** (number) - The score used for ranking. - **change** (number) - The change in rank since the last period. - **historical_ranks** (array) - An array of historical rank data. ### Response Example { "domain": "example.com", "rank": 1, "score": 98.5, "change": 0, "historical_ranks": [ {"date": "2023-10-20", "rank": 1, "score": 98.0} ] } ``` -------------------------------- ### get_domains_ranking Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/apps/radar/README.md Gets top or trending domains. ```APIDOC ## get_domains_ranking ### Description Retrieves a list of top or trending domain names based on various metrics. ### Method GET ### Endpoint /radar/domains/ranking ### Parameters #### Query Parameters - **ranking_type** (string) - Optional - Type of ranking ('top' or 'trending'). Defaults to 'top'. - **limit** (integer) - Optional - The maximum number of domains to return. - **offset** (integer) - Optional - The offset for pagination. ### Response #### Success Response (200) - **domain** (string) - The domain name. - **rank** (integer) - The rank of the domain. - **score** (number) - The score used for ranking. ### Response Example { "data": [ { "domain": "example.com", "rank": 1, "score": 98.5 } ] } ``` -------------------------------- ### Deploy MCP Server Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/apps/docs-autorag/README.md Execute this command to deploy the MCP server to a specified environment. Replace `[ENVIRONMENT]` with your target deployment environment. ```bash pnpm run deploy --env [ENVIRONMENT] ``` -------------------------------- ### Registering a Tool with agent.server.tool() Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/implementation-guides/tools.md Use this method to register a new tool for an MCP agent. Ensure the tool name is unique, the description is detailed for the LLM, and parameters are defined using Zod schemas. The implementation logic should be an async function that handles parameters and returns a formatted response or error. ```typescript import { z } from 'zod' import { getCloudflareClient } from '../cloudflare-api' import { MISSING_ACCOUNT_ID_RESPONSE } from '../constants' import { type CloudflareMcpAgent } from '../types/cloudflare-mcp-agent' import { KvNamespaceIdSchema, KvNamespaceTitleSchema } from '../types/kv_namespace' export function registerMyServiceTools(agent: CloudflareMcpAgent) { agent.server.tool( 'tool_name', // String: Unique name for the tool 'Detailed description', // String: Description for the LLM (CRITICAL!) { // Object: Parameter definitions using Zod schemas param1: MyParam1Schema, param2: MyParam2Schema.optional(), // ... other parameters }, async (params) => { // Async Function: The implementation logic // params contains the validated parameters { param1, param2, ... } // --- Tool Logic Start --- try { // Access agent context if needed (e.g., account ID, credentials) const account_id = await agent.getActiveAccountId() if (!account_id) { return MISSING_ACCOUNT_ID_RESPONSE // Handle missing context } // Perform the action (e.g., call SDK, query DB) // const client = getCloudflareClient(agent.props.accessToken); // const result = await client.someService.someAction(...); // Format the successful response return { content: [ { type: 'text', text: JSON.stringify({ success: true /*, result */ }), }, // Or potentially EmbeddedResource for richer data ], } } catch (error) { // Format the error response return { content: [ { type: 'text', text: `Error performing action: ${error instanceof Error ? error.message : String(error)}`, }, ], } } // --- Tool Logic End --- } ) // ... register other tools ... } ``` -------------------------------- ### get_url_scan_screenshot Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/apps/radar/README.md Get screenshot URL for a completed scan. ```APIDOC ## get_url_scan_screenshot ### Description Get screenshot URL for a completed scan. ### Method GET (assumed) ### Endpoint /radar/url_scanner/scans/{scanUuid}/screenshot (assumed) ### Parameters #### Path Parameters - **scanUuid** (string) - Required - The UUID of the completed scan. ### Request Example ```json { "example": "No example provided" } ``` ### Response #### Success Response (200) - **screenshotUrl** (string) - The URL of the scan screenshot. ### Response Example ```json { "example": "No example provided" } ``` ``` -------------------------------- ### Instrumented MCP Server Initialization Source: https://context7.com/cloudflare/mcp-server-cloudflare/llms.txt Initialize the CloudflareMCPServer to automatically track metrics and route errors. Ensure Analytics Engine and optional Sentry bindings are configured. ```typescript import { CloudflareMCPServer } from '@repo/mcp-common/src/server' import { MetricsTracker } from 'packages/mcp-observability/src' // In an app's init() method: this.server = new CloudflareMCPServer({ userId: 'user-abc123', // optional: tracks per-user metrics wae: this.env.MCP_METRICS, // Analytics Engine binding serverInfo: { name: 'my-mcp-server', version: '0.1.0', }, // sentry: sentryClient, // optional Sentry error reporting }) // Every tool call is now automatically tracked: this.server.tool( 'my_tool', 'Description for the LLM', { param: z.string() }, async ({ param }) => { return { content: [{ type: 'text', text: `Result: ${param}` }] } } ) // On success: emits ToolCall metric. On error: emits ToolCall with errorCode. ``` -------------------------------- ### Run Specific Test File Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/CONTRIBUTING.md Use this command to run a specific test file, providing the path to the test file. ```bash pnpm test -- tests/tools/queues.test.ts ``` -------------------------------- ### Conceptual Tool Definition (Illustrative) Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/implementation-guides/type-validators.md Illustrates the recommended approach for defining tool parameters using individual schemas versus the discouraged single object schema. ```typescript // DON'T DO THIS for tool params const CreateParamsSchema = z.object({ name: HyperdriveConfigNameSchema, host: HyperdriveOriginHostSchema, port: HyperdriveOriginPortSchema, // ... other fields }) // Tool definition would accept one arg: { params: CreateParamsSchema } ``` ```typescript // DO THIS: Tool definition accepts multiple named args // tool('hyperdrive_create', { // name: HyperdriveConfigNameSchema, // host: HyperdriveOriginHostSchema, // port: HyperdriveOriginPortSchema, // // ... other named parameters with their individual schemas // }, ...) ``` -------------------------------- ### get_ct_authority_details Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/apps/radar/README.md Gets details for a specific CA by fingerprint. ```APIDOC ## get_ct_authority_details ### Description Retrieves detailed information about a specific Certificate Authority (CA) using its certificate fingerprint. ### Method GET ### Endpoint /radar/certificate-transparency/authorities/{fingerprint} ### Parameters #### Path Parameters - **fingerprint** (string) - Required - The SHA-1 fingerprint of the CA's certificate. ### Response #### Success Response (200) - **fingerprint** (string) - The SHA-1 fingerprint of the CA's certificate. - **name** (string) - The name of the Certificate Authority. - **log_count** (integer) - The number of CT logs the CA appears in. - **first_seen** (string) - The date when the CA was first seen in CT logs. ### Response Example { "fingerprint": "A1B2C3D4E5F678901234567890ABCDEF12345678", "name": "Let's Encrypt Authority X3", "log_count": 50, "first_seen": "2015-06-15T00:00:00Z" } ``` -------------------------------- ### Run All Tests Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/CONTRIBUTING.md Execute this command to run all tests in the project using Vitest. ```bash pnpm test ``` -------------------------------- ### get_geolocation_details Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/apps/radar/README.md Gets details for a specific geolocation by GeoNames ID. ```APIDOC ## get_geolocation_details ### Description Retrieves detailed information for a specific geographic location using its GeoNames ID. ### Method GET ### Endpoint /radar/geolocations/{geoname_id} ### Parameters #### Path Parameters - **geoname_id** (integer) - Required - The GeoNames ID for the location. ### Response #### Success Response (200) - **geoname_id** (integer) - The GeoNames ID for the location. - **name** (string) - The name of the state or province. - **country_code** (string) - The ISO 3166-1 alpha-2 country code. - **subdivisions** (array) - A list of subdivisions within this location (e.g., counties). ### Response Example { "geoname_id": 5879092, "name": "California", "country_code": "US", "subdivisions": ["Los Angeles County", "San Francisco County"] } ``` -------------------------------- ### LLM Task Execution with `runTask()` Source: https://context7.com/cloudflare/mcp-server-cloudflare/llms.txt Drives an LLM through a tool-use loop for evaluation. It takes an MCP client manager, a model, and an input prompt, returning the prompt output, full generation result, and a list of tool calls. Ensure the client is initialized before calling. ```typescript // packages/eval-tools/src/runTask.ts import { runTask } from '@repo/eval-tools/src/runTask' import { eachModel } from '@repo/eval-tools/src/test-models' import { checkFactuality } from '@repo/eval-tools/src/scorers' import { describeEval } from 'vitest-evals' eachModel('$modelName', ({ model }) => { describeEval('KV Namespace Operations', { data: async () => [ { input: 'List all KV namespaces in my account', expected: 'The kv_namespaces_list tool was called to list KV namespaces', }, ], task: async (input) => { const client = await initializeClient() // sets up MCP + tools const { promptOutput, toolCalls } = await runTask(client, model, input) const kvCall = toolCalls.find((c) => c.toolName === 'kv_namespaces_list') expect(kvCall).toBeDefined() // Optionally check args: expect(kvCall?.args).toEqual(expect.objectContaining({ ... })) return promptOutput // scored by checkFactuality against expected }, scorers: [checkFactuality], threshold: 1, timeout: 60000, }) }) ``` -------------------------------- ### get_ct_log_details Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/apps/radar/README.md Gets details for a specific CT log by slug. ```APIDOC ## get_ct_log_details ### Description Retrieves detailed information about a specific Certificate Transparency (CT) log using its slug. ### Method GET ### Endpoint /radar/certificate-transparency/logs/{slug} ### Parameters #### Path Parameters - **slug** (string) - Required - The unique slug identifier for the CT log. ### Response #### Success Response (200) - **url** (string) - The URL of the CT log. - **name** (string) - The name of the CT log. - **operated_by** (string) - The entity operating the log. - **state** (string) - The current state of the log (e.g., "active", "retired"). - **max_entries** (integer) - The maximum number of entries the log can hold. ### Response Example { "url": "https://ct.googleapis.com/logs/google4096", "name": "Google Log 4096", "operated_by": "Google", "state": "active", "max_entries": 4096 } ``` -------------------------------- ### Create and Configure KV Namespace Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/apps/cloudflare-one-casb/README.md Create a new KV namespace for OAuth data using Wrangler and update your Wrangler configuration file with the assigned KV ID. ```bash wrangler kv:namespace create "OAUTH_KV" ``` -------------------------------- ### Define Zod Schema with Description Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/implementation-guides/type-validators.md Always include a `.describe()` call with a clear, concise explanation for every Zod schema. This aids LLM understanding and serves as inline developer documentation. ```typescript /** Zod schema for the list page number. */ export const HyperdriveListParamPageSchema = z .number() .int() .positive() .optional() .describe('Page number of results') // <-- Good description! ``` -------------------------------- ### get_url_scan_har Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/apps/radar/README.md Get HAR (HTTP Archive) data for a completed scan. ```APIDOC ## get_url_scan_har ### Description Get HAR (HTTP Archive) data for a completed scan. ### Method GET (assumed) ### Endpoint /radar/url_scanner/scans/{scanUuid}/har (assumed) ### Parameters #### Path Parameters - **scanUuid** (string) - Required - The UUID of the completed scan. ### Request Example ```json { "example": "No example provided" } ``` ### Response #### Success Response (200) - **harData** (object) - The HAR data for the scan. ### Response Example ```json { "example": "No example provided" } ``` ``` -------------------------------- ### get_url_scan Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/apps/radar/README.md Get scan results by UUID (verdicts, page info, stats). ```APIDOC ## get_url_scan ### Description Get scan results by UUID (verdicts, page info, stats). ### Method GET (assumed) ### Endpoint /radar/url_scanner/scans/{scanUuid} (assumed) ### Parameters #### Path Parameters - **scanUuid** (string) - Required - The UUID of the scan to retrieve results for. ### Request Example ```json { "example": "No example provided" } ``` ### Response #### Success Response (200) - **data** (object) - Scan results including verdicts, page info, and stats. ### Response Example ```json { "example": "No example provided" } ``` ``` -------------------------------- ### get_domains_ranking_timeseries Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/apps/radar/README.md Gets domain ranking timeseries data to track how domains rank over time. ```APIDOC ## get_domains_ranking_timeseries ### Description Retrieves timeseries data for domain rankings, allowing tracking of how domain ranks change over time. ### Method GET ### Endpoint /radar/domains/ranking/timeseries ### Parameters #### Query Parameters - **domain** (string) - Required - The domain name to get timeseries data for. - **start_date** (string) - Optional - The start date for the timeseries (YYYY-MM-DD). - **end_date** (string) - Optional - The end date for the timeseries (YYYY-MM-DD). ### Response #### Success Response (200) - **date** (string) - The date of the data point. - **rank** (integer) - The rank of the domain on that date. - **score** (number) - The score used for ranking on that date. ### Response Example { "data": [ {"date": "2023-10-20", "rank": 1, "score": 98.0}, {"date": "2023-10-21", "rank": 1, "score": 98.5} ] } ``` -------------------------------- ### Register Account Listing and Selection Tools Source: https://context7.com/cloudflare/mcp-server-cloudflare/llms.txt The `registerAccountTools` function registers two essential tools: `accounts_list` to retrieve all Cloudflare accounts and `set_active_account` to specify the account for subsequent tool operations. `set_active_account` is only available for user-scoped tokens. ```typescript // packages/mcp-common/src/tools/account.tools.ts import { registerAccountTools } from '@repo/mcp-common/src/tools/account.tools' // In an app's init(): registerAccountTools(this) // LLM usage flow: // 1. Call accounts_list → returns [{ id, name, created_on }, ...] // 2. Call set_active_account with the desired id // 3. All subsequent tools that call agent.getActiveAccountId() now use that account // Expected output of accounts_list: // { "accounts": [{ "id": "abc123", "name": "My Org", "created_on": "2022-01-01T00:00:00Z" }], "count": 1 } ``` -------------------------------- ### Registering MCP Tools with Zod Schemas Source: https://context7.com/cloudflare/mcp-server-cloudflare/llms.txt Register tools using agent.server.tool(), defining the name, LLM description, Zod parameter schema, and an async handler. Use snake_case for tool names and include readOnlyHint annotations for non-destructive operations. ```typescript import { z } from 'zod' import { getCloudflareClient } from '@repo/mcp-common/src/cloudflare-api' import { MISSING_ACCOUNT_ID_RESPONSE } from '@repo/mcp-common/src/constants' export function registerMyTools(agent: CloudflareMcpAgent) { agent.server.tool( 'my_resource_list', // snake_case: service_noun_verb 'List all my resources. Use when the user asks to see their resources.', { page: z.number().int().positive().optional().describe('Page number'), per_page: z.number().int().min(1).max(100).optional().describe('Items per page'), }, { title: 'List My Resources', annotations: { readOnlyHint: true }, // tells clients this is non-destructive }, async ({ page, per_page }) => { const account_id = await agent.getActiveAccountId() if (!account_id) return MISSING_ACCOUNT_ID_RESPONSE // standard guard try { const client = getCloudflareClient(agent.props.accessToken) const result = await client.someService.list({ account_id, page, per_page }) return { content: [{ type: 'text', text: JSON.stringify(result) }], } } catch (error) { return { content: [{ type: 'text', text: `Error: ${error instanceof Error ? error.message : String(error)}`, }], } } } ) } ``` -------------------------------- ### get_speed_histogram Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/apps/radar/README.md Gets speed test histogram data showing distribution of results for bandwidth, latency, or jitter. ```APIDOC ## get_speed_histogram ### Description Gets speed test histogram data showing distribution of results for bandwidth, latency, or jitter. ### Method GET (assumed) ### Endpoint /radar/speed/histogram (assumed) ### Parameters None explicitly documented. ### Request Example ```json { "example": "No example provided" } ``` ### Response #### Success Response (200) - **data** (object) - Histogram data for speed test results. ### Response Example ```json { "example": "No example provided" } ``` ``` -------------------------------- ### Deploy Container MCP Server Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/apps/sandbox-container/CONTRIBUTING.md Use this command to deploy the Container MCP Server. Ensure the Docker daemon is running and WARP is disabled before execution. ```bash npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14387504770/npm-package-wrangler-8740 deploy ``` -------------------------------- ### Configure Remote MCP Server Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/apps/dex-analysis/README.md Use this JSON configuration to set up your MCP client to access the remote MCP server if it does not have first-class support. Restart the MCP client after updating the configuration file. ```json { "mcpServers": { "cloudflare": { "command": "npx", "args": ["mcp-remote", "https://dex.mcp.cloudflare.com/mcp"] } } } ``` -------------------------------- ### Test Remote Server with Inspector Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/apps/cloudflare-one-casb/README.md After deploying, test the remote MCP server's functionality using the Inspector tool, which can be run via npx. ```bash npx wrangler deploy ``` -------------------------------- ### Configure mcp-remote for Cloudflare Documentation Server Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/apps/docs-ai-search/README.md Use this JSON configuration to set up your MCP client to access the Cloudflare Documentation MCP server if it does not natively support remote servers. This requires the `mcp-remote` package. ```json { "mcpServers": { "cloudflare": { "command": "npx", "args": ["mcp-remote", "https://docs.mcp.cloudflare.com/mcp"] } } } ``` -------------------------------- ### Local Development Variables Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/apps/workers-observability/CONTRIBUTING.md Configure local development environment variables in `.dev.vars`. Use Cloudflare client credentials or a development API token for external contributors. ```env CLOUDFLARE_CLIENT_ID=your_development_cloudflare_client_id CLOUDFLARE_CLIENT_SECRET=your_development_cloudflare_client_secret ``` ```env DEV_DISABLE_OAUTH=true DEV_CLOUDFLARE_API_TOKEN=your_development_api_token ``` -------------------------------- ### D1 Database Management Tools Source: https://context7.com/cloudflare/mcp-server-cloudflare/llms.txt Enables full lifecycle management for Cloudflare D1 databases, including listing, creating, retrieving, deleting, and querying. The query tool supports raw SQL with optional parameterized values. ```typescript import { registerD1Tools } from '@repo/mcp-common/src/tools/d1.tools' registerD1Tools(agent) ``` -------------------------------- ### Browser Rendering Tools Source: https://context7.com/cloudflare/mcp-server-cloudflare/llms.txt Interact with live web pages to fetch HTML, convert pages to Markdown, or take screenshots using Cloudflare's Browser Rendering API. ```APIDOC ## Browser Rendering Tools ### Description Uses Cloudflare's Browser Rendering API to interact with live web pages. ### Methods #### `get_url_html_content` Fetches the HTML content of a given URL. - **Args** - `url` (string) - The URL to fetch HTML from. - **Returns** - `result` (string) - The HTML content of the page. #### `get_url_markdown` Converts the content of a given URL to Markdown. - **Args** - `url` (string) - The URL to convert to Markdown. - **Returns** - `result` (string) - The Markdown representation of the page content. #### `get_url_screenshot` Captures a screenshot of a given URL. - **Args** - `url` (string) - The URL to capture a screenshot of. - `viewport` (object) - The viewport dimensions for the screenshot. - `width` (number) - The width of the viewport. - `height` (number) - The height of the viewport. - **Returns** - `content` (array) - A content block containing the screenshot image. - `type` (string) - The type of content, e.g., "image". - `mimeType` (string) - The MIME type of the image, e.g., "image/png". - `data` (string) - The base64 encoded image data. ``` -------------------------------- ### Deploy MCP Server with Wrangler Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/apps/cloudflare-one-casb/README.md Deploy the MCP server to your Cloudflare Workers domain using the Wrangler CLI. This command makes the server accessible. ```bash wrangler deploy ``` -------------------------------- ### Configure Remote MCP Server Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/apps/logpush/README.md Use this JSON configuration to set up a remote MCP server connection for clients that do not natively support it. Replace the content with this configuration and restart your MCP client. ```json { "mcpServers": { "cloudflare": { "command": "npx", "args": ["mcp-remote", "https://logs.mcp.cloudflare.com/mcp"] } } } ``` -------------------------------- ### Runx CLI Usage Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/packages/tools/README.md Use the runx CLI for complex automation tasks requiring type safety and programmatic control. It automatically uses Bun if available, falling back to tsx. ```bash pnpm runx [options] ``` -------------------------------- ### Deploy Worker Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/apps/browser-rendering/CONTRIBUTING.md Deploy the MCP server to your Cloudflare workers.dev domain. Replace `` with your target environment. ```bash npx wrangler deploy -e ``` -------------------------------- ### list_ct_logs Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/apps/radar/README.md Lists Certificate Transparency logs. ```APIDOC ## list_ct_logs ### Description Lists all available Certificate Transparency (CT) logs. ### Method GET ### Endpoint /radar/certificate-transparency/logs ### Parameters #### Query Parameters - **limit** (integer) - Optional - The maximum number of logs to return. - **offset** (integer) - Optional - The offset for pagination. ### Response #### Success Response (200) - **url** (string) - The URL of the CT log. - **name** (string) - The name of the CT log. - **operated_by** (string) - The entity operating the log. ### Response Example { "data": [ { "url": "https://ct.googleapis.com/logs/google4096", "name": "Google Log 4096", "operated_by": "Google" } ] } ``` -------------------------------- ### Local Development Environment Variables Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/apps/dns-analytics/CONTRIBUTING.md Configure environment variables for local development. For Cloudflare employees, use provided client IDs and secrets. External contributors can disable OAuth and use an API token. ```bash CLOUDFLARE_CLIENT_ID=your_development_cloudflare_client_id CLOUDFLARE_CLIENT_SECRET=your_development_cloudflare_client_secret DEV_CLOUDFLARE_API_TOKEN=your_development_api_token ``` ```bash DEV_DISABLE_OAUTH=true your_cloudflare_email # This is your api token with endpoint access. DEV_CLOUDFLARE_API_TOKEN=your_development_api_token ``` -------------------------------- ### D1 Database Tools Source: https://context7.com/cloudflare/mcp-server-cloudflare/llms.txt Enables full lifecycle management for Cloudflare D1 serverless SQLite databases, including listing, creating, retrieving, deleting, and querying. ```APIDOC ## D1 Database Tools ### Description Provides full lifecycle management for Cloudflare D1 (serverless SQLite) databases: list, create, get, delete, and query. The `d1_database_query` tool accepts raw SQL with optional parameterized values. ### Tools * **`d1_database_create(args)`**: Creates a new D1 database. * **Args**: `{ name: string, primary_location_hint?: string }` * **LLM Prompt Example**: "Create a D1 database called users-db in Western Europe" * **Returns**: `{ "uuid": "db-uuid", "name": "users-db", "version": "production", ... }` * **`d1_database_query(args)`**: Executes a SQL query against a D1 database. * **Args**: `{ database_id: string, sql: string, params?: any[] }` * **LLM Prompt Example**: "Select all users from the database" * **Returns**: `[{ "results": [{ "id": 1, "name": "Alice" }], "success": true, "meta": { "duration": 0.5 } }]` * **`d1_database_delete(args)`**: Deletes a D1 database. * **Args**: `{ database_id: string }` ``` -------------------------------- ### R2 Bucket Tools Source: https://context7.com/cloudflare/mcp-server-cloudflare/llms.txt Facilitates management of Cloudflare R2 object storage buckets, including listing with pagination and filtering, creation, retrieval, and deletion. ```APIDOC ## R2 Bucket Tools ### Description Manages Cloudflare R2 object storage buckets: list (with cursor pagination, name filtering, sorting), create, get, and delete. ### Tools * **`r2_buckets_list(args)`**: Lists R2 buckets with filtering and pagination. * **Args**: `{ name_contains?: string, per_page?: number, direction?: "asc" | "desc" }` * **Returns**: `{ "buckets": [{ "name": "media-uploads", "creation_date": "2024-01-01T00:00:00Z" }], "count": 1 }` * **`r2_bucket_create(args)`**: Creates a new R2 bucket. * **Args**: `{ name: string }` * **Returns**: `{ "name": "my-new-bucket" }` * **`r2_bucket_get(args)`**: Retrieves details for a specific R2 bucket. * **Args**: `{ name: string }` * **Returns**: `{ "name": "my-new-bucket", "creation_date": "...", "location": "ENAM" }` * **`r2_bucket_delete(args)`**: Deletes an R2 bucket. * **Args**: `{ name: string }` * **Note**: `[destructiveHint: true]` ``` -------------------------------- ### get_internet_services_timeseries Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/apps/radar/README.md Tracks internet service ranking changes over time (e.g., how ChatGPT ranks over months). ```APIDOC ## get_internet_services_timeseries ### Description Tracks internet service ranking changes over time. ### Method GET (assumed) ### Endpoint /radar/internet_services/timeseries (assumed) ### Parameters None explicitly documented. ### Request Example ```json { "example": "No example provided" } ``` ### Response #### Success Response (200) - **data** (object) - Time series data of internet service rankings. ### Response Example ```json { "example": "No example provided" } ``` ``` -------------------------------- ### Cloudflare Documentation Search Source: https://context7.com/cloudflare/mcp-server-cloudflare/llms.txt Perform semantic vector search over Cloudflare's developer documentation to find relevant information. ```APIDOC ## Cloudflare Documentation Search ### Description Semantic vector search over the entire Cloudflare developer documentation. ### Methods #### `search_cloudflare_documentation` Searches Cloudflare's documentation for relevant chunks based on a query. - **Args** - `query` (string) - The search query. - **Returns** - XML containing the top 10 most relevant documentation chunks, including URL, title, and text. #### `migrate_pages_to_workers_guide` Fetches the full Cloudflare Pages-to-Workers migration guide. - **Args** - None. - **Returns** - The full content of the migration guide as a string. ``` -------------------------------- ### Configure Remote MCP Server Access Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/apps/sandbox-container/README.md Use this JSON configuration to set up access to the remote MCP server if your client does not natively support remote servers. This involves specifying the command and arguments to connect via mcp-remote. ```json { "mcpServers": { "cloudflare": { "command": "npx", "args": ["mcp-remote", "https://containers.mcp.cloudflare.com/mcp"] } } } ``` -------------------------------- ### list_origins Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/apps/radar/README.md Lists cloud provider origins (AWS, GCP, Azure, OCI). ```APIDOC ## list_origins ### Description Lists the supported cloud provider origins, including AWS, Google Cloud Platform (GCP), Azure, and Oracle Cloud Infrastructure (OCI). ### Method GET ### Endpoint /radar/cloud-observatory/origins ### Parameters #### Query Parameters - **limit** (integer) - Optional - The maximum number of origins to return. - **offset** (integer) - Optional - The offset for pagination. ### Response #### Success Response (200) - **name** (string) - The name of the cloud provider. - **slug** (string) - A unique identifier for the cloud provider. ### Response Example { "data": [ { "name": "Amazon Web Services", "slug": "aws" }, { "name": "Google Cloud Platform", "slug": "gcp" } ] } ``` -------------------------------- ### Configure Remote MCP Servers Source: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/README.md Use this JSON configuration to specify remote MCP servers for your client. This is useful when your client does not have first-class support for remote MCP servers. ```json { "mcpServers": { "cloudflare-observability": { "command": "npx", "args": ["mcp-remote", "https://observability.mcp.cloudflare.com/mcp"] }, "cloudflare-bindings": { "command": "npx", "args": ["mcp-remote", "https://bindings.mcp.cloudflare.com/mcp"] } } } ```