MCP Servers · Publisher repository

Kubernetes MCP Server

A native Go MCP server that exposes Kubernetes and OpenShift resources, pod diagnostics, events, Helm operations, and optional ecosystem toolsets, with controls for read-only access, denied resources, and RBAC-scoped identities.

2.1k StarsApache-2.0GoUpdated today
01

Project overview

Kubernetes MCP Server is for teams that want an AI agent to observe or operate Kubernetes and OpenShift. It is a native Go implementation that talks directly to the Kubernetes API without requiring kubectl or the Helm CLI at runtime, and it ships through local stdio, containerized Streamable HTTP, npm, PyPI, and native binaries. The project organizes generic resources, pods, events, Helm, and optional ecosystem integrations as MCP tools. That usefulness comes with a high-trust boundary: the default configuration is not read-only. A safer starting point is a dedicated ServiceAccount, least-privilege RBAC, a separate kubeconfig, and the --read-only flag, followed by narrowly reviewed write access only when a concrete workflow requires it.

02

Core capabilities

01

Generic resource operations

Discovers and handles common and custom resources through the dynamic Kubernetes API. Tool settings and RBAC jointly define the effective scope.

02

Pod diagnostics and operations

Provides pod listing, details, logs, metrics, exec, deletion, and ephemeral-run tools. The execution features require particular care.

03

Helm lifecycle management

Includes Helm install, list, and uninstall without depending on an external Helm CLI. Write access should have separate RBAC and confirmation rules.

04

Multi-cluster and config reload

Supports multiple kubeconfig contexts and reloading changed cluster configuration within an explicitly controlled target set.

05

Optional ecosystem toolsets

Tekton, Kiali, KubeVirt, NetObserv, and kcp toolsets can be enabled as needed, reducing irrelevant tools in model context.

06

Self-hosting and observability

Streamable HTTP, OAuth/OIDC, metrics, and OpenTelemetry support team deployments, but network and identity boundaries must be hardened by the operator.

03

Setup and connection

Create a dedicated read-only identity and kubeconfig, then register the npx package with Claude Code using --read-only. Verify the connection with a side-effect-free namespace query.

AI AGENT INSTALL

Let an AI Agent install it

Send this prompt to Codex, Claude Code, or another AI agent that can work with your local environment.

Install Kubernetes MCP Server from https://github.com/containers/kubernetes-mcp-server. First read the README, docs/getting-started-claude-code.md, docs/getting-started-kubernetes.md, and docs/configuration.md. Do not use my everyday administrator kubeconfig. Confirm the target cluster and namespace, then create a dedicated ServiceAccount, least-privilege read-only RBAC, and a separate kubeconfig. Connect it to Claude Code through npx with --read-only. Ask before requesting credentials, adding permissions, overwriting files, exposing a network endpoint, or running any write operation. Finally run claude mcp list and one side-effect-free namespace listing. Report the config location, identity, permission scope, and result without printing any token.
01Before you start
  • A running and reachable Kubernetes or OpenShift cluster
  • kubectl and administrator permission to provision a dedicated ServiceAccount and RBAC
  • Node.js and npx, or another distribution method documented by the project
  • An MCP client such as Claude Code
  • An absolute path to a separate kubeconfig for the MCP server
02Copy the install command or configuration
claude mcp add-json kubernetes-mcp-server '{"command":"npx","args":["-y","kubernetes-mcp-server@latest","--read-only"],"env":{"KUBECONFIG":"/absolute/path/to/mcp-viewer.kubeconfig"}}' -s user
03Complete the setup steps
  1. 1
    Create a least-privilege identity

    Follow the Kubernetes guide to create a dedicated namespace and ServiceAccount, for example kubectl create namespace mcp and kubectl create serviceaccount mcp-viewer -n mcp. Prefer a namespace-scoped view RoleBinding, using a ClusterRoleBinding only for an explicit cross-namespace read requirement.

  2. 2
    Generate a dedicated kubeconfig

    Use docs/getting-started-kubernetes.md to obtain a short-lived ServiceAccount token and write the API server, CA, token, and dedicated context to a separate kubeconfig. Do not reuse an everyday administrator configuration or print the token in logs.

  3. 3
    Register the server in read-only mode

    Run claude mcp add-json kubernetes-mcp-server '{"command":"npx","args":["-y","kubernetes-mcp-server@latest","--read-only"],"env":{"KUBECONFIG":"/absolute/path/to/mcp-viewer.kubeconfig"}}' -s user after replacing the kubeconfig path.

  4. 4
    Run a side-effect-free verification

    Run claude mcp list and check for Connected, then ask the client to list namespaces. Confirm the target cluster, identity, and returned scope, with no create, update, delete, or exec action.

  5. 5
    Narrow any later write access

    If a later workflow genuinely needs mutations, define toolsets, enabled_tools, disabled_tools, denied_resources, and confirmation_fallback=deny before adding the minimum RBAC for one operation.

How to verify the setup

Run claude mcp list and confirm that kubernetes-mcp-server is Connected. Then ask the client only to list namespaces, confirm the objects belong to the intended cluster, and verify that no resource was changed.

Before using it
  • read_only defaults to false, so pass --read-only explicitly for the first connection.
  • If some write access is required, use disable_destructive, enabled_tools, disabled_tools, and denied_resources to reduce scope.
  • confirmation_fallback defaults to allow when the client lacks elicitation support; write-enabled deployments should set it to deny.
  • Short-lived ServiceAccount tokens expire and must be renewed in the dedicated kubeconfig.
  • HTTP mode does not require OAuth by default; configure TLS, OAuth/OIDC, and network controls before remote exposure.
04

Use cases

SCENARIO 01

Cluster status Q&A

Summarize namespaces, workloads, resource health, and events for read-only checks or on-call context.

SCENARIO 02

Pod troubleshooting

Combine pod details, logs, metrics, and events under a controlled identity to investigate crashes, scheduling failures, or resource pressure.

SCENARIO 03

Multi-cluster operations assistance

Query a controlled set of restricted kubeconfig contexts while requiring the agent to state its target before every operation.

SCENARIO 04

Reviewed Helm operations

In an isolated environment, define purpose-specific RBAC, a tool allowlist, and deny-by-default confirmation behavior before the agent executes an approved plan.

05

Assessment

Based on the public implementation and documentation, the project combines broad Kubernetes coverage and flexible distribution with a substantial set of controls for read-only access, resource filtering, OAuth/OIDC, and observability. The critical caveat is that the default mode is write-capable and confirmation fallback permits actions when a client cannot elicit confirmation. Treat it as an operations interface that requires deliberate RBAC design, never as something to attach directly to production with an administrator kubeconfig.

Why it may be useful

  • Native Go access to the Kubernetes API avoids runtime dependencies on kubectl and the Helm CLI
  • npm, PyPI, native binaries, containers, and a Helm chart cover common delivery paths
  • Read-only mode, destructive-tool controls, denied resources, and tool filters provide layered scope reduction
  • Documentation covers clients, cluster deployment, OAuth/OIDC, logging, and OpenTelemetry
  • The repository includes unit, end-to-end, and MCP conformance test areas

What to know first

  • The defaults read_only=false and confirmation_fallback=allow are unsuitable for unreviewed production access
  • Creating a dedicated kubeconfig and correct RBAC still requires Kubernetes administration experience
  • Optional toolsets depend on matching CRDs or services in the cluster
  • Security fixes target only the latest release
06

README

Kubernetes MCP Server


Overview

A native Go MCP server that exposes Kubernetes and OpenShift resources, pod diagnostics, events, Helm operations, and optional ecosystem toolsets, with controls for read-only access, denied resources, and RBAC-scoped identities. Model Context Protocol (MCP) server for Kubernetes and OpenShift.

Getting started

  • Create a dedicated read-only identity and kubeconfig, then register the npx package with Claude Code using --read-only. Verify the connection with a side-effect-free namespace query.
  • The server uses the Kubernetes API directly, offers generic resource CRUD, and adds dedicated tools for pods, namespaces, events, OpenShift Projects, and Helm.
  • Pod tools cover listing, inspection, deletion, logs, metrics, exec, and temporary runs. Actual access depends on cluster APIs and the calling identity's RBAC.
  • Run claude mcp list and confirm that kubernetes-mcp-server is Connected. Then ask the client only to list namespaces, confirm the objects belong to the intended cluster, and verify that no resource was changed.

Configuration

claude mcp add-json kubernetes-mcp-server '{"command":"npx","args":["-y","kubernetes-mcp-server@latest","--read-only"],"env":{"KUBECONFIG":"/absolute/path/to/mcp-viewer.kubeconfig"}}' -s user
Read the complete README on GitHub