Skip to main content
Glama

NetBox MCP Server

by fringemonkey

๐Ÿš€ 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

  • 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 - All tests passing with streamlined test suite

Test Coverage

  • โœ… Core MCP Server functionality

  • โœ… 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/ -v

Configuration

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=html

Code 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 โ”‚ โ”œโ”€โ”€ structured_protocol.py # JSON protocol โ”‚ โ”œโ”€โ”€ llm_optimizer.py # LLM optimizations โ”‚ โ”œโ”€โ”€ llm_mcp_server.py # LLM MCP server โ”‚ โ”œโ”€โ”€ structured_mcp_server.py # Structured MCP server โ”‚ โ””โ”€โ”€ tools/ # MCP tools โ”‚ โ”œโ”€โ”€ hosts.py โ”‚ โ”œโ”€โ”€ virtual_machines.py โ”‚ โ”œโ”€โ”€ ip_addresses.py โ”‚ โ””โ”€โ”€ vlans.py โ”œโ”€โ”€ tests/ # Test suite โ”‚ โ”œโ”€โ”€ test_server.py โ”‚ โ”œโ”€โ”€ test_llm_optimization.py โ”‚ โ”œโ”€โ”€ test_simple_performance.py โ”‚ โ””โ”€โ”€ test_structured_protocol.py โ”œโ”€โ”€ examples/ # Example scripts โ”œโ”€โ”€ scripts/ # Utility scripts โ”œโ”€โ”€ docs/ # Documentation โ””โ”€โ”€ .devcontainer/ # Development container

๐Ÿ”ง MCP Tools

Host Management

  • list_hosts - List all devices

  • get_host - Get specific device details

  • search_hosts - Search devices by criteria

Virtual Machine Management

  • list_vms - List all VMs

  • get_vm - Get specific VM details

  • list_vm_interfaces - List VM interfaces

IP Address Management

  • list_ips - List all IP addresses

  • get_ip - Get specific IP details

  • search_ips - Search IP addresses

VLAN Management

  • list_vlans - List all VLANs

  • get_vlan - Get specific VLAN details

  • list_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

  1. Fork the repository

  2. Create a feature branch

  3. Make your changes

  4. Add tests for new functionality

  5. Ensure all tests pass

  6. 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

-
security - not tested
F
license - not found
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Enables interaction with NetBox infrastructure management platform to query and manage devices, VMs, IP addresses, and VLANs. Features secure HashiCorp Vault integration and PostgreSQL state tracking for comprehensive infrastructure automation.

  1. ๐ŸŽฏ Features
    1. Core Functionality
    2. Advanced Capabilities
  2. ๐Ÿงช Test Suite
    1. Test Coverage
  3. ๐Ÿš€ Quick Start
    1. Prerequisites
    2. Installation
    3. Configuration
  4. ๐Ÿ› ๏ธ Development
    1. Running Tests
    2. Code Quality
  5. ๐Ÿ“ Project Structure
    1. ๐Ÿ”ง MCP Tools
      1. Host Management
      2. Virtual Machine Management
      3. IP Address Management
      4. VLAN Management
    2. ๐ŸŽ“ Educational Value
      1. ๐Ÿš€ Performance
        1. ๐Ÿ”’ Security
          1. ๐Ÿ“Š Monitoring
            1. ๐Ÿค Contributing
              1. ๐Ÿ“„ License
                1. ๐ŸŽ‰ Acknowledgments

                  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/fringemonkey/mcp-dc'

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