Sponsored by Deepsite.site

mcp-kubernetes

Created By
Azure8 months ago
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
Content

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 opencode@microsoft.com 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.

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Y GuiA web-based graphical interface for AI chat interactions with support for multiple AI models and MCP (Model Context Protocol) servers.
ChatWiseThe second fastest AI chatbot™
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
CursorThe AI Code Editor
Amap Maps高德地图官方 MCP Server
WindsurfThe new purpose-built IDE to harness magic
Playwright McpPlaywright MCP server
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Tavily Mcp
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Serper MCP ServerA Serper MCP Server
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
DeepChatYour AI Partner on Desktop