io.github.aplaceforallmystuff/mcp-pihole

平台与服务

by aplaceforallmystuff

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

什么是 io.github.aplaceforallmystuff/mcp-pihole

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

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.git
cd mcp-pihole
npm install
npm 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

code
╔════════════════════════════════════════════════════════════════════════════╗
║                         🛡️  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 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

常见问题

io.github.aplaceforallmystuff/mcp-pihole 是什么?

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

相关 Skills

MCP构建

by anthropics

Universal
热门

聚焦高质量 MCP Server 开发,覆盖协议研究、工具设计、错误处理与传输选型,适合用 FastMCP 或 MCP SDK 对接外部 API、封装服务能力。

想让 LLM 稳定调用外部 API,就用 MCP构建:从 Python 到 Node 都有成熟指引,帮你更快做出高质量 MCP 服务器。

平台与服务
未扫描114.1k

Slack动图

by anthropics

Universal
热门

面向Slack的动图制作Skill,内置emoji/消息GIF的尺寸、帧率和色彩约束、校验与优化流程,适合把创意或上传图片快速做成可直接发送的Slack动画。

帮你快速做出适配 Slack 的动图,内置约束规则和校验工具,少踩上传与播放坑,做表情包和演示都更省心。

平台与服务
未扫描114.1k

MCP服务构建器

by alirezarezvani

Universal
热门

从 OpenAPI 一键生成 Python/TypeScript MCP server 脚手架,并校验 tool schema、命名规范与版本兼容性,适合把现有 REST API 快速发布成可生产演进的 MCP 服务。

帮你快速搭建 MCP 服务与后端 API,脚手架完善、扩展顺手,尤其适合想高效验证服务能力的开发者。

平台与服务
未扫描10.2k

相关 MCP Server

Slack 消息

编辑精选

by Anthropic

热门

Slack 是让 AI 助手直接读写你的 Slack 频道和消息的 MCP 服务器。

这个服务器解决了团队协作中需要 AI 实时获取 Slack 信息的痛点,特别适合开发团队让 Claude 帮忙汇总频道讨论或发送通知。不过,它目前只是参考实现,文档有限,不建议在生产环境直接使用——更适合开发者学习 MCP 如何集成第三方服务。

平台与服务
83.4k

by netdata

热门

io.github.netdata/mcp-server 是让 AI 助手实时监控服务器指标和日志的 MCP 服务器。

这个工具解决了运维人员需要手动检查系统状态的痛点,最适合 DevOps 团队让 Claude 自动分析性能数据。不过,它依赖 NetData 的现有部署,如果你没用过这个监控平台,得先花时间配置。

平台与服务
78.4k

by d4vinci

热门

Scrapling MCP Server 是专为现代网页设计的智能爬虫工具,支持绕过 Cloudflare 等反爬机制。

这个工具解决了爬取动态网页和反爬网站时的头疼问题,特别适合需要批量采集电商价格或新闻数据的开发者。不过,它依赖外部浏览器引擎,资源消耗较大,不适合轻量级任务。

平台与服务
35.4k

评论