K8s Multicluster

python-k8s-multicluster-mcp
  • python

0

GitHub Stars

python

Language

7 months ago

First Indexed

3 months ago

Catalog Refreshed

Documentation & install

Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.

Installation

Add the following to your MCP client configuration file.

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.

How to use

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.

How to install

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.py

## Configuration

Configure 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" } } } }

## Security and best practices

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.

## Examples and common scenarios

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.

## Notes

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.

## Available tools

### k8s\_get\_contexts

List all available Kubernetes contexts across the loaded kubeconfig files.

### k8s\_get\_namespaces

List all namespaces in a specified context.

### k8s\_get\_nodes

List all nodes in a cluster.

### k8s\_get\_resources

List resources of a specified kind within a context/namespace.

### k8s\_get\_resource

Get detailed information about a specific resource.

### k8s\_get\_pod\_logs

Retrieve logs from a specific pod.

### k8s\_describe

Describe a resource with detailed information similar to kubectl describe.

### k8s\_apis

Discover available API groups and resources in the cluster.

### k8s\_crds

List Custom Resource Definitions in the cluster.

### k8s\_top\_nodes

Display resource usage (CPU/memory) for nodes.

### k8s\_top\_pods

Display resource usage (CPU/memory) for pods.

### k8s\_rollout\_status

Get rollout status for a deployment/statefulset/daemonset.

### k8s\_rollout\_history

Get revision history of a rollout.

### k8s\_rollout\_undo

Undo a rollout to a previous revision.

### k8s\_rollout\_restart

Restart a rollout.

### k8s\_rollout\_pause

Pause a rollout.

### k8s\_rollout\_resume

Resume a paused rollout.

### k8s\_scale\_resource

Scale a deployment/statefulset/daemonset to a desired number of replicas.

### k8s\_autoscale\_resource

Configure a Horizontal Pod Autoscaler for a resource.

### k8s\_update\_resources

Update resource requests and limits for containers.

### k8s\_diagnose\_application

Diagnose issues with an application across clusters.

### k8s\_create\_resource

Create a Kubernetes resource from YAML/JSON content.

### k8s\_apply\_resource

Apply a configuration to a resource (create or update).

### k8s\_patch\_resource

Patch fields of a resource.

### k8s\_label\_resource

Update labels on a resource.

### k8s\_annotate\_resource

Update annotations on a resource.

### k8s\_expose\_resource

Expose a resource as a new Kubernetes service.

### k8s\_set\_resources\_for\_container

Set resource limits and requests for containers.

### k8s\_cordon\_node

Mark a node as unschedulable.

### k8s\_uncordon\_node

Mark a node as schedulable again.

### k8s\_drain\_node

Drain a node in preparation for maintenance.

### k8s\_taint\_node

Taint a node with scheduling constraints.

### k8s\_untaint\_node

Remove taints from a node.

### k8s\_pod\_exec

Execute a command in a container within a pod.
Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational
K8s Multicluster MCP Server - feibai406/k8s-multicluster-mcp | VeilStrat