Mcp Pihole

io.github.aplaceforallmystuff由 GitHub 账号 aplaceforallmystuff 发布v1.0.1更新于 Oct 24, 2026

Pi-hole v6 MCP server - manage DNS blocking, stats, whitelists/blacklists

概览

AI 生成的概览

把助手连接到自建的 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。
安装前请注意
Pi-hole 应用密码以明文形式通过 PIHOLE_PASSWORD 环境变量提供,请保护好客户端配置文件。多个工具会改变网络状态:关闭拦截、增删列表条目、更新 gravity 和清空缓存。查询日志会暴露客户端 IP 地址和访问的域名。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Mcp Pihole,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

MCP Pi-hole Server

[npm version] [CI] [License: MIT] [MCP]

[Architecture]

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

CategoryTools
StatisticsQuery totals, blocking percentage, top domains, top clients
Blocking ControlEnable, disable (with optional timer), check status
Domain ListsWhitelist/blacklist CRUD operations
Query LogRecent DNS queries with client, status, response time
MaintenanceUpdate gravity, flush cache
VisualizationsASCII 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)

bash
npx mcp-pihole-server

Or install globally:

bash
npm install -g mcp-pihole-server

Option 2: Clone and Build

bash
git clone https://github.com/aplaceforallmystuff/mcp-pihole.gitcd mcp-piholenpm installnpm run build

Configuration

1. Get Your Pi-hole App Password

  1. Open your Pi-hole web interface
  2. Go to Settings > API
  3. Generate a new app password
  4. 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

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:

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

VariableDescriptionExample
PIHOLE_URLPi-hole web interface URLhttp://pihole.local:8080
PIHOLE_PASSWORDPi-hole app passwordYour 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 statistics
  • pihole_get_top_blocked - Get top blocked domains
  • pihole_get_top_permitted - Get top permitted domains
  • pihole_get_top_clients - Get top clients by query count
  • pihole_get_query_log - Get recent DNS queries

Blocking Control

  • pihole_get_blocking_status - Check if blocking is enabled
  • pihole_enable_blocking - Enable DNS blocking
  • pihole_disable_blocking - Disable blocking (optionally with timer)

Domain Management

  • pihole_get_whitelist - List all whitelisted domains
  • pihole_get_blacklist - List all blacklisted domains
  • pihole_add_to_whitelist - Add domain to whitelist
  • pihole_add_to_blacklist - Add domain to blacklist
  • pihole_remove_from_whitelist - Remove domain from whitelist
  • pihole_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:

ToolVisualization
pihole_get_statsFull dashboard with summary stats, top clients, blocked domains, and permitted domains
pihole_get_top_blockedRed bar chart of blocked domains
pihole_get_top_permittedGreen bar chart of permitted domains
pihole_get_top_clientsBlue bar chart of client activity

Usage

Pass visualize: true to any supported tool:

json
{  "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

bash
# Run in development mode (auto-reloads)npm run watch
# Build for productionnpm run build
# Run the built versionnode 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

来源:README.md,提交 ac5c0d7

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v1.0.1最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分