dns_lookup
Resolve DNS records for domains to analyze infrastructure, verify configurations, and investigate network security. Supports A, AAAA, MX, TXT, NS, SOA, CNAME, and SRV record types.
Instructions
Resolve DNS records for a domain. Supports A, AAAA, MX, TXT, NS, SOA, CNAME, SRV record types.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| domain | Yes | Domain name to query | |
| type | Yes | DNS record type |
Implementation Reference
- src/dns/index.ts:71-125 (handler)The main implementation of the dns_lookup tool handler, which uses Node's native dns/promises module to resolve various DNS record types.
export async function dnsLookup(domain: string, type: string): Promise<DnsRecord[]> { const records: DnsRecord[] = []; switch (type.toUpperCase()) { case "A": { const ips = await dns.resolve4(domain); for (const ip of ips) records.push({ type: "A", value: ip }); break; } case "AAAA": { const ips = await dns.resolve6(domain); for (const ip of ips) records.push({ type: "AAAA", value: ip }); break; } case "MX": { const mxs = await dns.resolveMx(domain); for (const mx of mxs) records.push({ type: "MX", value: mx.exchange, priority: mx.priority }); break; } case "TXT": { const txts = await dns.resolveTxt(domain); for (const txt of txts) records.push({ type: "TXT", value: txt.join("") }); break; } case "NS": { const nss = await dns.resolveNs(domain); for (const ns of nss) records.push({ type: "NS", value: ns }); break; } case "SOA": { const soa = await dns.resolveSoa(domain); records.push({ type: "SOA", value: `${soa.nsname} ${soa.hostmaster} ${soa.serial} ${soa.refresh} ${soa.retry} ${soa.expire} ${soa.minttl}`, }); break; } case "CNAME": { const cname = await dns.resolveCname(domain); for (const c of cname) records.push({ type: "CNAME", value: c }); break; } case "SRV": { const srvs = await dns.resolveSrv(domain); for (const s of srvs) { records.push({ type: "SRV", value: s.name, priority: s.priority, weight: s.weight, port: s.port }); } break; } default: throw new Error(`Unsupported DNS record type: ${type}`); } return records; } - src/protocol/tools.ts:27-36 (registration)Registration of the dns_lookup tool in the MCP protocol tools definition file.
const dnsLookupTool: ToolDef = { name: "dns_lookup", description: "Resolve DNS records for a domain. Supports A, AAAA, MX, TXT, NS, SOA, CNAME, SRV record types.", schema: { domain: z.string().describe("Domain name to query"), type: z.enum(["A", "AAAA", "MX", "TXT", "NS", "SOA", "CNAME", "SRV"]).describe("DNS record type"), }, execute: async (args) => json(await dnsLookup(args.domain as string, args.type as string)), };