dns_trace
Trace the complete DNS resolution path from root servers to the final result for a specified domain and record type using the DNS MCP Server.
Instructions
Trace the DNS resolution path from root servers to the final result
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| domain | Yes | The domain to trace DNS resolution path | |
| recordType | No | The record type to trace | A |
Input Schema (JSON Schema)
{
"properties": {
"domain": {
"description": "The domain to trace DNS resolution path",
"type": "string"
},
"recordType": {
"default": "A",
"description": "The record type to trace",
"enum": [
"A",
"AAAA",
"CNAME",
"MX",
"TXT",
"NS",
"SOA",
"PTR",
"SRV",
"CAA"
],
"type": "string"
}
},
"required": [
"domain"
],
"type": "object"
}
Implementation Reference
- src/dns-resolver.ts:194-226 (handler)Core handler function that performs DNS tracing: resolves root NS, iteratively NS for domain parts from TLD up, final lookup.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/index.ts:228-247 (handler)MCP tool call handler: parses input with schema and delegates to DnsResolver.traceDns, 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) } ] }; }
- src/index.ts:132-151 (registration)Tool registration in TOOLS array with name, description, and inputSchema for MCP ListTools.{ 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/tools/schemas.ts:28-36 (schema)Zod schema for input validation (domain, optional recordType) and TypeScript type inference.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') }); export type DnsLookupInput = z.infer<typeof DnsLookupSchema>; export type ReverseDnsInput = z.infer<typeof ReverseDnsSchema>; export type BatchDnsInput = z.infer<typeof BatchDnsSchema>; export type DnsTraceInput = z.infer<typeof DnsTraceSchema>;