Skip to main content
Glama
anhhung04

DNSDumpster MCP Server

by anhhung04

get_ns_records

Retrieve nameserver (NS) records for any domain to identify DNS infrastructure and hosting providers.

Instructions

Get NS (nameserver) records for a domain.

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

Returns: Formatted string containing NS records

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
domainYes

Implementation Reference

  • The handler function decorated with @mcp.tool() that implements the logic for retrieving and formatting NS records for a given domain using DNSDumpsterClient. Includes input validation and error handling.
    @mcp.tool()
    async def get_ns_records(domain: str, ctx: Context) -> str:
        """Get NS (nameserver) records for a domain.
    
        Args:
            domain: The domain name to query (e.g., example.com)
            ctx: Request context
    
        Returns:
            Formatted string containing NS records
        """
        if not domain:
            return "Error: Domain is required"
    
        # Validate domain
        if not is_valid_domain(domain):
            return "Error: Invalid domain name format"
    
        try:
            api_key = os.environ.get("DNSDUMPSTER_API_KEY")
            if not api_key:
                return "Error: API key not configured. Set DNSDUMPSTER_API_KEY environment variable."
    
            client = DNSDumpsterClient(api_key)
    
            try:
                ctx.info(f"Querying NS records for {domain}")
                result = await client.get_dns_records(domain)
    
                if "ns" not in result or not result["ns"]:
                    return f"No NS records found for {domain}"
    
                output_lines = [f"NS Records for {domain}:"]
    
                for record in result["ns"]:
                    host = record.get("host", "")
                    output_lines.append(f"\nHost: {host}")
    
                    for ip_info in record.get("ips", []):
                        ip = ip_info.get("ip", "")
                        country = ip_info.get("country", "Unknown")
                        asn = ip_info.get("asn", "")
                        asn_name = ip_info.get("asn_name", "")
                        asn_range = ip_info.get("asn_range", "")
    
                        output_lines.append(f"  IP: {ip}")
                        output_lines.append(f"  Country: {country}")
                        if asn:
                            output_lines.append(f"  ASN: {asn}")
                        if asn_name:
                            output_lines.append(f"  ASN Name: {asn_name}")
                        if asn_range:
                            output_lines.append(f"  ASN Range: {asn_range}")
    
                return "\n".join(output_lines)
            finally:
                await client.close()
    
        except Exception as e:
            return f"Error: {str(e)}"

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