delete_dns_record
Remove DNS records to manage domain configurations. Deletes specific records by ID across providers like GoDaddy, Cloudflare, Namecheap, and Porkbun.
Instructions
Delete a DNS record. On GoDaddy, deletes ALL records of same type+name (API limitation).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| domain | Yes | ||
| id | Yes | Record ID from list_dns_records | |
| provider | No | Provider name, or omit to auto-detect |
Implementation Reference
- src/tools/dns.ts:41-46 (handler)Main handler function `handleDeleteDnsRecord` that executes the delete_dns_record tool logic. It resolves the provider, checks DNS write permissions, and calls the provider's deleteDNSRecord method.
export async function handleDeleteDnsRecord(input: { domain: string; id: string; provider?: string }, registry: ProviderRegistry) { const provider = input.provider ? registry.get(input.provider) : await registry.resolveProviderForDomain(input.domain); assertDnsWrite(provider.name(), (f) => provider.supports(f)); await provider.deleteDNSRecord(input.domain, input.id); return { success: true, id: input.id, domain: input.domain }; } - src/server.ts:171-183 (registration)Registration of the 'delete_dns_record' tool with the MCP server. Defines the tool name, description, input schema (domain, id, provider), and imports/calls the handler function.
server.tool('delete_dns_record', 'Delete a DNS record. On GoDaddy, deletes ALL records of same type+name (API limitation).', { domain: domainSchema, id: z.string().min(1).describe('Record ID from list_dns_records'), provider: z.string().optional().describe('Provider name, or omit to auto-detect'), }, async (input) => { try { const { handleDeleteDnsRecord } = await import('./tools/dns.js'); const result = await handleDeleteDnsRecord(input as { domain: string; id: string; provider?: string }, registry); return { content: [{ type: 'text', text: JSON.stringify(result) }] }; } catch (err) { return { content: [{ type: 'text', text: formatErrorForAgent(err) }], isError: true }; } }); - src/server.ts:10-15 (schema)Definition of `domainSchema` using Zod - validates domain names with RFC 1123 compliant regex pattern. Used in the tool's input schema for the domain parameter.
const domainSchema = z .string() .regex( /^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/, 'Must be a valid domain name (e.g. example.com)', ); - src/providers/types.ts:95-95 (schema)Interface definition for `deleteDNSRecord` method in the Provider interface, defining the contract that all provider implementations must follow.
deleteDNSRecord(domain: string, recordId: string): Promise<void>; - GoDaddy provider implementation of deleteDNSRecord. Shows provider-specific logic including parsing the recordId format 'TYPE-name' and handling GoDaddy API limitations.
async deleteDNSRecord(domain: string, recordId: string): Promise<void> { // GoDaddy v1 DELETE removes all records for a type+name set (API limitation). // The recordId format is "TYPE-name". const dashIdx = recordId.indexOf('-'); if (dashIdx === -1) { throw new AgentError( 'INVALID_RECORD_ID', `Invalid record ID format: '${recordId}'. Expected 'TYPE-name'.`, 'Use list_dns_records to get valid record IDs.', 'godaddy', ); } const type = recordId.substring(0, dashIdx); const name = recordId.substring(dashIdx + 1); await this.client.deleteDNSRecord(domain, type, name); }