cloudflare-dns-mcp_delete_dns_record
Remove a DNS record from a specified zone using its unique ID, enabling streamlined DNS management within the Cloudflare MCP Server.
Instructions
Delete a DNS record by ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| record_id | Yes | ||
| zone_name | Yes |
Implementation Reference
- src/tools/dns-records.ts:239-253 (handler)The core handler function that validates input parameters, looks up the zone ID from the zone name, and performs the DELETE request to Cloudflare's DNS records API endpoint.handler: async (params: z.infer<typeof DeleteDnsRecordInputSchema>) => { const { zone_name, record_id } = DeleteDnsRecordInputSchema.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; await client.delete(`/zones/${zoneId}/dns_records/${record_id}`); return { content: [ { type: "text", text: JSON.stringify({ success: true, id: record_id }, null, 2) } ] }; },
- src/tools/dns-records.ts:233-233 (schema)Zod input schema defining required parameters: zone_name (string) and record_id (string). Converted to JSON schema for the tool's inputSchema.const DeleteDnsRecordInputSchema = z.object({ zone_name: z.string(), record_id: z.string() });
- src/tools/dns-records.ts:338-338 (registration)Local registration of the tool object in the getDnsTools() return value using the slash-separated name.'cloudflare-dns-mcp/delete_dns_record': deleteDnsRecordTool,
- src/index.ts:18-32 (registration)Main server registration: calls getDnsTools and spreads DNS tools into the combined allTools map used for MCP server toolset.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>;
- src/index.ts:50-52 (helper)Helper function that sanitizes tool names, replacing '/' with '_', creating the exact queried name 'cloudflare-dns-mcp_delete_dns_record' from 'cloudflare-dns-mcp/delete_dns_record'.const safeName = tool.name.replace(/[^a-zA-Z0-9_-]/g, '_'); toolsMap[safeName] = tool; }