pihole-mcp
pihole-mcp
統合型Pi-hole v6 MCPサーバー。3つのアップストリームMCP(aplaceforallmystuff/mcp-pihole、sbarbett/pihole-mcp-server、cwdcwd/mcp-server-pihole)から有用なツールを統合し、chris2ao-unifi-mcpスタック(FastMCP + httpx + Pydantic v2)に準拠したPythonサーバーです。
ツール (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はセッションベースの認証を使用します。このサーバーは自動的に処理します:
POST /api/authに{"password": "<app-password>"}を送信し、セッションSIDを取得します。以降のすべての呼び出しに
X-FTL-SID: <sid>を含めます。401エラーまたは有効期限切れに近い場合、クライアントは再認証を行い、一度だけ再試行します。
シャットダウン時に
DELETE /api/authでセッションを解放します。
アプリケーションパスワードはPi-hole Web UIで作成します:Settings > Web Interface > "Application password" > Generate。これはメインの管理用Webパスワードとは別のものであり、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.shClaude 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=termPython: 3.12+
chris2ao-unifi-mcp との関係
同じスタック(FastMCP、httpx、Pydantic-settings、hatchling、uv)を使用しています。Pi-holeは単一の製品であるため(動的な製品ロードや検出がない)、unifi-mcpよりもシンプルです。これをマルチPi-hole対応や不足機能(adlist/gravity CRUD、グループ、DHCP、Teleporter)のために拡張する場合は、unifi-mcpの機能ごとのモジュールパターンに従ってください。
Available Tools
73 toolsadd_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
Scored across 73 tools
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.
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.
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.
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
Related MCP Connectors
MCP server for querying and analyzing data from ad platforms, analytics tools, and spreadsheets
MCP registry & directory: search, find & install 31k+ MCP servers & tools. Catalog and marketplace.
Related MCP Servers
- AlicenseAqualityDmaintenanceAn 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.196 npm1MIT
- FlicenseNot gradedqualityDmaintenanceEnables 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.-
- AlicenseBqualityDmaintenanceAn 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.712MIT
- AlicenseBqualityDmaintenanceA 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.31MIT