Pi-hole MCP Server

Official registry Other

MCP server for Pi-hole v6 API — manage multiple instances: queries, lists, groups, stats

What can you do with Pi-hole MCP Server?

  • Multi-instance support - configure 1 to N Pi-hole instances via environment variables
  • Full Pi-hole v6 API coverage - query logs, allow/deny lists (full CRUD), group and client management, blocking control, local DNS (A + CNAME) records, gravity reload, stats
  • Smart regex detection - automatically routes domains to exact or regex lists based on metacharacter analysis
  • Regex landmine detector - finds deny-exact entries that look like they should be regex (miscategorized rules)
  • Docker-ready - multi-stage Dockerfile with non-root user, health checks, and security hardening
  • Streamable HTTP or stdio transport - run as a long-lived HTTP service, or let the MCP client spawn it on demand
  • Docker secrets support - passwords via env vars or /run/secrets/ files

Install

Add this to your client's MCP configuration (Claude Desktop: claude_desktop_config.json; Cursor: .cursor/mcp.json; VS Code and others use the same "mcpServers" shape).

NPM package @ranklancer/pihole-mcp
Claude Code
claude mcp add pi-hole-mcp-server -e 'PIHOLE_INSTANCES=<PIHOLE_INSTANCES>' -e 'PIHOLE_BASE_URL=<PIHOLE_BASE_URL>' -e 'PIHOLE_PASSWORD=<your pihole_password>' -- npx -y @ranklancer/pihole-mcp@0.2.0
JSON configuration (Claude Desktop, Cursor, VS Code)
{
    "mcpServers": {
        "pi-hole-mcp-server": {
            "command": "npx",
            "args": [
                "-y",
                "@ranklancer/pihole-mcp@0.2.0"
            ],
            "env": {
                "PIHOLE_INSTANCES": "<PIHOLE_INSTANCES>",
                "PIHOLE_BASE_URL": "<PIHOLE_BASE_URL>",
                "PIHOLE_PASSWORD": "<your pihole_password>"
            }
        }
    }
}

Environment variables

  • PIHOLE_INSTANCES required Comma-separated list of Pi-hole instance names (e.g. 'pihole' or 'primary,secondary')
  • PIHOLE_BASE_URL required Base URL of your first Pi-hole instance (e.g. 'http://192.168.1.100')
  • PIHOLE_PASSWORD required secret API password for your first Pi-hole instance

Documentation

From the project's README on GitHub, refreshed weekly. Links open on GitHub.

Contents
  1. pihole-mcp
  2. Why?
  3. Features
  4. Quick Start
  5. Configuration
  6. Available MCP Tools
  7. Connecting to Your MCP Client
  8. Health Check
  9. Development
  10. Requirements
  11. Related Projects
  12. License

pihole-mcp

An MCP (Model Context Protocol) server that gives AI assistants like Claude full control over your Pi-hole v6 DNS ad-blocker - query logs, allow/deny lists, group management, gravity reload, and stats. Designed from day one for multi-instance deployments: manage one or many Pi-hole instances from a single MCP endpoint.

Why?

Pi-hole's admin API is powerful but cumbersome to script against. This MCP server turns every Pi-hole API action into a tool that any MCP-compatible AI assistant can call directly. Instead of clicking through the admin UI or writing curl commands, just ask your AI to check what's being blocked, allowlist a domain, or compare stats across instances.

Perfect for homelabbers running multiple Pi-holes (primary + secondary, or per-VLAN), network admins managing DNS filtering at scale, and anyone who wants AI-assisted DNS management.

Features

  • Multi-instance support - configure 1 to N Pi-hole instances via environment variables
  • Full Pi-hole v6 API coverage - query logs, allow/deny lists (full CRUD), group and client management, blocking control, local DNS (A + CNAME) records, gravity reload, stats
  • Smart regex detection - automatically routes domains to exact or regex lists based on metacharacter analysis
  • Regex landmine detector - finds deny-exact entries that look like they should be regex (miscategorized rules)
  • Docker-ready - multi-stage Dockerfile with non-root user, health checks, and security hardening
  • Streamable HTTP or stdio transport - run as a long-lived HTTP service, or let the MCP client spawn it on demand
  • Docker secrets support - passwords via env vars or /run/secrets/ files

Quick Start

git clone https://github.com/ranklancer/pihole-mcp.git
cd pihole-mcp
cp .env.example .env
# Edit .env with your Pi-hole URL(s) and password(s)

mkdir -p secrets
echo "your-pihole-password" > secrets/pihole_password
chmod 600 secrets/pihole_password

cp docker-compose.example.yml docker-compose.yml
docker compose up -d
Node.js
npm install
npm run build
export PIHOLE_INSTANCES=pihole
export PIHOLE_BASE_URL=http://pihole.example.com
export PIHOLE_PASSWORD=your-password
npm start
Local on demand (stdio, no Docker)

The MCP client starts the server as a child process when needed and talks to it over stdin/stdout. No port is opened and nothing keeps running in the background.

npm ci
npm run build
cp .env.example .env
chmod 600 .env
# Edit .env with your Pi-hole URL(s) and password(s)

Register it with Claude Code (user scope):

claude mcp add --scope user pihole -- bash -c \
  'set -a; . ~/path/to/pihole-mcp/.env; set +a; MCP_TRANSPORT=stdio exec node ~/path/to/pihole-mcp/dist/index.js'

Or add it manually to your MCP client config:

{
  "mcpServers": {
    "pihole": {
      "type": "stdio",
      "command": "bash",
      "args": ["-c", "set -a; . ~/path/to/pihole-mcp/.env; set +a; MCP_TRANSPORT=stdio exec node ~/path/to/pihole-mcp/dist/index.js"]
    }
  }
}

HOST and PORT from .env are ignored in stdio mode.

Configuration

All configuration is via environment variables. See .env.example for the full reference.

Single Instance
PIHOLE_INSTANCES=pihole
PIHOLE_BASE_URL=http://192.0.2.100
PIHOLE_PASSWORD=your-password
Multiple Instances
PIHOLE_INSTANCES=primary,secondary
PRIMARY_BASE_URL=http://192.0.2.100
PRIMARY_PASSWORD=password1
SECONDARY_BASE_URL=https://198.51.100.101
SECONDARY_PASSWORD=password2
SECONDARY_INSECURE_TLS=true

For each instance name in PIHOLE_INSTANCES, provide:

VariableRequiredDescription
<NAME>_BASE_URLYesPi-hole base URL (e.g. http://pihole.local)
<NAME>_PASSWORDYesPi-hole API password (or use Docker secrets)
<NAME>_INSECURE_TLSNoSet true for self-signed certs (default: false)

Docker secrets are supported as a fallback: /run/secrets/<name>_password (lowercase).

Available MCP Tools

ToolDescription
pihole_query_logFetch query log with filters (limit, time range, client IP or name, domain, status)
pihole_allow_domainAdd to allowlist (auto-detects exact vs regex)
pihole_deny_domainAdd to denylist (auto-detects exact vs regex)
pihole_list_allowlistList all allowlist entries (exact + regex merged)
pihole_list_denylistList all denylist entries (exact + regex merged)
pihole_stats_summaryGet Pi-hole statistics summary
pihole_reload_listsTrigger gravity reload
pihole_group_managementCRUD operations on Pi-hole groups
pihole_client_managementCRUD operations on Pi-hole clients and their group assignments
pihole_check_regex_typesDetect miscategorized regex in deny-exact list
pihole_set_blockingEnable/disable blocking, with optional auto-revert timer
pihole_domain_managementUpdate or delete an allow/deny domain (completes CRUD)
pihole_local_dnsList/add/delete local DNS A records
pihole_local_cnameList/add/delete local CNAME records

Every tool accepts an optional instance parameter to target a specific Pi-hole. Defaults to the first configured instance.

Connecting to Your MCP Client

This section applies to the HTTP transport (Docker or npm start). For stdio, see Local on demand.

The server listens on http://HOST:PORT/mcp (default: http://localhost:3000/mcp). The HTTP endpoint has no authentication, so keep it bound to localhost or a trusted network.

Claude Desktop / Claude Code

Add to your MCP settings:

{
  "mcpServers": {
    "pihole": {
      "url": "http://localhost:3031/mcp"
    }
  }
}

Health Check

curl http://localhost:3031/health
# {"ok":true,"service":"pihole-mcp","version":"0.3.0"}

Development

npm install
npm run dev     # Watch mode — recompiles on save
npm start       # Run the server

Requirements

  • Node.js >= 20
  • Pi-hole v6 with API access enabled
  • Network connectivity to your Pi-hole instance(s)

License

MIT

Frequently asked questions

What is Pi-hole MCP Server?

MCP server for Pi-hole v6 API — manage multiple instances: queries, lists, groups, stats

How do I install Pi-hole MCP Server?

It runs on your machine. In Claude Code: claude mcp add pi-hole-mcp-server -e 'PIHOLE_INSTANCES=<PIHOLE_INSTANCES>' -e 'PIHOLE_BASE_URL=<PIHOLE_BASE_URL>' -e 'PIHOLE_PASSWORD=<your pihole_password>' -- npx -y @ranklancer/pihole-mcp@0.2.0. For other clients, paste the JSON configuration from this page into their MCP settings.

Does Pi-hole MCP Server need an API key?

Yes. It expects PIHOLE_INSTANCES, PIHOLE_BASE_URL, PIHOLE_PASSWORD, which you set in its configuration.

Is Pi-hole MCP Server open source?

Yes. Its code is on GitHub under the MIT license.

Who maintains Pi-hole MCP Server?

It is published by ranklancer. AI.tn lists it but does not maintain or endorse it.

From the official MCP Registry. Listing is not an endorsement: review a server's code and permissions before giving it access to your data.