Get the FREE Ultimate OpenClaw Setup Guide →

k8s

MCP Server that talks to the Kubernetes APIs

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio briankscheong-k8s-mcp-server path/to/k8smcp stdio --kubeconfig=/path/to/your/kubeconfig \
  --env K8S_MCP_TOOLSETS="all"

How to use

The Kubernetes MCP Server enables AI tools to interact with a Kubernetes cluster through a Model Context Protocol interface. It exposes a range of resource and management operations (such as getting pod or deployment details, listing resources, and fetching pod logs) in a structured, natural-language friendly way. Users can leverage built-in toolsets to perform read and write operations against the cluster, with the server enforcing access via the provided kubeconfig or in-cluster configuration.

To use it, configure your MCP client (e.g., Claude Desktop, VS Code, or Cline) to point to the k8smcp executable and provide the necessary kubeconfig path. The server supports stdio transport by default, and can also be exposed via SSE for HTTP-based clients. Once configured, you can issue prompts that map to Kubernetes operations (for example, asking for pod details, listing deployments in a namespace, or retrieving logs) and receive structured responses that reflect Kubernetes state and metadata.

How to install

Prerequisites:

  • A Kubernetes cluster with API access
  • Go toolchain installed (1.20+) or a prebuilt k8s-mcp-server binary
  • Access to the repository if building from source

Install from source (recommended):

  1. Clone the repository: git clone https://github.com/briankscheong/k8s-mcp-server.git
  2. Build the binary: cd k8s-mcp-server make build

    or, if you have Go module setup:

    go install github.com/briankscheong/k8s-mcp-server/cmd/k8s-mcp-server@latest
  3. Run the server (example): ./k8s-mcp-server stdio --kubeconfig=/path/to/your/kubeconfig

Alternative: Use npx, Docker, or other package managers if prebuilt images are available (see repository for details). Ensure the kubeconfig path is accessible to the server process.

Additional notes

Environment variables and configuration:

  • K8S_MCP_KUBECONFIG: Path to kubeconfig (if not using --kubeconfig on the command line)
  • K8S_MCP_NAMESPACE: Default namespace for operations (default: default)
  • K8S_MCP_IN_CLUSTER: Use in-cluster config (true/false)
  • K8S_MCP_READ_ONLY: Restrict to read-only operations (true/false)
  • K8S_MCP_RESOURCE_TYPES: Comma-separated list of resource types to enable (pods, deployments, services, configmaps, namespaces, nodes)
  • K8S_MCP_TOOLSETS: Comma-separated list of toolsets to enable (default all)

Common issues:

  • Ensure kubeconfig has appropriate RBAC permissions for the requested operations.
  • When deploying in-cluster, use in-cluster configuration and ensure the service account has needed permissions.
  • If using SSE, remember to expose the port and configure transport accordingly.

Tips:

  • Use read-only mode to prevent accidental mutations during experimentation.
  • Start with stdio transport for local development, then switch to SSE for cluster deployments.

Related MCP Servers

Sponsor this space

Reach thousands of developers