remove_from_whitelist
Remove a domain from the allow list to restore ad-blocking and DNS filtering for that domain.
Instructions
Remove a domain from the allow list.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| domain | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/pihole_mcp/tools/domains.py:35-38 (handler)The handler function for the 'remove_from_whitelist' tool. It sends a DELETE request to /domains/allow/exact/{domain} with URL encoding.
@mcp.tool() async def remove_from_whitelist(domain: str) -> dict: """Remove a domain from the allow list.""" return await client.delete(f"/domains/allow/exact/{quote(domain, safe='')}") - src/pihole_mcp/tools/domains.py:8-45 (registration)The register() function in domains.py that registers all domain tools (including remove_from_whitelist) via @mcp.tool() decorator. Called by register_all in __init__.py.
def register(mcp: FastMCP, client: PiholeClient) -> int: @mcp.tool() async def get_whitelist() -> dict: """List all exact-match allowed domains.""" return await client.get("/domains/allow/exact") @mcp.tool() async def get_blacklist() -> dict: """List all exact-match blocked domains.""" return await client.get("/domains/deny/exact") @mcp.tool() async def add_to_whitelist(domain: str, comment: str | None = None) -> dict: """Add a domain to the allow list (whitelist).""" body: dict = {"domain": domain} if comment: body["comment"] = comment return await client.post("/domains/allow/exact", json=body) @mcp.tool() async def add_to_blacklist(domain: str, comment: str | None = None) -> dict: """Add a domain to the deny list (blacklist).""" body: dict = {"domain": domain} if comment: body["comment"] = comment return await client.post("/domains/deny/exact", json=body) @mcp.tool() async def remove_from_whitelist(domain: str) -> dict: """Remove a domain from the allow list.""" return await client.delete(f"/domains/allow/exact/{quote(domain, safe='')}") @mcp.tool() async def remove_from_blacklist(domain: str) -> dict: """Remove a domain from the deny list.""" return await client.delete(f"/domains/deny/exact/{quote(domain, safe='')}") return 6 - src/pihole_mcp/tools/__init__.py:14-19 (registration)The register_all() function that iterates over all tool modules and calls register() on each, which registers remove_from_whitelist via the domains module.
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 - src/pihole_mcp/server.py:15-15 (registration)The server entry point where register_all is called to register all tools including remove_from_whitelist on the FastMCP instance.
_tool_count = register_all(mcp, _client) - src/pihole_mcp/client.py:109-110 (helper)The client.delete() method used by remove_from_whitelist to send the HTTP DELETE request to the Pi-hole API.
async def delete(self, path: str) -> Any: return await self.request("DELETE", path)