home / mcp / k8s multicluster mcp server
python-k8s-multicluster-mcp
Configuration
View docs{
"mcpServers": {
"feibai406-k8s-multicluster-mcp": {
"command": "python3",
"args": [
"/path/to/k8s-multicluster-mcp/app.py"
],
"env": {
"KUBECONFIG_DIR": "/path/to/your/kubeconfigs"
}
}
}
}Multi Cluster Kubernetes MCP Server provides a standardized API to interact with multiple Kubernetes clusters at once by loading several kubeconfig files. It lets you manage dev, staging, and production clusters from a single interface, enabling cross-cluster operations, context switching, and centralized cluster visibility.
You interact with the MCP server through an MCP client to perform actions across multiple Kubernetes clusters. Start by placing all of your kubeconfig files into a single directory and pointing the server at that directory. Use the context parameter in your requests to target a specific cluster or namespace, and leverage cross-cluster commands to compare state, resources, and configurations across clusters. Common workflows include listing contexts, namespaces, and nodes across clusters, retrieving resource details from different contexts, and executing operations like scaling, applying configurations, or rolling back deployments across multiple clusters from one control plane.
When you issue a request, you can specify which cluster context to target, and the server will resolve it against the corresponding kubeconfig file. This enables centralized governance of dev, staging, and production environments without switching between multiple tooling setups.
Prerequisites you need before running the MCP server: Python 3.8 or higher, and the pip package manager. An optional uv package manager can speed up installation.
Install and run locally with the following concrete steps.
# Prerequisites check
python3 --version
pip --version
# Optional: install uv for faster installation
uv pip install -r requirements.txt
```
# Step 1: Obtain the code
git clone https://github.com/razvanmacovei/k8s-multicluster-mcp.git
cd k8s-multicluster-mcp
# Step 2: Create and activate a virtual environment
python3 -m venv .venv
# On Windows
.venv\Scripts\activate
# On macOS/Linux
source .venv/bin/activate
# Step 3: Install dependencies
pip install -r requirements.txt
# Step 4: Configure environment (point to kubeconfigs directory)
# This example uses an environment variable to locate kubeconfig files
export KUBECONFIG_DIR=/path/to/your/kubeconfigs
# Step 5: Run the application
python3 app.pyConfigure the MCP server to load multiple kubeconfig files from a single directory. The server runs a Python script and reads the kubeconfig directory from an environment variable.
{
"mcpServers": {
"kubernetes": {
"command": "python3",
"args": ["/path/to/k8s-multicluster-mcp/app.py"],
"env": {
"KUBECONFIG_DIR": "/path/to/your/kubeconfigs"
}
}
}
}Keep kubeconfig files secure. Limit access to the kubeconfig directory and rotate credentials as needed. Use least privilege contexts when performing sensitive operations across clusters. Consider running the MCP server behind authentication and an internal firewall in production environments.
Multi-cluster context listing: Retrieve available kubecontexts across all kubeconfig files and compare resource counts between clusters.
Cross-cluster deployment status: Check rollout status and history for a deployment in prod and prod-like environments, then apply consistent changes across clusters.
Only the explicit MCP command and the kubeconfig directory path shown in the configuration are used to wire the server. Ensure your environment variable KUBECONFIG_DIR points to the directory containing all kubeconfig files for the clusters you want to manage.
List all available Kubernetes contexts across the loaded kubeconfig files.
List all namespaces in a specified context.
List all nodes in a cluster.
List resources of a specified kind within a context/namespace.
Get detailed information about a specific resource.
Retrieve logs from a specific pod.
Describe a resource with detailed information similar to kubectl describe.
Discover available API groups and resources in the cluster.
List Custom Resource Definitions in the cluster.
Display resource usage (CPU/memory) for nodes.
Display resource usage (CPU/memory) for pods.
Get rollout status for a deployment/statefulset/daemonset.
Get revision history of a rollout.
Undo a rollout to a previous revision.
Restart a rollout.
Pause a rollout.
Resume a paused rollout.
Scale a deployment/statefulset/daemonset to a desired number of replicas.
Configure a Horizontal Pod Autoscaler for a resource.
Update resource requests and limits for containers.
Diagnose issues with an application across clusters.
Create a Kubernetes resource from YAML/JSON content.
Apply a configuration to a resource (create or update).
Patch fields of a resource.
Update labels on a resource.
Update annotations on a resource.
Expose a resource as a new Kubernetes service.
Set resource limits and requests for containers.
Mark a node as unschedulable.
Mark a node as schedulable again.
Drain a node in preparation for maintenance.
Taint a node with scheduling constraints.
Remove taints from a node.
Execute a command in a container within a pod.