Skip to main content
Glama
gilberth

MCP Cloudflare DNS Server

delete_dns_record

Remove a specified DNS record from Cloudflare by providing its ID using this tool on the MCP Cloudflare DNS Server.

Instructions

Delete a DNS record

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
recordIdYesThe DNS record ID to delete

Implementation Reference

  • The primary handler function for the 'delete_dns_record' tool in the MCP server. It checks configuration, calls the Cloudflare API via CloudflareApi.deleteDnsRecord, handles errors, and returns a formatted response.
    const handleDeleteDnsRecord = async (args: { recordId: string }) => { try { if (!configureApiIfNeeded()) { return { content: [{ type: "text", text: "❌ Configuration incomplete. Please configure Cloudflare API Token and Zone ID first." }], }; } await CloudflareApi.deleteDnsRecord(args.recordId); return { content: [{ type: "text", text: `✅ DNS record deleted successfully! (ID: ${args.recordId})` }], }; } catch (error) { return { content: [{ type: "text", text: `❌ Error deleting DNS record: ${error instanceof Error ? error.message : 'Unknown error'}` }], }; } };
  • Core helper function that performs the actual HTTP DELETE request to Cloudflare's API to delete the DNS record by ID, including response validation.
    deleteDnsRecord: async (recordId: string): Promise<void> => { const response = await api(`dns_records/${recordId}`, 'DELETE'); const data = CloudflareApiResponse.parse(await response.json()); if (!data.success) { throw new Error(`API Error: ${data.errors.map(e => e.message).join(', ')}`); } },
  • src/index.ts:157-170 (registration)
    Registration of the 'delete_dns_record' tool in the MCP server's listTools response, including name, description, and input schema.
    { name: "delete_dns_record", description: "Delete a DNS record", inputSchema: { type: "object", properties: { recordId: { type: "string", description: "The DNS record ID to delete", }, }, required: ["recordId"], }, },
  • src/index.ts:195-197 (registration)
    Dispatch logic in the MCP CallToolRequestHandler that routes calls to 'delete_dns_record' to the appropriate handler function.
    if (name === "delete_dns_record") { return await handleDeleteDnsRecord(args as { recordId: string }); }
  • Response validation using CloudflareApiResponse schema after the DELETE API call.
    const data = CloudflareApiResponse.parse(await response.json()); if (!data.success) { throw new Error(`API Error: ${data.errors.map(e => e.message).join(', ')}`); } },

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/gilberth/mcp-cloudflare'

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