dns_trace
Trace DNS resolution paths from root servers to final results to diagnose DNS issues and understand domain delegation chains.
Instructions
Trace the DNS resolution path from root servers to the final result
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| domain | Yes | The domain to trace DNS resolution path | |
| recordType | No | The record type to trace | A |
Implementation Reference
- src/dns-resolver.ts:194-226 (handler)The core handler function traceDns in DnsResolver class that performs DNS tracing from root servers through delegation chain to final resolution.async traceDns(domain: string, recordType: DnsRecordType = 'A'): Promise<any> { const trace: any[] = []; try { const rootServers = await this.resolver.resolveNs('.'); trace.push({ level: 'root', servers: rootServers }); const parts = domain.split('.').reverse(); let currentDomain = ''; for (const part of parts) { currentDomain = currentDomain ? `${part}.${currentDomain}` : part; try { const nsRecords = await this.resolver.resolveNs(currentDomain); trace.push({ level: currentDomain, servers: nsRecords }); } catch (error) { break; } } const finalResult = await this.lookup(domain, recordType); trace.push({ level: 'final', result: finalResult }); return trace; } catch (error: any) { throw { code: 'TRACE_FAILED', message: error.message || 'DNS trace failed', domain, recordType } as DnsError; } }
- src/tools/schemas.ts:28-31 (schema)Zod schema defining input for dns_trace tool: domain (required) and optional recordType.export const DnsTraceSchema = z.object({ domain: z.string().min(1).describe('The domain to trace DNS resolution path'), recordType: DnsRecordTypeSchema.default('A').describe('The record type to trace') });
- src/index.ts:132-151 (registration)Tool registration in TOOLS array, defining name, description, and inputSchema for dns_trace.{ name: 'dns_trace', description: 'Trace the DNS resolution path from root servers to the final result', inputSchema: { type: 'object', properties: { domain: { type: 'string', description: 'The domain to trace DNS resolution path' }, recordType: { type: 'string', enum: ['A', 'AAAA', 'CNAME', 'MX', 'TXT', 'NS', 'SOA', 'PTR', 'SRV', 'CAA'], default: 'A', description: 'The record type to trace' } }, required: ['domain'] } }
- src/index.ts:228-247 (handler)Dispatcher handler case in CallToolRequestSchema that parses input, calls dnsResolver.traceDns, and formats response.case 'dns_trace': { const input = DnsTraceSchema.parse(args) as DnsTraceInput; const trace = await dnsResolver.traceDns( input.domain, input.recordType as DnsRecordType ); return { content: [ { type: 'text', text: JSON.stringify({ domain: input.domain, recordType: input.recordType, trace, timestamp: new Date().toISOString() }, null, 2) } ] }; }