by razvanmacovei
Provides a standardized API to interact with multiple Kubernetes clusters simultaneously using multiple kubeconfig files.
K8s Multicluster MCP enables centralized management of several Kubernetes clusters through a single Model Context Protocol (MCP) server. By reading multiple kubeconfig files, it exposes a uniform set of tools that let AI assistants or other clients query, modify, and diagnose resources across clusters.
KUBECONFIG_DIR
environment variable to the folder containing all your kubeconfig files.python3 app.py
(or invoke it through the MCPO configuration).config.json
as shown in the README.k8s_get_contexts
, k8s_scale_resource
) from an AI assistant or CLI.k8s_top_nodes
, k8s_top_pods
show CPU/memory usage.k8s_diagnose_application
aggregates events, logs, and status.Q: Which Python version is required? A: Python 3.8 or higher.
Q: Do I need to install any Kubernetes client libraries?
A: All required dependencies are listed in requirements.txt
and are installed with pip or uv.
Q: How does the server know which cluster to act on? A: You specify the target context (derived from the kubeconfig filename) in each tool’s parameters.
Q: Can I add new kubeconfig files after the server has started?
A: Yes, the server rescans the KUBECONFIG_DIR
on each request, so newly added files become immediately available.
Q: Is authentication handled by the kubeconfig files? A: Exactly. The server uses the credentials defined in each kubeconfig to communicate with its cluster.
Q: How do I integrate this MCP server with Claude Desktop or other AI assistants?
A: Add the server entry to the MCPO config.json
as shown in the README, then reference the tools in your prompts.
An MCP (Model Context Protocol) server application for Kubernetes operations, providing a standardized API to interact with multiple Kubernetes clusters simultaneously using multiple kubeconfig files.
Add the following configuration to your MCPO server's config.json
file (e.g., in Claude Desktop):
{
"mcpServers": {
"kubernetes": {
"command": "python3",
"args": ["/path/to/k8s-multicluster-mcp/app.py"],
"env": {
"KUBECONFIG_DIR": "/path/to/your/kubeconfigs"
}
}
}
}
Replace
/path/to/your/kubeconfigs
with the actual path to your kubeconfig files directory.
The server expects multiple kubeconfig files to be placed in the directory you specified. Each kubeconfig file represents a different Kubernetes cluster that you can interact with.
To install Multi Cluster Kubernetes Server for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @razvanmacovei/k8s-multicluster-mcp --client claude
Clone the repository
git clone https://github.com/razvanmacovei/k8s-multicluster-mcp.git
cd k8s-multicluster-mcp
Create a virtual environment
# Using venv (built-in)
python3 -m venv .venv
# Activate the virtual environment
# On Windows
.venv\Scripts\activate
# On macOS/Linux
source .venv/bin/activate
Install dependencies
# Using pip
pip install -r requirements.txt
# Or using uv (faster)
uv pip install -r requirements.txt
Configure your environment
KUBECONFIG_DIR
environment variable to point to your kubeconfig directoryRun the application
python3 app.py
This MCP server is designed specifically to work with multiple Kubernetes clusters:
KUBECONFIG_DIR
The Kubernetes MCP Server provides a comprehensive set of tools for interacting with Kubernetes clusters:
kubectl describe
Here are some examples of how to use the Kubernetes MCP Server with AI assistants:
List all available contexts across my kubeconfig files.
Compare the number of pods running in the 'backend' namespace between my 'prod' and 'staging' contexts.
Show me resource usage across all nodes in my 'dev' and 'prod' clusters.
I have a deployment called 'my-app' in the 'production' namespace that's having issues. Can you check what's wrong?
I need to scale my 'backend' deployment in the 'default' namespace to 5 replicas.
Show me the resource usage of nodes in my cluster.
My application 'web-app' in namespace 'web' is experiencing OOM issues. Can you increase the memory limit of the 'app' container to 512Mi?
I need to rollback my 'api-gateway' deployment in the 'services' namespace to the previous version.
What APIs are available in my Kubernetes cluster?
Can you describe the pod 'my-pod' in the 'default' namespace?
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
namespace: default
spec:
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.21
ports:
- containerPort: 80
Expose my 'backend' deployment in the 'default' namespace as a service on port 80 targeting port 8080.
Execute the command 'ls -la /app' in the 'app' container of pod 'web-app-1234' in the 'default' namespace.
I need to perform maintenance on node 'worker-1'. Please cordon it, drain it, and then uncordon it after I complete my work.
Apply this configuration to update my existing deployment:
apiVersion: apps/v1
kind: Deployment
metadata:
name: existing-deployment
namespace: default
spec:
replicas: 3
template:
spec:
containers:
- name: app
image: myapp:v2
Patch the 'my-configmap' ConfigMap in the 'default' namespace to add a new key 'NEW_SETTING' with value 'enabled'.
Add the label 'environment=production' to the 'api' deployment in the 'backend' namespace.
The server implements the following MCP tools:
k8s_get_contexts
: List all available Kubernetes contextsk8s_get_namespaces
: List all namespaces in a specified contextk8s_get_nodes
: List all nodes in a clusterk8s_get_resources
: List resources of a specified kindk8s_get_resource
: Get detailed information about a specific resourcek8s_get_pod_logs
: Get logs from a specific podk8s_describe
: Show detailed information about a specific resource or group of resourcesk8s_apis
: List all available APIs in the Kubernetes clusterk8s_crds
: List all Custom Resource Definitions (CRDs) in the clusterk8s_top_nodes
: Display resource usage of nodesk8s_top_pods
: Display resource usage of podsk8s_rollout_status
: Get status of a rolloutk8s_rollout_history
: Get revision history of a rolloutk8s_rollout_undo
: Undo a rollout to a previous revisionk8s_rollout_restart
: Restart a rolloutk8s_rollout_pause
: Pause a rolloutk8s_rollout_resume
: Resume a paused rolloutk8s_scale_resource
: Scale a resource to a specified number of replicask8s_autoscale_resource
: Configure a Horizontal Pod Autoscaler (HPA)k8s_update_resources
: Update resource requests and limitsk8s_diagnose_application
: Diagnose issues with an applicationk8s_create_resource
: Create a Kubernetes resource from YAML/JSON contentk8s_apply_resource
: Apply a configuration to a resource (create or update)k8s_patch_resource
: Update fields of a resourcek8s_label_resource
: Update the labels on a resourcek8s_annotate_resource
: Update the annotations on a resourcek8s_expose_resource
: Expose a resource as a new Kubernetes servicek8s_set_resources_for_container
: Set resource limits and requests for containersk8s_cordon_node
: Mark a node as unschedulablek8s_uncordon_node
: Mark a node as schedulablek8s_drain_node
: Drain a node in preparation for maintenancek8s_taint_node
: Update the taints on a nodek8s_untaint_node
: Remove taints from a nodek8s_pod_exec
: Execute a command in a containerContributions are welcome! Please feel free to submit a Pull Request.
Please log in to share your review and rating for this MCP.
{ "mcpServers": { "kubernetes": { "command": "python3", "args": [ "/path/to/k8s-multicluster-mcp/app.py" ], "env": { "KUBECONFIG_DIR": "/path/to/your/kubeconfigs" } } } }
Explore related MCPs that share similar capabilities and solve comparable challenges
by awslabs
Provides specialized servers that expose AWS capabilities through the Model Context Protocol, enabling AI assistants to retrieve up-to-date documentation, execute API calls, and automate infrastructure workflows directly within development environments.
by cloudflare
Provides a collection of Model Context Protocol servers that enable MCP‑compatible clients to interact with Cloudflare services such as Workers, Observability, Radar, and more, allowing natural‑language driven management of configurations, data, and operations.
by Flux159
Connects to a Kubernetes cluster and offers a unified MCP interface for kubectl, Helm, port‑forwarding, diagnostics, and non‑destructive read‑only mode.
by TencentEdgeOne
Deploy HTML, folders, or zip archives to EdgeOne Pages and instantly obtain a public URL for fast edge delivery.
by rishikavikondala
Provides Model Context Protocol tools for performing AWS S3 and DynamoDB operations, with automatic logging and audit access via the `audit://aws-operations` endpoint.
by confluentinc
Enables AI assistants to manage Confluent Cloud resources such as Kafka topics, connectors, and Flink SQL statements through natural‑language interactions.
by aliyun
Enables AI assistants to operate Alibaba Cloud resources such as ECS, Cloud Monitor, OOS and other services through seamless integration with Alibaba Cloud APIs via the Model Context Protocol.
by aws-samples
Retrieve PDF documents and other S3 objects through Model Context Protocol resources, enabling LLMs to pull data directly from AWS S3 buckets.
by kocierik
Connects to HashiCorp Nomad and exposes Model Context Protocol endpoints for job, deployment, node, allocation, variable, volume, ACL, Sentinel, and cluster management via a Go‑based server.