Skip to main content
Glama
Multi Cluster Kubernetes MCP Server

Multi Cluster Kubernetes MCP Server

Multi Cluster Kubernetes MCP Server

Python 3.11+ License: Apache 2.0

An MCP (Model Context Protocol) server for managing multiple Kubernetes clusters simultaneously. Provides 60+ tools covering cluster operations, resource management, monitoring, RBAC, storage, networking, and more -- all accessible through AI assistants like Claude Desktop.

Quick Start

Installing via Smithery

npx -y @smithery/cli install @razvanmacovei/k8s-multicluster-mcp --client claude

Manual Installation

git clone https://github.com/razvanmacovei/k8s-multicluster-mcp.git
cd k8s-multicluster-mcp
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
python3 app.py

Docker

docker build -t k8s-mcp .
docker run -v ~/.kube:/root/.kube k8s-mcp

Related MCP server: MCP Server Kubernetes

Configuration

Claude Desktop / MCP Client

Add to your MCP client configuration:

{
  "mcpServers": {
    "kubernetes": {
      "command": "python3",
      "args": ["/path/to/k8s-multicluster-mcp/app.py"],
      "env": {
        "KUBECONFIG_DIR": "/path/to/your/kubeconfigs"
      }
    }
  }
}

Environment Variables

Variable

Default

Description

KUBECONFIG_DIR

~/.kube

Directory containing kubeconfig files. Each file can contain one or more contexts.

Place your kubeconfig files in the configured directory. The server discovers all contexts across all files automatically.

Prerequisites

  • Python 3.11 or higher

  • One or more kubeconfig files with valid cluster credentials

  • metrics-server installed in clusters for k8s_top_* and k8s_cluster_info tools

Multi-Cluster Management

This server is purpose-built for managing multiple Kubernetes clusters:

  • Automatic Discovery: Scans all kubeconfig files in KUBECONFIG_DIR and aggregates contexts

  • Partial Name Matching: Use prod instead of arn:aws:eks:us-east-1:123456:cluster/prod-cluster

  • Cross-Cluster Operations: Compare resources, health, and configurations across clusters

  • Context Caching: Efficient 30-second TTL cache avoids re-reading kubeconfig files on every call

  • Centralized Management: Manage dev, staging, and production from a single interface

Tools Reference (60+ tools)

Cluster & Context Management (6 tools)

Tool

Description

k8s_get_contexts

List all available contexts across all kubeconfig files

k8s_get_namespaces

List all namespaces in a cluster

k8s_create_ns

Create a new namespace with optional labels/annotations

k8s_delete_ns

Delete a namespace (protects system namespaces)

k8s_get_nodes

List all nodes with status, roles, capacity, and version

k8s_cluster_info

Comprehensive cluster health summary (nodes, pods, deployments, warnings)

Resource Discovery & Inspection (7 tools)

Tool

Description

k8s_get_resources

List resources of any kind (pods, deployments, services, ingress, etc.)

k8s_get_resource

Get the complete definition of a single resource

k8s_get_pod_logs

Get pod logs with duration filtering and container selection

k8s_get_events

List cluster events in a namespace, sorted by most recent

k8s_describe

Detailed resource description similar to kubectl describe

k8s_apis

List all available API groups and resources in the cluster

k8s_crds

List all Custom Resource Definitions with versions and scope

Metrics & Monitoring (3 tools)

Tool

Description

k8s_top_nodes

Display node CPU/memory usage alongside capacity

k8s_top_pods

Display pod/container CPU/memory usage

k8s_diagnose_application

Comprehensive app diagnostics with issue detection and recommendations

Rollout Management (6 tools)

Tool

Description

k8s_rollout_status

Get rollout status for deployment/statefulset/daemonset

k8s_rollout_history

Get revision history

k8s_rollout_undo

Roll back to a previous revision

k8s_rollout_restart

Trigger a rolling restart

k8s_rollout_pause

Pause an in-progress rollout

k8s_rollout_resume

Resume a paused rollout

Scaling (3 tools)

Tool

Description

k8s_scale_resource

Scale deployment/statefulset/replicaset to N replicas

k8s_autoscale_resource

Configure Horizontal Pod Autoscaler (HPA)

k8s_update_resources

Update CPU/memory requests and limits for a container

Resource CRUD (6 tools)

Tool

Description

k8s_create_resource

Create a resource from YAML/JSON content

k8s_apply_resource

Apply configuration (create or update, like kubectl apply)

k8s_delete_resource

Delete any resource type with optional force/grace period

k8s_patch_resource

Update specific fields with strategic merge patch

k8s_label_resource

Add or update labels on a resource

k8s_annotate_resource

Add or update annotations on a resource

Workload Management (3 tools)

Tool

Description

k8s_expose_resource

Expose a deployment/pod as a new Service

k8s_run_pod

Create and run a pod with a specified image

k8s_set_resources_for_container

Set resource limits/requests for containers

Node Management (5 tools)

Tool

Description

k8s_cordon_node

Mark a node as unschedulable

k8s_uncordon_node

Mark a node as schedulable

k8s_drain_node

Drain a node by evicting pods (for maintenance)

k8s_taint_node

Add taints to a node

k8s_untaint_node

Remove taints from a node

Pod Operations (1 tool)

Tool

Description

k8s_pod_exec

Execute a command in a container (supports quoted arguments)

Secrets & ConfigMaps (6 tools)

Tool

Description

k8s_list_secret

List secrets with metadata (values hidden for security)

k8s_get_secret_detail

Get a secret; optionally decode values

k8s_create_secret_resource

Create a new secret (auto base64-encodes values)

k8s_list_configmap

List ConfigMaps with their key names

k8s_get_configmap_detail

Get a ConfigMap with full data contents

k8s_create_configmap_resource

Create a new ConfigMap

RBAC (5 tools)

Tool

Description

k8s_get_roles

List RBAC Roles with permission rules

k8s_get_clusterroles

List RBAC ClusterRoles

k8s_get_rolebindings

List RoleBindings (who has what role)

k8s_get_clusterrolebindings

List ClusterRoleBindings

k8s_get_service_accounts

List ServiceAccounts

Storage (3 tools)

Tool

Description

k8s_get_pvcs

List PersistentVolumeClaims with status, capacity, and storage class

k8s_get_pvs

List PersistentVolumes with capacity and bound claims

k8s_get_storage_classes

List StorageClasses with provisioner and default status

Networking (1 tool)

Tool

Description

k8s_get_network_policies

List NetworkPolicies with pod selectors and rule counts

Job Management (2 tools)

Tool

Description

k8s_get_jobs

List Jobs with completion status and timing

k8s_get_cronjobs

List CronJobs with schedule, suspend status, and last run

Usage Examples

Cluster Health Check

Give me a health overview of my production cluster.

Multi-Cluster Comparison

Compare the number of pods running in the 'backend' namespace between my 'prod' and 'staging' contexts.

Diagnose Application Issues

My deployment 'my-app' in the 'production' namespace is having issues. Can you diagnose what's wrong?

Scale Resources

Scale the 'backend' deployment in the 'default' namespace to 5 replicas.

Resource Management

Delete the failed job 'data-migration-v1' in the 'batch' namespace.
Create a new namespace called 'staging' with the label environment=staging.

Secret Management

List all secrets in the 'production' namespace and show me the keys in the 'api-credentials' secret.

RBAC Inspection

Show me all role bindings in the 'default' namespace -- who has access to what?

Storage Overview

List all PVCs in the cluster and show which ones are Pending.

Node Maintenance

Cordon node 'worker-3', drain it ignoring DaemonSets, then uncordon when maintenance is complete.

Rollback Deployment

Roll back the 'api-gateway' deployment in the 'services' namespace to the previous version.

Execute in Pod

Run 'ls -la /app/config' inside the 'app' container of pod 'web-app-xyz' in the 'default' namespace.

Create Resources

Create a new deployment with this YAML:
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.27
        ports:
        - containerPort: 80

Architecture

k8s-multicluster-mcp/
├── app.py                          # MCP server entry point & tool registration
├── src/
│   ├── utils/
│   │   ├── k8s_client.py           # Multi-cluster client with context caching
│   │   └── pluralize.py            # Kubernetes resource kind pluralization
│   └── tools/
│       ├── contexts.py             # Context listing
│       ├── namespaces.py           # Namespace listing
│       ├── namespace_management.py # Namespace create/delete
│       ├── nodes.py                # Node listing
│       ├── pods.py                 # Resource listing & pod logs
│       ├── resources.py            # Single resource retrieval
│       ├── events.py               # Event listing
│       ├── describe.py             # kubectl describe equivalent
│       ├── api_discovery.py        # API & CRD discovery
│       ├── metrics.py              # Node/pod metrics (top)
│       ├── diagnosis.py            # Application diagnostics
│       ├── cluster_health.py       # Cluster health summary
│       ├── rollouts.py             # Rollout management
│       ├── scaling.py              # Scale & autoscale & resource updates
│       ├── resource_management.py  # Create, apply, patch, label, annotate
│       ├── delete_resource.py      # Resource deletion
│       ├── workload_management.py  # Expose, run pod, set resources
│       ├── node_management.py      # Cordon, drain, taint
│       ├── pod_operations.py       # Exec into pods
│       ├── secret_configmap.py     # Secret & ConfigMap management
│       ├── rbac.py                 # Roles, bindings, service accounts
│       ├── storage_network.py      # PVC, PV, StorageClass, NetworkPolicy
│       └── job_management.py       # Jobs & CronJobs
├── requirements.txt
├── pyproject.toml
├── Dockerfile
└── smithery.yaml

What's New in v2.0.0

  • 20+ new tools: Resource deletion, namespace management, secrets & configmaps, RBAC inspection, storage & network visibility, job management, cluster health summary, pod creation

  • Bug fixes: Fixed resource pluralization (e.g., Ingress -> ingresses not ingresss), fixed pod exec command splitting to handle quoted arguments, fixed timeout parameter handling

  • Performance: Context discovery now uses a 30-second TTL cache with direct context-to-file mapping, eliminating redundant file scanning

  • Improved tool descriptions: All 60+ tools have detailed descriptions for better AI assistant integration

  • Dependency cleanup: Removed unused fastapi and uvicorn dependencies

  • Security: Namespace deletion protects system namespaces; secret values hidden by default

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Available Tools

57 tools
k8s_annotate_resourceC

Add or update annotations on a Kubernetes resource. Annotations store non-identifying metadata for tools and libraries.

Inputs: name (required), context (required), annotations (required), resource_type (required), +2 more.

k8s_apisA

List all available API groups and resources in the Kubernetes cluster. Useful for discovering what resource types are available, including CRD-based APIs.

Inputs: context (required).

k8s_apply_resourceB

Apply a configuration to a resource (create if it doesn't exist, update if it does). Similar to 'kubectl apply'. The content must include apiVersion, kind, and metadata with name.

Inputs: context (required), yaml_content (required), namespace.

k8s_autoscale_resourceB

Configure a Horizontal Pod Autoscaler (HPA) for a deployment, statefulset, or replicaset. Creates or updates an HPA that scales between min and max replicas based on CPU utilization.

Inputs: name (required), context (required), namespace (required), max_replicas (required), +3 more.

k8s_cluster_infoA

Get a comprehensive health summary of the entire Kubernetes cluster. Checks node status, pod health across all namespaces, deployment availability, resource pressure, and recent warning events. Returns an overall health status (healthy/degraded/unhealthy) with detailed breakdowns.

Inputs: context (required).

k8s_cordon_nodeA

Mark a node as unschedulable. Existing pods continue running but no new pods will be scheduled on this node.

Inputs: context (required), node_name (required).

k8s_crdsA

List all Custom Resource Definitions (CRDs) installed in the cluster. Shows CRD names, groups, versions, scope, and status conditions.

Inputs: context (required).

k8s_create_configmap_resourceC

Create a new Kubernetes ConfigMap with the specified key-value data pairs.

Inputs: data (required), name (required), context (required), namespace (required), +1 more.

k8s_create_nsC

Create a new Kubernetes namespace. Optionally attach labels and annotations at creation time.

Inputs: name (required), context (required), labels, annotations.

k8s_create_resourceC

Create a Kubernetes resource from YAML or JSON content. The content must include apiVersion, kind, and metadata. Optionally override the namespace.

Inputs: context (required), yaml_content (required), namespace.

k8s_create_secret_resourceB

Create a new Kubernetes Secret. Values in data will be automatically base64-encoded. Common types: Opaque (default), kubernetes.io/tls, kubernetes.io/dockerconfigjson.

Inputs: data (required), name (required), context (required), namespace (required), +2 more.

k8s_delete_nsA

Delete a Kubernetes namespace and all resources within it. Protected namespaces (default, kube-system, kube-public, kube-node-lease) cannot be deleted.

Inputs: name (required), context (required).

k8s_delete_resourceA

Delete a Kubernetes resource. Supports all common resource types (pod, deployment, service, configmap, secret, statefulset, daemonset, job, cronjob, ingress, pvc, pv, namespace, serviceaccount, networkpolicy, hpa). Set force=True for immediate deletion (grace_period=0).

Inputs: name (required), context (required), resource_type (required), force, +2 more.

k8s_describeA

Show detailed information about a resource, similar to 'kubectl describe'. Can describe a single resource by name, or multiple resources using a label selector. Set all_namespaces=True to search across all namespaces.

Inputs: context (required), resource_type (required), name, selector, +2 more.

k8s_diagnose_applicationA

Diagnose issues with a Kubernetes application by checking resource status, pod health, events, and container logs. Automatically detects common problems like CrashLoopBackOff, OOMKilled, ImagePullBackOff, permission errors, and connection issues. Returns a structured report with issues, severity, and recommendations.

Inputs: context (required), app_name (required), namespace (required), resource_type.

k8s_drain_nodeA

Drain a node by evicting all pods, preparing it for maintenance. Automatically cordons the node first. Set ignore_daemonsets=True to skip DaemonSet pods. Set force=True to evict pods not managed by a controller.

Inputs: context (required), node_name (required), force, timeout, +2 more.

k8s_expose_resourceC

Expose a deployment or pod as a new Kubernetes Service. Creates a Service that routes traffic to the target resource. Specify type='LoadBalancer' for external access or type='NodePort' for node-level access.

Inputs: name (required), port (required), context (required), resource_type (required), +7 more.

k8s_get_clusterrolebindingsB

List RBAC ClusterRoleBindings showing cluster-wide role assignments.

Inputs: context (required).

k8s_get_clusterrolesB

List RBAC ClusterRoles with their permission rules. ClusterRoles grant cluster-wide permissions or can be bound per-namespace.

Inputs: context (required).

k8s_get_configmap_detailA

Get a Kubernetes ConfigMap with its full data contents.

Inputs: name (required), context (required), namespace (required).

k8s_get_contextsA

List all available Kubernetes contexts from all kubeconfig files. Returns context names that can be used with other tools. Supports partial context name matching in all other commands.

Inputs: no named parameters.

k8s_get_cronjobsB

List Kubernetes CronJobs with schedule, suspension status, active jobs, and last schedule/success times. Omit namespace for all namespaces.

Inputs: context (required), namespace, label_selector.

k8s_get_eventsB

List Kubernetes events in a namespace, sorted by most recent first. Events show scheduling decisions, image pulls, container crashes, and other cluster activity.

Inputs: context (required), namespace (required), limit.

k8s_get_jobsB

List Kubernetes Jobs with completion status, active/succeeded/failed counts, and timing information. Omit namespace for all namespaces.

Inputs: context (required), namespace, label_selector.

k8s_get_namespacesB

List all namespaces in a Kubernetes cluster. Use this to discover available namespaces before querying resources.

Inputs: context (required).

k8s_get_network_policiesB

List NetworkPolicies that control pod-to-pod and pod-to-external traffic. Shows pod selectors, policy types (Ingress/Egress), and rule counts.

Inputs: context (required), namespace.

k8s_get_nodesC

List all nodes in a Kubernetes cluster with status, roles, capacity, and version info.

Inputs: context (required).

k8s_get_pod_logsA

Get logs from a Kubernetes pod. For multi-container pods, logs from the first container are returned by default. Use sinceDuration to filter (e.g., '5m', '1h', '2d'). Set previousContainer=True to get logs from the previously terminated container.

Inputs: pod (required), context (required), namespace (required), sinceDuration, +1 more.

k8s_get_pvcsB

List PersistentVolumeClaims (PVCs) with status, capacity, access modes, and storage class. Omit namespace for all namespaces.

Inputs: context (required), namespace, label_selector.

k8s_get_pvsB

List PersistentVolumes (PVs) in the cluster with capacity, access modes, reclaim policy, and bound claim information.

Inputs: context (required).

k8s_get_resourceC

Get the complete definition of a single Kubernetes resource. Returns the full resource spec, status, and metadata as a dictionary.

Inputs: kind (required), name (required), context (required), namespace (required), +2 more.

k8s_get_resourcesA

List Kubernetes resources of a specified kind (e.g., Pod, Deployment, Service, Ingress). Common kinds auto-detect their API group. For custom resources, specify group and version. Omit namespace to query across all namespaces.

Inputs: kind (required), context (required), group, version, +1 more.

k8s_get_rolebindingsA

List RBAC RoleBindings showing which subjects (users, groups, service accounts) are bound to which roles. Omit namespace for all namespaces.

Inputs: context (required), namespace.

k8s_get_rolesA

List RBAC Roles with their permission rules. Roles grant permissions within a specific namespace. Omit namespace to list roles across all namespaces.

Inputs: context (required), namespace.

k8s_get_secret_detailA

Get a Kubernetes Secret. By default shows only key names for security. Set decode=True to include the actual decoded values. Use with caution - decoded secrets may contain sensitive credentials.

Inputs: name (required), context (required), namespace (required), decode.

k8s_get_service_accountsB

List Kubernetes ServiceAccounts. ServiceAccounts provide pod-level identity for RBAC authorization. Omit namespace for all namespaces.

Inputs: context (required), namespace.

k8s_get_storage_classesA

List StorageClasses in the cluster with provisioner, reclaim policy, volume binding mode, and whether each is the default class.

Inputs: context (required).

k8s_label_resourceB

Add or update labels on a Kubernetes resource. Labels are key-value pairs used for organizing and selecting resources.

Inputs: name (required), labels (required), context (required), resource_type (required), +2 more.

k8s_list_configmapA

List Kubernetes ConfigMaps with their key names. Use label_selector to filter. Omit namespace for all namespaces.

Inputs: context (required), namespace, label_selector.

k8s_list_secretA

List Kubernetes Secrets with metadata (keys only, values hidden for security). Use label_selector to filter (e.g., 'app=myapp'). Omit namespace for all namespaces.

Inputs: context (required), namespace, label_selector.

k8s_patch_resourceB

Update specific fields of a resource using a strategic merge patch. Supports pod, deployment, service, configmap, secret, and custom resources.

Inputs: name (required), patch (required), context (required), resource_type (required), +1 more.

k8s_pod_execB

Execute a command inside a running container. Supports quoted arguments (e.g., 'ls -la "/my dir"'). Specify container for multi-container pods. Defaults to the 'default' namespace if not specified.

Inputs: command (required), context (required), pod_name (required), tty, +4 more.

k8s_rollout_historyA

Get the revision history of a deployment, daemonset, or statefulset. Shows past revisions that can be used with rollout_undo.

Inputs: name (required), context (required), namespace (required), resource_type (required).

k8s_rollout_pauseA

Pause an in-progress rollout for a deployment, daemonset, or statefulset. Useful for canary-style deployments where you want to inspect before continuing.

Inputs: name (required), context (required), namespace (required), resource_type (required).

k8s_rollout_restartC

Trigger a rolling restart of a deployment, daemonset, or statefulset. All pods will be recreated in a rolling fashion.

Inputs: name (required), context (required), namespace (required), resource_type (required).

k8s_rollout_resumeC

Resume a previously paused rollout for a deployment, daemonset, or statefulset.

Inputs: name (required), context (required), namespace (required), resource_type (required).

k8s_rollout_statusB

Get the rollout status of a deployment, daemonset, or statefulset. Shows replica counts, conditions, and whether the rollout is complete.

Inputs: name (required), context (required), namespace (required), resource_type (required).

k8s_rollout_undoA

Roll back a deployment, daemonset, or statefulset to a previous revision. Omit to_revision to roll back to the immediately previous revision, or specify a revision number from rollout_history.

Inputs: name (required), context (required), namespace (required), resource_type (required), +1 more.

k8s_run_podA

Create and run a pod with the specified container image. Useful for running one-off tasks, debugging, or testing. Set restart='Never' for one-shot jobs.

Inputs: name (required), image (required), context (required), env, +4 more.

k8s_scale_resourceB

Scale a deployment, statefulset, or replicaset to the specified number of replicas. Set replicas=0 to scale down completely.

Inputs: name (required), context (required), replicas (required), namespace (required), +1 more.

k8s_set_resources_for_containerB

Set resource limits and requests for containers in a deployment, statefulset, or daemonset. Example: limits={'cpu': '500m', 'memory': '256Mi'}, requests={'cpu': '100m', 'memory': '128Mi'}.

Inputs: context (required), resource_name (required), resource_type (required), limits, +3 more.

k8s_taint_nodeC

Add a taint to a node. Taints prevent pods without matching tolerations from being scheduled. Effects: NoSchedule (hard), PreferNoSchedule (soft), NoExecute (evict existing pods too).

Inputs: key (required), context (required), node_name (required), value, +1 more.

k8s_top_nodesB

Display CPU and memory usage of all nodes in the cluster. Requires metrics-server to be installed. Shows usage alongside capacity.

Inputs: context (required).

k8s_top_podsA

Display CPU and memory usage of pods, broken down by container. Requires metrics-server to be installed. Omit namespace for all namespaces.

Inputs: context (required), namespace.

k8s_uncordon_nodeA

Mark a previously cordoned node as schedulable again. New pods can be scheduled on this node after uncordoning.

Inputs: context (required), node_name (required).

k8s_untaint_nodeB

Remove a taint from a node. Omit effect to remove all taints with the given key.

Inputs: key (required), context (required), node_name (required), effect.

k8s_update_resourcesB

Update CPU/memory requests and limits for a specific container in a deployment, statefulset, or daemonset. Values use Kubernetes notation (e.g., '128Mi', '500m', '1Gi', '2').

Inputs: name (required), context (required), container (required), namespace (required), +5 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.1/5.0

    Scored across 57 tools

    Disambiguation3/5

    Most tools are distinct, but several pairs like k8s_update_resources and k8s_set_resources_for_container have nearly identical purposes, which could cause confusion. Additionally, k8s_create_ns and k8s_create_resource overlap in creating namespaces.

    Naming Consistency2/5

    Tool names mix different patterns: some use 'get_' (k8s_get_contexts), others 'list_' (k8s_list_secret), and several are noun-only like k8s_cluster_info or verb-only like k8s_describe. The naming is inconsistent and not predictable.

    Tool Count3/5

    57 tools is high but justified by Kubernetes' complexity, covering many resource types and operations. However, some redundancy suggests the set could be streamlined, making it borderline too large.

    Completeness5/5

    The tool set covers nearly all common Kubernetes operations: CRUD for resources, rollout management, scaling, node operations, RBAC, storage, network policies, jobs, and diagnostics. Only niche features like operator management are missing.

    Maintenance

    ActivityNo data
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables comprehensive Kubernetes cluster management through kubectl operations, Helm chart deployments, pod troubleshooting, and node management. Supports both read-only and full cluster administration capabilities with built-in safety features.
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables interaction with Kubernetes clusters through 32 specialized tools for managing resources, deployments, and services. Provides both CLI and web interfaces for real-time Kubernetes operations powered by Google Gemini.
      5
      -
    • A
      license
      B
      quality
      D
      maintenance
      Enables AI assistants to interact with Kubernetes clusters through 50 specialized tools for comprehensive cluster management. Supports both local kubectl and remote SSH-based execution for managing pods, deployments, services, and other Kubernetes resources.
      49
      MIT