mcp-kubernetes
You can inspect and (with opt-in flags) operate Kubernetes clusters across multiple contexts via MCP tools, with safe defaults.
List kube-config contexts, namespaces, pods, deployments, services, nodes, and events.
Get pod details, pod logs, and arbitrary Kubernetes resources by apiVersion/kind/name.
With read-write mode: scale/restart deployments, set deployment image, create namespaces, apply manifests (if allowed).
With admin mode and opt-ins: delete resources and exec into pods.
Security: namespace/context allowlists, protected namespaces, dry-run, audit logging, and optional AI risk guard.
Allows MCP clients to inspect and operate Kubernetes clusters, with tools for listing contexts, namespaces, pods, deployments, services, nodes, and events, fetching pod logs, scaling and restarting deployments, setting deployment images, creating namespaces, applying manifests, deleting resources, and executing commands in pods, governed by configurable access modes and security flags.
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., "@mcp-kubernetes list pods in the staging context for the web 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.
mcp-kubernetes
A Model Context Protocol server for Kubernetes. It lets an MCP-capable client (Claude Desktop, Claude Code, etc.) inspect and operate Kubernetes clusters across multiple contexts — with behaviour controlled entirely by flags.
The design goal is safe by default: it starts read-only, can be scoped to an allowlist of namespaces and contexts, protects system namespaces from mutation, and gates the dangerous operations (delete, apply, exec) behind explicit opt-ins.
Features
Multi-cluster — every tool accepts an optional
context; scope which contexts are usable with an allowlist.Access modes —
read-only→read-write→admin, layered so a mode never exposes tools above its level.Security flags — namespace allowlist, protected namespaces, context allowlist, plus independent opt-ins for delete / apply / exec, dry-run, and JSON audit logging (see below).
Standard auth — uses your kube-config (or in-cluster service account). No credentials are stored by the server.
Related MCP server: k8s-mcp-go
Security model
Concern | Flag | Default | Effect |
What can the server do at all? |
|
|
|
Which namespaces are in scope? |
| (all) | When set, any operation on a namespace outside the list is refused. |
Which namespaces are read-only forever? |
|
| Can be read but never mutated or deleted, regardless of mode. |
Which clusters are reachable? |
| (all) | When set, only these kube-config contexts may be targeted. |
Can it delete? |
|
|
|
Can it apply manifests? |
|
|
|
Can it exec into pods? |
|
|
|
Preview without touching the cluster |
|
| Write/admin tools validate + log intent, then return without calling the API. |
Audit trail |
|
| Emits a JSON line to stderr per guarded operation ( |
Interactive confirmation | (automatic) | — | Destructive & high-impact actions prompt the human to approve via MCP elicitation before running; clients without elicitation fall back to the |
The layers are independent — e.g. admin mode with all three opt-ins false can restart and scale deployments but can neither delete resources nor exec into pods.
Tools
Read (read-only+): list_contexts, list_namespaces, list_pods, get_pod, get_pod_logs, list_deployments, list_services, list_nodes, list_events, get_resource
Write (read-write+): scale_deployment, restart_deployment, set_deployment_image, create_namespace, apply_manifest (needs K8S_ALLOW_APPLY)
Admin (admin): delete_resource (needs K8S_ALLOW_DELETE), exec_in_pod (needs K8S_ALLOW_EXEC)
Optional AI risk guard. Set K8S_GUARD_MODE=monitor|enforce to have delete_resource, exec_in_pod and apply_manifest consult a local laya-guard daemon (pipx install laya-guard && laya-guard) that classifies the operation allow/confirm/block before it runs. Runs after the delete/exec/apply gates; only tightens, never grants; fails closed.
Quickstart — add to your agent
Published on npm as @dockndevai/mcp-kubernetes. No clone or build needed — your MCP client runs it on demand with npx. Start in read-only mode; see .env.example for every variable and docs/CLIENTS.md for the full per-client guide.
Claude Code (CLI)
claude mcp add kubernetes -e KUBECONFIG_PATH="/Users/you/.kube/config" -e K8S_MODE="read-only" -- npx -y @dockndevai/mcp-kubernetesClaude Desktop · Cursor · Windsurf — same block in claude_desktop_config.json, .cursor/mcp.json, or ~/.codeium/windsurf/mcp_config.json:
{
"mcpServers": {
"kubernetes": {
"command": "npx",
"args": [
"-y",
"@dockndevai/mcp-kubernetes"
],
"env": {
"KUBECONFIG_PATH": "/Users/you/.kube/config",
"K8S_MODE": "read-only"
}
}
}
}OpenAI Codex CLI — in ~/.codex/config.toml:
[mcp_servers.kubernetes]
command = "npx"
args = ["-y", "@dockndevai/mcp-kubernetes"]
env = { KUBECONFIG_PATH = "/Users/you/.kube/config", K8S_MODE = "read-only" }VS Code (GitHub Copilot, Agent mode) — in .vscode/mcp.json:
{
"servers": {
"kubernetes": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@dockndevai/mcp-kubernetes"
],
"env": {
"KUBECONFIG_PATH": "/Users/you/.kube/config",
"K8S_MODE": "read-only"
}
}
}
}Run from source (development)
Prefer the published package above. To run from a clone:
npm install
npm run build
node dist/index.js # with the environment variables setDevelop
npm run dev # watch mode
npm test # unit tests for the security policy
npm run typecheckPublishing
This server ships a server.json for the official MCP registry and an mcpName for npm ownership validation. See PUBLISHING.md for publishing to npm and listing on the MCP registry, Smithery, Glama, Cursor, and PulseMCP.
License
MIT
Available Tools
10 toolsget_podGet podBRead-onlyIdempotent
Fetch the full representation of a single pod.
Inputs: name (required), namespace (required), context.
get_pod_logsGet pod logsARead-onlyIdempotent
Fetch recent logs from a pod container.
Inputs: name (required), namespace (required), context, previous, +2 more.
get_resourceGet any resourceARead-onlyIdempotent
Read an arbitrary Kubernetes object by apiVersion/kind/name (e.g. apiVersion=apps/v1, kind=Deployment).
Inputs: kind (required), name (required), apiVersion (required), context, +1 more.
list_contextsList kube-config contextsARead-onlyIdempotent
List the contexts (clusters) available in the loaded kube-config.
Inputs: no named parameters.
list_deploymentsList deploymentsARead-onlyIdempotent
List deployments in a namespace with replica status.
Inputs: namespace (required), context.
list_eventsList eventsARead-onlyIdempotent
List recent events in a namespace — useful for diagnosing failures.
Inputs: namespace (required), context.
list_namespacesList namespacesARead-onlyIdempotent
List namespaces in the cluster. Namespaces outside the allowlist are filtered out.
Inputs: context.
list_nodesList nodesARead-onlyIdempotent
List cluster nodes with readiness and kubelet version.
Inputs: context.
list_podsList podsARead-onlyIdempotent
List pods in a namespace with status, readiness, restarts, and node.
Inputs: namespace (required), context.
list_servicesList servicesARead-onlyIdempotent
List services in a namespace with type and cluster IP.
Inputs: namespace (required), context.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 10 tools
Each tool targets a distinct resource or action: list contexts, namespaces, pods, deployments, services, nodes, events, and specific getters for pod details, logs, and arbitrary resources. No two tools have overlapping purposes; get_resource is clearly defined as a generic read that complements the specific ones.
All tools follow a consistent verb_resource pattern: list_* for enumerations and get_* for single-object retrieval. Names use lowercase snake_case consistently, with clear pluralization for list operations and singular for get operations, including a mixed get_pod_logs that still fits the pattern.
Ten tools is well-scoped for a Kubernetes read-only server, covering core resource types (pods, deployments, services, nodes, events) plus generic access. Each tool has a clear purpose and the count is neither overwhelming nor too thin.
The server provides comprehensive read coverage for common Kubernetes resources, including list/get operations, logs, events, and arbitrary object retrieval via get_resource. It lacks write operations (create/update/delete), but this appears intentional for a diagnostic-focused tool, leaving only minor gaps like lack of pod exec or resource watches.
Maintenance
Related MCP Connectors
Governed MCP gateway: one endpoint for your tools, with credential custody and audit log.
Provides read access to your GKE and Kubernetes resources.
Managed Keycloak from any MCP client: clusters, realms, apps, SSO, users, domains, audit events.
Authenticated MCP server for ClearPolicy policy and compliance workflows.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceAn MCP server that enables interaction with multiple Kubernetes clusters simultaneously, providing comprehensive tools for cluster management, resource operations, and diagnostics across different environments.-
- AlicenseNot gradedqualityCmaintenanceSafe, read-only-by-default Kubernetes access for AI agents via MCP. Provides explicit readonly, readwrite, and dangerous permission modes, plus MCPB bundles for desktop clients.2MIT
- AlicenseNot gradedqualityDmaintenanceEnables Kubernetes cluster introspection via MCP tools, such as listing pods, namespaces, nodes, and events.4ISC
- AlicenseNot gradedqualityDmaintenanceAn MCP server for generating Kubernetes manifests (deployments, services, configmaps, secrets, ingresses, namespaces) and performing kubectl operations like apply, delete, get, describe, logs, and exec.MIT