dns-mcp

dns-mcp

Enables DNS record CRUD operations (list, get, create, update, delete) through MCP tools, provider-agnostic and secure.

Category
访问服务器

README

dns-mcp

CI License: MIT

dns-mcp is a small, provider-agnostic Model Context Protocol server that exposes DNS record CRUD as typed tools: list a zone's records, get one, and create / update / delete records. It turns ad-hoc "go poke the DNS API" scripts into constrained, structured tools an agent can call.

The server is provider-agnostic by design: it hard-codes no DNS provider. A zone's records are served entirely by the injected backend, so the same server works against whatever provider infra wires up (e.g. Porkbun or Google Cloud DNS).

Repo structure: this ships as a per-server repo, following the shipped convention (e.g. telemetry-mcp, reddit-mcp, dispatch-mcp). Whether the fleet's MCP servers consolidate into a single agent-mcp repo is pending a consolidation decision; until that lands, this stays per-server.

Tools

Tool Purpose
dns_list_records(zone) List every DNS record in the zone (sorted by name then type).
dns_get_record(zone, name, type) Get the record identified by name + type.
dns_create_record(zone, name, type, value, ttl?, priority?) Create a record; the backend rejects a conflict.
dns_update_record(zone, name, type, value, ttl?, priority?) Update the record identified by name + type.
dns_delete_record(zone, name, type) Delete the record identified by name + type.

zone is the apex domain (e.g. example.com). name is the record name — @ for the apex, * for a wildcard, or a host label / FQDN. type is a supported RR type (A/AAAA/CNAME/TXT/MX/NS/SRV/CAA/ALIAS/PTR). ttl (seconds) is optional — None lets the provider default it. priority is used by MX / SRV.

Security model

This server is built so that exposing it does not expose arbitrary provider access or command execution. The properties below are enforced in code and covered by tests.

  • Bounded surface. The tools are list/get/create/update/delete over a validated record model. There is no raw provider-call escape hatch — a caller cannot supply arbitrary API text.
  • No embedded credentials. Nothing in this package stores a token or key. Credentials are resolved at call time by an injected CredentialProvider (backed by WIF/GSM/env in production) and handed to the backend per request; they never live in source, in the service, or in a returned payload (tests assert the sentinel credential never appears in output).
  • Validated inputs. Zone, record name, type, and TTL are restricted to a conservative shape (RR types are an allowlist), so a rejected request cannot smuggle injection into the backend (defence in depth; the provider's own validation is the real gate).
  • Provider-agnostic. No provider is hard-coded; the backend defines how records are stored and served, so the server cannot leak provider-specific surface.

Deliberate omissions

  • No tool lets the caller supply or override raw provider API calls.
  • No tool returns or accepts credentials.
  • Zone-level operations (creating/deleting whole zones, nameserver delegation) are out of scope here by design — this is record CRUD only.

Configuration (environment, resolved at call time)

Variable Effect
DNS_PROVIDER Which provider adapter the production backend uses (consumed once infra wires it).
DNS_ZONE The default zone the backend operates on.

No credentials are read from the environment by this server; identity is resolved per call from the runtime (WIF/GSM) by the credential provider.

What infra must wire (the build split)

This repo is the offline-testable scaffold. The core, the MCP wrapper, the backend interface, and a full offline test suite (fake in-memory backend) are complete here. The live provider adapter + credentials are intentionally not wired — that is the infra half:

  1. Backend implementation. Add a real adapter implementing the DnsBackend protocol in src/dns_mcp/backend.py (the default UnconfiguredBackend currently fails fast with "not wired up"). It must map the provider-neutral Record model to and from the provider's record API:
    • list_records / get_record read the zone's records.
    • create_record / update_record / delete_record mutate them, honouring conflict (create) and missing-record (get/update/delete) semantics.
    • A likely first adapter is Porkbun (speedforge.dev is registered there) or Google Cloud DNS.
  2. Zone. The DNS zone(s) the adapter operates on (DNS_ZONE).
  3. Identity (keyless). Prefer a Workload Identity Federation service account for Cloud DNS, or a GSM-backed API key for an API-key provider like Porkbun. The CredentialProvider resolves this at call time; no key is stored in this repo or the image.
  4. Config. Set DNS_PROVIDER and DNS_ZONE for the workload.

Until step 1 lands, the production backend raises and only the fake-backed offline path runs — so this scaffold is safe to ship and CI is green without any provider access.

Install

Run directly from GitHub with the MCP extra:

uvx --from "dns-mcp[mcp] @ git+https://github.com/selamy-labs/dns-mcp@v0.1.0" dns-mcp

Or with pipx:

pipx install "dns-mcp[mcp] @ git+https://github.com/selamy-labs/dns-mcp@v0.1.0"

MCP client config

{
  "mcpServers": {
    "dns": {
      "command": "uvx",
      "args": [
        "--from",
        "dns-mcp[mcp] @ git+https://github.com/selamy-labs/dns-mcp@v0.1.0",
        "dns-mcp"
      ],
      "env": {
        "DNS_PROVIDER": "porkbun",
        "DNS_ZONE": "example.com"
      }
    }
  }
}

Architecture

The DNS record logic lives once in dns_mcp.core.DnsService; the MCP server in dns_mcp.mcp_server is a thin wrapper that serialises structured results to JSON and maps expected failures to ToolError. All record access goes through an injected backend (dns_mcp.backend.DnsBackend) and all credential resolution through an injected CredentialProvider, so the full validate / route / shape path is exercised offline in tests with a fake in-memory backend — no provider, no network. The default backend (UnconfiguredBackend) uses only the standard library until infra wires a real adapter, so the core package has zero runtime dependencies; the mcp SDK is an optional extra.

Development

python -m pip install -e ".[test]"
ruff format --check .
ruff check .
coverage run -m pytest
coverage report --fail-under=95

License

MIT — see LICENSE.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选