Skip to main content
Glama
anhhung04

DNSDumpster MCP Server

by anhhung04

query_domain

Retrieve comprehensive DNS records for any domain, including subdomains, mail servers, and infrastructure details, using DNSDumpster's database.

Instructions

Query DNSDumpster for all DNS records related to a domain.

Args: domain: The domain name to query (e.g., example.com) ctx: Request context

Returns: JSON string containing all DNS records

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
domainYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function for the 'query_domain' tool. It handles input validation, API key retrieval, DNSDumpsterClient initialization, API call to fetch DNS records, and returns the result as JSON. Includes the @mcp.tool() decorator which registers the tool.
    @mcp.tool()
    async def query_domain(domain: str, ctx: Context) -> str:
        """Query DNSDumpster for all DNS records related to a domain.
    
        Args:
            domain: The domain name to query (e.g., example.com)
            ctx: Request context
    
        Returns:
            JSON string containing all DNS records
        """
        if not domain:
            return json.dumps({"error": "Domain is required"})
    
        # Validate domain
        if not is_valid_domain(domain):
            return json.dumps({"error": "Invalid domain name format"})
    
        try:
            api_key = os.environ.get("DNSDUMPSTER_API_KEY")
            if not api_key:
                return json.dumps(
                    {
                        "error": "API key not configured. Set DNSDUMPSTER_API_KEY environment variable."
                    }
                )
    
            client = DNSDumpsterClient(api_key)
    
            try:
                ctx.info(f"Querying DNS records for {domain}")
                result = await client.get_dns_records(domain)
                return json.dumps(result, indent=2)
            finally:
                await client.close()
    
        except Exception as e:
            return json.dumps({"error": str(e)})
  • Core helper class DNSDumpsterClient used by query_domain. Its get_dns_records method performs the actual API query with caching and rate limiting.
    class DNSDumpsterClient:
        """Client for the DNSDumpster API."""
    
        def __init__(self, api_key: str):
            """Initialize the DNSDumpster API client.
    
            Args:
                api_key: DNSDumpster API key
            """
            self.api_key = api_key
            self.api_base_url = "https://api.dnsdumpster.com/domain"
            self.rate_limiter = APIRateLimiter()
            self.cache = DNSCache()
            self.client = httpx.AsyncClient(timeout=30.0, headers={"X-API-Key": api_key})
    
        async def get_dns_records(self, domain: str, page: Optional[int] = None) -> DNSData:
            """Query the DNSDumpster API for a domain's DNS records.
    
            Args:
                domain: Domain name to query
                page: Page number for pagination (Plus accounts only)
    
            Returns:
                Dictionary containing DNS records
            """
            # Check cache first
            cache_key = f"{domain}:{page or 1}"
            cached_data = await self.cache.get(cache_key)
            if cached_data:
                return cached_data
    
            # Wait for rate limiting
            await self.rate_limiter.wait_for_rate_limit()
    
            # Build URL with query parameters
            url = f"{self.api_base_url}/{domain}"
            params = {}
    
            if page is not None:
                params["page"] = str(page)
    
            # Retry logic for network errors
            max_retries = 3
            retry_delay = 2.0
    
            for attempt in range(max_retries):
                try:
                    response = await self.client.get(url, params=params)
    
                    if response.status_code == 429:
                        # Handle rate limiting
                        retry_after = int(response.headers.get("Retry-After", "5"))
                        await asyncio.sleep(retry_after)
                        continue
    
                    response.raise_for_status()
                    data = response.json()
    
                    # Cache the response
                    await self.cache.set(cache_key, data)
    
                    return data
    
                except httpx.HTTPError as e:
                    if attempt == max_retries - 1:
                        raise Exception(f"Failed to query DNSDumpster API: {str(e)}")
    
                    # Exponential backoff
                    await asyncio.sleep(retry_delay * (2**attempt))
    
        async def close(self):
            """Close the HTTP client."""
            await self.client.aclose()
  • Helper function for domain validation used in the query_domain handler.
    def is_valid_domain(domain: str) -> bool:
        """Validate a domain name.
    
        Args:
            domain: Domain name to validate
    
        Returns:
            True if the domain is valid, False otherwise
        """
        pattern = r"^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$"
        return bool(re.match(pattern, domain))
  • server.py:184-187 (registration)
    Creation of the FastMCP instance 'mcp' to which tools are registered via decorators.
    mcp = FastMCP(
        "mcp-dnsdumpster",
        dependencies=["httpx"],
    )
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It mentions the data source (DNSDumpster) and return format (JSON string), but lacks details on rate limits, authentication needs, error handling, or whether this is a read-only operation. For a tool with no annotations, this leaves significant behavioral gaps.

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

Conciseness4/5

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

The description is front-loaded with the core purpose, followed by structured sections for Args and Returns. It is efficient but includes an extra 'ctx' parameter in the description that is not in the schema, slightly reducing clarity.

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

Completeness4/5

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

Given the tool has an output schema (though not shown), the description need not detail return values. It covers the purpose and parameter basics, but with no annotations and incomplete parameter coverage, it could benefit from more behavioral context to be fully complete.

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 0%, but the description adds value by explaining the 'domain' parameter with an example (e.g., example.com). However, it does not cover constraints like valid domain formats or the 'ctx' parameter mentioned in the description but not in the schema, leaving some ambiguity.

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 specific action ('Query DNSDumpster') and target resource ('all DNS records related to a domain'), distinguishing it from sibling tools that fetch specific record types (e.g., get_a_records, get_mx_records) rather than comprehensive results.

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

Usage Guidelines4/5

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

The description implies usage for retrieving all DNS records, but does not explicitly state when to use this tool versus the sibling tools that fetch specific record types (e.g., get_a_records for only A records). It provides clear context but lacks explicit alternatives or exclusions.

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/anhhung04/mcp-dnsdumpster'

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