Skip to main content
Glama
anhhung04

DNSDumpster MCP Server

by anhhung04

get_txt_records

Retrieve TXT records for any domain to analyze DNS configurations, verify domain ownership, or check for security settings like SPF and DMARC policies.

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
NameRequiredDescriptionDefault
domainYes

Implementation Reference

  • The main handler function for the 'get_txt_records' tool. It validates the domain, fetches DNS records from DNSDumpster API using the client, extracts TXT records, formats them, and returns as a string. Includes the @mcp.tool() decorator which registers it as an MCP tool.
    @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)}"

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