flush_cache
Clear the Pi-hole DNS cache to resolve outdated DNS entries and restore fresh resolution.
Instructions
Flush the Pi-hole DNS cache.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The 'flush_cache' tool handler function. It calls client.post('/action/flush/cache') to flush the Pi-hole DNS cache.
async def flush_cache() -> dict: """Flush the Pi-hole DNS cache.""" return await client.post("/action/flush/cache") - src/pihole_mcp/tools/maintenance.py:8-32 (registration)The 'register' function in maintenance.py registers all tools (including flush_cache) via @mcp.tool() decorators. flush_cache is registered at line 14.
def register(mcp: FastMCP, client: PiholeClient) -> int: @mcp.tool() async def update_gravity() -> dict: """Refresh Pi-hole gravity (adlist database). Takes a minute or more to complete.""" return await client.post("/action/gravity") @mcp.tool() async def flush_cache() -> dict: """Flush the Pi-hole DNS cache.""" return await client.post("/action/flush/cache") @mcp.tool() async def flush_logs() -> dict: """Clear the Pi-hole query log.""" return await client.post("/action/flush/logs") @mcp.tool() async def get_tail_log( lines: int = 100, log: Literal["dnsmasq", "ftl", "webserver"] = "dnsmasq", ) -> dict: """Get the tail of a Pi-hole log file. log must be one of 'dnsmasq', 'ftl', 'webserver'.""" return await client.get(f"/logs/{log}", params={"lines": lines}) return 4 - src/pihole_mcp/tools/__init__.py:14-19 (registration)The register_all() function that calls maintenance.register() to register the flush_cache tool on the FastMCP server.
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/client.py:103-104 (helper)The PiholeClient.post() helper method used by flush_cache to make the HTTP POST request to the Pi-hole API.
async def post(self, path: str, *, json: Any | None = None) -> Any: return await self.request("POST", path, json=json)