k8s-mcp
Manage Kubernetes/OpenShift clusters through MCP sessions for inspection, diagnostics, and guarded changes.
Connect, disconnect, and list active kubeconfig/in-cluster sessions.
List namespaces, nodes, pods, deployments, services, events, and secret names only (values hidden).
Read pod log tails and inspect basic pod status.
Scale deployments and trigger rolling restarts.
Delete a pod only with
confirm=true.Apply Deployment or ConfigMap YAML manifests.
The README also documents broader capabilities not present in this schema: cluster overview, pod health diagnostics, OpenShift Routes, rollout status, digest-pinned rollout, rollback, and DeploymentConfig listing.
Provides tools for interacting with Kubernetes clusters, including listing namespaces, pods, deployments, services, and nodes, reading pod logs and events, scaling and restarting Deployments, deleting pods, and applying Deployment or ConfigMap manifests.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@k8s-mcp list all pods in the default namespace"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Kubernetes & OpenShift MCP Server (k8s-cloud-deploy-mcp)
A Python Model Context Protocol (MCP) server for Kubernetes, Red Hat OpenShift, and managed cloud clusters (AWS EKS, Azure AKS, GCP GKE) — cluster overview, pod health diagnostics, container logs, OpenShift Routes, immutable
sha256digest rollouts, and confirmation-gated rollbacks.
Overview
k8s-cloud-deploy-mcp lets AI assistants inspect Kubernetes and OpenShift workloads, diagnose failing pods (CrashLoopBackOff, OOMKilled, event timelines), and execute safe, digest-pinned deployments.
Multi-cloud & OpenShift: Automatically detects OpenShift (
apps.openshift.io/v1/route.openshift.io), EKS, AKS, GKE, or standard Kubernetes clusters viaKUBECONFIG,K8S_CONTEXT, or an in-cluster service account.Safety guardrails:
Read-only inspection tools run immediately without extra confirmation.
k8s_trigger_deployment_rollout,k8s_rollback_deployment, andk8s_delete_podreturn a preview plan first and only apply when called withconfirm=true.Image updates enforce immutable
@sha256:...digests and reject:latest.k8s_list_secret_namesreturns secret metadata only — secret values are never exposed.
Related MCP server: MCP Server Kubernetes
Architecture & How It Works
flowchart TB
subgraph L1["Layer 1 — AI Client"]
IDE["Cursor, Claude Code, VS Code"]
end
subgraph L2["Layer 2 — MCP Server"]
SRV["k8s-cloud-deploy-mcp (FastMCP)"]
HUB["K8sHub sessions + Guards"]
end
subgraph L3["Layer 3 — Cluster"]
CFG["kubeconfig / in-cluster SA"]
API["Kubernetes / OpenShift API"]
end
IDE --> SRV --> HUB --> CFG --> APIUses the official Python
kubernetesclient as the authoritative API layer.kubectl/ocare optional and only invoked for client version checks androllout statusverification withshell=Falseand fixed argument lists.
Project Layout
k8s-mcp/
├── src/k8s_cloud_deploy_mcp/
│ ├── __init__.py # Package metadata
│ ├── __main__.py # `python -m k8s_cloud_deploy_mcp` entry point
│ ├── server.py # FastMCP server, 23 tools, /health, CLI transport
│ ├── kube.py # K8sHub session manager & Kubernetes/OpenShift API calls
│ ├── cloud.py # EKS/AKS/GKE/OpenShift detection & auth-gap checks
│ ├── diagnostics.py # Container states, rollout progress, rollback stamping
│ ├── guards.py # sha256 digest & :latest guards, confirmation previews
│ ├── rollout.py # Trigger rollout & revision rollback logic
│ ├── cli.py # Safe shell=False kubectl/oc argument builders
│ ├── models.py # Pydantic models
│ └── output.py # Structured output & error redaction
├── tests/ # Unit and regression tests
├── pyproject.toml # Hatchling config (`k8s-cloud-deploy-mcp`, `k8s-mcp`)
├── Dockerfile # Streamable HTTP container
└── mcpize.yaml # Hosted HTTP runtime configTools Reference (23)
Cluster Sessions & Discovery (4)
Tool | Description |
| Connect to a kubeconfig context / namespace as a named session. |
| Close a named cluster session. |
| Show active sessions, provider, and context info. |
| Cluster health, nodes, namespaces, and OpenShift/cloud provider detection. |
Read-Only Inspection & Diagnostics (13)
Tool | Description |
| List namespaces / OpenShift projects. |
| List cluster nodes and conditions. |
| List Deployments and OpenShift DeploymentConfigs. |
| List Services and endpoints. |
| List pods filtered by namespace or label selector. |
| Inspect pod phase, container waiting/terminated reasons ( |
| Fetch recent or previous container logs. |
| List namespace events ordered by timestamp. |
| List Secret names and types only (never exposes Secret values). |
| Inspect OpenShift Routes and backing Services. |
| Check deployment rollout status and replica availability. |
Deployment, Scaling & Mutating Operations (6)
Tool | Guard | Description |
| Requires | Update deployment image to an immutable |
| Requires | Roll back to a previous ReplicaSet revision. |
| Requires | Delete a pod (for example to restart a stuck pod). |
| Deployment scale | Scale deployment replicas in a namespace. |
| Rollout restart | Trigger a rolling restart via pod template annotation. |
| Rejects | Apply YAML manifests after image digest/tag policy validation. |
Installation & Configuration
Requires Python 3.10+ and uv. Prepare your kubeconfig first (aws eks update-kubeconfig, az aks get-credentials, gcloud container clusters get-credentials, or oc login).
git clone https://github.com/Pawangunjkar/k8s-mcp.git
cd k8s-mcp
uv sync
uv run k8s-cloud-deploy-mcpEnvironment Variables
Variable | Default | Purpose |
|
| Kubeconfig file or path list. |
| current context | Target kubeconfig context name. |
|
| Default namespace or OpenShift project. |
| auto-detected |
|
| unset | Required when |
| unset | Required when |
| unset | Required when |
Cursor / Claude Desktop / Claude Code
{
"mcpServers": {
"k8s-cloud-deploy-mcp": {
"command": "uv",
"args": ["run", "--directory", "/absolute/path/to/k8s-mcp", "k8s-cloud-deploy-mcp"],
"env": {
"KUBECONFIG": "/path/to/.kube/config",
"K8S_CONTEXT": "dev",
"CLOUD_PROVIDER": "generic_k8s"
}
}
}
}Development & Tests
uv run python -m unittest discover -s tests -v
uv buildAuthor & License
Pawan Gunjkar — pawangunjkar@gmail.com · GitHub
MIT License — see LICENSE.
Available Tools
15 toolsk8s_applyB
Create or patch a Deployment or ConfigMap from YAML.
Inputs: manifest_yaml (required), session_name. Returns: result
k8s_connectC
Load a kubeconfig context, or in-cluster config when no kubeconfig is available.
Inputs: context, namespace, kubeconfig, session_name. Returns: result
k8s_delete_podB
Delete one pod so the controller recreates it. confirm=true is required.
Inputs: pod (required), confirm, namespace, session_name. Returns: result
k8s_disconnectC
Drop a Kubernetes session.
Inputs: session_name. Returns: result
k8s_eventsA
Show the latest 30 namespaced events.
Inputs: namespace, session_name. Returns: result
k8s_list_deploymentsB
List deployments and ready replica counts.
Inputs: namespace, session_name. Returns: result
k8s_list_namespacesB
List namespace names.
Inputs: session_name. Returns: result
k8s_list_nodesB
List nodes and Ready condition.
Inputs: session_name. Returns: result
k8s_list_podsB
List pods with phase, ready count, and node.
Inputs: label, namespace, session_name. Returns: result
k8s_list_secret_namesB
List Secret names only. Values are not returned.
Inputs: namespace, session_name. Returns: result
k8s_list_servicesB
List services, type, and cluster IP.
Inputs: namespace, session_name. Returns: result
k8s_pod_logsB
Read the tail of a pod log.
Inputs: pod (required), tail, container, namespace, +1 more. Returns: result
k8s_restartC
Roll a Deployment by setting restartedAt.
Inputs: name (required), namespace, session_name. Returns: result
k8s_scaleC
Scale a Deployment.
Inputs: name (required), replicas (required), namespace, session_name. Returns: result
k8s_statusB
List Kubernetes sessions.
Inputs: no named parameters. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 15 tools
Each tool targets a distinct resource and action: connect/disconnect manage sessions, list_* covers different Kubernetes resources, and pod_logs/scale/restart/delete_pod/apply are specific operations. There is no meaningful overlap—even multiple pod-related tools are clearly differentiated by their verbs.
All tools share the k8s_ prefix and generally follow a verb_noun pattern (list_namespaces, scale, delete_pod). Minor deviations exist: k8s_events and k8s_pod_logs omit the list/get verb, but the pattern is still predictable and readable.
At 15 tools, the server sits at the upper bound of the typical well-scoped range. The breadth is justified by covering connection management plus a variety of Kubernetes resources and operations, though it feels slightly heavy for a single-purpose MCP server.
The server covers listing many resources, logs, events, scaling, restarting, and applying YAML, but lacks get operations for individual resources, delete for most resources (only pods), and any write operations for services, secrets, or namespaces. It is read-heavy with limited lifecycle coverage beyond Deployments.
Related MCP Connectors
Deploy applications and manage governed Kubernetes preview spaces and capacity.
Deploy and run apps, workers, jobs, Postgres, and Valkey on Ownkube from your coding agent.
Secrets for developers and agents—secure context and workflows without exposing secret values.
Deploy and operate Kubernetes: clusters, stacks, apps, logs, metrics and security, with OAuth.
Related MCP Servers
- AlicenseBqualityDmaintenanceEnables managing Kubernetes clusters through natural language by providing tools to list resources, view logs, port-forward services, scale deployments, and execute kubectl operations via AI assistants.81MIT
- AlicenseNot gradedqualityDmaintenanceEnables 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
- AlicenseCqualityDmaintenanceEnables connecting to a Kubernetes cluster to manage resources and troubleshoot workloads with kubectl and Helm operations, including logs, scaling, port forwarding, and non-destructive mode.22MIT
- AlicenseBqualityDmaintenanceEnables connection to a Kubernetes cluster to list and manage pods, services, deployments, and nodes, create/delete/describe pods, inspect namespaces, and retrieve logs for debugging.11MIT