dns_lookup
Resolve DNS records for a domain, supporting A, AAAA, MX, TXT, NS, SOA, CNAME, and SRV types.
Instructions
Resolve DNS records for a domain. Supports A, AAAA, MX, TXT, NS, SOA, CNAME, SRV record types.
Input 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 core implementation of dns_lookup. Uses Node.js built-in node:dns/promises to resolve DNS records. Supports A, AAAA, MX, TXT, NS, SOA, CNAME, and SRV record types. Returns an array of DnsRecord objects.
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-35 (schema)Tool definition and schema for dns_lookup. Defines the tool name 'dns_lookup', description, Zod schema for 'domain' (string) and 'type' (enum of A/AAAA/MX/TXT/NS/SOA/CNAME/SRV), and the execute handler that calls dnsLookup().
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)), }; - src/protocol/tools.ts:481-488 (registration)Registration of dns_lookup in the exported allTools array. The dnsLookupTool is included as the first entry in the DNS tools group (line 483).
export const allTools: ToolDef[] = [ // DNS (6) dnsLookupTool, dnsReverseTool, dnsEmailSecurityTool, dnsSpfChainTool, dnsSrvDiscoverTool, dnsWildcardCheckTool, - src/protocol/tools.ts:8-8 (helper)Import of the dnsLookup function from src/dns/index.js into the tools registry module.
import { dnsLookup, dnsReverse, dnsEmailSecurity, dnsSpfChain, dnsSrvDiscover, dnsWildcardCheck } from "../dns/index.js"; - src/index.ts:24-26 (registration)CLI category listing that includes 'dns_lookup' in the DNS tool group (no API key required). Also referenced in example usage on line 53.
label: "DNS", env: null, tools: ["dns_lookup", "dns_reverse", "dns_email_security", "dns_spf_chain", "dns_srv_discover", "dns_wildcard_check"],