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.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。