Skip to main content
Glama

get_query_log

Fetch recent DNS queries with optional filters for length, time range, domain, client IP, upstream type, and cursor for pagination.

Instructions

Fetch recent DNS queries with optional filters.

Filters:

  • length: number of queries (default 100)

  • from_ts / until_ts: Unix timestamps

  • domain: exact or wildcard (*) domain match

  • client_ip: exact or wildcard (*) client IP match

  • upstream: one of 'cache', 'blocklist', 'permitted'

  • cursor: pagination cursor from previous response

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
lengthNo
from_tsNo
until_tsNo
domainNo
client_ipNo
upstreamNo
cursorNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for 'get_query_log' tool. Accepts filters (length, from_ts, until_ts, domain, client_ip, upstream, cursor) and calls client.get('/queries', params=params) to fetch DNS query data from Pi-hole API.
    @mcp.tool()
    async def get_query_log(
        length: int = 100,
        from_ts: int | None = None,
        until_ts: int | None = None,
        domain: str | None = None,
        client_ip: str | None = None,
        upstream: str | None = None,
        cursor: str | None = None,
    ) -> dict:
        """Fetch recent DNS queries with optional filters.
    
        Filters:
        - length: number of queries (default 100)
        - from_ts / until_ts: Unix timestamps
        - domain: exact or wildcard (*) domain match
        - client_ip: exact or wildcard (*) client IP match
        - upstream: one of 'cache', 'blocklist', 'permitted'
        - cursor: pagination cursor from previous response
        """
        params: dict = {"length": length}
        if from_ts is not None:
            params["from"] = from_ts
        if until_ts is not None:
            params["until"] = until_ts
        if domain:
            params["domain"] = domain
        if client_ip:
            params["client"] = client_ip
        if upstream:
            params["upstream"] = upstream
        if cursor:
            params["cursor"] = cursor
        return await client.get("/queries", params=params)
  • Registration function that registers the tool via @mcp.tool() decorator on the FastMCP instance. Called from register_all() in __init__.py.
    def register(mcp: FastMCP, client: PiholeClient) -> int:
        @mcp.tool()
        async def get_query_log(
            length: int = 100,
            from_ts: int | None = None,
            until_ts: int | None = None,
            domain: str | None = None,
            client_ip: str | None = None,
            upstream: str | None = None,
            cursor: str | None = None,
        ) -> dict:
            """Fetch recent DNS queries with optional filters.
    
            Filters:
            - length: number of queries (default 100)
            - from_ts / until_ts: Unix timestamps
            - domain: exact or wildcard (*) domain match
            - client_ip: exact or wildcard (*) client IP match
            - upstream: one of 'cache', 'blocklist', 'permitted'
            - cursor: pagination cursor from previous response
            """
            params: dict = {"length": length}
            if from_ts is not None:
                params["from"] = from_ts
            if until_ts is not None:
                params["until"] = until_ts
            if domain:
                params["domain"] = domain
            if client_ip:
                params["client"] = client_ip
            if upstream:
                params["upstream"] = upstream
            if cursor:
                params["cursor"] = cursor
            return await client.get("/queries", params=params)
    
        @mcp.tool()
        async def get_query_suggestions() -> dict:
            """Get available filter values for the query log (domains, clients, upstreams, types, statuses)."""
            return await client.get("/queries/suggestions")
    
        return 2
  • Top-level registration loop that calls queries.register(mcp, client) to register the get_query_log tool.
    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
  • Server entry point calls register_all(mcp, _client) to register all tools including get_query_log.
    _tool_count = register_all(mcp, _client)
  • The client.get() helper method that the handler delegates to for making the GET request to /queries.
    async def get(self, path: str, *, params: dict[str, Any] | None = None) -> Any:
        return await self.request("GET", path, params=params)
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It discloses pagination via cursor and mentions 'recent' queries, but does not specify read-only nature, authentication requirements, rate limits, or behavior for empty results. With an output schema present, return structure is covered, but behavioral transparency is adequate but not thorough.

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

Conciseness5/5

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

The description is exceptionally concise: two lines of main purpose followed by a clean bullet list of filters. Every sentence adds value, no fluff, and the structure is front-loaded with the primary action.

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?

Given 7 optional parameters and an output schema, the description covers the tool's functionality well. It includes all filter details and pagination. However, it omits ordering of results (presumably by time) and does not mention that the tool is read-only. Still, for a query tool with an output schema, completeness is high.

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

Parameters5/5

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

Schema description coverage is 0%, but the description compensates exceptionally by explaining all 7 parameters with context: length default, Unix timestamps for from_ts/until_ts, wildcard support for domain and client_ip, allowed values for upstream (cache, blocklist, permitted), and cursor for pagination. This adds significant meaning beyond the schema's type and default information.

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

Purpose4/5

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

The description clearly states the tool fetches recent DNS queries with optional filters, establishing a specific verb and resource. However, it does not explicitly differentiate from the sibling tool 'get_tail_log', which also provides query logs but in real-time, so clarity is slightly diminished.

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

Usage Guidelines3/5

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

The description lists filter options which imply usage, but it provides no explicit guidance on when to use this tool over alternatives like get_tail_log or get_stats. There are no when-to-use or when-not-to-use statements, leaving the agent to infer context.

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