cloudflare-dns-mcp_delete_security_rule
Remove a firewall security rule by specifying the zone name and rule ID, ensuring precise management of your Cloudflare DNS and security settings.
Instructions
Delete a firewall security rule
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| rule_id | Yes | ||
| zone_name | Yes |
Implementation Reference
- src/tools/security.ts:165-181 (handler)Handler function that parses input, resolves the Cloudflare zone ID from zone_name, deletes the WAF security rule by rule_id using the CloudflareClient, and returns a formatted MCP response confirming deletion.handler: async (params: z.infer<typeof DeleteSecurityRuleInputSchema>) => { const { zone_name, rule_id } = DeleteSecurityRuleInputSchema.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 resp = await client.delete<{ id: string }>(`/zones/${zoneId}/firewall/rules/${rule_id}`); return { content: [ { type: "text", text: JSON.stringify({ id: resp.id ?? rule_id, deleted: true }, null, 2) } ] }; }, };
- src/tools/security.ts:150-153 (schema)Zod schema defining the input parameters: zone_name (string) and rule_id (string) for the tool.const DeleteSecurityRuleInputSchema = z.object({ zone_name: z.string(), rule_id: z.string(), });
- src/tools/security.ts:184-190 (registration)The delete_security_rule tool is registered within the tools object returned by getSecurityTools function.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:18-32 (registration)Higher-level registration where securityTools (including delete_security_rule) are merged into the allTools object for the MCP server.const dnsTools = getDnsTools(cfClient); 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, ...sslCertTools.tools, ...echoTools.tools, ...redirectTools.tools, ...zoneTools.tools, } as Record<string, any>;