Skip to main content
Glama
jeffgolden

Cloudflare MCP Server

by jeffgolden

cloudflare-dns-mcp_purge_cache

Purge Cloudflare cache for a specified zone by selecting purge type (everything, files, tags, hosts) and targeting specific resources. Streamlines cache management for improved performance.

Instructions

Purge Cloudflare cache for a zone

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
purge_typeNoeverything
targetsNo
zone_nameYes

Implementation Reference

  • Handler function that executes the cache purge logic: resolves zone ID, constructs purge body based on type and targets, calls Cloudflare POST /zones/{id}/purge_cache API.
    handler: async (params: any) => {
      const { zone_name, purge_type, targets } = PurgeCacheInputSchema.parse(params);
      const zones = await client.get<any[]>('/zones', { name: zone_name });
      if (zones.length === 0) throw new Error(`Zone ${zone_name} not found`);
      const zoneId = zones[0].id;
    
      let body: any = {};
      if (purge_type === 'everything') {
        body = { purge_everything: true };
      } else {
        if (!targets || targets.length === 0) {
          throw new Error('targets must be provided when purge_type is not "everything"');
        }
        body = { [`${purge_type}`]: targets };
      }
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(await client.post(`/zones/${zoneId}/purge_cache`, body), null, 2)
          }
        ]
      };
    },
  • Zod schema for input validation: requires zone_name, optional purge_type (defaults to 'everything'), optional targets array.
    const PurgeCacheInputSchema = z.object({
      zone_name: z.string(),
      purge_type: z.enum(['everything', 'files', 'tags', 'hosts']).optional().default('everything'),
      targets: z.array(z.string()).optional(),
    });
  • Registration of purge_cache tool within the getZoneManagementTools function's return object (note: slash-separated name).
      tools: {
        'cloudflare-dns-mcp/list_zones': listZonesTool,
        'cloudflare-dns-mcp/get_zone_settings': getZoneSettingsTool,
        'cloudflare-dns-mcp/update_zone_settings': updateZoneSettingsTool,
        'cloudflare-dns-mcp/purge_cache': purgeCacheTool,
      },
    };
  • src/index.ts:49-52 (registration)
    Global registration in MCP server: sanitizes tool names by replacing '/' with '_', creating 'cloudflare-dns-mcp_purge_cache' key used by clients.
    for (const tool of Object.values(allTools)) {
      const safeName = tool.name.replace(/[^a-zA-Z0-9_-]/g, '_');
      toolsMap[safeName] = tool;
    }
  • src/index.ts:25-32 (registration)
    Aggregates tools from all modules including zoneTools (containing purge_cache) into single allTools object for server.
    const allTools = {
      ...dnsTools.tools,
      ...securityTools.tools,
      ...sslCertTools.tools,
      ...echoTools.tools,
      ...redirectTools.tools,
      ...zoneTools.tools,
    } as Record<string, any>;
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It states the tool purges cache, implying a destructive operation, but does not disclose behavioral traits such as permissions needed, rate limits, irreversible effects, or response format. This is inadequate for a mutation tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste, front-loaded with the core action. It is appropriately sized for the tool's purpose, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (destructive cache operation), lack of annotations, no output schema, and low schema coverage, the description is incomplete. It does not cover behavioral aspects, parameter details, or usage context, leaving significant gaps for the agent to understand and invoke the tool correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It mentions 'for a zone', hinting at the 'zone_name' parameter, but does not explain 'purge_type' enum values or 'targets' array usage. This adds minimal meaning beyond the schema, failing to address undocumented parameters adequately.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Purge') and resource ('Cloudflare cache for a zone'), providing a specific verb+resource combination. However, it does not differentiate from siblings like 'delete' operations, which might handle different resources, so it lacks explicit sibling distinction.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. The description does not mention prerequisites, exclusions, or context for cache purging compared to other tools like updating settings or deleting records, leaving the agent without usage direction.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jeffgolden/cloudflare_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server