Skip to main content
Glama

DNS MCP Server

by cenemil

batch_dns

Execute multiple DNS queries simultaneously to resolve domains and retrieve various record types (A, AAAA, MX, etc.) efficiently. Supports parallel processing and customizable timeout for streamlined DNS operations.

Instructions

Perform multiple DNS lookups in a single operation

Input Schema

NameRequiredDescriptionDefault
parallelNoExecute queries in parallel
queriesYesArray of DNS queries to perform
timeoutNoQuery timeout per request

Input Schema (JSON Schema)

{ "properties": { "parallel": { "default": true, "description": "Execute queries in parallel", "type": "boolean" }, "queries": { "description": "Array of DNS queries to perform", "items": { "properties": { "domain": { "type": "string" }, "recordTypes": { "items": { "enum": [ "A", "AAAA", "CNAME", "MX", "TXT", "NS", "SOA", "PTR", "SRV", "CAA" ], "type": "string" }, "type": "array" } }, "required": [ "domain", "recordTypes" ], "type": "object" }, "type": "array" }, "timeout": { "description": "Query timeout per request", "type": "number" } }, "required": [ "queries" ], "type": "object" }

Implementation Reference

  • Core implementation of batch DNS lookups, handling multiple queries in parallel or sequentially using the underlying DNS resolver.
    async batchLookup( queries: { domain: string; recordTypes: DnsRecordType[] }[], parallel: boolean = true ): Promise<{ results: DnsLookupResult[]; errors: DnsError[] }> { const results: DnsLookupResult[] = []; const errors: DnsError[] = []; const performQuery = async (domain: string, recordType: DnsRecordType) => { try { const result = await this.lookup(domain, recordType); results.push(result); } catch (error) { errors.push(error as DnsError); } }; const allQueries = queries.flatMap(q => q.recordTypes.map(rt => ({ domain: q.domain, recordType: rt })) ); if (parallel) { await Promise.all( allQueries.map(q => performQuery(q.domain, q.recordType)) ); } else { for (const q of allQueries) { await performQuery(q.domain, q.recordType); } } return { results, errors }; }
  • src/index.ts:93-131 (registration)
    Registers the 'batch_dns' tool with the MCP server, including name, description, and JSON input schema.
    { name: 'batch_dns', description: 'Perform multiple DNS lookups in a single operation', inputSchema: { type: 'object', properties: { queries: { type: 'array', items: { type: 'object', properties: { domain: { type: 'string' }, recordTypes: { type: 'array', items: { type: 'string', enum: ['A', 'AAAA', 'CNAME', 'MX', 'TXT', 'NS', 'SOA', 'PTR', 'SRV', 'CAA'] } } }, required: ['domain', 'recordTypes'] }, description: 'Array of DNS queries to perform' }, parallel: { type: 'boolean', default: true, description: 'Execute queries in parallel' }, timeout: { type: 'number', description: 'Query timeout per request' } }, required: ['queries'] } },
  • Zod schema used for input validation of the batch_dns tool in the handler.
    export const BatchDnsSchema = z.object({ queries: z.array(z.object({ domain: z.string().min(1), recordTypes: z.array(DnsRecordTypeSchema).min(1) })).min(1).max(50).describe('Array of DNS queries to perform'), parallel: z.boolean().default(true).describe('Execute queries in parallel'), timeout: z.number().min(100).max(30000).optional().describe('Query timeout per request') });
  • MCP tool request handler that validates input with BatchDnsSchema and calls DnsResolver.batchLookup, formats the response.
    case 'batch_dns': { const input = BatchDnsSchema.parse(args) as BatchDnsInput; const startTime = Date.now(); const { results, errors } = await dnsResolver.batchLookup( input.queries.map(q => ({ domain: q.domain, recordTypes: q.recordTypes as DnsRecordType[] })), input.parallel ); return { content: [ { type: 'text', text: JSON.stringify({ results, errors, totalTime: Date.now() - startTime, timestamp: new Date().toISOString() }, null, 2) } ] }; }
  • Type definitions for batch DNS query inputs and results used in the resolver.
    export interface BatchDnsQuery { domain: string; recordTypes: DnsRecordType[]; } export interface BatchDnsResult { results: DnsLookupResult[]; errors: DnsError[]; totalTime: number; }

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cenemil/dns-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server