Get the FREE Ultimate OpenClaw Setup Guide →

mcp-k8s

This is an MCP kubernetes Server.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio abhijeetka-mcp-k8s-server uv --directory ~/mcp/mcp-k8s-server run kubernetes.py \
  --env KUBECONFIG="Path to kubeconfig (optional; defaults to standard kubectl config if unset)"

How to use

This MCP server provides a Kubernetes control surface by wrapping kubectl-like operations into MCP tools. It exposes a set of Kubernetes operations (deployments, pods, services, nodes, namespaces, contexts, and more) that you can invoke through your language model. Typical flows include creating and updating deployments, scaling replicas, querying cluster resources, fetching pod logs, and annotating or labeling resources. The tooling is designed to be context-aware and type-safe, helping LLMs generate well-formed requests and receive structured responses about the cluster state.

You can use the available tools to: create deployments and update container images, scale deployments, retrieve lists of resources (pods, services, deployments, jobs, cronjobs, statefulsets, daemonsets, namespaces, contexts), switch contexts, fetch logs and events, annotate and label resources, expose resources, port-forward, and delete resources. The server leverages kubectl under the hood, so it inherits kubectl’s capabilities and familiarity while providing a higher-level, MCP-driven interface for LLMs and automation scripts.

How to install

Prerequisites

  • Python 3.x installed
  • Kubernetes cluster access configured via kubectl (kubectl must be configured and able to reach the cluster)
  • MCP framework installed and available in your environment
  • Optional: Smithery for one-click deployment (as described in the README)
  1. Prepare your environment
  • Ensure Python is installed and accessible in your PATH
  • Verify kubectl is installed and can reach your cluster: kubectl cluster-info
  1. Install the MCP server dependencies
  • Install the MCP framework if not already installed (follow your project’s guidance or the MCP docs)
  1. Run the MCP Kubernetes server locally (example using uv for Python)
  • Ensure you have a kubeconfig file if you’re connecting to a cluster outside the default context
  1. Optional: Install via Smithery for Claude Desktop (as shown in the README)
npx -y @smithery/cli install @abhijeetka/mcp-k8s-server --client claude
  1. Verify the MCP server is running and accessible through your MCP client configuration

Additional notes

Environment and configuration tips:

  • The KUBECONFIG environment/config path is optional if your kubectl config is already configured system-wide.
  • Ensure proper RBAC permissions in the Kubernetes cluster for the actions your LLM prompts may request.
  • Use namespace scoping (production, development, etc.) to limit impact during demonstrations.
  • When exposing deployments or port-forwarding, validate that security controls (firewalls, access policies) are in place.
  • If you encounter issues with uv commands, confirm that the kubectl context is set correctly and that the Python script kubernetes.py is present at the expected directory.
  • For Claude Desktop usage, the README shows an example configuration using uv with a directory pointing to the server files. Adapt the path and context as needed for your environment.

Related MCP Servers

Sponsor this space

Reach thousands of developers