Skip to main content
Glama

pihole-mcp

test License: MIT Python MCP Pi-hole v6

Unified Pi-hole v6 MCP server. Consolidates the useful tools from three upstream MCPs (aplaceforallmystuff/mcp-pihole, sbarbett/pihole-mcp-server, cwdcwd/mcp-server-pihole) into one Python server that matches the chris2ao-unifi-mcp stack (FastMCP + httpx + Pydantic v2).

Tools (72)

Stats (9): get_stats, get_top_blocked, get_top_permitted, get_top_clients, get_query_types, get_forward_destinations, get_recent_blocked, get_history, get_client_history. Pass from_ts and until_ts to any of them (except get_recent_blocked) to query the long-term database for any time range.

Queries (2): get_query_log (filters: time range, domain, client IP or name, upstream, query type, status, reply, DNSSEC, paging, disk for the long-term database), get_query_suggestions

Search (1): search_domain explains why a domain is blocked or allowed (matching lists, regexes, adlists, groups)

Blocking (3): get_blocking_status, enable_blocking, disable_blocking (with optional timer)

Domain lists (10): list_domains, add_domain, update_domain, remove_domain (allow/deny, exact/regex, groups, comments), plus the legacy exact-match get_whitelist, get_blacklist, add_to_whitelist, add_to_blacklist, remove_from_whitelist, remove_from_blacklist

Adlists (4): list_adlists, add_adlist, update_adlist, remove_adlist

Groups and clients (9): list_groups, add_group, update_group, remove_group, list_clients, get_client_suggestions, add_client, update_client, remove_client

Local DNS (5): list_local_dns, add_local_a_record, remove_local_a_record, add_local_cname_record, remove_local_cname_record

System info (10): get_version, get_system_info, get_host_info, get_sensors, get_ftl_info, get_database_info, get_metrics, get_messages, delete_message, get_padd

Network and DHCP (7): list_network_devices, delete_network_device, get_gateway, get_routes, get_interfaces, list_dhcp_leases, remove_dhcp_lease

Settings (4): get_config, update_config, add_config_item, remove_config_item

Maintenance (8): update_gravity, flush_cache, restart_dns, flush_logs, flush_arp, flush_network, get_tail_log, export_teleporter

Plus server_info.

Related MCP server: Pi-hole MCP Server

Safety

  • Disruptive or destructive tools return a preview and change nothing unless called with confirm=true: update_config, add_config_item, remove_config_item, restart_dns, flush_arp, flush_network, remove_adlist, remove_group, delete_network_device, remove_dhcp_lease.

  • get_config redacts password hashes and the TOTP secret. The settings tools refuse any change under webserver.api (authentication settings).

  • export_teleporter writes the backup zip to a directory you name and never overwrites a file. The archive includes the password hash, so store it securely. Teleporter import is deliberately not exposed.

Auth

Pi-hole v6 uses session-based auth. This server handles it automatically:

  1. POST /api/auth with {"password": "<app-password>"} returns a session SID.

  2. All subsequent calls include X-FTL-SID: <sid>.

  3. On 401 or near-expiry, the client re-authenticates and retries once.

  4. On shutdown, DELETE /api/auth releases the session.

App password is created in the Pi-hole Web UI: Settings > Web Interface > "Application password" > Generate. This is separate from the main admin web password and is the correct credential for API clients. App passwords also bypass two-factor (TOTP) login, which this server does not implement.

Install

cd /Users/chris2ao/GitProjects/chris2ao-pihole-mcp
uv sync
cp .env.example .env   # fill in PIHOLE_URL and PIHOLE_PASSWORD
uv run pytest

Or via the wrapper (production use with Claude Code):

~/.claude/scripts/pihole-wrapper.sh

Register with Claude Code

In ~/.claude.json, add to mcpServers:

"pihole": {
  "command": "/Users/chris2ao/.claude/scripts/pihole-wrapper.sh",
  "args": []
}

The wrapper sources ~/.claude/secrets/secrets.env for PIHOLE_URL and PIHOLE_PASSWORD, then invokes uv run.

Development

  • Run tests: uv run pytest

  • Coverage: uv run pytest --cov --cov-report=term

  • Python: 3.12+

Relation to chris2ao-unifi-mcp

Same stack (FastMCP, httpx, Pydantic-settings, hatchling, uv) and the same module-per-capability layout under src/pihole_mcp/tools/. Simpler than unifi-mcp because Pi-hole is a single product (no dynamic product loading or discovery).

See CHANGELOG.md for release notes.

Available Tools

73 tools
add_adlistA

Subscribe to an adlist URL. Run update_gravity afterwards to download it.

Inputs: address (required), groups, comment, enabled, +1 more. Returns: object

add_clientC

Configure a client by IP, MAC, hostname, CIDR subnet, or :interface, and assign group IDs.

Inputs: client_id (required), groups, comment. Returns: object

add_config_itemB

Append one value to an array setting, e.g. element='dns.upstreams', value='1.1.1.1'. Preview unless confirm=true.

Inputs: value (required), element (required), confirm, restart. Returns: object

add_domainC

Add an exact domain or a regex to the allow or deny list. groups are group IDs (default group 0).

Inputs: domain (required), domain_type (required), kind, groups, +2 more. Returns: object

add_groupC

Create a group.

Inputs: name (required), comment, enabled. Returns: object

add_local_a_recordA

Add a local A record (host -> IP). Replaces any existing entry for the same host.

Inputs: ip (required), host (required). Returns: object

add_local_cname_recordA

Add a local CNAME record (host -> target). Replaces any existing CNAME for the same host.

Inputs: host (required), target (required), ttl. Returns: object

add_to_blacklistC

Add a domain to the deny list (blacklist).

Inputs: domain (required), comment. Returns: object

add_to_whitelistC

Add a domain to the allow list (whitelist).

Inputs: domain (required), comment. Returns: object

delete_messageB

Dismiss one diagnostic message by ID.

Inputs: message_id (required). Returns: object

delete_network_deviceA

Remove one device from the network table by its ID. Preview unless confirm=true.

Inputs: device_id (required), confirm. Returns: object

disable_blockingA

Disable DNS blocking. If duration_seconds is given, re-enables after that timer; otherwise indefinite.

Inputs: duration_seconds. Returns: object

enable_blockingA

Enable DNS blocking immediately.

Inputs: no named parameters. Returns: object

export_teleporterA

Download a Teleporter backup zip of all Pi-hole settings and lists into output_dir.

The archive contains the password hash, so store it securely. Existing files are never overwritten.

Inputs: output_dir (required). Returns: object

flush_arpA

Flush the ARP cache of the Pi-hole host. Preview unless confirm=true.

Inputs: confirm. Returns: object

flush_cacheA

Flush the DNS cache. Pi-hole v6 has no separate cache-flush endpoint, so this restarts the DNS resolver.

Inputs: no named parameters. Returns: object

flush_logsA

Clear the Pi-hole query log.

Inputs: no named parameters. Returns: object

flush_networkA

Clear Pi-hole's network device table (device history is lost). Preview unless confirm=true.

Inputs: confirm. Returns: object

get_blacklistA

List all exact-match blocked domains.

Inputs: no named parameters. Returns: object

get_blocking_statusA

Check if Pi-hole DNS blocking is enabled. Returns status and any active timer.

Inputs: no named parameters. Returns: object

get_client_historyA

Per-client query time series for the top count clients (0 = all).

from_ts/until_ts query the long-term database instead (count is then ignored).

Inputs: count, from_ts, until_ts. Returns: object

get_client_suggestionsB

Clients seen on the network that are not yet configured, as candidates for add_client.

Inputs: count. Returns: object

get_configA

Read Pi-hole settings. element narrows to a section or key, e.g. 'dns', 'dns.upstreams', 'dhcp'.

detailed=true adds descriptions, allowed values, and defaults. Password hashes and the TOTP secret are redacted.

Inputs: element, detailed. Returns: object

get_database_infoB

Long-term query database size, query count, and SQLite version.

Inputs: no named parameters. Returns: object

get_forward_destinationsB

Upstream DNS server stats (which forwarders served how many queries). from_ts/until_ts use the long-term database.

Inputs: from_ts, until_ts. Returns: object

get_ftl_infoB

FTL process status: PID, uptime, privacy level, client and gravity counts, query frequency.

Inputs: no named parameters. Returns: object

get_gatewayA

Default gateway address and interface (detailed=true includes routes and interfaces).

Inputs: detailed. Returns: object

get_historyC

Time-series activity: allowed/blocked/other counts per bucket. from_ts/until_ts use the long-term database.

Inputs: from_ts, until_ts. Returns: object

get_host_infoB

Host hardware model, kernel, and OS details.

Inputs: no named parameters. Returns: object

get_interfacesC

Network interfaces of the Pi-hole host with addresses and traffic counters.

Inputs: detailed. Returns: object

get_messagesB

Pi-hole diagnostic warnings (rate limiting, load, DNSMASQ errors, list issues).

Inputs: no named parameters. Returns: object

get_metricsB

DNS cache and DHCP metrics (cache size, insertions, evictions, reply types).

Inputs: no named parameters. Returns: object

get_paddB

Compact dashboard in one call (PADD data): blocking, stats, top items, system, versions.

Inputs: full. Returns: object

get_query_logA

Fetch DNS queries with optional filters (wildcards * supported on text filters).

Filters:

  • length: number of queries (default 100); start: offset for paging

  • from_ts / until_ts: Unix timestamps

  • domain, client_ip, client_name, upstream: exact or wildcard match

  • query_type: e.g. A, AAAA, HTTPS, PTR (unmapped types appear as TYPEnnn or OTHER)

  • status: e.g. GRAVITY, FORWARDED, CACHE, REGEX, DENYLIST

  • reply: e.g. IP, NXDOMAIN, NODATA, CNAME

  • dnssec: e.g. SECURE, INSECURE, BOGUS

  • cursor: cursor value from a previous response

  • disk: true searches the long-term database instead of in-memory queries Valid filter values come from get_query_suggestions.

Inputs: disk, reply, start, cursor, +10 more. Returns: object

get_query_suggestionsA

Get available filter values for the query log (domains, clients, upstreams, types, statuses).

Inputs: no named parameters. Returns: object

get_query_typesB

Breakdown of DNS query types (A, AAAA, PTR, SRV, etc). from_ts/until_ts use the long-term database.

Inputs: from_ts, until_ts. Returns: object

get_recent_blockedC

Recently blocked domains.

Inputs: count. Returns: object

get_routesC

Routing table of the Pi-hole host.

Inputs: detailed. Returns: object

get_sensorsA

Temperature sensor readings and the configured hot limit.

Inputs: no named parameters. Returns: object

get_statsA

Summary statistics (total/blocked queries, percentage, unique domains, clients).

Pass from_ts and until_ts (Unix timestamps) to query the long-term database for any range.

Inputs: from_ts, until_ts. Returns: object

get_system_infoB

Host uptime, memory, swap, CPU load, and process count.

Inputs: no named parameters. Returns: object

get_tail_logA

Get the last lines entries of a Pi-hole log ('dnsmasq', 'ftl', 'webserver').

Pass next_id from a previous response to get only newer entries.

Inputs: log, lines, next_id. Returns: object

get_top_blockedB

Top blocked domains by query count. from_ts/until_ts switch to the long-term database.

Inputs: count, from_ts, until_ts. Returns: object

get_top_clientsB

Top clients by query count (blocked=true ranks by blocked queries). from_ts/until_ts use the long-term database.

Inputs: count, blocked, from_ts, until_ts. Returns: object

get_top_permittedB

Top allowed domains by query count. from_ts/until_ts switch to the long-term database.

Inputs: count, from_ts, until_ts. Returns: object

get_versionA

Installed and latest available versions of Pi-hole core, web, FTL, and Docker tag.

Inputs: no named parameters. Returns: object

get_whitelistA

List all exact-match allowed domains.

Inputs: no named parameters. Returns: object

list_adlistsB

List subscribed adlists (block lists and allow lists) with status and domain counts.

Inputs: list_type. Returns: object

list_clientsA

List configured clients (IP, MAC, hostname, CIDR, or interface) and their groups.

Inputs: no named parameters. Returns: object

list_dhcp_leasesA

Active DHCP leases (only populated when Pi-hole's DHCP server is enabled).

Inputs: no named parameters. Returns: object

list_domainsA

List domain-list entries, optionally narrowed to allow/deny and exact/regex.

kind requires domain_type.

Inputs: kind, domain_type. Returns: object

list_groupsB

List groups. Groups tie clients to domain lists and adlists for per-device policy.

Inputs: no named parameters. Returns: object

list_local_dnsA

List local DNS entries (hosts and CNAME records).

Inputs: no named parameters. Returns: object

list_network_devicesC

Pi-hole's network table: MAC address, vendor, IPs, hostnames, first/last seen, query count.

Inputs: max_devices, max_addresses. Returns: object

remove_adlistA

Unsubscribe from an adlist. Preview unless confirm=true. Run update_gravity afterwards.

Inputs: address (required), confirm, list_type. Returns: object

remove_clientB

Remove a configured client (it falls back to the default group).

Inputs: client_id (required). Returns: object

remove_config_itemA

Remove one value from an array setting. Preview unless confirm=true.

Inputs: value (required), element (required), confirm, restart. Returns: object

remove_dhcp_leaseA

Remove a DHCP lease by IP. Preview unless confirm=true.

Inputs: ip (required), confirm. Returns: object

remove_domainC

Remove an exact domain or regex from the allow or deny list.

Inputs: domain (required), domain_type (required), kind. Returns: object

remove_from_blacklistB

Remove a domain from the deny list.

Inputs: domain (required). Returns: object

remove_from_whitelistB

Remove a domain from the allow list.

Inputs: domain (required). Returns: object

remove_groupA

Delete a group. Preview unless confirm=true.

Inputs: name (required), confirm. Returns: object

remove_local_a_recordB

Remove any local A record matching the given host.

Inputs: host (required). Returns: object

remove_local_cname_recordB

Remove any local CNAME record for the given host.

Inputs: host (required). Returns: object

restart_dnsA

Restart the DNS resolver (brief DNS outage, clears cache). Preview unless confirm=true.

Inputs: confirm. Returns: object

search_domainA

Explain why a domain is blocked or allowed: shows matching domain-list entries, regexes, and adlists (gravity), with the groups each applies to.

partial=true also matches substrings. max_results caps results per category.

Inputs: domain (required), partial, max_results. Returns: object

server_infoA

Return chris2ao-pihole-mcp server version, configured Pi-hole URL, and tool count.

Inputs: no named parameters. Returns: object

update_adlistB

Change an adlist's comment, groups, or enabled state. Run update_gravity to apply.

Inputs: address (required), groups, comment, enabled, +1 more. Returns: object

update_clientC

Change a configured client's comment or group IDs.

Inputs: client_id (required), groups, comment. Returns: object

update_configA

Set a Pi-hole setting, e.g. element='dns.upstreams', value=['9.9.9.9'].

Preview (current value) unless confirm=true. Some settings restart FTL; restart=false defers that. Authentication settings (webserver.api.*) are refused.

Inputs: value (required), element (required), confirm, restart. Returns: object

update_domainC

Update a domain-list entry: move it between lists, change comment, groups, or enabled state.

Inputs: domain (required), domain_type (required), kind, groups, +4 more. Returns: object

update_gravityA

Refresh Pi-hole gravity (download adlists). Takes a minute or more.

Returns the last output_lines lines of the gravity run. Reports cleanly if a run is already in progress.

Inputs: output_lines. Returns: object

update_groupC

Rename a group or change its comment or enabled state.

Inputs: name (required), comment, enabled, new_name. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    C2.9/5.0

    Scored across 73 tools

    Disambiguation3/5

    Most tools have distinct resource/action purposes, but there is substantial overlap between the legacy whitelist/blacklist tools (get_whitelist, add_to_whitelist, remove_from_whitelist, etc.) and the newer domain-list tools (list_domains, add_domain, remove_domain). Descriptions clarify each individually, but do not guide which set to prefer, creating real misselection risk.

    Naming Consistency4/5

    The set overwhelmingly follows a verb_noun convention (get_*, list_*, add_*, update_*, remove_*, delete_*, flush_*), making names predictable. Minor deviations exist: server_info lacks a verb, and add_to_whitelist/remove_from_whitelist use a different preposition pattern than add_domain/remove_domain.

    Tool Count1/5

    73 tools is far beyond the typical 3-15 range and is extreme for a single Pi-hole instance. The count is inflated by fine-grained maintenance operations (flush_arp, flush_network, flush_cache, restart_dns) and duplicate whitelist/domain-list management surfaces.

    Completeness4/5

    The surface is very comprehensive, covering stats, query logs, adlists, groups, clients, DHCP, network, config, local DNS, system info, and maintenance. Minor gaps remain, such as no Teleporter import (only export) and no dedicated update for local A/CNAME records (add replaces instead).

    Maintenance

    ActivitySlowing
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      An MCP server for managing Cloudron instances that enables monitoring and controlling self-hosted applications, backups, and infrastructure. It provides tools for listing installed apps, retrieving system status, and performing administrative tasks through the Model Context Protocol.
      19
      12 npm
      1
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables control of Pi-hole v6 ad blocking, allowing users to toggle DNS blocking status and retrieve real-time statistics like query counts and blocked domains. It provides a structured interface for monitoring and managing network-level ad filtering through the Pi-hole REST API.
      -
    • A
      license
      B
      quality
      D
      maintenance
      An MCP server for managing and operating Minecraft servers through multiple backend protocols including MCSManager API, RCON, and MSMP. It provides tools for instance lifecycle management, file operations, console commands, player administration, and server configuration with built-in security controls.
      71
      2
      MIT
    • A
      license
      B
      quality
      D
      maintenance
      A local MCP server for managing WHM and cPanel servers through AI clients, supporting server health, account, DNS, email, database, SSL, bandwidth, disk, cron, and service-management tools across multiple WHM accounts.
      31
      MIT