Skip to main content
Glama
jeffgolden

Cloudflare MCP Server

by jeffgolden

cloudflare-dns-mcp_update_security_rule

Modify an existing firewall security rule to enhance protection across Cloudflare zones. Specify zone, rule ID, action, priority, and expression for precise updates.

Instructions

Update an existing firewall security rule

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionNo
descriptionNo
expressionNo
pausedNo
priorityNo
rule_idYes
zone_nameYes

Implementation Reference

  • The main handler function that implements the logic to update a Cloudflare WAF security rule by fetching the zone, preparing the update body, and calling the Cloudflare PUT API.
    handler: async (params: z.infer<typeof UpdateSecurityRuleInputSchema>) => {
      const { zone_name, rule_id, description, expression, action, priority, paused } = UpdateSecurityRuleInputSchema.parse(params);
      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 body: any = { id: rule_id };
      if (description !== undefined) body.description = description;
      if (expression !== undefined) {
        // need to include filter id per Cloudflare API
        const existing = await client.get<any>(`/zones/${zoneId}/firewall/rules/${rule_id}`);
        const filterId = existing.filter?.id;
        body.filter = { id: filterId, expression };
      }
      if (action !== undefined) body.action = action;
      if (priority !== undefined) body.priority = priority;
      if (paused !== undefined) body.paused = paused;
    
      const updated = await client.put<typeof WafRuleSchema["_type"]>(`/zones/${zoneId}/firewall/rules/${rule_id}`, body);
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(updated, null, 2)
          }
        ]
      };
    },
  • Zod schema defining the input parameters for the update_security_rule tool.
    const UpdateSecurityRuleInputSchema = z.object({
      zone_name: z.string(),
      rule_id: z.string(),
      description: z.string().optional(),
      expression: z.string().optional(),
      action: z.string().optional(),
      priority: z.number().optional(),
      paused: z.boolean().optional(),
    });
  • Tool object definition including name, description, schemas, and handler reference for 'cloudflare-dns-mcp/update_security_rule'.
    const updateSecurityRuleTool: Tool = {
      name: 'cloudflare-dns-mcp/update_security_rule',
      description: 'Update an existing firewall security rule',
      inputSchema: zodToJsonSchema(UpdateSecurityRuleInputSchema) as any,
      outputSchema: zodToJsonSchema(WafRuleSchema) as any,
      annotations: { destructiveHint: true },
      handler: async (params: z.infer<typeof UpdateSecurityRuleInputSchema>) => {
        const { zone_name, rule_id, description, expression, action, priority, paused } = UpdateSecurityRuleInputSchema.parse(params);
        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 body: any = { id: rule_id };
        if (description !== undefined) body.description = description;
        if (expression !== undefined) {
          // need to include filter id per Cloudflare API
          const existing = await client.get<any>(`/zones/${zoneId}/firewall/rules/${rule_id}`);
          const filterId = existing.filter?.id;
          body.filter = { id: filterId, expression };
        }
        if (action !== undefined) body.action = action;
        if (priority !== undefined) body.priority = priority;
        if (paused !== undefined) body.paused = paused;
    
        const updated = await client.put<typeof WafRuleSchema["_type"]>(`/zones/${zoneId}/firewall/rules/${rule_id}`, body);
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(updated, null, 2)
            }
          ]
        };
      },
    };
  • Registration of the update_security_rule tool (and related security tools) in the tools map returned by getSecurityTools function.
    return {
      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,
      },
    };
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. While 'update' implies a mutation, the description doesn't disclose critical traits such as required permissions, whether changes are reversible, rate limits, or what happens to unspecified fields. It also doesn't describe the response format or error conditions, which is a significant gap for a mutation tool.

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 directly states the tool's purpose without unnecessary words. It is appropriately sized and front-loaded, making it easy to parse quickly. Every part of the sentence earns its place by conveying essential information.

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 complexity of updating a security rule with 7 parameters, no annotations, and no output schema, the description is incomplete. It doesn't provide enough context for safe and effective use, such as behavioral details, parameter explanations, or output expectations. This is inadequate for a mutation tool with multiple undocumented parameters.

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?

The input schema has 7 parameters with 0% description coverage, meaning none are documented in the schema. The description adds no semantic information about parameters like 'action', 'expression', or 'priority', nor does it explain the required 'zone_name' and 'rule_id'. This fails to compensate for the schema's lack of documentation, leaving parameters largely unexplained.

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

Purpose3/5

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

The description states the verb ('update') and resource ('an existing firewall security rule'), which clarifies the basic purpose. However, it doesn't differentiate this tool from sibling tools like 'update_dns_record' or 'update_zone_settings' beyond the resource type, nor does it specify what aspects of the rule can be updated. This makes it somewhat vague compared to more specific descriptions.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an existing rule ID), exclusions, or comparisons to sibling tools like 'create_security_rule' or 'delete_security_rule'. This lack of context leaves the agent without clear usage instructions.

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