Pi-hole MCP Server
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.
README
Pi-hole MCP Server
WARNING!!: Currently works only when this MCP server and AI client are on the same machine. Need to figure out why it doesn't approve request from other machines in local network.
An MCP (Model Context Protocol) server for controlling Pi-hole ad blocking.
Note: This server is configured for Pi-hole v6 with REST API authentication using app passwords.
Configuration
The server uses a config.json file for configuration. Create this file in the project root:
{
"server": {
"mode": "stdio",
"port": 5000
},
"pihole": {
"base_url": "http://192.168.68.59:8081/api"
}
}
Configuration Options
server.mode: Server mode -"stdio"(default) or"port"server.port: Port number when using port mode (default: 5000)pihole.base_url: Pi-hole API base URL (default: "http://192.168.68.59:8081/api")
Setup
- Ensure your Pi-hole has an app password configured (Settings > API > App Password)
- Set the environment variable with your app password:
export PIHOLE_APP_PASSWORD=your_app_password_here - Configure the server mode in
config.json
Running
Stdio Mode (Default)
Run the server in stdio mode (for MCP clients):
python main.py
Port Mode
Set "mode": "port" in config.json and run:
python main.py
The server will start on the configured port (default: 5000) using Server-Sent Events (SSE).
Or use the VS Code task: Ctrl+Shift+P > Tasks: Run Task > Run Python Script
Running with Docker
Prerequisites
- Docker and Docker Compose installed
- Pi-hole app password configured
Setup
- Ensure your
config.jsonis configured for your environment - Set the Pi-hole app password as an environment variable:
export PIHOLE_APP_PASSWORD=your_app_password_here
Running
# Build and start the container
docker-compose up --build
# Or run in background
docker-compose up -d --build
Configuration
The container uses the config.json file mounted as a volume. You can modify the configuration file and restart the container:
docker-compose restart
Logs
# View logs
docker-compose logs -f
# View logs for specific service
docker-compose logs -f pihole-mcp
Cleanup
# Stop and remove containers
docker-compose down
# Remove containers and volumes
docker-compose down -v
# Remove images
docker-compose down --rmi all
Tools
get_pihole_status: Get current Pi-hole blocking status (enabled/disabled)get_pihole_summary: Get Pi-hole statistics summary (queries, blocked domains, etc.)enable_pihole: Enable ad blocking permanentlydisable_pihole: Disable ad blocking (optional duration in seconds)
API Details
This implementation uses Pi-hole v6 REST API with session-based authentication:
- Authentication: POST to
/api/authwith app password - Status: GET
/api/dns/blocking - Summary: GET
/api/stats/summary - Control: POST to
/api/dns/blockingwith JSON payload
Testing
Run unit tests (mocked):
python -m pytest test_main.py::TestPiHoleMCP -v
Run configuration tests:
python -m pytest test_main.py::TestConfiguration -v
Run integration tests (requires PIHOLE_APP_PASSWORD and will actually control Pi-hole):
export PIHOLE_APP_PASSWORD=your_app_password
python -m pytest test_main.py::TestPiHoleIntegration -v -s
Warning: Integration tests will enable/disable Pi-hole blocking. Use with caution!
Debugging
Open main.py, press F5 or use the Run and Debug panel.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
E2B
Using MCP to run code via e2b.