remove_local_a_record
Delete a local A record from Pi-hole DNS for a specified host to maintain accurate name resolution.
Instructions
Remove any local A record matching the given host.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| host | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/pihole_mcp/tools/local_dns.py:32-37 (handler)The handler function for remove_local_a_record tool. Fetches current DNS config, filters out any host entry ending with the given host name, and patches DNS config with the updated host list.
@mcp.tool() async def remove_local_a_record(host: str) -> dict: """Remove any local A record matching the given host.""" dns = await _current_dns_config(client) hosts = [h for h in dns.get("hosts", []) if not h.endswith(f" {host}")] return await _patch_dns(client, {"hosts": hosts}) - src/pihole_mcp/tools/local_dns.py:32-37 (registration)Registered as an MCP tool via the @mcp.tool() decorator inside the register() function of local_dns.py module.
@mcp.tool() async def remove_local_a_record(host: str) -> dict: """Remove any local A record matching the given host.""" dns = await _current_dns_config(client) hosts = [h for h in dns.get("hosts", []) if not h.endswith(f" {host}")] return await _patch_dns(client, {"hosts": hosts}) - Helper function to fetch the current DNS configuration from the Pi-hole API.
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 async def _patch_dns(client: PiholeClient, dns_delta: dict) -> dict: return await client.patch("/config/dns", json={"config": {"dns": dns_delta}}) - Helper function to patch the DNS configuration via the Pi-hole API.
async def _patch_dns(client: PiholeClient, dns_delta: dict) -> dict: return await client.patch("/config/dns", json={"config": {"dns": dns_delta}})