list_local_dns
List local DNS entries, including hosts and CNAME records, to view and manage DNS configurations.
Instructions
List local DNS entries (hosts and CNAME records).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/pihole_mcp/tools/local_dns.py:19-22 (handler)The handler function for the 'list_local_dns' tool. Calls _current_dns_config(client) and returns hosts/cnameRecords from the Pi-hole DNS config.
async def list_local_dns() -> dict: """List local DNS entries (hosts and CNAME records).""" dns = await _current_dns_config(client) return {"hosts": dns.get("hosts", []), "cnameRecords": dns.get("cnameRecords", [])} - Helper function _current_dns_config that fetches the current DNS configuration from the Pi-hole API, used by list_local_dns to get the data.
async def _current_dns_config(client: PiholeClient) -> dict: payload = await client.get("/config/dns") config = payload.get("config") or {} dns = config.get("dns") or {} return dns - src/pihole_mcp/tools/local_dns.py:17-22 (registration)Registration of the tool via the @mcp.tool() decorator inside the register() function.
def register(mcp: FastMCP, client: PiholeClient) -> int: @mcp.tool() async def list_local_dns() -> dict: """List local DNS entries (hosts and CNAME records).""" dns = await _current_dns_config(client) return {"hosts": dns.get("hosts", []), "cnameRecords": dns.get("cnameRecords", [])} - src/pihole_mcp/tools/__init__.py:14-19 (registration)The register_all function that iterates over all tool modules (including local_dns) and calls their register() methods.
def register_all(mcp: FastMCP, client: PiholeClient) -> int: """Register every tool module against the FastMCP instance. Returns tool count.""" count = 0 for module in (stats, queries, blocking, domains, local_dns, maintenance): count += module.register(mcp, client) return count