Skip to main content
Glama
anhhung04

DNSDumpster MCP Server

by anhhung04

get_a_records

Retrieve A records for a domain to identify associated IP addresses and analyze DNS infrastructure using the DNSDumpster MCP Server.

Instructions

Get A records for a domain.

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

Returns: Formatted string containing A records

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
domainYes

Implementation Reference

  • The @mcp.tool() decorator registers the get_a_records tool, and the function implements its core logic: validates domain, fetches DNS records from DNSDumpster API, filters A records, and formats output with IP details, ASN info, and banner data (HTTP/HTTPS).
    @mcp.tool()
    async def get_a_records(domain: str, ctx: Context) -> str:
        """Get A records for a domain.
    
        Args:
            domain: The domain name to query (e.g., example.com)
            ctx: Request context
    
        Returns:
            Formatted string containing A 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 A records for {domain}")
                result = await client.get_dns_records(domain)
    
                if "a" not in result or not result["a"]:
                    return f"No A records found for {domain}"
    
                output_lines = [f"A Records for {domain}:"]
    
                for record in result["a"]:
                    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}")
    
                        # If banner information is available
                        if "banners" in ip_info:
                            output_lines.append("  Banners:")
                            banners = ip_info["banners"]
    
                            if "http" in banners:
                                http_banner = banners["http"]
                                output_lines.append("    HTTP:")
    
                                if "title" in http_banner:
                                    output_lines.append(
                                        f"      Title: {http_banner['title']}"
                                    )
    
                                if "server" in http_banner:
                                    output_lines.append(
                                        f"      Server: {http_banner['server']}"
                                    )
    
                                if "apps" in http_banner:
                                    output_lines.append(
                                        f"      Apps: {', '.join(http_banner['apps'])}"
                                    )
    
                            if "https" in banners:
                                https_banner = banners["https"]
                                output_lines.append("    HTTPS:")
    
                                if "title" in https_banner:
                                    output_lines.append(
                                        f"      Title: {https_banner['title']}"
                                    )
    
                                if "server" in https_banner:
                                    output_lines.append(
                                        f"      Server: {https_banner['server']}"
                                    )
    
                                if "apps" in https_banner:
                                    output_lines.append(
                                        f"      Apps: {', '.join(https_banner['apps'])}"
                                    )
    
                                if "cn" in https_banner:
                                    output_lines.append(f"      CN: {https_banner['cn']}")
    
                                if "alt_n" in https_banner:
                                    output_lines.append(
                                        f"      Alt Names: {', '.join(https_banner['alt_n'])}"
                                    )
    
                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