loading…
Search for a command to run...
loading…
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.
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.
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.
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"
}
}
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")export PIHOLE_APP_PASSWORD=your_app_password_here
config.jsonRun the server in stdio mode (for MCP clients):
python main.py
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
config.json is configured for your environmentexport PIHOLE_APP_PASSWORD=your_app_password_here
# Build and start the container
docker-compose up --build
# Or run in background
docker-compose up -d --build
The container uses the config.json file mounted as a volume. You can modify the configuration file and restart the container:
docker-compose restart
# View logs
docker-compose logs -f
# View logs for specific service
docker-compose logs -f pihole-mcp
# Stop and remove containers
docker-compose down
# Remove containers and volumes
docker-compose down -v
# Remove images
docker-compose down --rmi all
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)This implementation uses Pi-hole v6 REST API with session-based authentication:
/api/auth with app password/api/dns/blocking/api/stats/summary/api/dns/blocking with JSON payloadRun 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!
Open main.py, press F5 or use the Run and Debug panel.
Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"pi-hole-mcp-server": {
"command": "npx",
"args": []
}
}
}