Skip to main content
Glama

pfSense MCP Server

by gensecaihq
README.mdโ€ข16 kB
# pfSense Enhanced MCP Server ๐Ÿš€ **A next-generation Model Context Protocol (MCP) server** that enables natural language interaction with pfSense firewalls through Claude Desktop and other GenAI applications. Now with **advanced API features** by pfrest.org including intelligent filtering, HATEOAS navigation, and enterprise-grade controls. ## ๐Ÿงช **Community Testing Needed** > **โš ๏ธ IMPORTANT:** This project needs community testing and validation! > **๐Ÿ‘ฅ We need your help to test this with real pfSense devices and environments.** > > - **๐Ÿ” Test it** with your pfSense setup > - **๐Ÿ› Report issues** via GitHub Issues > - **๐Ÿ”ง Fix bugs** and submit PRs > - **๐Ÿ“ Improve documentation** based on real-world usage > - **๐Ÿ’ก Contribute features** and enhancements > > **Your testing and contributions will help make this production-ready for everyone!** [![Version](https://img.shields.io/badge/version-4.0.0-blue.svg)](https://github.com/gensecaihq/pfsense-mcp-server) [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE) [![MCP](https://img.shields.io/badge/MCP-Compatible-green.svg)](https://modelcontextprotocol.io) [![pfSense API](https://img.shields.io/badge/pfSense%20API-v2-orange.svg)](https://pfrest.org/) [![Community](https://img.shields.io/badge/Community-Welcome-brightgreen.svg)](#-community--contributions) ## โœจ Enhanced Features ### ๐ŸŽฏ **Core Capabilities** - **๐Ÿ—ฃ๏ธ Natural Language Interface**: Control pfSense using plain English with Claude - **๐Ÿ”ง Advanced API Integration**: Full support for [jaredhendrickson13/pfsense-api](https://github.com/jaredhendrickson13/pfsense-api) v2 - **๐Ÿ” Intelligent Filtering**: 8 filter types (exact, contains, regex, ranges) with multi-field support - **๐Ÿ“Š Smart Pagination**: Efficient handling of large datasets with sorting - **๐Ÿ”— HATEOAS Navigation**: Dynamic API exploration with hypermedia controls - **โš™๏ธ Control Parameters**: Fine-grained operation control (apply, async, placement) - **๐Ÿ†” Object ID Management**: Handles dynamic IDs with field-based lookups ### ๐Ÿข **Enterprise Ready** - **๐Ÿ”’ Multi-Auth Support**: API Key, Basic Auth, JWT with security best practices - **๐Ÿ“ˆ Production Monitoring**: Health checks, metrics, audit logging - **๐Ÿณ Container Ready**: Docker deployment with security hardening - **๐ŸŽจ 25+ MCP Tools**: Comprehensive pfSense management capabilities - **โšก High Performance**: Async operations, caching, connection pooling ### ๐ŸŽฎ **Supported pfSense Versions** | Version | Status | API Package | Features | |---------|--------|-------------|----------| | **pfSense CE 2.8.0** | โœ… Fully Supported | [Download](https://github.com/jaredhendrickson13/pfsense-api/releases/latest/download/pfSense-2.8.0-pkg-RESTAPI.pkg) | All enhanced features | | **pfSense Plus 24.11** | โœ… Fully Supported | [Download](https://github.com/jaredhendrickson13/pfsense-api/releases/latest/download/pfSense-24.11-pkg-RESTAPI.pkg) | All enhanced features | ## ๐Ÿš€ Quick Start ### 1. Install pfSense REST API Package **On your pfSense system** (via SSH or console): ```bash # For pfSense CE 2.8.0 pkg-static add https://github.com/jaredhendrickson13/pfsense-api/releases/latest/download/pfSense-2.8.0-pkg-RESTAPI.pkg # For pfSense Plus 24.11 pkg-static -C /dev/null add https://github.com/jaredhendrickson13/pfsense-api/releases/latest/download/pfSense-24.11-pkg-RESTAPI.pkg ``` ### 2. Configure pfSense API 1. Navigate to **System โ†’ REST API** in pfSense webConfigurator 2. Enable the REST API 3. Generate an API key: **System โ†’ User Manager โ†’ [Your User] โ†’ API Keys** 4. Assign appropriate privileges to your API user ### 3. Setup MCP Server ```bash # Clone the repository git clone https://github.com/gensecaihq/pfsense-mcp-server.git cd pfsense-mcp-server # Install dependencies pip install -r requirements.txt # Configure environment cp .env.example .env nano .env # Add your pfSense details ``` **Minimal `.env` configuration:** ```bash PFSENSE_URL=https://your-pfsense.local PFSENSE_API_KEY=your-api-key-here PFSENSE_VERSION=CE_2_8_0 # or PLUS_24_11 AUTH_METHOD=api_key VERIFY_SSL=true ENABLE_HATEOAS=false # Set true for navigation links ``` ### 4. Test Your Setup ```bash # Test enhanced features python tests/test_enhanced_features.py # Start the enhanced MCP server python -m src.main ``` ### 5. Configure Claude Desktop Add to your Claude Desktop configuration: ```json { "mcpServers": { "pfsense-enhanced": { "command": "python", "args": ["/path/to/pfsense-mcp-server/main_enhanced_mcp.py"], "env": { "PFSENSE_URL": "https://your-pfsense.local", "PFSENSE_API_KEY": "your-api-key", "PFSENSE_VERSION": "CE_2_8_0", "ENABLE_HATEOAS": "false" } } } } ``` ## ๐Ÿ› ๏ธ Enhanced MCP Tools ### ๐Ÿ” **Search & Discovery** - `search_interfaces()` - Find interfaces with advanced filtering - `search_firewall_rules()` - Multi-field rule search with pagination - `search_aliases()` - Intelligent alias discovery - `search_dhcp_leases()` - DHCP lease management with state filtering - `find_blocked_rules()` - Locate blocking rules across interfaces ### ๐Ÿ›ก๏ธ **Advanced Firewall Management** - `create_firewall_rule_advanced()` - Create rules with position control - `move_firewall_rule()` - Reorder rules dynamically - `bulk_block_ips()` - Block multiple IPs efficiently - `manage_alias_addresses()` - Add/remove alias entries - `analyze_blocked_traffic()` - Pattern analysis and threat scoring ### ๐Ÿ“Š **Enhanced Monitoring** - `search_logs_by_ip()` - IP-specific log analysis - `get_api_capabilities()` - Discover API features - `follow_api_link()` - Navigate HATEOAS links dynamically - `refresh_object_ids()` - Handle dynamic ID changes - `find_object_by_field()` - Field-based object lookup ### โš™๏ธ **Object & ID Management** - `enable_hateoas()` / `disable_hateoas()` - Control navigation links - `test_enhanced_connection()` - Comprehensive connectivity testing ## ๐Ÿ’ฌ Enhanced Example Prompts ``` "Search for firewall rules on WAN interface blocking port 22" "Show me blocked traffic patterns from the last 24 hours" "Find all aliases containing IP 192.168.1.100" "Block these suspicious IPs: 198.51.100.1, 203.0.113.1" "Search DHCP leases for hostname containing 'server'" "Move firewall rule ID 5 to position 1" "Analyze blocked traffic and group by source IP" "Find interfaces that are currently down" "Search for firewall rules with 'malware' in description" "Show me the top 10 blocked source IPs" ``` ## ๐Ÿ“š Documentation ### ๐Ÿ“– **Setup Guides** - **[pfSense API Installation Guide](PFSENSE_API_INSTALLATION.md)** - Complete setup instructions - **[Enhanced Features Guide](docs/ENHANCED_FEATURES.md)** - Advanced capabilities overview - **[Configuration Reference](docs/CONFIGURATION.md)** - All environment variables ### ๐Ÿ”ง **Technical Documentation** - **[API Integration Details](docs/API_INTEGRATION.md)** - How the enhanced API works - **[MCP Tools Reference](docs/MCP_TOOLS.md)** - Complete tool documentation - **[Troubleshooting Guide](docs/TROUBLESHOOTING.md)** - Common issues and solutions ### ๐Ÿš€ **Deployment** - **[Docker Deployment](docs/DOCKER_DEPLOYMENT.md)** - Container setup - **[Production Guide](docs/PRODUCTION.md)** - Enterprise deployment - **[Security Best Practices](docs/SECURITY.md)** - Hardening guidelines ## ๐Ÿงช Testing ```bash # Test basic API connection python test_pfsense_api_v2.py # Test all enhanced features python test_enhanced_features.py # Run comprehensive test suite pytest tests/ -v # Test specific MCP tools python -c " import asyncio from main_enhanced_mcp import search_firewall_rules print(asyncio.run(search_firewall_rules(interface='wan', page_size=5))) " ``` ## ๐Ÿ—๏ธ Architecture ``` โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ Claude Desktop โ”‚โ”€โ”€โ”€โ”€โ”‚ Enhanced MCP โ”‚โ”€โ”€โ”€โ”€โ”‚ pfSense API v2 โ”‚ โ”‚ (Natural Lang) โ”‚ โ”‚ Server (Python) โ”‚ โ”‚ (REST/GraphQL) โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ โ–ผ โ–ผ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ Advanced Features โ”‚ โ”‚ pfSense System โ”‚ โ”‚ โ€ข Filtering โ”‚ โ”‚ โ€ข Firewall โ”‚ โ”‚ โ€ข Pagination โ”‚ โ”‚ โ€ข Interfaces โ”‚ โ”‚ โ€ข HATEOAS โ”‚ โ”‚ โ€ข Services โ”‚ โ”‚ โ€ข Object IDs โ”‚ โ”‚ โ€ข DHCP/VPN โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ ``` ## ๐Ÿค Community & Contributions ### ๐ŸŒŸ **We Need Your Help!** This MCP server represents a significant advancement in pfSense automation, but **we need the community to help make it even better**! Whether you're a pfSense veteran, Python developer, or GenAI enthusiast, there are many ways to contribute. ### ๐ŸŽฏ **How You Can Help** #### ๐Ÿงช **Beta Testing & Feedback** - **Test in your environment**: Try the enhanced MCP server with your pfSense setup - **Report compatibility**: Let us know what works (and what doesn't) with different pfSense versions - **Share use cases**: Tell us how you're using the MCP tools in real scenarios - **Performance feedback**: Help us optimize for different network sizes and configurations #### ๐Ÿ› **Bug Reports & Issues** - **Found a bug?** [Open an issue](https://github.com/gensecaihq/pfsense-mcp-server/issues) with detailed reproduction steps - **Missing feature?** Suggest new MCP tools or API integrations - **Documentation unclear?** Help us improve the guides and examples #### ๐Ÿ’ป **Code Contributions** - **New MCP tools**: Add tools for pfSense packages (HAProxy, Suricata, etc.) - **Enhanced filtering**: Improve search and discovery capabilities - **Performance optimizations**: Help make the server faster and more efficient - **Test coverage**: Add comprehensive tests for edge cases #### ๐Ÿ“š **Documentation & Examples** - **Real-world examples**: Share Claude prompts that work well - **Integration guides**: How to use with other tools and workflows - **Video tutorials**: Create setup and usage demonstrations - **Translation**: Help make documentation accessible in other languages ### ๐Ÿš€ **Getting Started as a Contributor** 1. **๐Ÿด Fork the repository** and create a feature branch 2. **๐Ÿงช Test your changes** with the comprehensive test suite 3. **๐Ÿ“ Update documentation** for any new features 4. **๐Ÿ”„ Submit a pull request** with a clear description ### ๐Ÿ’ก **Ideas for Contributions** #### ๐ŸŽฏ **High Priority** - Support for additional pfSense packages (Snort, ntopng, FreeRADIUS) - Enhanced security analysis tools - Backup and restore automation - Multi-pfSense instance management #### ๐Ÿ”ง **Technical Improvements** - GraphQL API integration - WebSocket real-time updates - Advanced caching strategies - Performance profiling tools #### ๐ŸŽจ **User Experience** - Natural language query improvements - Claude Desktop interface enhancements - Web-based configuration UI - Mobile-friendly tools ### ๐Ÿ† **Recognition** Contributors will be: - **Listed in our contributors section** - **Credited in release notes** - **Given priority support** for their own deployments - **Invited to the contributor Discord** for direct collaboration ### ๐Ÿ“ข **Stay Connected** - **GitHub Discussions**: Share ideas and ask questions - **Issues**: Report bugs and request features - **Pull Requests**: Contribute code and documentation - **Releases**: Follow for updates and new features **Together, we can make pfSense automation accessible to everyone through natural language! ๐ŸŒŸ** --- *"The best open source projects are built by communities, not individuals. Your contribution, no matter how small, makes a difference!"* ## ๐Ÿ“Š Feature Comparison | Feature | Basic MCP | Enhanced MCP | Benefits | |---------|-----------|--------------|----------| | **API Integration** | XML-RPC only | REST API v2 + fallbacks | Modern, faster, more reliable | | **Filtering** | Basic queries | 8 filter types + regex | Find exactly what you need | | **Pagination** | None | Smart pagination | Handle large datasets | | **Object Management** | Static IDs | Dynamic ID handling | Robust against changes | | **Navigation** | Manual endpoints | HATEOAS links | Discover API capabilities | | **Controls** | Basic operations | Fine-grained parameters | Precise operation control | | **Performance** | Basic caching | Advanced optimization | Faster response times | ## ๐Ÿ”’ Security Considerations - **๐Ÿ” Authentication**: Multi-method support with privilege checking - **๐Ÿ›ก๏ธ Input Validation**: All user inputs validated and sanitized - **๐Ÿ” Audit Logging**: Comprehensive activity tracking - **๐Ÿšซ Rate Limiting**: Protection against abuse - **๐Ÿ”’ SSL/TLS**: Encrypted communication enforced - **๐Ÿ‘ค Privilege Management**: Role-based access control ## ๐Ÿ“ˆ Performance & Scalability - **โšก Async Operations**: Non-blocking I/O for better performance - **๐Ÿ’พ Intelligent Caching**: Reduce API calls with smart caching - **๐Ÿ”„ Connection Pooling**: Efficient resource utilization - **๐Ÿ“Š Pagination**: Handle large datasets efficiently - **๐ŸŽฏ Targeted Queries**: Advanced filtering reduces data transfer - **๐Ÿ“ˆ Metrics**: Built-in monitoring and performance tracking ## ๐Ÿ†˜ Support & Troubleshooting ### Common Issues 1. **Connection Failed**: Check pfSense API package installation 2. **Authentication Error**: Verify API key and user privileges 3. **Permission Denied**: Ensure user has required pfSense privileges 4. **Filter Not Working**: Check filter syntax and field names 5. **Slow Performance**: Enable caching and optimize queries ### Getting Help - **๐Ÿ“– Documentation**: Check our comprehensive guides - **๐Ÿ› Issues**: Search existing issues or create a new one - **๐Ÿ’ฌ Discussions**: Ask questions in GitHub Discussions - **๐Ÿ“ง Support**: Community support through GitHub ## ๐Ÿ“ Changelog ### v4.0.0 - Enhanced API Integration - โœจ Full pfSense REST API v2 support - ๐Ÿ” Advanced filtering with 8 operators - ๐Ÿ“Š Smart pagination and sorting - ๐Ÿ”— HATEOAS navigation support - โš™๏ธ Control parameters implementation - ๐Ÿ†” Dynamic object ID management - ๐Ÿ› ๏ธ 25+ enhanced MCP tools - ๐Ÿ“š Comprehensive documentation ### v3.0.0 - FastMCP Integration - ๐Ÿš€ Migrated to FastMCP framework - ๐Ÿ”ง Improved tool organization - ๐Ÿ“ˆ Better performance and reliability ### v2.0.0 - Production Ready - ๐Ÿณ Docker deployment support - ๐Ÿ”’ Security hardening - ๐Ÿ“Š Monitoring and metrics ### v1.0.0 - Initial Release - ๐ŸŽฏ Basic MCP functionality - ๐Ÿ”Œ XML-RPC integration - ๐Ÿ› ๏ธ Core pfSense tools ## ๐Ÿ“„ License MIT License - see [LICENSE](LICENSE) for details. --- ## ๐Ÿ™ Acknowledgments - **[jaredhendrickson13](https://github.com/jaredhendrickson13)** for the excellent pfSense REST API package - **[Anthropic](https://anthropic.com)** for the Model Context Protocol and Claude - **[Netgate](https://netgate.com)** for pfSense - **[FastMCP](https://github.com/jlowin/fastmcp)** for the MCP framework - **Community contributors** for testing, feedback, and improvements --- <div align="center"> **โญ Star this repo if it helps you manage pfSense with AI! โญ** Made with โค๏ธ by the community, for the community </div>

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/gensecaihq/pfsense-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server