Skip to main content
Glama
jeffgolden

Cloudflare MCP Server

by jeffgolden

cloudflare-dns-mcp_list_waf_rules

Retrieve Web Application Firewall (WAF) rules for a specific zone using the Cloudflare MCP Server, enabling efficient rule management and security monitoring.

Instructions

List Web Application Firewall (WAF) rules for a zone

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
rule_typeNo
zone_nameYes

Implementation Reference

  • The handler function that implements the core logic of listing WAF rules: parses input, fetches zone ID, queries Cloudflare firewall/rules endpoint, and formats response as MCP content.
    handler: async (params: z.infer<typeof ListWafRulesInputSchema>) => {
      const { zone_name, rule_type } = ListWafRulesInputSchema.parse(params);
    
      // Resolve zone ID
      const zones = await client.get<Array<{ id: string; name: string }>>('/zones', { name: zone_name });
      if (zones.length === 0) throw new Error(`Zone ${zone_name} not found`);
      const zoneId = zones[0].id;
    
      const query: Record<string, any> = {};
      if (rule_type) query.mode = rule_type;
    
      const wafRules = await client.get<Array<typeof WafRuleSchema['_type']>>(`/zones/${zoneId}/firewall/rules`, query);
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(wafRules, null, 2)
          }
        ]
      };
    },
  • Zod input schema for the tool: requires zone_name, optional rule_type.
    const ListWafRulesInputSchema = z.object({
      zone_name: z.string(),
      rule_type: z.string().optional(), // Placeholder – Cloudflare uses "mode" & "action"
    });
  • Shared Zod schema for individual WafRule objects, used to type the output array items.
    const WafRuleSchema = z.object({
      id: z.string(),
      description: z.string(),
      action: z.string(),
      expression: z.string(),
      paused: z.boolean(),
      priority: z.number().optional(),
    });
  • Registration of the list_waf_rules tool in the security tools map returned by getSecurityTools(client). This map is spread into the main server tools in src/index.ts.
    tools: {
      'cloudflare-dns-mcp/list_waf_rules': listWafRulesTool,
      'cloudflare-dns-mcp/create_security_rule': createSecurityRuleTool,
      'cloudflare-dns-mcp/update_security_rule': updateSecurityRuleTool,
      'cloudflare-dns-mcp/delete_security_rule': deleteSecurityRuleTool,
    },
  • src/index.ts:19-27 (registration)
    Main server registration: calls getSecurityTools and spreads its tools into the aggregate allTools used for MCP server handlers.
    const securityTools = getSecurityTools(cfClient);
    const sslCertTools = getSslCertTools(cfClient);
    const zoneTools = getZoneManagementTools(cfClient);
    const echoTools = getEchoTools();
    const redirectTools = getRedirectTools(cfClient);
    
    const allTools = {
      ...dnsTools.tools,
      ...securityTools.tools,
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool lists WAF rules but doesn't mention whether it's read-only, safe to use, requires authentication, has rate limits, or what the output format looks like. For a tool with zero annotation coverage, this is a significant gap in transparency.

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 that front-loads the core purpose without any wasted words. It's appropriately sized for a simple list operation, 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 moderate complexity (2 parameters, no output schema, no annotations), the description is incomplete. It lacks details on behavioral traits, parameter usage, and output expectations, which are essential for an AI agent to invoke this tool correctly in a real-world scenario.

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 for undocumented parameters. It mentions 'for a zone', which hints at the required 'zone_name' parameter, but doesn't explain the optional 'rule_type' parameter or provide any details on format, constraints, or examples. This leaves key parameter semantics unclear.

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 ('List') and resource ('Web Application Firewall (WAF) rules for a zone'), making the purpose immediately understandable. It distinguishes itself from siblings like list_dns_records or list_page_rules by specifying WAF rules, though it doesn't explicitly contrast with list_security_rule tools which might overlap.

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 doesn't mention prerequisites, such as needing a valid zone, or differentiate from other list tools (e.g., list_security_rule might handle similar data). This leaves the agent to infer usage from context alone.

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