MCP Pi-hole Server
Connects AI assistants to Pi-hole network-wide ad blocker, enabling monitoring of DNS traffic statistics, controlling blocking settings, managing whitelist/blacklist domains, viewing query logs, and performing maintenance tasks through natural language.
README
MCP Pi-hole Server

An MCP (Model Context Protocol) server that connects AI assistants like Claude to your Pi-hole network-wide ad blocker. Manage DNS blocking, view statistics, control whitelists/blacklists, and more through natural language.
Why Use This?
If you're running Pi-hole on your network, this MCP server lets you:
- Monitor DNS traffic - View query statistics, top blocked domains, and client activity
- Control blocking - Enable/disable Pi-hole blocking instantly or with a timer
- Manage lists - Add or remove domains from whitelist and blacklist without opening the web UI
- View query logs - See recent DNS queries with detailed information
- Maintain your Pi-hole - Update gravity (blocklists) and flush DNS cache
Features
| Category | Tools |
|---|---|
| Statistics | Query totals, blocking percentage, top domains, top clients |
| Blocking Control | Enable, disable (with optional timer), check status |
| Domain Lists | Whitelist/blacklist CRUD operations |
| Query Log | Recent DNS queries with client, status, response time |
| Maintenance | Update gravity, flush cache |
| Visualizations | ASCII art dashboards and bar charts with ANSI colors |
Prerequisites
- Node.js 18+
- Pi-hole v6 with API enabled
- Pi-hole app password (generated in Pi-hole settings)
- Network access to Pi-hole from your machine
Installation
Option 1: Install from npm (recommended)
npx mcp-pihole-server
Or install globally:
npm install -g mcp-pihole-server
Option 2: Clone and Build
git clone https://github.com/aplaceforallmystuff/mcp-pihole.git
cd mcp-pihole
npm install
npm run build
Configuration
1. Get Your Pi-hole App Password
- Open your Pi-hole web interface
- Go to Settings > API
- Generate a new app password
- Copy the password (it's only shown once)
2. Configure Your MCP Client
For Claude Desktop
Add to your Claude Desktop config file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"pihole": {
"command": "npx",
"args": ["-y", "mcp-pihole-server"],
"env": {
"PIHOLE_URL": "http://your-pihole-address:8080",
"PIHOLE_PASSWORD": "your-app-password"
}
}
}
}
For Claude Code
Add to ~/.claude.json:
{
"mcpServers": {
"pihole": {
"command": "npx",
"args": ["-y", "mcp-pihole-server"],
"env": {
"PIHOLE_URL": "http://your-pihole-address:8080",
"PIHOLE_PASSWORD": "your-app-password"
}
}
}
}
Environment Variables
| Variable | Description | Example |
|---|---|---|
PIHOLE_URL |
Pi-hole web interface URL | http://pihole.local:8080 |
PIHOLE_PASSWORD |
Pi-hole app password | Your app password from settings |
Usage Examples
Once configured, you can interact with Pi-hole through natural language:
View Statistics
"Show me Pi-hole stats"
"What are the top blocked domains?"
"Which clients are making the most queries?"
Control Blocking
"Is Pi-hole blocking enabled?"
"Disable Pi-hole for 5 minutes"
"Re-enable Pi-hole blocking"
Manage Domain Lists
"Add example.com to the whitelist"
"Block ads.trackersite.com"
"Show me all whitelisted domains"
View Query Log
"Show me the last 50 DNS queries"
"What domains has my phone been querying?"
Visual Dashboards
"Show me Pi-hole stats with visualize: true"
"Get top blocked domains with visualization"
Available Tools
Statistics
pihole_get_stats- Get comprehensive Pi-hole statisticspihole_get_top_blocked- Get top blocked domainspihole_get_top_permitted- Get top permitted domainspihole_get_top_clients- Get top clients by query countpihole_get_query_log- Get recent DNS queries
Blocking Control
pihole_get_blocking_status- Check if blocking is enabledpihole_enable_blocking- Enable DNS blockingpihole_disable_blocking- Disable blocking (optionally with timer)
Domain Management
pihole_get_whitelist- List all whitelisted domainspihole_get_blacklist- List all blacklisted domainspihole_add_to_whitelist- Add domain to whitelistpihole_add_to_blacklist- Add domain to blacklistpihole_remove_from_whitelist- Remove domain from whitelistpihole_remove_from_blacklist- Remove domain from blacklist
Maintenance
pihole_update_gravity- Update blocklists (gravity)pihole_flush_cache- Flush DNS cache
ASCII Visualizations
This server supports colorful ASCII art visualizations rendered directly in your terminal using ANSI escape codes.
Supported Tools
The following tools support the optional visualize: true parameter:
| Tool | Visualization |
|---|---|
pihole_get_stats |
Full dashboard with summary stats, top clients, blocked domains, and permitted domains |
pihole_get_top_blocked |
Red bar chart of blocked domains |
pihole_get_top_permitted |
Green bar chart of permitted domains |
pihole_get_top_clients |
Blue bar chart of client activity |
Usage
Pass visualize: true to any supported tool:
{
"name": "pihole_get_stats",
"arguments": {
"visualize": true
}
}
When visualize is not set or false, tools return JSON data as usual.
Example Output
╔════════════════════════════════════════════════════════════════════════════╗
║ 🛡️ PI-HOLE DASHBOARD ║
╠════════════════════════════════════════════════════════════════════════════╣
║ ║
║ 📊 SUMMARY ║
║ ────────────────────────────────────────────────────────────────────────── ║
║ Total Queries: 73K Domains Blocked: 2.4M ║
║ Blocked: 22K Active Clients: 28 ║
║ Block Rate: 29.7% Total Clients: 115 ║
╠════════════════════════════════════════════════════════════════════════════╣
║ 🔝 TOP CLIENTS ║
║ ────────────────────────────────────────────────────────────────────────── ║
║ 192.168.1.52 ████████████████████████████████████████ 28K (38%) ║
║ 192.168.1.51 ███████████████████▋ 14K (19%) ║
╚════════════════════════════════════════════════════════════════════════════╝
(Colors appear in terminals that support ANSI escape codes)
Development
# Run in development mode (auto-reloads)
npm run watch
# Build for production
npm run build
# Run the built version
node dist/index.js
Troubleshooting
"PIHOLE_URL and PIHOLE_PASSWORD environment variables are required"
Ensure both environment variables are set in your MCP config.
"Authentication failed"
Your app password is invalid or expired. Generate a new one from Pi-hole Settings > API.
"API request failed: 401"
Session expired. The server will automatically re-authenticate, but if issues persist, check your password.
Connection refused
Ensure Pi-hole is running and the URL is correct. Check that you can access the Pi-hole web interface from your machine.
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
License
MIT License - see LICENSE for details.
Links
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。