remove_from_blacklist
Remove a domain from the Pi-hole deny list to allow previously blocked queries. Helps restore access to blocked domains when needed.
Instructions
Remove a domain from the deny 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:40-43 (handler)The handler function for remove_from_blacklist. It URL-encodes the domain and sends a DELETE request to the Pi-hole API endpoint /domains/deny/exact/{domain}.
@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='')}") - src/pihole_mcp/tools/domains.py:8-45 (registration)The register function uses the @mcp.tool() decorator to register remove_from_blacklist (and other domain tools) with the FastMCP server.
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/client.py:109-110 (helper)The client.delete method used by remove_from_blacklist to send the HTTP DELETE request to the Pi-hole API.
async def delete(self, path: str) -> Any: return await self.request("DELETE", path) - src/pihole_mcp/client.py:63-98 (helper)The underlying request method that handles authentication, retries on 401, and error handling for all HTTP requests including the DELETE used by remove_from_blacklist.
async def request( self, method: str, path: str, *, params: dict[str, Any] | None = None, json: Any | None = None, ) -> Any: """Issue a request, auto-authenticating and retrying once on 401.""" sid = await self._ensure_session() resp = await self._http.request( method, path, params=params, json=json, headers={"X-FTL-SID": sid}, ) if resp.status_code == 401: self._sid = None sid = await self._ensure_session() resp = await self._http.request( method, path, params=params, json=json, headers={"X-FTL-SID": sid}, ) if resp.status_code >= 400: try: body = resp.json() except ValueError: body = resp.text raise PiholeAPIError(resp.status_code, f"{method} {path} failed", body) if resp.status_code == 204 or not resp.content: return None return resp.json()