get_ns_records
Retrieve nameserver records for any domain to identify DNS infrastructure and hosting details using DNSDumpster API.
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
| Name | Required | Description | Default |
|---|---|---|---|
| domain | Yes |
Implementation Reference
- server.py:405-464 (handler)The handler function for the 'get_ns_records' MCP tool. It is registered via @mcp.tool() decorator. Validates input domain, fetches DNS records from DNSDumpster API using the client, extracts and formats NS records with associated IP details, ASN info, etc., and returns a formatted string.@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)}"