Skip to main content
Glama

DNS MCP Server

A DNS query MCP server built with FastMCP, supporting cross-platform operation (Windows/Linux/macOS) and customizable upstream DNS servers.

Features

  • πŸ” Support for multiple DNS record types (A, AAAA, MX, CNAME, TXT, NS, SOA)

  • 🌐 Cross-platform support (Windows/Linux/macOS)

  • βš™οΈ Configurable upstream DNS servers via environment variables or command line parameters

  • πŸš€ High performance using FastMCP framework

  • πŸ“¦ Dependency management with uv

Related MCP server: DNS MCP Server

Installation

uv sync

Using pip

pip install -r requirements.txt

Usage

1. Using System Default DNS Servers

Using uv:

uv run dns-mcp

Using Python:

python -m dns_mcp.server

2. Specifying DNS Servers via Command Line

Using uv:

uv run dns-mcp --dns-servers 8.8.8.8 1.1.1.1

Using Python:

python -m dns_mcp.server --dns-servers 8.8.8.8 1.1.1.1

3. Specifying DNS Servers via Environment Variables

# Windows
set DNS_MCP_SERVERS=8.8.8.8,1.1.1.1

# Linux/macOS
export DNS_MCP_SERVERS=8.8.8.8,1.1.1.1

Then run:

# Using uv
uv run dns-mcp

# Using Python
python -m dns_mcp.server

MCP Tools

dns_query

Query DNS records for a specified hostname.

Install

"mcpServers": {
    "dns-mcp": {
      "command": "uv",
      "args": [
        "--directory", "PATH_TO_SOURCES",
        "run", "dns-mcp"
      ]
    }
}

Parameters

  • host (required): The hostname to query (e.g., 'example.com')

  • type (optional): DNS record type, defaults to 'A'

Supported Record Types

  • A: IPv4 address records

  • AAAA: IPv6 address records

  • MX: Mail exchange records

  • CNAME: Canonical name records

  • TXT: Text records

  • NS: Name server records

  • SOA: Start of authority records

Response Format

{
  "host": "example.com",
  "type": "A",
  "success": true,
  "records": ["93.184.216.34"],
  "ttl": 86400,
  "upstream_servers": ["8.8.8.8", "8.8.4.4"]
}

Usage Examples

# Query A record
result = await dns_query("example.com")

# Query MX record
result = await dns_query("example.com", "MX")

# Query TXT record
result = await dns_query("example.com", "TXT")

Configuration Options

Environment Variables

  • DNS_MCP_SERVERS: Comma-separated list of upstream DNS servers

Command Line Arguments

  • --dns-servers: Specify upstream DNS servers (space-separated)

  • --port: Specify MCP server port (default: 3000)

System DNS Server Detection

The server automatically detects system DNS configuration:

  • Windows: Uses nslookup command to get system DNS settings

  • Linux: Reads /etc/resolv.conf file

  • macOS: Uses scutil --dns and networksetup commands to detect DNS servers

  • Fallback: If system settings cannot be detected, falls back to Google Public DNS (8.8.8.8, 8.8.4.4)

Development

Install Development Dependencies

uv sync --dev

License

MIT License

Example Client

Here's a simple client example demonstrating how to use this DNS MCP server:

import asyncio
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client

async def main():
    server_params = StdioServerParameters(
        command="uv",
        args=["run", "dns-mcp"]
    )
    
    async with stdio_client(server_params) as (read, write):
        async with ClientSession(read, write) as session:
            # Initialize connection
            await session.initialize()
            
            # Query A record
            result = await session.call_tool("dns_query", {
                "host": "example.com",
                "type": "A"
            })
            print(f"A record: {result}")
            
            # Query MX record
            result = await session.call_tool("dns_query", {
                "host": "example.com", 
                "type": "MX"
            })
            print(f"MX record: {result}")

if __name__ == "__main__":
    asyncio.run(main())

Contributing

Pull requests and issue reports are welcome!

Available Tools

1 tool
dns_queryDns QueryB

Query DNS records for a hostname.

Inputs: host (required), type. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 1 tool

    Disambiguation5/5

    There is only one tool, so there are no overlapping purposes or selection ambiguity. An agent cannot confuse dns_query with another operation in this server.

    Naming Consistency5/5

    The sole tool uses clear snake_case naming. With only one tool there is no inconsistent convention to compare against.

    Tool Count3/5

    A single-tool DNS server is borderline thin. It may cover basic lookups, but the surface feels under-scoped for a general DNS MCP server.

    Completeness3/5

    The tool supports forward DNS record queries, but obvious complementary operations such as reverse lookup or DNS diagnostics are absent. It is usable for basic querying but leaves notable gaps.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      D
      maintenance
      A Model Context Protocol tool that provides DNS querying capabilities for various record types (A, AAAA, MX, TXT, CNAME, NS, etc.) through a standardized MCP interface.
      1
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Enables comprehensive DNS operations including lookups for various record types, reverse DNS queries, batch processing, and DNS resolution tracing. Supports multiple DNS servers with configurable caching and robust error handling.
      4
      11 npm
      2
      MIT
    • F
      license
      Not graded
      quality
      C
      maintenance
      A comprehensive DNS query server that enables querying all types of DNS records, including A, AAAA, MX, TXT, NS, CNAME, SOA, PTR, SRV, CAA, and DNSSEC checks, as well as advanced tools like WHOIS-style lookup and DNS delegation tracing.
      1
      -