Mcp Kubernetes

io.github.dockndevaiPublished by GitHub account dockndevaiv0.3.3Updated Oct 26, 2026

Kubernetes monitoring & ops for AI agents — safe-by-default access modes and guards.

Overview

AI-generated overview

Local MCP server that lets an AI assistant inspect and operate Kubernetes clusters across contexts, read-only by default with layered safety gates.

What you can do
  • List contexts, namespaces, pods, deployments, services, nodes and recent events
  • Read a single pod's full details and fetch recent container logs
  • Read arbitrary Kubernetes objects by apiVersion, kind and name
  • In read-write mode, scale or restart deployments, set deployment images, create namespaces and apply manifests
  • In admin mode with explicit opt-ins, delete resources and exec into pods
  • Gate and audit guarded operations, with optional dry-run and a local risk-guard daemon
When to use it
Useful when you want an assistant to diagnose cluster problems, check pod status and logs, or review deployments and events without switching to kubectl. It also suits teams that want controlled write or admin actions behind explicit flags and allowlists.
Requirements
Runs locally via npx from the npm package, so Node.js is needed. Requires a kube-config file (path via KUBECONFIG_PATH) or an in-cluster service account, plus network access to the clusters. Behaviour is set by environment variables such as K8S_MODE, namespace and context allowlists, and the delete, apply and exec opt-ins.
Before you install
Write and admin modes can change or delete cluster resources; keep K8S_MODE at read-only until needed and rely on the allowlists and protected namespaces. Delete, apply and exec stay off unless K8S_ALLOW_DELETE, K8S_ALLOW_APPLY or K8S_ALLOW_EXEC are enabled. The server uses your kube-config credentials, so it inherits their cluster permissions. The optional guard mode contacts a local laya-guard daemon.

Installation

In SourceWeft

  1. Open Mcp Kubernetes in the dashboard and add it to a workspace.
  2. Enable the server for the chats that should use its tools.

Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.

Other MCP clients

Follow the launch instructions in the repository.

README

mcp-kubernetes

[CI] [License: MIT] [npm]

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.

Security model

ConcernFlagDefaultEffect
What can the server do at all?K8S_MODEread-onlyread-only exposes only reads; read-write adds mutations; admin adds destructive tools. Tools above the mode are never registered.
Which namespaces are in scope?K8S_NAMESPACE_ALLOWLIST(all)When set, any operation on a namespace outside the list is refused.
Which namespaces are read-only forever?K8S_PROTECTED_NAMESPACESkube-system,kube-public,kube-node-leaseCan be read but never mutated or deleted, regardless of mode.
Which clusters are reachable?K8S_CONTEXT_ALLOWLIST(all)When set, only these kube-config contexts may be targeted.
Can it delete?K8S_ALLOW_DELETEfalsedelete_resource needs this and admin mode.
Can it apply manifests?K8S_ALLOW_APPLYfalseapply_manifest needs this and read-write mode.
Can it exec into pods?K8S_ALLOW_EXECfalseexec_in_pod needs this and admin mode; the tool isn't even registered otherwise.
Preview without touching the clusterK8S_DRY_RUNfalseWrite/admin tools validate + log intent, then return without calling the API.
Audit trailK8S_AUDIT_LOGtrueEmits a JSON line to stderr per guarded operation (ALLOW / DENY / DRY_RUN).
Interactive confirmation(automatic)—Destructive & high-impact actions prompt the human to approve via MCP elicitation before running; clients without elicitation fall back to the *_ALLOW_* gate.

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)

bash
claude mcp add kubernetes -e KUBECONFIG_PATH="/Users/you/.kube/config" -e K8S_MODE="read-only" -- npx -y @dockndevai/mcp-kubernetes

Claude Desktop · Cursor · Windsurf — same block in claude_desktop_config.json, .cursor/mcp.json, or ~/.codeium/windsurf/mcp_config.json:

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:

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:

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:

bash
npm installnpm run buildnode dist/index.js   # with the environment variables set

Develop

bash
npm run dev        # watch modenpm test           # unit tests for the security policynpm run typecheck

Publishing

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

Source: README.md at commit abda11f

Tools

10

list_contexts

List kube-config contexts

List the contexts (clusters) available in the loaded kube-config.

Takes no parameters.

list_namespaces

List namespaces

List namespaces in the cluster. Namespaces outside the allowlist are filtered out.

Parameterscontext

list_pods

List pods

List pods in a namespace with status, readiness, restarts, and node.

Parameterscontextnamespacerequired

get_pod

Get pod

Fetch the full representation of a single pod.

Parametersnamerequiredcontextnamespacerequired

get_pod_logs

Get pod logs

Fetch recent logs from a pod container.

ParametersnamerequiredcontextpreviouscontainernamespacerequiredtailLines

list_deployments

List deployments

List deployments in a namespace with replica status.

Parameterscontextnamespacerequired

list_services

List services

List services in a namespace with type and cluster IP.

Parameterscontextnamespacerequired

list_nodes

List nodes

List cluster nodes with readiness and kubelet version.

Parameterscontext

list_events

List events

List recent events in a namespace — useful for diagnosing failures.

Parameterscontextnamespacerequired

get_resource

Get any resource

Read an arbitrary Kubernetes object by apiVersion/kind/name (e.g. apiVersion=apps/v1, kind=Deployment).

ParameterskindrequirednamerequiredcontextnamespaceapiVersionrequired

Version history

3
  1. v0.3.3LatestOct 26, 2026
  2. v0.3.0Sep 27, 2026
  3. v0.2.2Sep 16, 2026

Score

90% of the applicable checks met

How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.

  • Reached in the last 30 days25 pts
  • Auth declared10 pts

    Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.

  • Tools listedRequired15 pts
  • DescriptionRequired15 pts
  • Logo10 pts
  • Documentation15 pts
  • License10 pts