Sponsored by Deepsite.site

PiHole MCP Server

Created By
NickJLange10 months ago
Content

PiHole MCP Server

Dear Lord, Why?

We are building this project to enhance the management experience of Pi-hole devices. We believe that natural language processing capabilities can make it easier for users to interact with their Pi-hole devices. We are also building this project to learn more about FastAPI and Retrieval-Augmented Generation (RAG) systems.

MCP Server Overview

The MCP Server is designed to interact with Pi-hole devices using a RESTful API built with FastAPI, allowing for query-based management and retrieval of Pi-hole statistics through a Retrieval-Augmented Generation (RAG) system. This service aims to enhance the Pi-hole management experience with natural language processing capabilities.

Installation
  1. Clone the Repository:

    git clone [your repository URL]
    cd mcp_server
    
  2. Set Up Virtual Environment:

    python -m venv venv
    source venv/bin/activate  # On Windows, use `venv\Scripts\activate`
    
  3. Install Dependencies:

    pip install -r requirements.txt
    
  4. Configuration:

    • Copy config.toml.example to config.toml.
    • Adjust the settings according to your Pi-hole setup, API keys, and Milvus database connection details.
    • For secrets like API keys, use an .env file:
Running the Server
uvicorn main:app --host 0.0.0.0 --port 8000
API Usage
  • Query Endpoint: Use POST requests to /query with headers including X-API-Key. Example:

    POST /query HTTP/1.1
    Host: yourserver.com
    X-API-Key: your_api_key_here
    Content-Type: application/json
    
    {
      "query": "Block internet for 10 minutes."
    }
    
  • Feature Flags: Check config.toml for feature flag settings which control available functionalities.

Documentation

  • Refer to the API documentation at /docs when the server is running for detailed endpoint usage.

README for Developers

We are going to use the LLM to scan the API endpoint and generate the code automatically. We are then going to apply a patch from the last known working version and work through the breaks.

We'll keep previous LLM generated code in a separate branch for reference to ensure benchmarking is correct.

Development Guidelines

  • Structure: The project uses FastAPI with dependencies managed via pyproject.toml or requirements.txt.
  • Logging: Logging configurations are stored in logging_config.py. Ensure logs are clear and do not include sensitive information.
  • Testing: Use pytest for writing and running tests. Mocking is encouraged for external services like Milvus and Pi-hole.
Code Contribution
  1. Fork the Repository:

    git clone [your fork]
    
  2. Setup & Develop:

    • Follow the installation guide above to set up your development environment.
    • Before committing:
      • Run tests:
        pytest
        
      • Ensure code style with linters (flake8, mypy, black, isort).
  3. Submit Pull Requests:

    • Push changes to your fork, then open a pull request against the main branch.
Error Handling
  • Customize and implement exception handlers for common errors like PiholeConnectionError or RagIntentNotFoundError.
Documentation
  • Update README.md for changes in functionality or dependencies.
  • Keep todo.md current with your development tasks.

Build Policy Using LLM and Patches

Overview:

  • We use an LLM (Language Model) to generate the initial codebase or provide solutions to new features or bug fixes, which is then refined through manual code review and patch application.

Process:

  1. Start up pihole in the containers directory

  2. cd prompts/; ./run_plan.sh

  3. Start new branch to compare gameplan.md for material differences

  4. Use gameplan.md to generate the individual prompts for aider.md

  5. Use aider to generate code for specific features or issues based on gameplan.md

  6. Work the diff between the code generated and the previous llm version

  7. Apply the patches from "Working" to clean up the mess

  8. $$$$ profit

  9. Integration Testing:

    • Ensure the new code works as expected by running full integration tests.
  10. Documentation Update:

    • Document the new feature, fix, or changes, updating both user and developer documentation.

Policy Notes:

  • Never directly commit LLM generated code without human review.
  • Maintain a log of generated code sources for traceability.
  • Prioritize security and efficiency when reviewing and patching LLM-generated code.
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
ChatWiseThe second fastest AI chatbot™
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Y GuiA web-based graphical interface for AI chat interactions with support for multiple AI models and MCP (Model Context Protocol) servers.
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
CursorThe AI Code Editor
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Serper MCP ServerA Serper MCP Server
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
DeepChatYour AI Partner on Desktop
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Playwright McpPlaywright MCP server
Amap Maps高德地图官方 MCP Server
Tavily Mcp
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
WindsurfThe new purpose-built IDE to harness magic