icon for mcp server

Kubernetes

STDIO

MCP server for AI assistants to interact with Kubernetes clusters via natural language

mcp-kubernetes

The mcp-kubernetes is a Model Context Protocol (MCP) server that enables AI assistants to interact with Kubernetes clusters. It serves as a bridge between AI tools (like Claude, Cursor, and GitHub Copilot) and Kubernetes, translating natural language requests into Kubernetes operations and returning the results in a format the AI tools can understand.

It allows AI tools to:

  • Query Kubernetes resources
  • Execute kubectl commands
  • Manage Kubernetes clusters through natural language interactions
  • Diagnose and interpret the states of Kubernetes resources

How it works

How to install

Docker

Get your kubeconfig file for your Kubernetes cluster and setup in the mcpServers (replace src path with your kubeconfig path):

{ "mcpServers": { "kubernetes": { "command": "docker", "args": [ "run", "-i", "--rm", "--mount", "type=bind,src=/home/username/.kube/config,dst=/home/mcp/.kube/config", "ghcr.io/azure/mcp-kubernetes" ] } } }

Local

Install kubectl

Install kubectl if it's not installed yet and add it to your PATH, e.g.

# For Linux curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" # For MacOS curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/darwin/arm64/kubectl"
Install helm

Install helm if it's not installed yet and add it to your PATH, e.g.

curl -sSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash

Config your MCP servers in Claude Desktop, Cursor, ChatGPT Copilot, Github Copilot and other supported AI clients, e.g.

{ "mcpServers": { "kubernetes": { "command": "<path of binary 'mcp-kubernetes'>", "args": [ "--transport", "stdio" ], "env": { "KUBECONFIG": "<your-kubeconfig-path>" } } } }

Options

Environment variables:

  • KUBECONFIG: Path to your kubeconfig file, e.g. /home/<username>/.kube/config.

Command line arguments:

Usage of ./mcp-kubernetes: --additional-tools string Comma-separated list of additional tools to support (kubectl is always enabled). Available: helm,cilium --allow-namespaces string Comma-separated list of namespaces to allow (empty means all allowed) --host string Host to listen for the server (only used with transport sse or streamable-http) (default "127.0.0.1") --port int Port to listen for the server (only used with transport sse or streamable-http) (default 8000) --readonly Enable read-only mode (prevents write operations) --timeout int Timeout for command execution in seconds, default is 60s (default 60) --transport string Transport mechanism to use (stdio, sse or streamable-http) (default "stdio")

Usage

Ask any questions about Kubernetes cluster in your AI client, e.g.

What is the status of my Kubernetes cluster? What is wrong with my nginx pod?

Available Tools

The mcp-kubernetes server provides the following tools for interacting with Kubernetes clusters:

Read-Only Tools

Read-Only Tools

  • kubectl_get: Get Kubernetes resources
  • kubectl_describe: Show detailed information about Kubernetes resources
  • kubectl_explain: Get documentation for Kubernetes resources
  • kubectl_logs: Print logs from containers in pods
  • kubectl_api_resources: List available API resources
  • kubectl_api_versions: List available API versions
  • kubectl_diff: Show differences between current state and applied changes
  • kubectl_cluster_info: Display cluster information
  • kubectl_top: Display resource usage (CPU/Memory)
  • kubectl_events: List events in the cluster
  • kubectl_auth: Inspect authorization settings
Read-Write Tools

Read-Write Tools

  • kubectl_create: Create Kubernetes resources
  • kubectl_delete: Delete Kubernetes resources
  • kubectl_apply: Apply configurations to resources
  • kubectl_expose: Expose a resource as a new Kubernetes service
  • kubectl_run: Run a particular image in the cluster
  • kubectl_set: Set specific features on objects
  • kubectl_rollout: Manage rollouts of deployments
  • kubectl_scale: Scale deployments, statefulsets, and replicasets
  • kubectl_autoscale: Auto-scale deployments, statefulsets, and replicasets
  • kubectl_label: Update labels on resources
  • kubectl_annotate: Update annotations on resources
  • kubectl_patch: Update fields of resources using strategic merge patch
  • kubectl_replace: Replace existing resources
  • kubectl_cp: Copy files between containers and local filesystems
  • kubectl_exec: Execute commands in containers
Admin Tools

Admin Tools

  • kubectl_cordon: Mark node as unschedulable
  • kubectl_uncordon: Mark node as schedulable
  • kubectl_drain: Drain node for maintenance
  • kubectl_taint: Update taints on nodes
  • kubectl_certificate: Modify certificate resources
Helm Tools

Helm Tools

  • Run-helm-command: Run helm commands and get results

Note: Read-write and admin tools are only available when the server is not run in read-only mode.

Development

How to inspect MCP server requests and responses:

npx @modelcontextprotocol/inspector <path of binary 'mcp-kubernetes'>

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.

Be the First to Experience MCP Now