Skip to main content
Glama

dns-mcp

Mentioned in Awesome MCP Servers r0bin2u/dns-mcp MCP server

一个 Model Context Protocol 服务器,允许任何 MCP 客户端(Claude Desktop、Claude Code、Cursor 等)在对话中进行 DNS、WHOIS 和 IP 地理位置查询。

询问 Claude “为什么 foo.com 在东京无法访问?”,它无需离开聊天界面即可实际查询记录、检查 WHOIS 并定位 IP 的地理位置。

功能

  • [x] resolve_dns — 通过 DNS-over-HTTPS 进行正向查询 (A, AAAA, CNAME, MX, TXT, NS, SOA, PTR, SRV, CAA)

  • [x] reverse_dns — IPv4 或 IPv6 的 PTR 查询

  • [x] whois_domain — 通过 RDAP(现代 WHOIS)获取结构化注册信息

  • [x] geo_ip — 获取公共 IP 的国家/城市/ASN/ISP 信息

  • [ ] 批量/区域传输查询

  • [ ] DNSSEC 验证输出

  • [ ] 本地缓存(减少重复的上游调用)

无需 API 密钥。所有四个工具均访问公共免费端点:

工具

上游

resolve_dns, reverse_dns

dns.google (DNS-over-HTTPS, JSON)

whois_domain

rdap.org (RDAP bootstrap,重定向至 TLD 注册局)

geo_ip

ip-api.com (HTTP, 免费层级 45 次请求/分钟)

Related MCP server: intodns-mcp

快速开始

安装

pipx install dns-mcp
# or
uv tool install dns-mcp

Claude Desktop

添加到 claude_desktop_config.json (macOS: ~/Library/Application Support/Claude/, Windows: %APPDATA%\Claude\):

{
  "mcpServers": {
    "dns": {
      "command": "dns-mcp"
    }
  }
}

重启 Claude Desktop;这四个工具应该会出现在工具菜单中。

Claude Code

claude mcp add dns dns-mcp

Codex CLI

添加到 ~/.codex/config.toml:

[mcp_servers.dns]
command = "dns-mcp"

重启 Codex。之后这四个工具即可在任何 Codex 会话中使用。

从源码运行

git clone https://github.com/r0bin2u/dns-mcp && cd dns-mcp
uv sync
uv run dns-mcp

示例提示词

  • “github.com 的 A 记录和 MX 记录是什么?”

  • “谁注册了 cloudflare.com,它什么时候过期?”

  • “定位 140.82.121.4 — 是哪个国家和 ISP?”

  • “我在东京的用户说 foo.com 很慢。解析它,然后定位该 IP 的地理位置。”

  • “我收到了一封来自 support@paypa1-security.com 的邮件。这个域名可疑吗?”

开发

uv sync
uv run pytest
uv run ruff check .

使用 MCP Inspector 进行交互式调试:

npx @modelcontextprotocol/inspector uv run dns-mcp

关于 ip-api.com 的说明

ip-api.com 的免费层级需要 HTTP(而非 HTTPS)。这对于定位任意公共 IP 是没问题的——因为不会发送凭据——但这意味着请求在网络传输中是可见的。如果这在您的环境中是一个问题,请通过编辑 src/dns_mcp/__init__.py 中的 IPGEO_URL 来替换为 HTTPS 替代方案(例如 ipwho.is,或带有令牌的 ipinfo.io)。

许可证

MIT — 参见 LICENSE。

Available Tools

4 tools
geo_ipA

Locate an IP address geographically. Returns country, city, ASN, and ISP.

Args:
    ip: Public IPv4 or IPv6 address. Private/reserved ranges are rejected.

Inputs: ip (required).

resolve_dnsA

Resolve a domain name via DNS-over-HTTPS. Returns answer records and TTL.

Args:
    name: Domain to look up, e.g. "github.com".
    record_type: DNS record type. One of A, AAAA, CNAME, MX, TXT, NS, SOA, PTR, SRV, CAA.

Inputs: name (required), record_type.

reverse_dnsA

Reverse-resolve an IP address to its PTR record (the hostname it points to).

Args:
    ip: IPv4 or IPv6 address, e.g. "140.82.121.4".

Inputs: ip (required).

whois_domainA

Look up domain registration info via RDAP (the modern structured WHOIS).

Args:
    domain: Domain name, e.g. "github.com".

Inputs: domain (required).

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A4/5.0

    Scored across 4 tools

    Disambiguation5/5

    Each tool addresses a distinct DNS function: geolocation, forward resolution, reverse resolution, and registration lookup. No overlapping purposes.

    Naming Consistency5/5

    All tools use a consistent verb_noun pattern in snake_case (e.g., geo_ip, resolve_dns), making their intent immediately clear.

    Tool Count5/5

    Four tools is well-scoped for a DNS utility server—enough to cover essential operations without redundancy or clutter.

    Completeness4/5

    The set provides forward/reverse DNS, geolocation, and WHOIS. Missing advanced features like bulk queries or DNSSEC validation, but core workflows are complete.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      MCP server for DNS lookups, reverse DNS, WHOIS, and domain checks. Zero auth, zero config.
      5
      72 npm
      3
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      MCP server for IntoDNS.ai providing 36 free tools for DNS, DMARC, SPF, DKIM, BIMI, DNSSEC, MTA-STS, FCrDNS, blacklist and email security checks. Citation-grade report snapshots with content hashes. No API key required.
      45
      160 npm
      2
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      MCP server for live IP and domain reputation checks via DNS lookups, providing abuse scores and network type without requiring an API key.
      2
      MIT