Skip to main content
Glama

dns_lookup

Resolve DNS records for any hostname, including A, AAAA, MX, TXT, NS, and CNAME types.

Instructions

Look up DNS records for a hostname. record_type: A, AAAA, MX, TXT, NS, CNAME.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
hostYes
record_typeNoA

Implementation Reference

  • The dns_lookup function is registered as an MCP tool via the @mcp.tool() decorator on line 38. This is both the registration and the handler.
    @mcp.tool()
    def dns_lookup(host: str, record_type: str = "A") -> dict:
        """Look up DNS records for a hostname. record_type: A, AAAA, MX, TXT, NS, CNAME."""
        try:
            answers = dns.resolver.resolve(host, record_type)
            return {
                "host": host,
                "record_type": record_type,
                "records": [str(r) for r in answers],
            }
        except Exception as e:
            return {"error": str(e), "tool": "dns_lookup", "host": host}
  • The dns_lookup function implements the core DNS lookup logic. It takes a host (string) and optional record_type (default 'A'), uses dns.resolver.resolve to query DNS, and returns host, record_type, and records list. On error, it returns an error dict with tool name 'dns_lookup'.
    @mcp.tool()
    def dns_lookup(host: str, record_type: str = "A") -> dict:
        """Look up DNS records for a hostname. record_type: A, AAAA, MX, TXT, NS, CNAME."""
        try:
            answers = dns.resolver.resolve(host, record_type)
            return {
                "host": host,
                "record_type": record_type,
                "records": [str(r) for r in answers],
            }
        except Exception as e:
            return {"error": str(e), "tool": "dns_lookup", "host": host}
  • The function signature defines the input schema: host (str, required) and record_type (str, default 'A') with docstring listing supported types: A, AAAA, MX, TXT, NS, CNAME.
    def dns_lookup(host: str, record_type: str = "A") -> dict:
  • Import of dns.resolver (dnspython library) which is the helper dependency used to perform DNS resolutions in dns_lookup.
    import dns.resolver
Behavior2/5

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

No annotations are provided, so the description must fully convey behavior. It does not mention what happens on invalid hostnames or record types, error responses, or output format. The read nature is implied but not confirmed.

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 extremely concise (12 words) and front-loaded with the action and resource, followed by the key parameter guidance. Every word earns its place.

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

Completeness3/5

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

Given no output schema, the description should clarify what the return value looks like (e.g., list of IP addresses or records). It also lacks error handling context. However, for a simple DNS lookup, the basic information suffices.

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

Parameters4/5

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

The description adds value by listing allowed values for record_type (A, AAAA, MX, TXT, NS, CNAME), which is absent from the input schema (no enum). This helps the agent choose a valid record type. The host parameter is not elaborated, but schema coverage is 0%, so the description partially compensates.

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

Purpose5/5

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

The description clearly states the verb 'look up' and the resource 'DNS records for a hostname', and lists the supported record types (A, AAAA, MX, TXT, NS, CNAME). This differentiates it from sibling tools like ping or traceroute.

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?

No guidance is provided on when to use this tool vs alternatives. Since siblings include other network diagnostic tools, explicit when-to-use instructions are missing.

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/aaronckj/mcp-nettools'

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