Skip to main content
Glama

NetBox MCP Server

by fringemonkey
post-start.shโ€ข4.56 kB
#!/bin/bash # NetBox MCP Server DevContainer Post-Start Script # This script runs every time the container starts set -e echo "๐Ÿ”„ Starting NetBox MCP Server development environment..." # Check if we're in a Codespace if [ -n "$CODESPACES" ]; then echo "๐ŸŒ Running in GitHub Codespaces" export CODESPACE_NAME="$CODESPACE_NAME" else echo "๐Ÿ’ป Running in local devcontainer" fi # Ensure Python path is set export PYTHONPATH="/workspaces/mcp-dc/src:$PYTHONPATH" # Check if development services are running echo "๐Ÿ” Checking development services..." # Function to check if a service is running check_service() { local service_name=$1 local port=$2 local url=$3 if curl -s --connect-timeout 5 "$url" > /dev/null 2>&1; then echo "โœ… $service_name is running on port $port" return 0 else echo "โŒ $service_name is not running on port $port" return 1 fi } # Check services netbox_running=false vault_running=false postgres_running=false if check_service "NetBox Mock" "8000" "http://localhost:8000/health"; then netbox_running=true fi if check_service "Vault Mock" "8200" "http://localhost:8200/v1/sys/health"; then vault_running=true fi if docker-compose -f docker-compose.dev.yml ps postgres | grep -q "Up"; then echo "โœ… PostgreSQL is running" postgres_running=true else echo "โŒ PostgreSQL is not running" fi # Start services if they're not running if [ "$netbox_running" = false ] || [ "$vault_running" = false ] || [ "$postgres_running" = false ]; then echo "๐Ÿš€ Starting development services..." ./scripts/start-dev-services.sh # Wait a bit for services to start echo "โณ Waiting for services to be ready..." sleep 10 # Verify services are now running echo "๐Ÿ” Verifying services..." check_service "NetBox Mock" "8000" "http://localhost:8000/health" check_service "Vault Mock" "8200" "http://localhost:8200/v1/sys/health" if docker-compose -f docker-compose.dev.yml ps postgres | grep -q "Up"; then echo "โœ… PostgreSQL is now running" else echo "โŒ PostgreSQL failed to start" fi fi # Set up environment for development echo "โš™๏ธ Setting up development environment..." # Create a symlink to the development environment file if [ ! -f .env ]; then ln -sf .env.dev .env echo "๐Ÿ“ Created .env symlink to .env.dev" fi # Ensure pre-commit hooks are installed if [ -f .pre-commit-config.yaml ]; then pre-commit install --install-hooks echo "๐Ÿช Pre-commit hooks installed" fi # Run a quick health check echo "๐Ÿฅ Running health check..." # Test Python imports python -c " import sys sys.path.insert(0, 'src') try: from src.server import list_tools, call_tool from src.vault_client import VaultClient from src.netbox_client import NetBoxClient from src.state_confidence import StateConfidenceClient print('โœ… All Python imports successful') except ImportError as e: print(f'โŒ Import error: {e}') sys.exit(1) " # Test database connection echo "๐Ÿ—„๏ธ Testing database connection..." python -c " import psycopg2 import os try: conn = psycopg2.connect( host=os.getenv('POSTGRES_HOST', 'localhost'), port=os.getenv('POSTGRES_PORT', '5432'), database=os.getenv('POSTGRES_DB', 'mcp_state'), user=os.getenv('POSTGRES_USER', 'mcp_user'), password=os.getenv('POSTGRES_PASSWORD', 'mcp_password') ) with conn.cursor() as cur: cur.execute('SELECT COUNT(*) FROM state.certainty_scores') count = cur.fetchone()[0] print(f'โœ… Database connection successful, {count} records in certainty_scores') conn.close() except Exception as e: print(f'โŒ Database connection failed: {e}') " # Display status echo "" echo "๐ŸŽ‰ Development environment is ready!" echo "" echo "๐Ÿ“Š Service Status:" echo " - NetBox Mock: http://localhost:8000" echo " - Vault Mock: http://localhost:8200" echo " - PostgreSQL: localhost:5432" echo " - Redis: localhost:6379" echo "" echo "๐Ÿš€ Quick Commands:" echo " - Run tests: ./scripts/test-mcp-server.sh" echo " - Start services: ./scripts/start-dev-services.sh" echo " - Stop services: ./scripts/stop-dev-services.sh" echo "" echo "๐Ÿ“– Documentation: .devcontainer/README.md" echo "" # If running in Codespaces, show the Codespace URL if [ -n "$CODESPACES" ]; then echo "๐ŸŒ Codespace URL: https://$CODESPACE_NAME-8000.app.github.dev" echo " (NetBox Mock will be available at this URL)" fi

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