← Back to project

DNS Server Architecture & MCP Management Specification



This report details the proposed architecture for a modern, Go‑based authoritative DNS server with SQLite‑backed zones and an embedded MCP (Model Context Protocol) control interface. It outlines core features, data model, MCP tool set, and component interactions.

---

Design Goals



---


Core Features



Authoritative DNS Serving



SQLite‑Backed Zone Storage



MCP Management Interface



---


Data Model (SQLite)



sql
-- Zones
CREATE TABLE zones (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL UNIQUE, -- e.g., "example.com."
ttl INTEGER DEFAULT 3600
);


-- Records
CREATE TABLE records (
id INTEGER PRIMARY KEY,
zone_id INTEGER NOT NULL,
name TEXT NOT NULL, -- relative to zone origin (e.g., "www" for www.example.com)
rtype TEXT NOT NULL, -- "A", "AAAA", "CNAME", "MX", "TXT", "NS"
value TEXT NOT NULL, -- formatted string; for MX: "10 mail.example.com."
ttl INTEGER,
FOREIGN KEY(zone_id) REFERENCES zones(id) ON DELETE CASCADE
);



Indexes:


---


In‑Memory Representation



On startup (and after each MCP‑triggered reload), the server:

1. Reads all zones from SQLite.
2. For each zone, builds an in‑memory map:

3. The DNS server’s query handler consults these maps to produce answers.


Reload strategy: To avoid downtime during updates, MCP writes to SQLite first, then sends a `SIGHUP` or calls an internal `Reload()` function that atomically swaps the new zone map after a successful read. Queries continue using the old map until swap; after swap, new queries use fresh data.

---

MCP Tool Specification



All tools follow JSON‑RPC 2.0 over stdio.

Zone Management



Record Management



Zone Reload & Stats



Utility



---


Component Diagram




+---------------------+ +-------------------+
| MCP Client (e.g., | ----> | MCP Server | (stdio)
| ChatGPT, CLI) | <---- | (goroutine) |
+---------------------+ +-------------------+
|
v
+---------------------+ +-------------------+
| DNS Server | <---- | Zone Manager | (in‑memory cache +
| (miekg/dns) | | + SQLite writer | SQLite persistence)
+---------------------+ +-------------------+


The DNS server listens on UDP/TCP (port 53). The MCP server runs as a separate goroutine attached to the same binary, communicating over stdin/stdout. It does not expose network endpoints by default (to avoid attack surface). The MCP client spawns the binary with a flag (e.g., `--mcp`) and then talks JSON‑RPC.

---

Security Considerations



---


Deployment Model



---


Example Workflow



1. Start server: `systemctl start dns-server`.
2. MCP client adds a zone:

json
{"jsonrpc":"2.0","method":"dns.add_zone","params":{"name":"example.com.","ttl":3600},"id":1}

3. MCP client adds an A record:
json
{"jsonrpc":"2.0","method":"dns.add_record","params":{"zone_name":"example.com.","name":"www","rtype":"A","value":"1.2.3.4","ttl":300},"id":2}

4. Server automatically reloads zone; queries to `www.example.com` now return `1.2.3.4`.
5. Change record: `dns.update_record(record_id=1, new_value="5.6.7.8")`.
6. List zones: `dns.list_zones()`.


All changes are persisted to SQLite and take effect immediately.

---

Advantages of This Approach



---


Open Questions & Future Work



---


Conclusion: The custom Go DNS server with SQLite and MCP meets all requirements precisely. It provides a clean, automation‑first design that fits the VPS environment and can be built within a few weeks. The next report will break down the implementation tasks and effort estimate.

---

Word count: ~1,050