Skip to main content
Glama

enable_blocking

Re-enables DNS blocking to filter ads and malicious content, restoring network protection.

Instructions

Enable DNS blocking immediately.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'enable_blocking' tool. Sends a POST request to Pi-hole's /dns/blocking endpoint with {"blocking": true} to enable DNS blocking immediately.
    @mcp.tool()
    async def enable_blocking() -> dict:
        """Enable DNS blocking immediately."""
        return await client.post("/dns/blocking", json={"blocking": True})
  • The register() function in blocking.py decorates enable_blocking with @mcp.tool(), which registers it as an MCP tool. The module is then imported and invoked via register_all() in tools/__init__.py.
    def register(mcp: FastMCP, client: PiholeClient) -> int:
        @mcp.tool()
        async def get_blocking_status() -> dict:
            """Check if Pi-hole DNS blocking is enabled. Returns status and any active timer."""
            return await client.get("/dns/blocking")
    
        @mcp.tool()
        async def enable_blocking() -> dict:
            """Enable DNS blocking immediately."""
            return await client.post("/dns/blocking", json={"blocking": True})
    
        @mcp.tool()
        async def disable_blocking(duration_seconds: int | None = None) -> dict:
            """Disable DNS blocking. If duration_seconds is given, re-enables after that timer; otherwise indefinite."""
            body: dict = {"blocking": False}
            if duration_seconds is not None:
                body["timer"] = duration_seconds
            return await client.post("/dns/blocking", json=body)
    
        return 3
  • register_all() iterates over tool modules (including blocking) and calls module.register(mcp, client), which triggers the @mcp.tool() decorations.
    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
  • PiholeClient.request() and the convenience post() method are the helpers that enable_blocking uses to make the HTTP call. request() handles auth, retry on 401, and error handling.
    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()
    
    async def get(self, path: str, *, params: dict[str, Any] | None = None) -> Any:
        return await self.request("GET", path, params=params)
    
    async def post(self, path: str, *, json: Any | None = None) -> Any:
        return await self.request("POST", path, json=json)
    
    async def patch(self, path: str, *, json: Any | None = None) -> Any:
        return await self.request("PATCH", path, json=json)
    
    async def delete(self, path: str) -> Any:
        return await self.request("DELETE", path)
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations. Description does not disclose effects (e.g., immediate toggle, no confirmation). Lacks details on idempotency or side effects.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Appropriately short for a simple toggle. No wasted words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 0-param tool with output schema, description covers main purpose. Could include return value hint but adequate.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

No parameters, so schema covers fully. Description adds no param info but not needed.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clearly states the action (Enable) and the resource (DNS blocking). Distinct from siblings like disable_blocking.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use or not use this tool. Does not mention checking current status or prerequisites.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/chris2ao/pihole-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server