Skip to main content
Glama
anhhung04

DNSDumpster MCP Server

by anhhung04

get_cname_records

Retrieve CNAME records for a domain to identify canonical name mappings and detect subdomain relationships in DNS infrastructure.

Instructions

Get CNAME records for a domain.

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

Returns: Formatted string containing CNAME records

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
domainYes

Implementation Reference

  • The handler function decorated with @mcp.tool(), implementing the logic to fetch and format CNAME DNS records for a given domain using the DNSDumpster API. Includes input validation, error handling, and formatted output.
    @mcp.tool()
    async def get_cname_records(domain: str, ctx: Context) -> str:
        """Get CNAME records for a domain.
    
        Args:
            domain: The domain name to query (e.g., example.com)
            ctx: Request context
    
        Returns:
            Formatted string containing CNAME 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 CNAME records for {domain}")
                result = await client.get_dns_records(domain)
    
                if "cname" not in result or not result["cname"]:
                    return f"No CNAME records found for {domain}"
    
                output_lines = [f"CNAME Records for {domain}:"]
    
                for record in result["cname"]:
                    host = record.get("host", "")
                    target = record.get("target", "")
    
                    output_lines.append(f"\nHost: {host}")
                    output_lines.append(f"Target: {target}")
    
                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