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 分