get_txt_records
Retrieve TXT records for any domain to analyze DNS configurations, verify domain ownership, or examine security policies through DNS reconnaissance.
Instructions
Get TXT records for a domain.
Args: domain: The domain name to query (e.g., example.com) ctx: Request context
Returns: Formatted string containing TXT records
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| domain | Yes |
Implementation Reference
- server.py:467-509 (handler)The @mcp.tool() decorator registers this async handler function that implements the 'get_txt_records' tool. It validates the domain, fetches DNS records from DNSDumpster API via the client, extracts TXT records, formats them, and returns as a string.@mcp.tool() async def get_txt_records(domain: str, ctx: Context) -> str: """Get TXT records for a domain. Args: domain: The domain name to query (e.g., example.com) ctx: Request context Returns: Formatted string containing TXT 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 TXT records for {domain}") result = await client.get_dns_records(domain) if "txt" not in result or not result["txt"]: return f"No TXT records found for {domain}" output_lines = [f"TXT Records for {domain}:"] for txt in result["txt"]: output_lines.append(f"\n{txt}") return "\n".join(output_lines) finally: await client.close() except Exception as e: return f"Error: {str(e)}"