Skip to main content
Glama

pihole-mcp

test License: MIT Python MCP Pi-hole v6

통합 Pi-hole v6 MCP 서버입니다. 세 개의 업스트림 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는 세션 기반 인증을 사용합니다. 이 서버는 이를 자동으로 처리합니다:

  1. {"password": "<app-password>"}를 포함한 POST /api/auth 요청은 세션 SID를 반환합니다.

  2. 이후의 모든 호출에는 X-FTL-SID: <sid>가 포함됩니다.

  3. 401 오류가 발생하거나 세션이 만료될 경우, 클라이언트는 재인증을 수행하고 한 번 재시도합니다.

  4. 종료 시 DELETE /api/auth를 통해 세션을 해제합니다.

앱 비밀번호는 Pi-hole 웹 UI에서 생성합니다: 설정 > 웹 인터페이스 > "애플리케이션 비밀번호" > 생성. 이는 메인 관리자 웹 비밀번호와는 별개이며 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": []
}

래퍼는 PIHOLE_URL 및 PIHOLE_PASSWORD를 위해 ~/.claude/secrets/secrets.env를 소싱한 후 uv run을 호출합니다.

개발

  • 테스트 실행: uv run pytest

  • 커버리지: uv run pytest --cov --cov-report=term

  • Python: 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 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