Skip to main content
Glama

pihole-mcp

test License: MIT Python MCP Pi-hole v6

Унифицированный MCP-сервер для Pi-hole v6. Объединяет полезные инструменты из трех исходных MCP (aplaceforallmystuff/mcp-pihole, sbarbett/pihole-mcp-server, cwdcwd/mcp-server-pihole) в один Python-сервер, соответствующий стеку chris2ao-unifi-mcp (FastMCP + httpx + Pydantic v2).

Инструменты (28)

Статистика (8): get_stats, get_top_blocked, get_top_permitted, get_top_clients, get_query_types, get_forward_destinations, get_recent_blocked, get_history

Запросы (2): get_query_log (расширенные фильтры: временной диапазон, домен, клиент, вышестоящий сервер, курсор), get_query_suggestions

Блокировка (3): get_blocking_status, enable_blocking, disable_blocking (с опциональным таймером)

Списки доменов (6): get_whitelist, get_blacklist, add_to_whitelist, add_to_blacklist, remove_from_whitelist, remove_from_blacklist

Локальный DNS (5): list_local_dns, add_local_a_record, remove_local_a_record, add_local_cname_record, remove_local_cname_record

Обслуживание (4): update_gravity, flush_cache, flush_logs, get_tail_log

Плюс server_info.

См. docs/plans/consolidated-tool-map.md для сопоставления инструментов с конечными точками.

Related MCP server: Pi-hole MCP Server

Аутентификация

Pi-hole v6 использует аутентификацию на основе сессий. Этот сервер обрабатывает её автоматически:

  1. POST /api/auth с {"password": "<app-password>"} возвращает SID сессии.

  2. Все последующие вызовы включают X-FTL-SID: <sid>.

  3. При получении 401 или истечении срока действия клиент повторно проходит аутентификацию и делает одну попытку повторного вызова.

  4. При завершении работы DELETE /api/auth закрывает сессию.

Пароль приложения создается в веб-интерфейсе Pi-hole: Settings > Web Interface > "Application password" > Generate. Это отдельный пароль, не связанный с основным паролем администратора, и именно он является правильными учетными данными для API-клиентов.

Установка

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

Или через обертку (для промышленного использования с Claude Code):

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

Регистрация в Claude Code

В файле ~/.claude.json добавьте в mcpServers:

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

Обертка считывает ~/.claude/secrets/secrets.env для получения PIHOLE_URL и PIHOLE_PASSWORD, а затем вызывает uv run.

Разработка

  • Запуск тестов: uv run pytest

  • Покрытие: uv run pytest --cov --cov-report=term

  • Python: 3.12+

Связь с chris2ao-unifi-mcp

Тот же стек (FastMCP, httpx, Pydantic-settings, hatchling, uv). Проще, чем unifi-mcp, так как Pi-hole — это единый продукт (нет динамической загрузки или обнаружения продуктов). Если вы расширяете этот сервер для работы с несколькими Pi-hole или для недостающих функций (CRUD списков адресов/gravity, группы, DHCP, Teleporter), следуйте паттерну «модуль на функциональность» из unifi-mcp.

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
      6 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