A Model Context Protocol (MCP) server for monitoring and managing OpenShift/Kubernetes clusters. This server provides real-time cluster insights through AI assistants, enabling natural language queries about your cluster health, performance, and resource usage.
- Cluster Health Monitoring: Check overall cluster health and identify stability issues
- Performance Metrics: Retrieve real-time performance metrics for nodes and pods
- Resource Issue Detection: Detect pods and nodes with resource allocation problems
- Pod Disruption Analysis: Analyze pod disruptions and restart patterns
- Node Condition Monitoring: Check node conditions and identify problematic nodes
- Deployment Monitoring: Monitor deployment status and rollout health
- System Diagnostics: Check kubelet, CRI-O status and analyze journalctl logs
- Application Deployment: Create deployments with guaranteed QoS and resource management
- Database Services: Deploy PostgreSQL, MySQL, MongoDB, or Redis with persistent storage
- Auto-scaling: Set up horizontal pod autoscalers with CPU/memory targets
- Service Management: Create and configure services (ClusterIP, NodePort, LoadBalancer)
- Network Security: Create network policies for secure pod-to-pod communication
- Cluster Performance: Execute kube-burner density testing for application deployment performance
- Storage Benchmarks: Run FIO workloads for sequential/random read/write performance testing
- Network Testing: Test network throughput, latency, and packet loss with iperf3
- Resource Stress Testing: Perform CPU and memory stress testing on worker nodes
- Database Benchmarking: Execute PostgreSQL (pgbench) or MySQL (sysbench) performance tests
- Bastion Host Support: Execute tests on private clusters through jump hosts
- SSH Integration: Secure remote command execution with credential management
- Multi-Cluster Testing: Test across different OpenShift environments
- Automated Benchmarking: Schedule and run performance tests through AI assistants
- Remote Execution: Execute performance benchmarks and tools on remote clusters through bastion hosts
- Multi-Cluster Support: Manage and test across different OpenShift environments
- Node.js 18+
- Access to an OpenShift/Kubernetes cluster
- Valid kubeconfig file or in-cluster configuration
- SSH access to bastion hosts (for remote deployments)
For remote cluster access through bastion hosts, follow these two setup phases:
For remote cluster access through bastion hosts, you can use either SSH key (recommended) or password authentication:
-
Generate SSH key pair (if you don't have one):
ssh-keygen -t ed25519 -f ~/.ssh/id_rsa_bastion -C "mcp-server-access"
-
Copy public key to bastion host:
ssh-copy-id -i ~/.ssh/id_rsa_bastion.pub user@your-bastion-host.com -
Test SSH connectivity:
ssh -i ~/.ssh/id_rsa_bastion user@your-bastion-host.com -
(optional) Configure MCP environment variables:
export MCP_BASTION_HOST="your-bastion-host.com" export MCP_BASTION_USER="your-username" export MCP_SSH_KEY="~/.ssh/id_rsa_bastion" export MCP_REMOTE_PATH="/opt/openshift-mcp-server" export MCP_REMOTE_KUBECONFIG="/path/to/remote/kubeconfig" export MCP_REMOTE_NODE_ENV="production"
For environments where SSH keys are not feasible:
-
Install sshpass (required for password authentication):
# Ubuntu/Debian sudo apt-get install sshpass # macOS brew install sshpass # RHEL/CentOS sudo yum install sshpass
-
(optional) Configure MCP environment variables:
export MCP_BASTION_HOST="your-bastion-host.com" export MCP_BASTION_USER="your-username" export MCP_BASTION_PASSWORD="your-secure-password" export MCP_REMOTE_PATH="/opt/openshift-mcp-server" export MCP_REMOTE_KUBECONFIG="/path/to/remote/kubeconfig" export MCP_REMOTE_NODE_ENV="production"
Security Note: SSH key authentication is strongly recommended over password authentication for better security. Password authentication should only be used when SSH keys are not available.
The remote-launcher.js provides comprehensive functionality:
- ✅ Automatic Configuration Validation - Validates all required environment variables
- ✅ Pre-Flight Connectivity Testing - Tests SSH connection before launching MCP server
- ✅ Dual Authentication Support - SSH key (recommended) and password authentication
- ✅ Linux Support - Tested and validated on Linux environments
- ✅ Robust Error Handling - Detailed error messages and troubleshooting guidance
- ✅ Graceful Shutdown - Proper signal handling and resource cleanup
- ✅ SSH Keep-Alive - Automatic connection maintenance for stability
- ✅ Sensitive Data Protection - Automatic redaction of tokens and credentials from logs
After configuring authentication, set up the MCP server on the bastion host:
Run the setup script to prepare the bastion host:
./scripts/setup-bastion.shYou may run the script using the following options:
Usage: ./scripts/setup-bastion.sh options
Options:
-H host Bastion host
-U user Bastion username
-P password Bastion password
-p path Path to mcp server on bastion
-s ssh_key SSH keyfile
-k kubeconfig Remote kubeconfig
-n Don't actually run commands
-v Verbose reporting
-q No verbose reporting (default)This script will:
- ✅ Install Node.js and npm on the bastion host (if not present)
- ✅ Create the remote directory structure
- ✅ Copy project files to the bastion host
- ✅ Install all Node.js dependencies
- ✅ Verify dependency installation with import tests
- ✅ Test cluster connectivity and kubeconfig
After successful setup, test the remote MCP server connection:
node ./scripts/remote-launcher.jsYou may run the script using the following options:
Usage: remote-launcher.js [options]
Options:
-H, --host <host> Bastion host address
-U, --user <user> Bastion username
-P, --password <password> Bastion password (alternative to SSH key)
-p, --path <path> Remote MCP server path
-s, --ssh-key <keyfile> SSH private key file path
-k, --kubeconfig <config> Remote kubeconfig file path
-e, --env <environment> Node environment (default: production)
-h, --help Show this help message
Environment Variables (used as defaults):
MCP_BASTION_HOST Bastion host address
MCP_BASTION_USER Bastion username
MCP_BASTION_PASSWORD Bastion password
MCP_REMOTE_PATH Remote MCP server path
MCP_SSH_KEY SSH private key file path
MCP_REMOTE_KUBECONFIG Remote kubeconfig file path
MCP_REMOTE_NODE_ENV Node environment
Examples:
# Using CLI arguments only
./scripts/remote-launcher.js -H bastion.example.com -U root -s ~/.ssh/id_rsa -k /path/to/kubeconfig -p /opt/mcp-server
# Using environment variables (backward compatible)
export MCP_BASTION_HOST=bastion.example.com
./scripts/remote-launcher.js
# Mixed: CLI args override env vars
export MCP_BASTION_HOST=bastion.example.com
./scripts/remote-launcher.js -U admin -k /custom/kubeconfigThis launcher will:
- Validate configuration and test connectivity
- Connect to the bastion host via SSH (key or password auth)
- Start the MCP server remotely with robust error handling
- Forward stdio for MCP protocol communication
- Enable AI Code Assistant integration with the remote cluster
Update your AI Code Assistant MCP configuration to use the remote launcher:
{
"mcpServers": {
"openshift-mcp-server": {
"command": "node",
"args": ["/path/to/openshift-mcp-server/remote-launcher.js"],
"env": {
"MCP_BASTION_HOST": "your-bastion-host.com",
"MCP_BASTION_USER": "your-username",
"MCP_SSH_KEY": "/path/to/your/ssh/key",
"MCP_REMOTE_PATH": "/opt/openshift-mcp-server",
"MCP_REMOTE_KUBECONFIG": "/path/to/remote/kubeconfig",
"MCP_REMOTE_NODE_ENV": "production"
},
"cwd": "/path/to/openshift-mcp-server"
}
}
}Common Issues:
-
SSH Connection Failures
- Verify SSH key permissions:
chmod 600 ~/.ssh/id_rsa_bastion - Test manual SSH connection:
ssh -i ~/.ssh/id_rsa_bastion user@bastion-host - Check network connectivity to bastion host
- Verify SSH key permissions:
-
Node.js Installation Issues
- Ensure bastion host has internet access for package downloads
- Check if package manager (dnf/yum/apt) is available
- Verify sudo permissions for Node.js installation
-
Dependency Installation Failures
- Check npm registry accessibility from bastion host
- Verify sufficient disk space in remote directory
- Review npm install logs for specific errors
-
Kubeconfig Issues
- Verify kubeconfig file exists at specified path
- Test cluster connectivity from bastion host:
kubectl cluster-info - Check network policies and firewall rules
Debug Mode:
export DEBUG=*
./scripts/setup-bastion.shRe-run Setup: If you need to re-run the setup (e.g., after fixing issues):
./scripts/setup-bastion.sh # Safe to run multiple timesThis MCP server can be deployed in two ways:
- Local Direct Access: Run locally with direct cluster access
- Remote Bastion Host Access: Run on a bastion host for private cluster access
npm installFor remote bastion host deployment, follow the Bastion Host Setup section above.
The server uses the standard Kubernetes client configuration methods:
-
KUBECONFIG environment variable: Set the path to your kubeconfig file
export KUBECONFIG=/path/to/your/kubeconfig -
Default kubeconfig location:
~/.kube/config -
In-cluster configuration: When running inside a Kubernetes pod
npm startOr directly:
node index.jsOnce the MCP server is configured in your AI Code Assistant, you can interact with your OpenShift cluster using natural language for monitoring and observability tasks:
- "Check the overall health of the OpenShift cluster"
- "Show me the current node conditions and identify any issues"
- "Are there any resource issues in the cluster right now?"
- "Monitor deployment status in the production namespace"
- "Get performance metrics for the last hour"
- "Analyze pod disruptions in the default namespace over the past 24 hours"
- "Check kubelet service status and recent logs"
- "Analyze CRI-O container runtime status and errors"
- "Show me journalctl logs for pod-related errors in the last 6 hours"
- "What system errors are occurring on the cluster?"
- "Detect pods with high CPU or memory usage"
- "Find nodes that are under resource pressure"
- "Show me pods that have restarted frequently"
- "What deployments are not ready or unhealthy?"
- "Create a new deployment with guaranteed QoS using 4 CPU cores in namespace test-ns"
- "Deploy a PostgreSQL database with persistent storage in the production namespace"
- "Create a service mesh configuration for microservices communication"
- "Set up a horizontal pod autoscaler for the web application"
- "Create network policies to secure pod-to-pod communication"
- "Set up ingress controllers and SSL termination"
- "Deploy a Redis cluster with high availability configuration"
- "Execute cluster density testing with kube-burner to measure application deployment performance"
- "Run storage performance benchmarks using FIO workloads"
- "Test network throughput between pods using iperf3"
- "Perform CPU and memory stress testing on worker nodes"
- "Execute PostgreSQL database performance tests with pgbench"
- "Execute MySQL database performance tests with sysbench"
- "Run comprehensive cluster health validation before production deployment"
- "Benchmark container startup times and resource allocation"
- "Test cluster recovery scenarios and failover mechanisms"
-
check_cluster_health
- Check overall OpenShift cluster health
- Parameters:
detailed(boolean, optional)
-
get_performance_metrics
- Retrieve current performance metrics
- Parameters:
namespace(string, optional),timeRange(string, default: "1h")
-
detect_resource_issues
- Detect resource allocation issues
- Parameters:
thresholds(object with cpu, memory, restarts limits)
-
analyze_pod_disruptions
- Analyze pod disruptions and restart patterns
- Parameters:
namespace(string, optional),hours(number, default: 24)
-
check_node_conditions
- Check node conditions and identify issues
- Parameters: none
-
monitor_deployments
- Monitor deployment status and health
- Parameters:
namespace(string, optional)
-
check_kubelet_status
- Check kubelet service status and recent logs for errors
- Parameters:
hoursBack(number, default: 24),includeSystemErrors(boolean, default: false)
-
check_crio_status
- Check CRI-O container runtime status and recent logs
- Parameters:
hoursBack(number, default: 24),includeContainerErrors(boolean, default: true)
-
analyze_journalctl_pod_errors
- Analyze journalctl logs for specific pod-related errors and system issues
- Parameters:
pod(string, optional),hoursBack(number, default: 24),service(string, optional),errorTypes(array, optional)
-
create_deployment
- Create a new deployment with specified configuration
- Parameters:
name(string, required),image(string, required),namespace(string, default: "default"),replicas(number, default: 1),resources(object, optional),ports(array, optional)
-
deploy_database
- Deploy a database with persistent storage
- Parameters:
type(string: postgresql|mysql|mongodb|redis, required),name(string, required),namespace(string, default: "default"),storageSize(string, default: "10Gi"),resources(object, optional)
-
create_hpa
- Set up a horizontal pod autoscaler for an application
- Parameters:
targetDeployment(string, required),namespace(string, default: "default"),minReplicas(number, default: 1),maxReplicas(number, default: 10),cpuTarget(number, default: 70),memoryTarget(number, default: 80)
-
create_service
- Create a service to expose an application
- Parameters:
name(string, required),namespace(string, default: "default"),selector(object, required),ports(array, required),type(string: ClusterIP|NodePort|LoadBalancer, default: "ClusterIP")
-
create_network_policy
- Create network policies to secure pod-to-pod communication
- Parameters:
name(string, required),namespace(string, default: "default"),podSelector(object, required),ingress(array, optional),egress(array, optional)
-
run_kube_burner
- Execute cluster density testing with kube-burner to measure application deployment performance
- Parameters:
testType(string: cluster-density-v2|node-density|pvc-density|crd-scale, default: "cluster-density-v2"),iterations(number, default: 5),namespace(string, default: "kube-burner-test"),timeout(string, default: "10m")
-
run_storage_benchmark
- Run storage performance benchmarks using FIO workloads
- Parameters:
testType(string: sequential-read|sequential-write|random-read|random-write|mixed, default: "mixed"),blockSize(string, default: "4k"),duration(string, default: "60s"),storageClass(string, optional),volumeSize(string, default: "10Gi")
-
run_network_test
- Test network throughput between pods using iperf3
- Parameters:
testType(string: throughput|latency|packet-loss, default: "throughput"),duration(string, default: "30s"),parallel(number, default: 1),protocol(string: tcp|udp, default: "tcp"),bandwidth(string, default: "1G")
-
run_cpu_stress_test
- Perform CPU and memory stress testing on worker nodes
- Parameters:
testType(string: cpu|memory|combined, default: "combined"),duration(string, default: "2m"),cpuCores(number, default: 2),memorySize(string, default: "1G"),nodeSelector(object, optional)
-
run_database_benchmark
- Execute database performance tests with sysbench (MySQL) or pgbench (PostgreSQL)
- Parameters:
dbType(string: postgresql|mysql, required),testType(string: oltp_read_write|oltp_read_only|oltp_write_only, default: "oltp_read_write"),threads(number, default: 10),duration(string, default: "60s"),tableSize(number, default: 100000)
// Check cluster health
{
"method": "tools/call",
"params": {
"name": "check_cluster_health",
"arguments": {
"detailed": true
}
}
}
// Get performance metrics
{
"method": "tools/call",
"params": {
"name": "get_performance_metrics",
"arguments": {
"namespace": "production",
"timeRange": "1h"
}
}
}// Create a web application deployment
{
"method": "tools/call",
"params": {
"name": "create_deployment",
"arguments": {
"name": "web-app",
"image": "nginx:latest",
"namespace": "production",
"replicas": 3,
"resources": {
"cpuRequest": "200m",
"memoryRequest": "256Mi",
"cpuLimit": "1000m",
"memoryLimit": "512Mi"
},
"ports": [{"containerPort": 80}]
}
}
}
// Deploy PostgreSQL database
{
"method": "tools/call",
"params": {
"name": "deploy_database",
"arguments": {
"type": "postgresql",
"name": "app-database",
"namespace": "production",
"storageSize": "20Gi"
}
}
}
// Deploy MySQL database
{
"method": "tools/call",
"params": {
"name": "deploy_database",
"arguments": {
"type": "mysql",
"name": "mysql-db",
"namespace": "production",
"storageSize": "20Gi"
}
}
}
// Create horizontal pod autoscaler
{
"method": "tools/call",
"params": {
"name": "create_hpa",
"arguments": {
"targetDeployment": "web-app",
"namespace": "production",
"minReplicas": 3,
"maxReplicas": 20,
"cpuTarget": 70,
"memoryTarget": 80
}
}
}// Run storage benchmark
{
"method": "tools/call",
"params": {
"name": "run_storage_benchmark",
"arguments": {
"testType": "mixed",
"duration": "120s",
"blockSize": "4k",
"volumeSize": "10Gi"
}
}
}
// Test network throughput
{
"method": "tools/call",
"params": {
"name": "run_network_test",
"arguments": {
"testType": "throughput",
"duration": "60s",
"protocol": "tcp",
"parallel": 4
}
}
}
// CPU stress test
{
"method": "tools/call",
"params": {
"name": "run_cpu_stress_test",
"arguments": {
"testType": "combined",
"duration": "5m",
"cpuCores": 4,
"memorySize": "2G"
}
}
}
// PostgreSQL database benchmark
{
"method": "tools/call",
"params": {
"name": "run_database_benchmark",
"arguments": {
"dbType": "postgresql",
"testType": "oltp_read_write",
"threads": 10,
"duration": "60s",
"tableSize": 100000
}
}
}
// MySQL database benchmark
{
"method": "tools/call",
"params": {
"name": "run_database_benchmark",
"arguments": {
"dbType": "mysql",
"testType": "oltp_read_write",
"threads": 10,
"duration": "60s",
"tableSize": 100000
}
}
}For detailed examples of extending the MCP server with performance testing capabilities, see:
- Kube-Burner Integration Example - Comprehensive guide for integrating kube-burner-ocp performance testing tools
This example demonstrates how to:
- Add remote performance testing capabilities
- Execute benchmarks through AI assistants
- Collect and analyze performance metrics
- Implement best practices for different cluster types
openshift-mcp-server/
├── index.js # Main MCP server implementation
├── package.json # Node.js dependencies and scripts
├── package-lock.json # Dependency lock file
├── README.md # Documentation
├── LICENSE # Project license
├── docs/ # Documentation
│ ├── CONTRIBUTING.md # Contribution guidelines
│ ├── kube-burner-example.md # Kube-burner testing guide
│ └── private-cluster-config.md # Private cluster configuration
├── examples/ # Configuration examples
│ └── cursor-mcp-config.example.json # Example MCP client config
├── scripts/ # Utility scripts
│ ├── setup-bastion.sh # Bastion host setup script
│ └── remote-launcher.js # Remote launcher for bastion hosts
└── docker/ # Docker configuration
├── Dockerfile # Container image definition
└── docker-compose.yml # Development setup
- Add the tool definition to the
ListToolsRequestSchemahandler - Add the implementation case to the
CallToolRequestSchemahandler - Implement the tool method in the class
The server includes comprehensive error handling for:
- Kubernetes API connection issues
- Authentication/authorization problems
- Resource access failures
- Malformed requests
Build and run using Docker:
docker build -f docker/Dockerfile -t openshift-mcp-server .
docker run -v ~/.kube/config:/root/.kube/config openshift-mcp-serverDeploy to your OpenShift/Kubernetes cluster:
kubectl apply -f kubernetes/- The server requires cluster-wide read permissions
- Use appropriate RBAC configurations in production
- Secure kubeconfig files and service account tokens
- Consider network policies for pod-to-pod communication
-
Authentication Errors
- Verify kubeconfig file path and validity
- Check service account permissions
-
Connection Timeouts
- Verify cluster connectivity
- Check firewall and network policies
-
Missing Metrics
- Ensure metrics-server is deployed
- Verify metrics API availability
Enable debug logging:
export DEBUG=*
node index.js- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
ISC License - see package.json for details
| Command | Description | Example Usage |
|---|---|---|
check_cluster_health |
Validate cluster health | "Check cluster health" |
get_performance_metrics |
Get current performance data | "Get performance metrics for last hour" |
detect_resource_issues |
Find resource problems | "Are there any resource issues?" |
analyze_pod_disruptions |
Analyze pod restart patterns | "Show pod disruptions in namespace X" |
check_node_conditions |
Check node health status | "What are the current node conditions?" |
monitor_deployments |
Monitor deployment status | "Check deployment status in test namespace" |
Local Direct Access:
{
"mcpServers": {
"openshift-mcp-server": {
"command": "node",
"args": ["/path/to/openshift-mcp-server/index.js"],
"env": {
"KUBECONFIG": "/path/to/kubeconfig"
}
}
}
}Remote Bastion Host Access - SSH Key (Recommended):
{
"mcpServers": {
"openshift-mcp-server": {
"command": "node",
"args": ["/path/to/openshift-mcp-server/remote-launcher.js"],
"env": {
"MCP_BASTION_HOST": "your-bastion-host.com",
"MCP_BASTION_USER": "admin",
"MCP_SSH_KEY": "/path/to/your/ssh/key",
"MCP_REMOTE_PATH": "/opt/openshift-mcp-server",
"MCP_REMOTE_KUBECONFIG": "/path/to/remote/kubeconfig",
"MCP_REMOTE_NODE_ENV": "production"
},
"cwd": "/path/to/openshift-mcp-server"
}
}
}Remote Bastion Host Access - Password (Optional):
{
"mcpServers": {
"openshift-mcp-server": {
"command": "node",
"args": ["/path/to/openshift-mcp-server/remote-launcher.js"],
"env": {
"MCP_BASTION_HOST": "your-bastion-host.com",
"MCP_BASTION_USER": "admin",
"MCP_BASTION_PASSWORD": "your-secure-password",
"MCP_REMOTE_PATH": "/opt/openshift-mcp-server",
"MCP_REMOTE_KUBECONFIG": "/path/to/remote/kubeconfig",
"MCP_REMOTE_NODE_ENV": "production"
},
"cwd": "/path/to/openshift-mcp-server"
}
}
}Local Direct Access:
export KUBECONFIG=/path/to/kubeconfigRemote Bastion Host Access - SSH Key:
export MCP_BASTION_HOST=bastion.example.com
export MCP_BASTION_USER=admin
export MCP_SSH_KEY=/path/to/your/ssh/key
export MCP_REMOTE_PATH=/opt/openshift-mcp-server
export MCP_REMOTE_KUBECONFIG=/path/to/remote/kubeconfig
export MCP_REMOTE_NODE_ENV=productionRemote Bastion Host Access - Password:
export MCP_BASTION_HOST=bastion.example.com
export MCP_BASTION_USER=admin
export MCP_BASTION_PASSWORD=your-secure-password
export MCP_REMOTE_PATH=/opt/openshift-mcp-server
export MCP_REMOTE_KUBECONFIG=/path/to/remote/kubeconfig
export MCP_REMOTE_NODE_ENV=productionFor issues and questions:
- Check the troubleshooting section
- Review Kubernetes/OpenShift documentation
- Review kube-burner-ocp documentation
- File an issue in the repository