NetBox MCP Server
Connects to PostgreSQL databases for state confidence queries and data reliability scoring using a muse certainty schema
Integrates with HashiCorp Vault for secure token management using AppRole authentication and just-in-time token minting
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@NetBox MCP Serverlist all devices in the datacenter"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
๐ NetBox MCP Server v1.0
A robust and well-engineered Python MCP (Model Context Protocol) server for NetBox infrastructure access, designed for teaching newer programmers and production use.
๐ฏ Features
Core Functionality
NetBox API Integration - Full access to devices, VMs, IP addresses, and VLANs
HashiCorp Vault Integration - JIT token minting with AppRole authentication
PostgreSQL State Confidence - Query module referencing muse certainty schema
MCP Tools - Comprehensive toolset for infrastructure management
Advanced Capabilities
Tiny LLM Testing - Simulated LLM for CI/CD environments
Structured JSON Protocol - Clear communication between components
Performance Optimizations - Connection pooling, caching, retry strategies
LLM Optimization - Token estimation, response formatting, streaming
๐งช Test Suite
100% Test Success Rate - 129 passed, 1 skipped, 0 failed
Test Coverage
โ Core MCP Server functionality
โ Tiny LLM implementation
โ Structured JSON protocol
โ End-to-end workflows
โ Performance optimizations
โ Tool functionality (hosts, VMs, IPs, VLANs)
โ Error handling and edge cases
๐ Quick Start
Prerequisites
Python 3.12+
NetBox instance
HashiCorp Vault
PostgreSQL database
Installation
# Clone the repository
git clone https://github.com/fringemonkey/mcp-dc.git
cd mcp-dc
# Install dependencies
pip install -r requirements.txt
pip install -r requirements-dev.txt
# Run tests
python -m pytest tests/ -vConfiguration
Set up environment variables:
export NETBOX_URL="http://your-netbox-instance"
export VAULT_ADDR="http://your-vault-instance"
export VAULT_TOKEN="your-vault-token"
export POSTGRES_HOST="localhost"
export POSTGRES_DB="mcp_state"
export POSTGRES_USER="mcp_user"
export POSTGRES_PASSWORD="mcp_password"๐ ๏ธ Development
Running Tests
# Run all tests
python -m pytest tests/ -v
# Run specific test categories
python -m pytest tests/ -m unit
python -m pytest tests/ -m integration
python -m pytest tests/ -m performance
# Run with coverage
python -m pytest tests/ --cov=src --cov-report=htmlCode Quality
# Format code
black src/ tests/
isort src/ tests/
# Lint code
flake8 src/ tests/
mypy src/
# Security check
bandit -r src/
safety check๐ Project Structure
mcp-dc/
โโโ src/ # Source code
โ โโโ server.py # Main MCP server
โ โโโ netbox_client.py # NetBox API client
โ โโโ vault_client.py # Vault authentication
โ โโโ state_confidence.py # PostgreSQL client
โ โโโ tiny_llm.py # Tiny LLM for testing
โ โโโ structured_protocol.py # JSON protocol
โ โโโ llm_optimizer.py # LLM optimizations
โ โโโ tools/ # MCP tools
โ โโโ hosts.py
โ โโโ virtual_machines.py
โ โโโ ip_addresses.py
โ โโโ vlans.py
โโโ tests/ # Test suite
โ โโโ test_core_functionality.py
โ โโโ test_simple_tools.py
โ โโโ test_tiny_llm.py
โ โโโ test_structured_protocol.py
โ โโโ test_llm_optimization.py
โ โโโ test_simple_performance.py
โโโ examples/ # Example scripts
โโโ scripts/ # Utility scripts
โโโ .github/workflows/ # CI/CD pipelines
โโโ .devcontainer/ # Development container๐ง MCP Tools
Host Management
list_hosts- List all devicesget_host- Get specific device detailssearch_hosts- Search devices by criteria
Virtual Machine Management
list_vms- List all VMsget_vm- Get specific VM detailslist_vm_interfaces- List VM interfaces
IP Address Management
list_ips- List all IP addressesget_ip- Get specific IP detailssearch_ips- Search IP addresses
VLAN Management
list_vlans- List all VLANsget_vlan- Get specific VLAN detailslist_vlan_ips- List IPs in VLAN
๐ Educational Value
This project is designed to teach:
MCP Protocol - Model Context Protocol implementation
API Integration - NetBox, Vault, PostgreSQL integration
Testing Strategies - Unit, integration, performance testing
Code Quality - Linting, formatting, security practices
CI/CD - GitHub Actions, automated testing
Documentation - Comprehensive README and code comments
๐ Performance
Connection Pooling - Efficient HTTP connections
Caching - TTL-based response caching
Retry Strategies - Exponential backoff for failures
Memory Efficiency - Optimized data structures
Concurrent Operations - Async/await patterns
๐ Security
Vault Integration - Secure token management
Input Validation - Parameter sanitization
Error Handling - Secure error responses
Security Scanning - Bandit and Safety checks
๐ Monitoring
Metrics Collection - Performance and usage metrics
Logging - Structured logging with levels
Health Checks - Service availability monitoring
State Confidence - Data reliability scoring
๐ค Contributing
Fork the repository
Create a feature branch
Make your changes
Add tests for new functionality
Ensure all tests pass
Submit a pull request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
NetBox team for the excellent infrastructure management platform
HashiCorp for Vault security solutions
PostgreSQL community for the robust database
MCP protocol contributors
Ready for production deployment! ๐
Version 1.0 - Zero test failures, comprehensive functionality, production-ready
Related MCP Connectors
Provides capabilities that let LLM agents perform a range of infrastructure management tasks.
- ZopDev MCPOAuthdev.zop
Cloud cost, inventory and governance on AWS/Azure/GCP. Read-only by default, optional scoped writes
- mcpOAuthcom.vibgrate
Query your team's drift, vulnerability, and upgrade data from any AI assistant. OAuth 2.1, 51 tools.
Unified API to query AWS, GCP, Azure and generate Terraform/CLI execution kits for AI agents.