dns-query
Query DNS records for domain names to retrieve information like IP addresses, mail servers, and text records using the MCP DNS server.
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 that performs the DNS query using Node.js dns/promises Resolver, resolves the records for the given name and type, and returns a structured text response with JSON-formatted results.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) and 'type' (DNS record 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.)"), },
- src/server.ts:16-46 (registration)Registration of the 'dns-query' tool using McpServer.tool(), including description, input schema, and inline 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, }), }, ], }; } );