get_cname_records
Retrieve CNAME records for any domain to identify canonical name mappings and discover 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
| Name | Required | Description | Default |
|---|---|---|---|
| domain | Yes |
Implementation Reference
- server.py:513-558 (handler)The asynchronous handler function that implements the logic for the 'get_cname_records' tool. It queries the DNSDumpster API for CNAME records of a given domain, validates input, handles errors, and formats the output.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)}"
- server.py:512-512 (registration)The @mcp.tool() decorator registers the 'get_cname_records' function as an MCP tool, with the tool name inferred from the function name.@mcp.tool()