MCP-OpenStack-Ops

A comprehensive MCP (Model Context Protocol) server providing OpenStack cluster management and monitoring capabilities with built-in safety controls.

MCP-OpenStack-Ops

MCP OpenStack Operations Server: A comprehensive MCP (Model Context Protocol) server providing OpenStack cluster management and monitoring capabilities with built-in safety controls.

License: MIT Deploy to PyPI with tag Ask DeepWiki BuyMeACoffee


🎯 Target Environment: This MCP server is specifically designed and tested for OpenStack Epoxy (2025.1) using OpenStack SDK 4.1.0-4.4.0. For optimal compatibility and performance, ensure your OpenStack environment is running Epoxy release.

Features

  • OpenStack Epoxy Integration: Direct integration with OpenStack SDK 4.1.0-4.4.0 for real-time cluster operations.
  • Production-Safe Operations: Built-in safety controls with ALLOW_MODIFY_OPERATIONS environment variable to prevent destructive actions in production environments.
  • Comprehensive Monitoring: Enhanced cluster status reports with hypervisor health, resource utilization, and health scoring.
  • Complete Service Coverage: 39 comprehensive tools covering Identity, Compute, Network, Storage, Image, and Orchestration services.
  • Advanced Instance Management: Enhanced server lifecycle operations with backup, migration, rescue, and administrative functions.
  • Server Event Tracking: Detailed server event history and lifecycle monitoring with comprehensive logging.
  • Hypervisor Monitoring: Real-time hypervisor resource statistics with utilization tracking and cluster totals.
  • Volume Management: Comprehensive volume attachment/detachment operations with metadata tracking.
  • Large-Scale Environment Support: Pagination and limits for environments with thousands of instances.
  • Enterprise Features: User management, role assignments, keypair management, floating IP operations, volume snapshots.
  • Intelligent Search: Flexible instance search with partial matching and case-sensitive options.
  • Network & Volume Operations: Comprehensive network analysis and volume management capabilities.
  • Connection Optimization: Global connection caching and automatic retry mechanisms.
  • Docker Support: Containerized deployment optimized for OpenStack Epoxy environments.
  • Flexible Transport: Support for both stdio and streamable-http transports with comprehensive logging.

⚠️ Compatibility Notice: This MCP server is developed and optimized for OpenStack Epoxy (2025.1) as the primary target environment. However, it is compatible with most modern OpenStack releases (Dalmatian, Caracal, Bobcat, etc.) as the majority of APIs remain consistent across versions. Only a few specific API endpoints may require adaptation for full compatibility with older releases.

🚧 Coming Soon: Dynamic multi-version OpenStack API compatibility is actively under development and will be available in upcoming releases, providing seamless support for all major OpenStack deployments automatically.


Screenshots

OpenStack Dashboard (Epoxy 2025.1)

OpenStack Dashboard (Epoxy 2025.1)

MCP Query Example - Cluster Status

Example Cluster Status


📊 OpenStack CLI vs MCP Tools Mapping

Detailed Mapping by Category

1. 🖥️ Compute (Nova) - 85% Implementation

OpenStack CLI CommandMCP ToolStatusNotes
openstack server listget_instance_detailsPagination, filtering support
openstack server showget_instance_by_name, get_instance_by_idID/name search
openstack server createset_instance (action="create")Instance creation
openstack server start/stop/rebootset_instanceFull lifecycle management
openstack server deleteset_instance (action="delete")Instance deletion
openstack server backupset_instance (action="backup")Backup creation
openstack server shelve/unshelveset_instanceInstance shelving
openstack server resizeset_instance (action="resize")Instance resizing
openstack server rebuildset_instance (action="rebuild")Instance rebuilding
openstack server rescue/unrescueset_instanceRecovery mode
openstack server migrateNot implementedMigration functionality
openstack server event listget_server_eventsServer event tracking
openstack server group listget_server_groupsServer group listing
openstack server group create/deleteset_server_groupServer group management
openstack flavor listget_flavor_list (via cluster_status)Flavor listing
openstack flavor create/deleteset_flavorFlavor management
openstack keypair listget_keypair_listKeypair listing
openstack keypair create/deleteset_keypairKeypair management
openstack hypervisor listget_hypervisor_detailsHypervisor querying
openstack availability zone listget_availability_zonesAvailability zone listing

2. 🌐 Network (Neutron) - 80% Implementation

OpenStack CLI CommandMCP ToolStatusNotes
openstack network listget_network_detailsDetailed network information
openstack network showget_network_details (name param)Specific network query
openstack network create/deleteNot implementedNetwork creation/deletion
openstack subnet listget_network_details (includes subnets)Subnet information included
openstack subnet create/deleteset_subnetsSubnet management
openstack router listget_routersRouter listing
openstack router create/deleteNot implementedRouter management
openstack floating ip listget_floating_ipsFloating IP listing
openstack floating ip create/deleteset_floating_ipFloating IP management
openstack security group listget_security_groupsSecurity group listing
openstack security group create/deleteNot implementedSecurity group management
openstack port listget_network_details (includes ports)Port information included
openstack port create/deleteset_network_portsPort management
openstack network qos policy listNot implementedQoS policy listing
openstack network qos policy createset_network_qos_policiesQoS policy management
openstack network agent listget_service_status (includes agents)Network agents
openstack network agent setset_network_agentsNetwork agent management

3. 💾 Storage (Cinder) - 90% Implementation

OpenStack CLI CommandMCP ToolStatusNotes
openstack volume listget_volume_listVolume listing
openstack volume showget_volume_list (filtering)Specific volume query
openstack volume create/deleteset_volumeVolume creation/deletion
openstack volume setset_volume (action="modify")Volume property modification
openstack volume type listget_volume_typesVolume type listing
openstack volume type create/deleteNot implementedVolume type management
openstack volume snapshot listget_volume_snapshotsSnapshot listing
openstack volume snapshot create/deleteset_snapshotSnapshot management
openstack backup listNot implementedBackup listing
openstack backup create/deleteset_volume_backupsVolume backup management
openstack volume transfer request listNot implementedVolume transfer
openstack server volume listget_server_volumesServer volume listing
openstack server add/remove volumeset_server_volumeServer volume attach/detach
openstack volume group listNot implementedVolume group listing
openstack volume group createset_volume_groupsVolume group management
openstack volume qos listNot implementedQoS listing
openstack volume qos createset_volume_qosQoS management

4. 🖼️ Image (Glance) - 75% Implementation

OpenStack CLI CommandMCP ToolStatusNotes
openstack image listget_image_detail_listImage listing
openstack image showget_image_detail_list (filtering)Specific image query
openstack image createset_image (action="create")Image creation
openstack image deleteset_image (action="delete")Image deletion
openstack image setset_image (action="update")Image property modification
openstack image saveset_image (action="save")Image download
openstack image add projectNot implementedProject sharing
openstack image member listNot implementedMember listing
openstack image member createset_image_membersImage member management
openstack image set --propertyset_image_metadataImage metadata
openstack image set --public/privateset_image_visibilityImage visibility setting

5. 👥 Identity (Keystone) - 70% Implementation

OpenStack CLI CommandMCP ToolStatusNotes
openstack user listget_user_listUser listing
openstack user showget_user_list (filtering)Specific user query
openstack user create/deleteNot implementedUser management
openstack project listget_project_detailsProject listing
openstack project showget_project_details (name param)Specific project query
openstack project create/deleteset_projectProject management
openstack role listget_role_assignmentsRole listing
openstack role assignment listget_role_assignmentsRole assignment listing
openstack role create/deleteset_rolesRole management
openstack domain listNot implementedDomain listing
openstack domain create/deleteset_domainsDomain management
openstack group listNot implementedGroup listing
openstack group create/deleteset_identity_groupsGroup management
openstack service listget_service_statusService listing
openstack service create/deleteset_servicesService management
openstack endpoint listget_service_status (includes endpoints)Endpoint information

6. 🔥 Orchestration (Heat) - 40% Implementation

OpenStack CLI CommandMCP ToolStatusNotes
openstack stack listget_heat_stacksStack listing
openstack stack showget_heat_stacks (filtering)Specific stack query
openstack stack createset_heat_stack (action="create")Stack creation
openstack stack deleteset_heat_stack (action="delete")Stack deletion
openstack stack updateset_heat_stack (action="update")Stack update
openstack stack suspend/resumeset_heat_stackStack suspend/resume
openstack stack resource listNot implementedStack resource listing
openstack stack event listNot implementedStack event listing
openstack stack template showNot implementedTemplate query
openstack stack output listNot implementedStack output listing

7. 📊 Monitoring & Logging - 60% Implementation

OpenStack CLI CommandMCP ToolStatusNotes
Resource monitoringget_resource_monitoringResource monitoring
Service statusget_service_statusService status query
Cluster overviewget_cluster_statusCluster overview
Service logsset_service_logsService log management
System metricsset_metricsMetrics management
Alarm managementset_alarmsAlarm management
Compute agentsset_compute_agentsCompute agent management
Usage statisticsget_usage_statisticsUsage statistics

8. 📏 Usage & Quota - 80% Implementation

OpenStack CLI CommandMCP ToolStatusNotes
openstack quota showget_quotaQuota query
openstack quota setset_quotaQuota setting
openstack usage showget_usage_statisticsUsage query
openstack limits showget_quota (includes limits)Limits query
Resource utilizationget_resource_monitoringResource utilization

Quick Start

1. Environment Setup

# Clone and navigate to project
cd MCP-OpenStack-Ops

# Install dependencies
uv sync

# Configure environment
cp .env.example .env
# Edit .env with your OpenStack credentials

Environment Configuration

Configure your .env file with OpenStack credentials:

# OpenStack Authentication (required)
OS_AUTH_HOST=your-openstack-host
OS_AUTH_PORT=5000
OS_IDENTITY_API_VERSION=3
OS_USERNAME=your-username
OS_PASSWORD=your-password
OS_PROJECT_NAME=your-project
OS_PROJECT_DOMAIN_NAME=default
OS_USER_DOMAIN_NAME=default
OS_REGION_NAME=RegionOne

# OpenStack Service Ports (customizable)
OS_COMPUTE_PORT=8774
OS_NETWORK_PORT=9696
OS_VOLUME_PORT=8776
OS_IMAGE_PORT=9292
OS_PLACEMENT_PORT=8780
OS_HEAT_STACK_PORT=8004
OS_HEAT_STACK_CFN_PORT=8000

# MCP Server Configuration (optional)
MCP_LOG_LEVEL=INFO
ALLOW_MODIFY_OPERATIONS=false
FASTMCP_TYPE=stdio
FASTMCP_HOST=127.0.0.1
FASTMCP_PORT=8080

2. Run Server

# Start all services
docker-compose up -d

# Check logs
docker-compose logs mcp-server
docker-compose logs mcpo-proxy

Container Architecture:

  • mcp-server: OpenStack MCP server with tools
  • mcpo-proxy: OpenAPI (REST-API)
  • open-webui: Web interface for testing and interaction

Service URLs - Docker Internal:

  • MCP Server: localhost:8080 (HTTP transport)
  • MCPO Proxy: localhost:8000 (OpenStack API proxy)
  • Open WebUI: localhost:3000 (Web interface)

Service URLs - Docker External:

  • MCP Server: host.docker.internal:18005 (HTTP transport)
  • MCPO Proxy: host.docker.internal:8005 (OpenStack API proxy)
  • Open WebUI: host.docker.internal:3005 (Web interface)

For Claude Desktop Integration

Add to your Claude Desktop configuration:

{
  "mcpServers": {
    "openstack-ops": {
      "command": "uvx",
      "args": ["--python", "3.11", "mcp-openstack-ops"],
      "env": {
        "OS_AUTH_HOST": "your-openstack-host",
        "OS_AUTH_PORT": "5000",
        "OS_PROJECT_NAME": "your-project",
        "OS_USERNAME": "your-username",
        "OS_PASSWORD": "your-password",
        "OS_USER_DOMAIN_NAME": "Default",
        "OS_PROJECT_DOMAIN_NAME": "Default",
        "OS_REGION_NAME": "RegionOne",
        "OS_IDENTITY_API_VERSION": "3",
        "OS_INTERFACE": "internal",
        "OS_COMPUTE_PORT": "8774",
        "OS_NETWORK_PORT": "9696",
        "OS_VOLUME_PORT": "8776",
        "OS_IMAGE_PORT": "9292",
        "OS_PLACEMENT_PORT": "8780",
        "OS_HEAT_STACK_PORT": "8004",
        "OS_HEAT_STACK_CFN_PORT": "18888",
        "ALLOW_MODIFY_OPERATIONS": "false",
        "MCP_LOG_LEVEL": "INFO"
      }
    }
  }
}

Server Configuration

Command Line Options

uv run python -m mcp_openstack_ops --help

Options:
  --log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL}
                        Logging level
  --type {stdio,streamable-http}
                        Transport type (default: stdio)
  --host HOST          Host address for HTTP transport (default: 127.0.0.1)
  --port PORT          Port number for HTTP transport (default: 8080)
  --auth-enable        Enable Bearer token authentication for streamable-http mode
  --secret-key SECRET  Secret key for Bearer token authentication

Environment Variables

VariableDescriptionDefaultUsage
OpenStack Authentication
OS_AUTH_HOSTOpenStack Identity service hostRequiredAuthentication host address
OS_AUTH_PORTOpenStack Identity service portRequiredAuthentication port
OS_USERNAMEOpenStack usernameRequiredUser credentials
OS_PASSWORDOpenStack passwordRequiredUser credentials
OS_PROJECT_NAMEOpenStack project nameRequiredProject scope
OS_IDENTITY_API_VERSIONIdentity API version3API version
OS_PROJECT_DOMAIN_NAMEProject domain namedefaultDomain scope
OS_USER_DOMAIN_NAMEUser domain namedefaultDomain scope
OS_REGION_NAMEOpenStack regionRegionOneRegional scope
OpenStack Service Ports
OS_COMPUTE_PORTCompute service port8774Nova endpoint
OS_NETWORK_PORTNetwork service port9696Neutron endpoint
OS_VOLUME_PORTVolume service port8776Cinder endpoint
OS_IMAGE_PORTImage service port9292Glance endpoint
OS_PLACEMENT_PORTPlacement service port8780Placement endpoint
OS_HEAT_STACK_PORTHeat orchestration service port8004Heat API endpoint
OS_HEAT_STACK_CFN_PORTHeat CloudFormation service port18888Heat CFN API endpoint
MCP Server Configuration
MCP_LOG_LEVELLogging levelINFODevelopment debugging
ALLOW_MODIFY_OPERATIONSEnable modify operationsfalseSafety control for state modifications
FASTMCP_TYPETransport typestdioRarely needed to change
FASTMCP_HOSTHTTP host address127.0.0.1For HTTP mode only
FASTMCP_PORTHTTP port number8080For HTTP mode only
Authentication (Optional)
REMOTE_AUTH_ENABLEEnable Bearer token authentication for streamable-http modefalseProduction security
REMOTE_SECRET_KEYSecret key for Bearer token authenticationRequired when auth enabledProduction security

Safety Controls

Modification Operations Protection

By default, all operations that can modify or delete OpenStack resources are disabled for safety:

# Default setting - Only read-only operations allowed
ALLOW_MODIFY_OPERATIONS=false

Protected Operations (when ALLOW_MODIFY_OPERATIONS=false):

  • Instance management (start, stop, restart, pause, unpause)
  • Volume operations (create, delete, attach, detach)
  • Keypair management (create, delete, import)
  • Floating IP operations (create, delete, associate, disassociate)
  • Snapshot management (create, delete)
  • Image management (create, delete, update)
  • Heat stack operations (create, delete, update)

Always Available (Read-Only Operations):

  • Cluster status and monitoring
  • Resource listings (instances, volumes, networks, etc.)
  • Service status checks
  • Usage and quota information
  • Search and filtering operations

⚠️ To Enable Modify Operations:

# Enable all operations (USE WITH CAUTION)
ALLOW_MODIFY_OPERATIONS=true

Tool Registration Behavior:

  • When ALLOW_MODIFY_OPERATIONS=false: Only read-only tools are registered with the MCP server
  • When ALLOW_MODIFY_OPERATIONS=true: All tools (read-only + modify operations) are registered
  • Tool availability is determined at server startup - restart required after changing this setting

Best Practices:

  • Keep ALLOW_MODIFY_OPERATIONS=false in production environments
  • Enable modify operations only in development/testing environments
  • Use separate configurations for different environments
  • Review operations before enabling modify capabilities
  • Restart the MCP server after changing the ALLOW_MODIFY_OPERATIONS setting

Example Queries

For comprehensive tool usage examples and query patterns, see: Example Queries in Prompt Template


Performance Optimization

Large-Scale Environment Support

The MCP server is optimized for large OpenStack environments with thousands of instances:

Pagination Features:

  • Default limits prevent memory overflow (50 instances per request)
  • Configurable safety limits (maximum 200 instances per request)
  • Offset-based pagination for browsing large datasets
  • Performance metrics tracking (processing time, instances per second)

Search Optimization:

  • 2-phase search process (basic info filtering → detailed info retrieval)
  • Intelligent caching with connection reuse
  • Selective API calls to minimize overhead
  • Case-sensitive search options for precise filtering

Connection Management:

  • Global connection caching with validity testing
  • Automatic retry mechanisms for transient failures
  • Connection pooling for high-throughput scenarios

Usage Examples:

# Safe large environment browsing
get_instance_details(limit=50, offset=0)     # First 50 instances
get_instance_details(limit=50, offset=50)    # Next 50 instances

# Emergency override for small environments
get_instance_details(include_all=True)       # All instances (use with caution)

# Optimized search for large datasets
search_instances("web", "name", limit=20)    # Search with reasonable limit

Development

Adding New Tools

Edit src/mcp_openstack_ops/mcp_main.py to add new MCP tools:

@mcp.tool()
async def my_openstack_tool(param: str) -> str:
    """
    Brief description of the tool's purpose.
    
    Functions:
    - List specific functions this tool performs
    - Describe the operations it enables
    - Mention when to use this tool
    
    Use when user requests [specific scenarios].
    
    Args:
        param: Description of the parameter
        
    Returns:
        Description of return value format.
    """
    try:
        logger.info(f"Tool called with param: {param}")
        # Implementation using functions.py helpers
        result = my_helper_function(param)
        
        response = {
            "timestamp": datetime.now().isoformat(),
            "result": result
        }
        
        return json.dumps(response, indent=2, ensure_ascii=False)
        
    except Exception as e:
        error_msg = f"Error: Failed to execute tool - {str(e)}"
        logger.error(error_msg)
        return error_msg

Helper Functions

Add utility functions to src/mcp_openstack_ops/functions.py:

def my_helper_function(param: str) -> dict:
    """Helper function for OpenStack operations"""
    try:
        conn = get_openstack_connection()
        
        # OpenStack SDK operations
        result = conn.some_service.some_operation(param)
        
        logger.info(f"Operation completed successfully")
        return {"success": True, "data": result}
        
    except Exception as e:
        logger.error(f"Helper function error: {e}")
        raise

Testing & Validation

Local Testing

# Test with MCP Inspector (recommended)
./scripts/run-mcp-inspector-local.sh

# Test with debug logging
MCP_LOG_LEVEL=DEBUG uv run python -m mcp_openstack_ops

# Validate OpenStack connection
uv run python -c "from src.mcp_openstack_ops.functions import get_openstack_connection; print(get_openstack_connection())"

🔐 Security & Authentication

Bearer Token Authentication

For streamable-http mode, this MCP server supports Bearer token authentication to secure remote access. This is especially important when running the server in production environments.

Configuration

Enable Authentication:

# In .env file
REMOTE_AUTH_ENABLE=true
REMOTE_SECRET_KEY=your-secure-secret-key-here

Or via CLI:

uv run python -m mcp_openstack_ops --type streamable-http --auth-enable --secret-key your-secure-secret-key-here

Security Levels

  1. stdio mode (Default): Local-only access, no authentication needed
  2. streamable-http + REMOTE_AUTH_ENABLE=false/undefined: Remote access without authentication ⚠️ NOT RECOMMENDED for production
  3. streamable-http + REMOTE_AUTH_ENABLE=true: Remote access with Bearer token authentication ✅ RECOMMENDED for production

🔒 Default Policy: REMOTE_AUTH_ENABLE defaults to false if undefined, empty, or null. This ensures the server starts even without explicit authentication configuration.

Client Configuration

When authentication is enabled, MCP clients must include the Bearer token in the Authorization header:

{
  "mcpServers": {
    "openstack-ops": {
      "type": "streamable-http",
      "url": "http://your-server:8000/mcp",
      "headers": {
        "Authorization": "Bearer your-secure-secret-key-here"
      }
    }
  }
}

Security Best Practices

  • Always enable authentication when using streamable-http mode in production
  • Use strong, randomly generated secret keys (32+ characters recommended)
  • Use HTTPS when possible (configure reverse proxy with SSL/TLS)
  • Restrict network access using firewalls or network policies
  • Rotate secret keys regularly for enhanced security
  • Monitor access logs for unauthorized access attempts

Error Handling

When authentication fails, the server returns:

  • 401 Unauthorized for missing or invalid tokens
  • Detailed error messages in JSON format for debugging

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Related Servers