dns-query
Query DNS records for a specific domain and record type, such as A, AAAA, MX, TXT, CNAME, or NS, using a standardized MCP interface for accurate results.
Instructions
Make a DNS query for a given name and type
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | The domain name to query | |
| type | Yes | The DNS record type (A, AAAA, MX, TXT, CNAME, NS, etc.) |
Implementation Reference
- src/server.ts:25-45 (handler)The handler function for the dns-query tool. It resolves the DNS records for the given domain name and type using Node.js dns/promises module, formats the result as JSON, and returns it as text content.async ({ name, type }) => { if (!name || !type) { // TODO: Validate inputs } const resolver = new dns.Resolver(); const records = await resolver.resolve(name, type); return { content: [ { type: "text", text: JSON.stringify({ domain: name, type: type, records: records, }), }, ], }; }
- src/server.ts:19-24 (schema)Zod schema defining the input parameters: 'name' (domain string) and 'type' (DNS record type string).{ name: z.string().describe("The domain name to query"), type: z .string() .describe("The DNS record type (A, AAAA, MX, TXT, CNAME, NS, etc.)"), },
- src/server.ts:16-46 (registration)Registration of the 'dns-query' tool on the MCP server using server.tool(), including description, input schema, and handler function.server.tool( "dns-query", "Make a DNS query for a given name and type", { name: z.string().describe("The domain name to query"), type: z .string() .describe("The DNS record type (A, AAAA, MX, TXT, CNAME, NS, etc.)"), }, async ({ name, type }) => { if (!name || !type) { // TODO: Validate inputs } const resolver = new dns.Resolver(); const records = await resolver.resolve(name, type); return { content: [ { type: "text", text: JSON.stringify({ domain: name, type: type, records: records, }), }, ], }; } );