
Mcp Pihole
io.github.aplaceforallmystuff由 GitHub 账号 aplaceforallmystuff 发布v1.0.1更新于 Oct 24, 2026
Pi-hole v6 MCP server - manage DNS blocking, stats, whitelists/blacklists
概览
把助手连接到自建的 Pi-hole v6 广告拦截器,用于查看 DNS 统计、开关拦截,并管理白名单和黑名单域名。
- 可以做什么
- 读取 DNS 统计:查询总量、拦截比例、拦截与放行最多的域名、查询最多的客户端以及最近的查询日志。
- 开启或关闭 DNS 拦截,可设置定时,并查看当前拦截状态。
- 列出、添加和删除白名单与黑名单中的域名。
- 执行维护操作:更新 gravity 拦截列表并清空 DNS 缓存。
- 可选在终端中以 ASCII 仪表盘和柱状图展示统计数据。
- 适用场景
- 适合在网络上运行 Pi-hole v6、希望用自然语言查询 DNS 流量、临时关闭拦截或修改允许与拦截列表,而不想打开网页管理界面的场景。
- 运行要求
- 通过 npx 或全局 npm 安装在本机运行,需要 Node.js 18 或更高版本。需要可访问且已启用 API 的 Pi-hole v6 实例,设置 PIHOLE_URL 环境变量,并在 PIHOLE_PASSWORD 中提供 Pi-hole 应用密码。本机需能通过网络访问 Pi-hole。
安装
在 SourceWeft 中
- 打开 控制台中的 Mcp Pihole,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
MCP Pi-hole Server
[npm version] [CI] [License: MIT] [MCP]
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
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)
Or install globally:
Option 2: Clone and 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
For Claude Code
Add to ~/.claude.json:
Environment Variables
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:
Usage
Pass visualize: true to any supported tool:
When visualize is not set or false, tools return JSON data as usual.
Example Output
(Colors appear in terminals that support ANSI escape codes)
Development
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
来源:README.md,提交 ac5c0d7
工具
0版本历史
1- v1.0.1最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分