Pi-hole MCP Server

by sbarbett
Verified

local-only server

The server can only run on the client’s local machine because it depends on local resources.

Integrations

  • Exposes Pi-hole functionality through tools for listing local DNS settings and retrieving recent DNS query history from a Pi-hole instance.

pihole-mcp-serer

A Model Context Protocol (MCP) server for Pi-hole. This server exposes Pi-hole functionality as tools that can be used by AI assistants.

Features

  • ListLocalDNS: Returns all local DNS settings from Pi-hole
  • ListQueries: Returns recent DNS query history from Pi-hole
  • ...more to come...

Dependencies

Docker

Environment

Create a .env file in the project root with your Pi-hole credentials:

PIHOLE_URL=https://your-pihole.local/ PIHOLE_PASSWORD=your-admin-password

Docker Deployment

Run the Pi-hole MCP server in Docker.

Using Docker Compose

  1. Pull and start the container:
    docker-compose up -d
  2. The server will be available at http://localhost:8383

Manual Docker Build

Alternatively, you can build and run the Docker container manually:

docker build -t pihole-mcp . docker run -p 8383:8000 --env-file .env -d pihole-mcp

API

This MCP server exposes two tools:

  • list_local_dns: Lists all local DNS settings from Pi-hole
  • list_queries: Fetches the recent DNS query history from Pi-hole

Testing in goose

Goose is a CLI LLM client that's useful for testing and development. Follow their install instructions here.

The following assumes you've completed the initial setup with goose configure.

Configure Extension

  1. Type goose configure to open the configuration menu.
  2. Select Add Extension
  3. Select Remote Extension
  4. It will ask for a name. It doesn't matter what you name it. I called mine pihole-mcp.
  5. When it asks "What is the SSE endpoint URI?" enter http://localhost:8383/sse.
  6. Enter a timeout.
  7. Add a description if you'd like.
  8. Select No when it asks about environment variables.

Start a Session

Once the server is installed, start a chat session.

goose session

Try asking it: "What are my local DNS records?"

...or telling it: "Show me my recent DNS queries."

Claude Desktop

Claude's desktop client currently only support's the STDIO protocol, however you can use a proxy to communicate with the SSE endpoint.

Add the following to your claude_desktop_config.json file.

{ "mcpServers": { "pihole": { "command": "npx", "args": [ "mcp-remote", "http://localhost:8383/sse" ] } } }

If you're connecting to a different host on your local network and using an unsecured connection, you'll need to explicitly allow it with the --allow-http argument. For example:

{ "mcpServers": { "pihole": { "command": "npx", "args": [ "mcp-remote", "http://192.168.1.255:8383/sse", "--allow-http" ] } } }

Afterwards, completely restart the application and try it out.

License

MIT

-
security - not tested
A
license - permissive license
-
quality - not tested

A server that exposes Pi-hole functionality as tools for AI assistants, allowing them to retrieve local DNS settings and query history through natural language.

  1. Features
    1. Dependencies
      1. Docker
    2. Environment
      1. Docker Deployment
        1. Using Docker Compose
        2. Manual Docker Build
      2. API
        1. Testing in goose
          1. Configure Extension
          2. Start a Session
        2. Claude Desktop
          1. License
            ID: w63srjkegx