jimmyjoe009/vmware_mcp_server
If you are the rightful owner of vmware_mcp_server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
A Model Context Protocol (MCP) server designed for managing VMware vCenter environments, providing a standardized interface for authentication, host management, and virtual machine operations.
VMware MCP Server
A Model Context Protocol (MCP) server for managing VMware vCenter environments. This server provides tools to authenticate, list hosts, and manage virtual machines through a standardized interface.
Features
- Secure Authentication: Connect to vCenter with username/password authentication
- VM Management: List virtual machines with detailed information including power state, resources, and guest OS
- Host Management: List ESXi hosts with hardware details, resource usage, and status
- Connection Management: Check connection status and properly disconnect
- Comprehensive Logging: Full logging support for debugging and monitoring
- Error Handling: Robust error handling with detailed error messages
- Security: Configurable SSL verification for secure connections
Installation
-
Install Python Dependencies:
pip install -r requirements.txt -
Verify Installation:
python vmware_mcp_server.py --help
Usage
Running the MCP Server
The server communicates via stdio (standard input/output) following the MCP protocol:
python vmware_mcp_server.py
Available Tools
1. login - Connect to vCenter
Connect to a VMware vCenter server with credentials.
Parameters:
host(required): vCenter server hostname or IP addressuser(required): Username for authenticationpassword(required): Password for authenticationverify_ssl(optional): Whether to verify SSL certificates (default: false)
Example:
{
"tool": "login",
"params": {
"host": "vcenter.example.com",
"user": "administrator@vsphere.local",
"password": "your_password",
"verify_ssl": false
}
}
2. list_vms - List Virtual Machines
List all virtual machines with detailed information.
Parameters:
power_state_filter(optional): Filter by power state ("poweredOn", "poweredOff", "suspended")
Example:
{
"tool": "list_vms",
"params": {
"power_state_filter": "poweredOn"
}
}
Returns:
- VM name, UUID, guest OS, power state
- CPU and memory configuration
- IP address and hostname
- VMware Tools status and version
- Host assignment and resource pool
- Folder location and annotations
3. list_hosts - List ESXi Hosts
List all ESXi hosts with detailed hardware and status information.
Parameters: None
Example:
{
"tool": "list_hosts",
"params": {}
}
Returns:
- Host name, connection state, power state
- CPU model, cores, threads, and usage
- Memory size and usage statistics
- Hardware vendor and model information
- Maintenance mode and standby status
- Uptime and boot time information
4. connection_status - Check Connection Status
Get current vCenter connection status.
Parameters: None
Example:
{
"tool": "connection_status",
"params": {}
}
5. disconnect - Disconnect from vCenter
Properly disconnect from the vCenter server.
Parameters: None
Example:
{
"tool": "disconnect",
"params": {}
}
Configuration
SSL Certificate Verification
For production environments, enable SSL verification:
{
"tool": "login",
"params": {
"host": "vcenter.example.com",
"user": "administrator@vsphere.local",
"password": "your_password",
"verify_ssl": true
}
}
Environment Variables
You can set these environment variables for default configuration:
VMWARE_HOST: Default vCenter hostnameVMWARE_USER: Default usernameVMWARE_VERIFY_SSL: Default SSL verification setting
Security Considerations
- Credentials: Never hardcode credentials in scripts. Use secure input methods.
- SSL Verification: Enable SSL verification in production environments.
- Network Security: Ensure vCenter access is restricted to authorized networks.
- Logging: Be careful not to log sensitive information like passwords.
Error Handling
The server provides detailed error messages for common issues:
- Connection Errors: Network connectivity, authentication failures
- Permission Errors: Insufficient privileges for operations
- Resource Errors: Missing VMs, hosts, or other vCenter objects
- API Errors: vSphere API limitations or version incompatibilities
Logging
Logs are written to stderr and include:
- Connection attempts and status
- Tool execution results
- Error messages and stack traces
- Performance metrics
To redirect logs to a file:
python vmware_mcp_server.py 2> vmware_mcp.log
Troubleshooting
Common Issues
-
Import Errors: Ensure all dependencies are installed
pip install -r requirements.txt -
Connection Timeouts: Check network connectivity to vCenter
ping vcenter.example.com telnet vcenter.example.com 443 -
SSL Errors: Disable SSL verification for development environments
{"verify_ssl": false} -
Authentication Errors: Verify credentials and permissions
- Ensure user has vCenter access
- Check for account lockouts
- Verify correct domain/realm
Debug Mode
Enable debug logging by setting the log level:
logging.basicConfig(level=logging.DEBUG)
API Compatibility
- vSphere API: Compatible with vSphere 6.7 and later
- Python: Requires Python 3.8 or later
- MCP Protocol: Implements MCP specification 1.0
Contributing
- Follow PEP 8 style guidelines
- Add comprehensive error handling
- Include detailed logging for debugging
- Write unit tests for new features
- Update documentation for API changes
License
This software is provided under the MIT License. See LICENSE file for details.