Skip to main content
Glama
cenemil

DNS MCP Server

by cenemil

dns_lookup

Perform DNS lookups to retrieve A, AAAA, MX, TXT, and other record types for domain analysis and troubleshooting.

Instructions

Perform DNS lookup for a domain to retrieve various record types (A, AAAA, MX, TXT, etc.)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
domainYesThe domain name to lookup
recordTypeNoThe type of DNS record to queryA
useCustomServerNoUse custom DNS server if configured
timeoutNoQuery timeout in milliseconds

Implementation Reference

  • Core implementation of the DNS lookup tool logic, handling different DNS record types (A, AAAA, CNAME, etc.) using Node.js 'dns/promises' Resolver class.
    async lookup(domain: string, recordType: DnsRecordType, timeout?: number): Promise<DnsLookupResult> {
      const startTime = Date.now();
      const records: DnsRecord[] = [];
      
      try {
        switch (recordType) {
          case 'A':
            const aRecords = await this.resolver.resolve4(domain, { ttl: true });
            records.push(...aRecords.map(r => ({
              type: 'A' as DnsRecordType,
              name: domain,
              value: r.address,
              ttl: r.ttl
            })));
            break;
            
          case 'AAAA':
            const aaaaRecords = await this.resolver.resolve6(domain, { ttl: true });
            records.push(...aaaaRecords.map(r => ({
              type: 'AAAA' as DnsRecordType,
              name: domain,
              value: r.address,
              ttl: r.ttl
            })));
            break;
            
          case 'CNAME':
            const cnameRecords = await this.resolver.resolveCname(domain);
            records.push(...cnameRecords.map(r => ({
              type: 'CNAME' as DnsRecordType,
              name: domain,
              value: r
            })));
            break;
            
          case 'MX':
            const mxRecords = await this.resolver.resolveMx(domain);
            records.push(...mxRecords.map(r => ({
              type: 'MX' as DnsRecordType,
              name: domain,
              value: r.exchange,
              priority: r.priority
            })));
            break;
            
          case 'TXT':
            const txtRecords = await this.resolver.resolveTxt(domain);
            records.push(...txtRecords.map(r => ({
              type: 'TXT' as DnsRecordType,
              name: domain,
              value: r.join('')
            })));
            break;
            
          case 'NS':
            const nsRecords = await this.resolver.resolveNs(domain);
            records.push(...nsRecords.map(r => ({
              type: 'NS' as DnsRecordType,
              name: domain,
              value: r
            })));
            break;
            
          case 'SOA':
            const soaRecord = await this.resolver.resolveSoa(domain);
            if (soaRecord) {
              records.push({
                type: 'SOA' as DnsRecordType,
                name: domain,
                value: JSON.stringify(soaRecord)
              });
            }
            break;
            
          case 'PTR':
            const ptrRecords = await this.resolver.resolvePtr(domain);
            records.push(...ptrRecords.map(r => ({
              type: 'PTR' as DnsRecordType,
              name: domain,
              value: r
            })));
            break;
            
          case 'SRV':
            const srvRecords = await this.resolver.resolveSrv(domain);
            records.push(...srvRecords.map(r => ({
              type: 'SRV' as DnsRecordType,
              name: domain,
              value: r.name,
              priority: r.priority,
              weight: r.weight,
              port: r.port
            })));
            break;
            
          case 'CAA':
            const caaRecords = await this.resolver.resolveCaa(domain);
            records.push(...caaRecords.map(r => ({
              type: 'CAA' as DnsRecordType,
              name: domain,
              value: `${r.critical ? '128' : '0'} ${r.issue || r.issuewild || r.iodef || ''}`
            })));
            break;
            
          default:
            throw new Error(`Unsupported record type: ${recordType}`);
        }
        
        return {
          domain,
          recordType,
          records,
          queryTime: Date.now() - startTime,
          server: this.config.servers[0],
          timestamp: new Date().toISOString()
        };
        
      } catch (error: any) {
        throw {
          code: error.code || 'UNKNOWN_ERROR',
          message: error.message || 'An unknown error occurred',
          domain,
          recordType
        } as DnsError;
      }
    }
  • Zod schema defining the input parameters for the dns_lookup tool, including domain, recordType, useCustomServer, and timeout.
    export const DnsLookupSchema = z.object({
      domain: z.string().min(1).describe('The domain name to lookup'),
      recordType: DnsRecordTypeSchema.default('A').describe('The type of DNS record to query'),
      useCustomServer: z.boolean().optional().describe('Use custom DNS server if configured'),
      timeout: z.number().min(100).max(30000).optional().describe('Query timeout in milliseconds')
    });
  • src/index.ts:47-74 (registration)
    Registration of the 'dns_lookup' tool in the MCP server's TOOLS array, including name, description, and input schema definition.
    {
      name: 'dns_lookup',
      description: 'Perform DNS lookup for a domain to retrieve various record types (A, AAAA, MX, TXT, etc.)',
      inputSchema: {
        type: 'object',
        properties: {
          domain: {
            type: 'string',
            description: 'The domain name to lookup'
          },
          recordType: {
            type: 'string',
            enum: ['A', 'AAAA', 'CNAME', 'MX', 'TXT', 'NS', 'SOA', 'PTR', 'SRV', 'CAA'],
            default: 'A',
            description: 'The type of DNS record to query'
          },
          useCustomServer: {
            type: 'boolean',
            description: 'Use custom DNS server if configured'
          },
          timeout: {
            type: 'number',
            description: 'Query timeout in milliseconds'
          }
        },
        required: ['domain']
      }
    },
  • MCP server request handler case for 'dns_lookup', which parses input using DnsLookupSchema and delegates to DnsResolver.lookup.
    case 'dns_lookup': {
      const input = DnsLookupSchema.parse(args) as DnsLookupInput;
      logger.info(`DNS lookup request for ${input.domain} (${input.recordType})`);
      const result = await dnsResolver.lookup(
        input.domain,
        input.recordType as DnsRecordType,
        input.timeout
      );
      logger.debug('DNS lookup result', result);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2)
          }
        ]
      };
    }
  • TypeScript interface defining the output structure of the dns_lookup tool.
    export interface DnsLookupResult {
      domain: string;
      recordType: DnsRecordType;
      records: DnsRecord[];
      queryTime: number;
      server?: string;
      timestamp: string;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions retrieving various record types but fails to describe critical behaviors like error handling, rate limits, authentication needs, or what happens if a record type is unsupported. For a tool with multiple parameters and no annotations, this leaves significant gaps in understanding how it operates.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core action ('perform DNS lookup') and includes key details (domain, record types). There is no wasted text, and it directly communicates the tool's function without redundancy or unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (4 parameters, no output schema, no annotations), the description is incomplete. It lacks information on output format, error conditions, performance characteristics, and how it differs from sibling tools. Without annotations or output schema, the description should provide more context to guide effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents all four parameters. The description adds minimal value beyond the schema by listing example record types (A, AAAA, MX, TXT, etc.), which aligns with the enum in the schema. No additional syntax, format details, or constraints are provided, meeting the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'perform DNS lookup' and resource 'domain' with specific examples of record types (A, AAAA, MX, TXT, etc.). It distinguishes the core lookup function from siblings like batch_dns (batch operations), dns_trace (tracing), and reverse_dns (reverse lookups), though it doesn't explicitly name these alternatives. The purpose is specific and actionable.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus sibling tools like batch_dns, dns_trace, or reverse_dns. It lacks context about use cases, prerequisites, or exclusions, such as when to choose batch_dns for multiple domains or reverse_dns for IP-to-domain lookups. Usage is implied but not explicitly stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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