get_dns_record
Retrieve a specific DNS record by its unique ID using this tool, designed for managing Cloudflare DNS records through the MCP Cloudflare DNS Server.
Instructions
Get a specific DNS record by ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| recordId | Yes | The DNS record ID |
Implementation Reference
- src/index.ts:236-266 (handler)The MCP tool handler for 'get_dns_record'. Configures API, fetches record via CloudflareApi.getDnsRecord, formats and returns text response.const handleGetDnsRecord = async (args: { recordId: string }) => { try { if (!configureApiIfNeeded()) { return { content: [{ type: "text", text: "❌ Configuration incomplete. Please configure Cloudflare API Token and Zone ID first." }], }; } const record = await CloudflareApi.getDnsRecord(args.recordId); return { content: [{ type: "text", text: `✅ DNS Record Details: 🔹 Name: ${record.name} 🔹 Type: ${record.type} 🔹 Content: ${record.content} 🔹 TTL: ${record.ttl} 🔹 Proxied: ${record.proxied ? 'Yes' : 'No'} ${record.priority ? `🔹 Priority: ${record.priority}` : ''} 🔹 ID: ${record.id} 🔹 Created: ${new Date(record.created_on).toLocaleString()} 🔹 Modified: ${new Date(record.modified_on).toLocaleString()}` }], }; } catch (error) { return { content: [{ type: "text", text: `❌ Error getting DNS record: ${error instanceof Error ? error.message : 'Unknown error'}` }], }; } };
- src/api.ts:136-149 (helper)Core Cloudflare API helper that makes the HTTP GET request to retrieve a specific DNS record by its ID.getDnsRecord: async (recordId: string): Promise<DnsRecord> => { const response = await api(`dns_records/${recordId}`); const data = CloudflareApiResponse.parse(await response.json()); if (!data.success) { throw new Error(`API Error: ${data.errors.map(e => e.message).join(', ')}`); } if (!data.result || Array.isArray(data.result)) { throw new Error('DNS record not found'); } return data.result; },
- src/index.ts:67-80 (registration)Tool registration in the ListTools response, defining name, description, and input schema for 'get_dns_record'.{ name: "get_dns_record", description: "Get a specific DNS record by ID", inputSchema: { type: "object", properties: { recordId: { type: "string", description: "The DNS record ID", }, }, required: ["recordId"], }, },
- src/index.ts:67-80 (schema)Input schema definition for the 'get_dns_record' tool as part of its registration.{ name: "get_dns_record", description: "Get a specific DNS record by ID", inputSchema: { type: "object", properties: { recordId: { type: "string", description: "The DNS record ID", }, }, required: ["recordId"], }, },