Skip to content
Back to search

kubectl-mcp-server

Published in CNCF Landscape: A MCP server for Kubernetes.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/rohitg00--kubectl-mcp-server/badge.svg)](/listings/rohitg00--kubectl-mcp-server)

HTML

<a href="/listings/rohitg00--kubectl-mcp-server"><img src="/api/listings/rohitg00--kubectl-mcp-server/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

Quick Start with npx (Recommended - Zero Install)

# Run directly without installation - works instantly!
npx -y kubectl-mcp-server

# Or install globally for faster startup
npm install -g kubectl-mcp-server

Or install with pip (Python)

# Standard installation
pip install kubectl-mcp-server

# With interactive UI dashboards (recommended)
pip install kubectl-mcp-server[ui]

---

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 1,059 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.

  1. <p align="center">
  2. <img src="logos/kubectl-mcp-server-icon.svg" alt="kubectl-mcp-server logo" width="80" height="80">
  3. <br>
  4. <strong style="font-size: 24px;">kubectl-mcp-server</strong>
  5. </p>
  6. <p align="center">
  7. <b>Control your entire Kubernetes infrastructure through natural language conversations with AI.</b><br>
  8. Talk to your clusters like you talk to a DevOps expert. Debug crashed pods, optimize costs, deploy applications, audit security, and manage Helm charts, all through natural language.<br>
  9. <b>Part of CNCF Landscape, Next to Terraform</b>
  10. </p>
  11. <img width="2473" height="1332" alt="Screenshot 2026-04-08 at 23 36 21" src="https://github.com/user-attachments/assets/616b4e65-37bc-474e-8124-68e64c6d7c95" />
  12. <p align="center">
  13. <a href="https://github.com/rohitg00/kubectl-mcp-server"><img src="https://img.shields.io/github/stars/rohitg00/kubectl-mcp-server?style=flat&logo=github" alt="GitHub Stars"></a>
  14. <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
  15. <a href="https://www.python.org/"><img src="https://img.shields.io/badge/python-3.10+-blue.svg" alt="Python"></a>
  16. <a href="https://kubernetes.io/"><img src="https://img.shields.io/badge/kubernetes-%23326ce5.svg?style=flat&logo=kubernetes&logoColor=white" alt="Kubernetes"></a>
  17. <a href="https://modelcontextprotocol.io"><img src="https://img.shields.io/badge/MCP-2026--07--28%20stateless-green.svg" alt="MCP 2026-07-28"></a>
  18. </p>
  19. <p align="center">
  20. <a href="https://pypi.org/project/kubectl-mcp-server/"><img src="https://img.shields.io/pypi/v/kubectl-mcp-server?color=blue&label=PyPI" alt="PyPI"></a>
  21. <a href="https://www.npmjs.com/package/kubectl-mcp-server"><img src="https://img.shields.io/npm/v/kubectl-mcp-server?color=green&label=npm" alt="npm"></a>
  22. <a href="https://hub.docker.com/r/rohitghumare64/kubectl-mcp-server"><img src="https://img.shields.io/docker/pulls/rohitghumare64/kubectl-mcp-server.svg" alt="Docker"></a>
  23. <a href="https://github.com/rohitg00/kubectl-mcp-server/actions"><img src="https://img.shields.io/badge/tests-555%20passed-success" alt="Tests"></a>
  24. <a href="https://deepwiki.com/rohitg00/kubectl-mcp-server"><img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki"></a>
  25. <a href="https://aregistry.ai"><img src="https://img.shields.io/badge/agentregistry-verified-blue?logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgZmlsbD0id2hpdGUiIHZpZXdCb3g9IjAgMCAxNiAxNiI+PHBhdGggZD0iTTE1Ljk5MiA2LjAzN2wtMy4wMjEtLjQzOS0xLjM1LTIuNzM2Yy0uMzQ2LS43MDItMS41MDQtLjcwMi0xLjg1IDBMOC40MjEgNS41OTggNS40IDYuMDM3Yy0uNzc2LjExMy0xLjA4OCAxLjA1My0uNTI4IDEuNTkzbDIuMTg2IDIuMTI5LS41MTYgMy4wMWMtLjEzMy43NzUuNjgyIDEuMzY2IDEuMzc4Ljk5OGwyLjcwMi0xLjQyIDIuNzAyIDEuNDJjLjY5Ni4zNjggMS41MTEtLjIyMyAxLjM3OC0uOTk4bC0uNTE2LTMuMDEgMi4xODYtMi4xMjljLjU2LS41NCAwLjI0OC0xLjQ4LS41MjgtMS41OTN6Ii8+PC9zdmc+" alt="agentregistry"></a>
  26. </p>
  27. ---
  28. ## Installation
  29. ### Quick Start with npx (Recommended - Zero Install)
  30. ```bash
  31. # Run directly without installation - works instantly!
  32. npx -y kubectl-mcp-server
  33. # Or install globally for faster startup
  34. npm install -g kubectl-mcp-server
  35. ```
  36. ### Or install with pip (Python)
  37. ```bash
  38. pip install kubectl-mcp-server
  39. # Or run it isolated with uv
  40. uvx --from kubectl-mcp-server kubectl-mcp
  41. ```
  42. ---
  43. ## 📑 Table of Contents
  44. - [What Can You Do?](#what-can-you-do)
  45. - [Why kubectl-mcp-server?](#why-kubectl-mcp-server)
  46. - [Live Demos](#live-demos)
  47. - [Installation](#installation)
  48. - [Quick Start with npx](#quick-start-with-npx-recommended---zero-install)
  49. - [Install with pip](#or-install-with-pip-python)
  50. - [Docker](#docker)
  51. - [Getting Started](#getting-started)
  52. - [Quick Setup with Your AI Assistant](#quick-setup-with-your-ai-assistant)
  53. - [All Supported AI Assistants](#all-supported-ai-assistants)
  54. - [Complete Feature Set](#complete-feature-set)
  55. - [Using the CLI](#using-the-cli)
  56. - [Advanced Configuration](#advanced-configuration)
  57. - [Stateless MCP (2026-07-28)](#stateless-mcp-2026-07-28)
  58. - [Enterprise](#enterprise-oauth-21-authentication)
  59. - [Security](#security)
  60. - [Integrations & Ecosystem](#integrations--ecosystem)
  61. - [In-Cluster Deployment](#in-cluster-deployment)
  62. - [Multi-Cluster Support](#multi-cluster-support)
  63. - [Architecture](#architecture)
  64. - [Agent Skills](#agent-skills-24-skills-for-ai-coding-agents)
  65. - [Development & Testing](#development--testing)
  66. - [Contributing](#contributing)
  67. - [Support & Community](#support--community)
  68. ---
  69. ## What Can You Do?
  70. Simply ask your AI assistant in natural language:
  71. 💬 **"Why is my pod crashing?"**
  72. - Instant crash diagnosis with logs, events, and resource analysis
  73. - Root cause identification with actionable recommendations
  74. 💬 **"Deploy a Redis cluster with 3 replicas"**
  75. - Creates deployment with best practices
  76. - Configures services, persistent storage, and health checks
  77. 💬 **"Show me which pods are wasting resources"**
  78. - AI-powered cost optimization analysis
  79. - Resource recommendations with potential savings
  80. 💬 **"Which services can't reach the database?"**
  81. - Network connectivity diagnostics with DNS resolution
  82. - Service chain tracing from ingress to pods
  83. 💬 **"Audit security across all namespaces"**
  84. - RBAC permission analysis
  85. - Secret security scanning and pod security policies
  86. **26 default tools, 209 with every toolset** | **14 workflow prompts** | **8 resources + 6 resource templates** | **Stateless MCP 2026-07-28** | **Works with all major AI assistants**
  87. ## Why kubectl-mcp-server?
  88. - **🚀 Stop context-switching** - Manage Kubernetes directly from your AI assistant conversations
  89. - **🧠 AI-powered diagnostics** - Get intelligent troubleshooting, not just raw data
  90. - **💰 Built-in cost optimization** - Identify waste and get actionable savings recommendations
  91. - **🔒 Enterprise-ready** - OAuth 2.1 auth with per-tool scopes, read-only mode, Secret redaction, fail-closed network binding
  92. - **⚡ Zero learning curve** - Natural language instead of memorizing kubectl commands
  93. - **🌐 Universal compatibility** - Works with Claude, Cursor, Windsurf, Copilot, and 15+ other AI tools
  94. - **☸️ Production-grade** - Stateless HTTP scales behind any load balancer, Helm chart, 516 passing tests
  95. From debugging crashed pods to optimizing cluster costs, kubectl-mcp-server is your AI-powered DevOps companion.
  96. ## Live Demos
  97. ### Claude Desktop
  98. ![Claude MCP](./docs/claude/claude-mcp.gif)
  99. ### Cursor AI
  100. ![Cursor MCP](./docs/cursor/cursor-mcp.gif)
  101. ### Windsurf
  102. ![Windsurf MCP](./docs/windsurf/windsurf-mcp.gif)
  103. ## Installation
  104. ### Quick Start with npx (Recommended - Zero Install)
  105. ```bash
  106. # Run directly without installation - works instantly!
  107. npx -y kubectl-mcp-server
  108. # Or install globally for faster startup
  109. npm install -g kubectl-mcp-server
  110. ```
  111. ### Or install with pip (Python)
  112. ```bash
  113. pip install kubectl-mcp-server
  114. # Or run it isolated with uv
  115. uvx --from kubectl-mcp-server kubectl-mcp
  116. ```
  117. ### Install from GitHub Release
  118. ```bash
  119. # Install specific version directly from GitHub release (replace {VERSION} with desired version)
  120. pip install https://github.com/rohitg00/kubectl-mcp-server/releases/download/v{VERSION}/kubectl_mcp_server-{VERSION}-py3-none-any.whl
  121. # Example: Install v2.0.0
  122. pip install https://github.com/rohitg00/kubectl-mcp-server/releases/download/v2.0.0/kubectl_mcp_server-2.0.0-py3-none-any.whl
  123. # Or install latest from git
  124. pip install git+https://github.com/rohitg00/kubectl-mcp-server.git
  125. ```
  126. ### Prerequisites
  127. - **Python 3.10+** or [uv](https://docs.astral.sh/uv/) (for pip/uvx installation)
  128. - **Node.js 18+** (for npx installation)
  129. - **kubectl** installed and configured
  130. - Access to a Kubernetes cluster
  131. ### Docker
  132. ```bash
  133. # Pull from Docker Hub
  134. docker pull rohitghumare64/kubectl-mcp-server:latest
  135. # Or pull from GitHub Container Registry
  136. docker pull ghcr.io/rohitg00/kubectl-mcp-server:latest
  137. # Run with stdio transport (the image runs as UID 10001 with HOME=/home/mcp)
  138. docker run -i --rm -v $HOME/.kube:/home/mcp/.kube:ro rohitghumare64/kubectl-mcp-server:latest
  139. # Run stateless HTTP on localhost only. The container listens on 0.0.0.0, so it refuses
  140. # to start without OAuth (MCP_AUTH_ENABLED) or an explicit MCP_ALLOW_UNAUTHENTICATED=true.
  141. docker run --rm -p 127.0.0.1:8000:8000 -v $HOME/.kube:/home/mcp/.kube:ro \
  142. -e MCP_ALLOW_UNAUTHENTICATED=true \
  143. rohitghumare64/kubectl-mcp-server:latest --transport http
  144. ```
  145. ## Getting Started
  146. ### 1. Test the Server (Optional)
  147. Before integrating with your AI assistant, verify the installation:
  148. ```bash
  149. # Check if kubectl is configured
  150. kubectl cluster-info
  151. # Test the MCP server directly
  152. kubectl-mcp-server info
  153. # List all available tools
  154. kubectl-mcp-server tools
  155. # Try calling a tool
  156. kubectl-mcp-server call kubectl_get '{"resource_type": "pods", "namespace": "kube-system"}'
  157. ```
  158. ### 2. Connect to Your AI Assistant
  159. Choose your favorite AI assistant and add the configuration:
  160. ## Quick Setup with Your AI Assistant
  161. ### Claude Desktop
  162. Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
  163. ```json
  164. {
  165. "mcpServers": {
  166. "kubernetes": {
  167. "command": "npx",
  168. "args": ["-y", "kubectl-mcp-server"]
  169. }
  170. }
  171. }
  172. ```
  173. ### Cursor AI
  174. Add to `~/.cursor/mcp.json`:
  175. ```json
  176. {
  177. "mcpServers": {
  178. "kubernetes": {
  179. "command": "npx",
  180. "args": ["-y", "kubectl-mcp-server"]
  181. }
  182. }
  183. }
  184. ```
  185. ### Windsurf
  186. Add to `~/.config/windsurf/mcp.json`:
  187. ```json
  188. {
  189. "mcpServers": {
  190. "kubernetes": {
  191. "command": "npx",
  192. "args": ["-y", "kubectl-mcp-server"]
  193. }
  194. }
  195. }
  196. ```
  197. ### Using Python Instead of npx
  198. ```json
  199. {
  200. "mcpServers": {
  201. "kubernetes": {
  202. "command": "python",
  203. "args": ["-m", "kubectl_mcp_tool.mcp_server"],
  204. "env": {
  205. "KUBECONFIG": "/path/to/.kube/config"
  206. }
  207. }
  208. }
  209. }
  210. ```
  211. **More integrations**: GitHub Copilot, Goose, Gemini CLI, Roo Code, and [15+ other clients](#mcp-client-compatibility) —> see [full configuration guide](#all-supported-ai-assistants) below.
  212. ### 3. Restart Your AI Assistant
  213. After adding the configuration, restart your AI assistant **(GitHub Copilot, Claude Code,Claude Desktop, Cursor, etc.)** to load the MCP server.
  214. ### 4. Try These Commands
  215. Start a conversation with your AI assistant and try these:
  216. **Troubleshooting:**
  217. ```
  218. "Show me all pods in the kube-system namespace"
  219. "Why is the nginx-deployment pod crashing?"
  220. "Diagnose network connectivity issues in the default namespace"
  221. ```
  222. **Deployments:**
  223. ```
  224. "Create a deployment for nginx with 3 replicas"
  225. "Scale my frontend deployment to 5 replicas"
  226. "Roll back the api-server deployment to the previous version"
  227. ```
  228. **Cost & Optimization:**
  229. ```
  230. "Which pods are using the most resources?"
  231. "Show me idle resources that are wasting money"
  232. "Analyze cost optimization opportunities in the production namespace"
  233. ```
  234. **Security:**
  235. ```
  236. "Audit RBAC permissions in all namespaces"
  237. "Check for insecure secrets and configurations"
  238. "Show me pods running with privileged access"
  239. ```
  240. **Helm:**
  241. ```
  242. "List all Helm releases in the cluster"
  243. "Install Redis from the Bitnami chart repository"
  244. "Show me the values for my nginx-ingress Helm release"
  245. ```
  246. **Multi-Cluster:**
  247. ```
  248. "List all available Kubernetes contexts"
  249. "Switch to the production cluster context"
  250. "Show me cluster information and version"
  251. ```
  252. ## MCP Client Compatibility
  253. Works seamlessly with **all MCP-compatible AI assistants**:
  254. | Client | Status | Client | Status |
  255. |--------|--------|--------|--------|
  256. | Claude Desktop | ✅ Native | Claude Code | ✅ Native |
  257. | Cursor | ✅ Native | Windsurf | ✅ Native |
  258. | GitHub Copilot | ✅ Native | OpenAI Codex | ✅ Native |
  259. | Gemini CLI | ✅ Native | Goose | ✅ Native |
  260. | Roo Code | ✅ Native | Kilo Code | ✅ Native |
  261. | Amp | ✅ Native | Trae | ✅ Native |
  262. | OpenCode | ✅ Native | Kiro CLI | ✅ Native |
  263. | Antigravity | ✅ Native | Clawdbot | ✅ Native |
  264. | Droid (Factory) | ✅ Native | Any MCP Client | ✅ Compatible |
  265. ## All Supported AI Assistants
  266. ### Claude Code
  267. Add to `~/.config/claude-code/mcp.json`:
  268. ```json
  269. {
  270. "mcpServers": {
  271. "kubernetes": {
  272. "command": "npx",
  273. "args": ["-y", "kubectl-mcp-server"]
  274. }
  275. }
  276. }
  277. ```
  278. ### GitHub Copilot (VS Code)
  279. Add to VS Code `settings.json`:
  280. ```json
  281. {
  282. "mcp": {
  283. "servers": {
  284. "kubernetes": {
  285. "command": "npx",
  286. "args": ["-y", "kubectl-mcp-server"]
  287. }
  288. }
  289. }
  290. }
  291. ```
  292. ### Goose
  293. Add to `~/.config/goose/config.yaml`:
  294. ```yaml
  295. extensions:
  296. kubernetes:
  297. command: npx
  298. args:
  299. - -y
  300. - kubectl-mcp-server
  301. ```
  302. ### Gemini CLI
  303. Add to `~/.gemini/settings.json`:
  304. ```json
  305. {
  306. "mcpServers": {
  307. "kubernetes": {
  308. "command": "npx",
  309. "args": ["-y", "kubectl-mcp-server"]
  310. }
  311. }
  312. }
  313. ```
  314. ### Roo Code / Kilo Code
  315. Add to `~/.config/roo-code/mcp.json` or `~/.config/kilo-code/mcp.json`:
  316. ```json
  317. {
  318. "mcpServers": {
  319. "kubernetes": {
  320. "command": "npx",
  321. "args": ["-y", "kubectl-mcp-server"]
  322. }
  323. }
  324. }
  325. ```
  326. ## Complete Feature Set
  327. ### Toolsets
  328. Every tool definition costs context on every request, and models pick tools less reliably as the list grows. The server therefore registers only the **`core` and `helm` toolsets (26 tools) by default**. `kubectl_get`, `kubectl_describe`, `kubectl_logs`, `kubectl_apply` and friends work for every resource kind, including custom resources, so the default set covers most day-to-day work. Everything else is opt-in; tools outside the enabled toolsets are not registered at all, so they cannot be called.
  329. ```bash
  330. kubectl-mcp-server # core + helm
  331. kubectl-mcp-server --toolsets default,diagnostics,certs
  332. kubectl-mcp-server --toolsets all # all 209 tools
  333. MCP_TOOLSETS=default,gitops kubectl-mcp-server # same, via environment
  334. ```
  335. `detect_ecosystem` reports which operators are installed and which toolsets cover them. With many toolsets enabled and a client that cannot search tools itself, add `--tool-search` (`MCP_TOOL_SEARCH=true`): the server then lists only the default tools plus `search_tools` and `call_tool`, and the rest are discovered on demand. Read-only mode, scopes and redaction still apply to every discovered call.
  336. For deep work in one ecosystem, its project-maintained MCP server is usually a better fit than the opt-in toolset:
  337. | Ecosystem | MCP server |
  338. |-----------|------------|
  339. | Argo CD | [argoproj-labs/mcp-for-argocd](https://github.com/argoproj-labs/mcp-for-argocd) |
  340. | Flux | [Flux Operator MCP server](https://fluxoperator.dev/mcp-server/) |
  341. | Kyverno | [nirmata/kyverno-mcp](https://github.com/nirmata/kyverno-mcp) |
  342. | Toolset | Default | Tools | Covers | Names |
  343. |---------|---------|-------|--------|-------|
  344. | `core` | yes | 18 | Generic kubectl operations for every resource kind, including CRDs | `kubectl_get`, `kubectl_describe`, `kubectl_logs`, `kubectl_top`, `kubectl_explain`, `get_api_resources`, `kubectl_generic`, `kubectl_apply`, `kubectl_patch`, `delete_resource`, `kubectl_scale`, `kubectl_rollout`, `exec_in_pod`, `list_contexts`, `health_check`, `diagnose_pod_crash`, `detect_pending_pods`, `detect_ecosystem` |
  345. | `helm` | yes | 8 | Helm release lifecycle | `helm_list`, `helm_status`, `helm_get`, `helm_history`, `install_helm_chart`, `upgrade_helm_chart`, `uninstall_helm_chart`, `helm_rollback` |
  346. | `helm_dev` | | 16 | Helm charts and repositories: search, show, template, lint, package, dependencies | `helm_show`, `helm_search_repo`, `helm_search_hub`, `helm_repo_list`, `helm_repo_add`, `helm_repo_remove`, `helm_repo_update`, `helm_test`, `helm_lint`, `helm_package`, `helm_dependency_update`, `helm_dependency_list`, `helm_dependency_build`, `helm_pull`, `helm_create`, `helm_template` |
  347. | `ops` | | 10 | Maintenance: create, label, annotate, taint, cordon/drain, copy files, wait, cleanup | `kubectl_create`, `kubectl_cp`, `backup_resource`, `label_resource`, `annotate_resource`, `taint_node`, `wait_for_condition`, `node_management`, `cleanup_pods`, `run_pod` |
  348. | `diagnostics` | | 9 | Network, DNS, node and pod health diagnostics | `check_pod_health`, `get_evicted_pods`, `diagnose_network_connectivity`, `check_dns_resolution`, `trace_service_chain`, `compare_namespaces`, `get_nodes_summary`, `node_logs`, `node_stats_summary` |
  349. | `security` | | 5 | RBAC, pod security and secret hygiene audits | `analyze_pod_security`, `analyze_network_policies`, `audit_rbac_permissions`, `check_secrets_security`, `get_pod_security_info` |
  350. | `cost` | | 8 | Resource right-sizing and cost allocation | `get_resource_recommendations`, `get_idle_resources`, `get_resource_quotas_usage`, `get_cost_analysis`, `get_overprovisioned_resources`, `get_resource_trends`, `get_namespace_cost_allocation`, `optimize_resource_requests` |
  351. | `multicluster` | | 7 | Kubeconfig contexts and cross-cluster queries | `get_context_details`, `kubeconfig_view`, `switch_context`, `set_namespace_for_context`, `multi_cluster_query`, `multi_cluster_health`, `multi_cluster_pod_count` |
  352. | `crds` | | 5 | CRD discovery and custom resource inspection | `discover_crds`, `search_crds`, `list_custom_resources`, `get_custom_resource`, `describe_crd` |
  353. | `gitops` | | 6 | Flux and Argo CD | `gitops_apps_list`, `gitops_app_get`, `gitops_app_sync`, `gitops_app_status`, `gitops_sources_list`, `gitops_source_get` |
  354. | `certs` | | 8 | cert-manager certificates and issuers | `list_certs`, `get_cert`, `list_cert_issuers`, `get_cert_issuer`, `renew_cert`, `explain_cert_status`, `list_cert_challenges`, `list_cert_requests` |
  355. | `policy` | | 5 | Kyverno and Gatekeeper policies | `get_policy_list`, `get_policy`, `get_policy_violations`, `explain_policy_denial`, `audit_policies` |
  356. | `backup` | | 10 | Velero backups and restores | `list_backups`, `get_backup`, `create_backup`, `delete_backup`, `list_restores`, `create_restore`, `get_restore`, `list_backup_locations`, `list_backup_schedules`, `create_backup_schedule` |
  357. | `keda` | | 6 | KEDA event-driven autoscaling | `keda_scaledobjects_list`, `keda_scaledobject_get`, `keda_scaledjobs_list`, `keda_triggerauths_list`, `keda_triggerauth_get`, `keda_hpa_list` |
  358. | `cilium` | | 7 | Cilium network policies and Hubble flows | `cilium_list_policies`, `cilium_get_policy`, `cilium_list_endpoints`, `cilium_list_identities`, `cilium_list_nodes`, `cilium_get_status`, `get_hubble_flows` |
  359. | `rollouts` | | 10 | Argo Rollouts and Flagger progressive delivery | `get_rollouts_list`, `get_rollout`, `get_rollout_status`, `promote_rollout`, `abort_rollout`, `retry_rollout`, `restart_rollout`, `get_analysis_runs`, `get_flagger_canaries`, `get_flagger_canary` |
  360. | `capi` | | 10 | Cluster API lifecycle | `capi_list_clusters`, `capi_get_cluster`, `capi_list_machines`, `capi_get_machine`, `capi_list_machinedeployments`, `capi_scale_machinedeployment`, `capi_list_machinesets`, `capi_list_machinehealthchecks`, `capi_list_clusterclasses`, `capi_get_cluster_kubeconfig` |
  361. | `kubevirt` | | 12 | KubeVirt virtual machines | `kubevirt_vms_list`, `kubevirt_vm_get`, `kubevirt_vmis_list`, `kubevirt_vm_start`, `kubevirt_vm_stop`, `kubevirt_vm_restart`, `kubevirt_vm_pause`, `kubevirt_vm_unpause`, `kubevirt_vm_migrate`, `kubevirt_datasources_list`, `kubevirt_instancetypes_list`, `kubevirt_datavolumes_list` |
  362. | `istio` | | 9 | Istio service mesh | `istio_virtualservices_list`, `istio_virtualservice_get`, `istio_destinationrules_list`, `istio_gateways_list`, `istio_peerauthentications_list`, `istio_authorizationpolicies_list`, `istio_proxy_status`, `istio_analyze`, `istio_sidecar_status` |
  363. | `kind` | | 29 | kind local clusters (runs docker on the server host) | `kind_list_clusters`, `kind_get_nodes`, `kind_get_kubeconfig`, `kind_export_logs`, `kind_cluster_info`, `kind_node_labels`, `kind_create_cluster`, `kind_delete_cluster`, `kind_load_image`, `kind_load_image_archive`, `kind_build_node_image`, `kind_set_kubeconfig`, `kind_config_validate`, `kind_config_generate`, `kind_config_show`, `kind_available_images`, `kind_registry_create`, `kind_registry_connect`, `kind_registry_status`, `kind_node_exec`, `kind_node_logs`, `kind_node_inspect`, `kind_node_restart`, `kind_network_inspect`, `kind_port_mappings`, `kind_ingress_setup`, `kind_cluster_status`, `kind_images_list`, `kind_provider_info` |
  364. | `vind` | | 11 | vCluster virtual clusters (runs vcluster on the server host) | `vind_list_clusters`, `vind_status`, `vind_get_kubeconfig`, `vind_create_cluster`, `vind_delete_cluster`, `vind_pause`, `vind_resume`, `vind_connect`, `vind_disconnect`, `vind_upgrade`, `vind_describe` |
  365. ### MCP Resources
  366. Access Kubernetes data as browsable resources:
  367. | Resource URI | Description |
  368. |--------------|-------------|
  369. | `kubeconfig://contexts` | List all available kubectl contexts |
  370. | `kubeconfig://current-context` | Get current active context |
  371. | `namespace://current` | Get current namespace |
  372. | `namespace://list` | List all namespaces |
  373. | `cluster://info` | Get cluster information |
  374. | `cluster://nodes` | Get detailed node information |
  375. | `cluster://version` | Get Kubernetes version |
  376. | `cluster://api-resources` | List available API resources |
  377. | `manifest://deployments/{ns}/{name}` | Get deployment YAML |
  378. | `manifest://services/{ns}/{name}` | Get service YAML |
  379. | `manifest://pods/{ns}/{name}` | Get pod YAML |
  380. | `manifest://configmaps/{ns}/{name}` | Get ConfigMap YAML |
  381. | `manifest://secrets/{ns}/{name}` | Get secret YAML (data masked) |
  382. | `manifest://ingresses/{ns}/{name}` | Get ingress YAML |
  383. ### MCP Prompts
  384. Pre-built workflow prompts for common Kubernetes operations:
  385. | Prompt | Description |
  386. |--------|-------------|
  387. | `troubleshoot_workload` | Comprehensive troubleshooting guide for pods/deployments |
  388. | `deploy_application` | Step-by-step deployment workflow |
  389. | `security_audit` | Security scanning and RBAC analysis workflow |
  390. | `cost_optimization` | Resource optimization and cost analysis workflow |
  391. | `disaster_recovery` | Backup and recovery planning workflow |
  392. | `debug_networking` | Network debugging for services and connectivity |
  393. | `scale_application` | Scaling guide with HPA/VPA best practices |
  394. | `upgrade_cluster` | Kubernetes cluster upgrade planning |
  395. | `cluster_health_check` | Cluster-wide health review |
  396. | `debug_workload` | Step-by-step debugging for a named workload |
  397. | `resource_usage` | Resource consumption and right-sizing review |
  398. | `security_posture` | Namespace or cluster security posture review |
  399. | `deployment_checklist` | Pre-deployment checklist for an application |
  400. | `incident_response` | Incident runbook by incident type |
  401. Add your own prompts in `~/.config/kubectl-mcp/prompts.toml`; same-named prompts override the built-ins.
  402. ### Key Capabilities
  403. - 🤖 **26 default tools, 209 opt-in** - Generic kubectl and Helm by default, ecosystem toolsets on demand
  404. - 🎯 **14 Workflow Prompts** - Pre-built workflows for common operations
  405. - 📊 **8 Resources + 6 Templates** - Browsable Kubernetes data exposure
  406. - 🔄 **Opt-in ecosystem toolsets** - GitOps, cert-manager, policy, Velero, KEDA, Cilium, Rollouts, CAPI, KubeVirt, Istio, kind, vCluster
  407. - ⚡ **Stateless MCP 2026-07-28** - stdio and Streamable HTTP, older clients negotiated automatically
  408. - 🔐 **Security First** - Read-only mode, per-call confirmation, Secret redaction, flag-injection guard
  409. - 🏥 **Advanced Diagnostics** - AI-powered troubleshooting and cost optimization
  410. - ☸️ **Multi-Cluster** - Target any cluster via context parameter in every tool
  411. - 🎡 **Full Helm v3** - Complete chart lifecycle management
  412. - 🔧 **Powerful CLI** - Shell-friendly tool discovery and direct calling
  413. - 🐳 **Cloud Native** - Deploy in-cluster with kMCP or kagent
  414. ## Using the CLI
  415. The built-in CLI lets you explore and test tools without an AI assistant:
  416. ```bash
  417. # List all tools with descriptions
  418. kubectl-mcp-server tools -d
  419. # Search for pod-related tools
  420. kubectl-mcp-server grep "*pod*"
  421. # Show specific tool schema
  422. kubectl-mcp-server tools kubectl_get
  423. # Call a tool directly
  424. kubectl-mcp-server call kubectl_get '{"resource_type": "pods", "namespace": "kube-system"}'
  425. # Pipe JSON from stdin
  426. echo '{"resource_type": "pods"}' | kubectl-mcp-server call kubectl_get
  427. # Check dependencies
  428. kubectl-mcp-server doctor
  429. # Show/switch Kubernetes context
  430. kubectl-mcp-server context
  431. kubectl-mcp-server context minikube
  432. # List resources and prompts
  433. kubectl-mcp-server resources
  434. kubectl-mcp-server prompts
  435. # Show server info
  436. kubectl-mcp-server info
  437. ```
  438. ### CLI Features
  439. - **Structured errors**: Actionable error messages with suggestions
  440. - **Colorized output**: Human-readable with JSON mode for scripting (`--json`)
  441. - **NO_COLOR support**: Respects `NO_COLOR` environment variable
  442. - **Stdin support**: Pipe JSON arguments to commands
  443. ## Advanced Configuration
  444. ### Transport Modes
  445. ```bash
  446. # stdio (default) - Claude Desktop, Cursor, Windsurf, Claude Code
  447. kubectl-mcp-server
  448. # Streamable HTTP, stateless, at http://127.0.0.1:8000/mcp
  449. kubectl-mcp-server --transport http --port 8000
  450. # SSE - deprecated by the MCP spec (SEP-2596), session-bound; kept for old clients
  451. kubectl-mcp-server --transport sse --port 8000
  452. ```
  453. **Server options** (every flag also reads an environment variable):
  454. | Flag | Env | Default | Description |
  455. |------|-----|---------|-------------|
  456. | `--transport` | `MCP_SERVER_TRANSPORT` | `stdio` | `stdio`, `http` / `streamable-http`, `sse` |
  457. | `--host` | `MCP_SERVER_HOST` | `127.0.0.1` | Bind address for network transports |
  458. | `--port` | `MCP_SERVER_PORT` | `8000` | Port for network transports |
  459. | `--allow-unauthenticated` | `MCP_ALLOW_UNAUTHENTICATED` | off | Permit a non-loopback bind without OAuth |
  460. | `--toolsets` | `MCP_TOOLSETS` | `default` | Toolsets to register (`default`, `all`, or names; see [Toolsets](#toolsets)) |
  461. | `--tool-search` | `MCP_TOOL_SEARCH` | off | List default tools plus `search_tools`/`call_tool`; discover the rest on demand |
  462. | `--read-only` | `MCP_SAFETY_MODE=read-only` | off | Hide and block every tool that changes state |
  463. | `--disable-destructive` | `MCP_SAFETY_MODE=disable-destructive` | off | Allow create/update, block deletes |
  464. | `--confirm-destructive` | `MCP_SAFETY_MODE=confirm` | off | Ask the user before each destructive call |
  465. | `--stateless` | `MCP_STATELESS_MODE` | off | Do not cache Kubernetes API clients |
  466. | `--watch-kubeconfig` | `MCP_KUBECONFIG_WATCH` | off | Reload kubeconfig when it changes |
  467. | `--config` | | | TOML config file |
  468. ### Environment Variables
  469. **Core Settings:**
  470. | Variable | Description | Default |
  471. |----------|-------------|---------|
  472. | `KUBECONFIG` | Path to kubeconfig file | `~/.kube/config` |
  473. | `MCP_DEBUG` | Enable verbose logging | `false` |
  474. | `MCP_LOG_FILE` | Log file path | None (stdout) |
  475. **Authentication (Enterprise):**
  476. | Variable | Description | Default |
  477. |----------|-------------|---------|
  478. | `MCP_AUTH_ENABLED` | Enable OAuth 2.1 authentication | `false` |
  479. | `MCP_AUTH_ISSUER` | OAuth 2.0 Authorization Server URL | - |
  480. | `MCP_AUTH_JWKS_URI` | JWKS endpoint URL | Auto-derived |
  481. | `MCP_AUTH_AUDIENCE` | Expected token audience | `kubectl-mcp-server` |
  482. | `MCP_AUTH_REQUIRED_SCOPES` | Scopes every token must carry | `mcp:tools` |
  483. | `MCP_AUTH_RESOURCE_URL` | Public URL advertised in RFC 9728 metadata | - |
  484. **Security and scaling:**
  485. | Variable | Description | Default |
  486. |----------|-------------|---------|
  487. | `MCP_SAFETY_MODE` | `read-only`, `disable-destructive`, `confirm`, `normal` (invalid values stop startup) | `normal` |
  488. | `MCP_MASK_SECRETS` | Redact Secret values, bearer tokens and JWTs from tool output | `true` |
  489. | `MCP_ALLOWED_HOSTS` / `MCP_ALLOWED_ORIGINS` | Comma-separated Host / Origin allowlists for HTTP | loopback |
  490. | `MCP_REQUEST_STATE_KEY` | >= 32 byte key shared by replicas so confirmation rounds can land on any replica | per-process |
  491. ## Enterprise: OAuth 2.1 Authentication
  492. Secure your MCP server with OAuth 2.1 authentication (RFC 9728).
  493. ```bash
  494. export MCP_AUTH_ENABLED=true
  495. export MCP_AUTH_ISSUER=https://your-idp.example.com
  496. export MCP_AUTH_AUDIENCE=kubectl-mcp-server
  497. kubectl-mcp-server --transport http --port 8000
  498. ```
  499. **Supported Identity Providers**: Okta, Auth0, Keycloak, Microsoft Entra ID, Google OAuth, and any OIDC-compliant provider.
  500. **Scopes**: tokens with `mcp:tools` or `mcp:admin` can call every tool. Set `MCP_AUTH_REQUIRED_SCOPES=mcp:read` to issue narrower tokens: read-only tools then need `mcp:read`, tools that change state need `mcp:write`.
  501. ## Security
  502. - **Network exposure fails closed.** HTTP binds `127.0.0.1` by default. Binding any other address requires OAuth or `--allow-unauthenticated`; the Helm chart refuses to render without one of the two.
  503. - **Read-only mode hides write tools.** With `--read-only` (or `MCP_SAFETY_MODE=read-only`) every tool whose `readOnlyHint` is false is removed from `tools/list` and rejected if called.
  504. - **Confirmation works on the stateless protocol.** `--confirm-destructive` returns an MRTR `InputRequiredResult` to 2026-07-28 clients and falls back to elicitation for older ones. The approval is bound to the exact operation.
  505. - **Secrets are redacted.** Secret `data`, `stringData`, the `last-applied-configuration` annotation, bearer tokens and JWTs are replaced with `[REDACTED]` in every tool result.
  506. - **No flag injection.** Identifier arguments (`name`, `namespace`, `chart`, `context`, label keys, ...) that start with `-` are rejected before any CLI runs, so `name="--server=https://attacker"` never reaches kubectl or helm. `kubectl_generic` only runs read verbs and blocks credential, connection and raw-output flags.
  507. - **No shell.** Every subprocess call uses an argument list; nothing runs through `sh -c`. [CVE-2025-69902](https://onemore-hayeon.github.io/security/CVE-2025-69902/) (shell injection in `kubectl-mcp-tool` <= 1.1.1) was fixed in 1.2.0; upgrade anything older.
  508. Report vulnerabilities privately; see [SECURITY.md](SECURITY.md).
  509. ## Stateless MCP (2026-07-28)
  510. The server speaks the [2026-07-28 specification](https://modelcontextprotocol.io/specification/2026-07-28/changelog): no `initialize` handshake, no `Mcp-Session-Id`, `server/discover` for capabilities, and per-request `_meta`. Clients on 2025-era revisions are negotiated automatically from the same process, over stdio and HTTP.
  511. Because no request depends on an earlier one, HTTP replicas scale behind a round-robin load balancer with no sticky sessions or shared store. Set `MCP_REQUEST_STATE_KEY` to the same value on every replica if you use `--confirm-destructive`.
  512. ```bash
  513. curl -s http://127.0.0.1:8000/mcp \
  514. -H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' \
  515. -H 'MCP-Protocol-Version: 2026-07-28' -H 'Mcp-Method: server/discover' \
  516. -d '{"jsonrpc":"2.0","id":1,"method":"server/discover","params":{"_meta":{"io.modelcontextprotocol/protocolVersion":"2026-07-28","io.modelcontextprotocol/clientCapabilities":{}}}}'
  517. ```
  518. ## Integrations & Ecosystem
  519. ### Docker MCP Toolkit
  520. Works with [Docker MCP Toolkit](https://docs.docker.com/ai/mcp-catalog-and-toolkit/toolkit/):
  521. ```bash
  522. docker mcp server add kubectl-mcp-server mcp/kubectl-mcp-server:latest
  523. docker mcp server configure kubectl-mcp-server --volume "$HOME/.kube:/home/mcp/.kube:ro"
  524. docker mcp server enable kubectl-mcp-server
  525. docker mcp client connect claude
  526. ```
  527. ### agentregistry
  528. Install from the centralized [agentregistry](https://aregistry.ai):
  529. ```bash
  530. # Install arctl CLI
  531. curl -fsSL https://raw.githubusercontent.com/agentregistry-dev/agentregistry/main/scripts/install.sh | bash
  532. # Install kubectl-mcp-server
  533. arctl mcp install io.github.rohitg00/kubectl-mcp-server
  534. ```
  535. **Available via**: PyPI (`uvx`), npm (`npx`), OCI (`docker.io/rohitghumare64/kubectl-mcp-server`)
  536. ### agentgateway
  537. Route to multiple MCP servers through [agentgateway](https://github.com/agentgateway/agentgateway):
  538. ```bash
  539. # Start stateless Streamable HTTP
  540. kubectl-mcp-server --transport http --port 8000
  541. # Configure gateway
  542. cat > gateway.yaml <<EOF
  543. binds:
  544. - port: 3000
  545. listeners:
  546. - routes:
  547. - backends:
  548. - mcp:
  549. targets:
  550. - name: kubectl-mcp-server
  551. mcp:
  552. host: http://localhost:8000/mcp
  553. EOF
  554. # Start gateway
  555. agentgateway --config gateway.yaml
  556. ```
  557. Connect clients to `http://localhost:3000/mcp`.
  558. ## In-Cluster Deployment
  559. ### Option 1: kMCP (Recommended)
  560. Deploy with [kMCP](https://github.com/kagent-dev/kmcp) - a control plane for MCP servers:
  561. ```bash
  562. # Install kMCP
  563. curl -fsSL https://raw.githubusercontent.com/kagent-dev/kmcp/refs/heads/main/scripts/get-kmcp.sh | bash
  564. kmcp install
  565. # Deploy kubectl-mcp-server (easiest)
  566. kmcp deploy package --deployment-name kubectl-mcp-server \
  567. --manager npx --args kubectl-mcp-server
  568. # Or with Docker image
  569. kmcp deploy --file deploy/kmcp/kmcp.yaml --image rohitghumare64/kubectl-mcp-server:latest
  570. ```
  571. See [kMCP quickstart](https://kagent.dev/docs/kmcp/quickstart) for details.
  572. ### Option 2: Standard Kubernetes
  573. Deploy with kubectl/kustomize:
  574. ```bash
  575. # Using kustomize (recommended)
  576. kubectl apply -k deploy/kubernetes/
  577. # Or individual manifests
  578. kubectl apply -f deploy/kubernetes/namespace.yaml
  579. kubectl apply -f deploy/kubernetes/rbac.yaml
  580. kubectl apply -f deploy/kubernetes/deployment.yaml
  581. kubectl apply -f deploy/kubernetes/service.yaml
  582. # Access via port-forward
  583. kubectl port-forward -n kubectl-mcp svc/kubectl-mcp-server 8000:8000
  584. ```
  585. See [deploy/](deploy/) directory for all manifests and configuration options.
  586. ### Option 3: kagent (AI Agent Framework)
  587. Integrate with [kagent](https://github.com/kagent-dev/kagent) - a CNCF Kubernetes-native AI agent framework:
  588. ```bash
  589. # Install kagent
  590. brew install kagent
  591. kagent install --profile demo
  592. # Register as ToolServer
  593. kubectl apply -f deploy/kagent/toolserver-stdio.yaml
  594. # Open dashboard
  595. kagent dashboard
  596. ```
  597. Your AI agents can now use the server's enabled toolsets. See [kagent quickstart](https://kagent.dev/docs/kagent/getting-started/quickstart).
  598. ## Architecture
  599. ```
  600. ┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
  601. │ AI Assistant │────▶│ MCP Server │────▶│ Kubernetes API │
  602. │ (Claude/Cursor) │◀────│ (kubectl-mcp) │◀────│ (kubectl) │
  603. └─────────────────┘ └──────────────────┘ └─────────────────┘
  604. ```
  605. The MCP server implements the [Model Context Protocol](https://github.com/modelcontextprotocol/spec), translating natural language requests into kubectl operations.
  606. ### Modular Structure
  607. ```
  608. kubectl_mcp_tool/
  609. ├── mcp_server.py # Main server (FastMCP, transports)
  610. ├── middleware.py # Safety mode, flag-injection guard, scopes, redaction, metrics
  611. ├── toolsets.py # Toolset registry, server instructions
  612. ├── tools/ # MCP tools, grouped into toolsets
  613. │ ├── kubectl.py # Generic get/logs/top/scale for every kind, detect_ecosystem
  614. │ ├── pods.py # Pod exec & diagnostics
  615. │ ├── cluster.py # Context/cluster management
  616. │ ├── networking.py # Network and DNS diagnostics
  617. │ ├── security.py # RBAC, pod security, secret hygiene audits
  618. │ ├── helm.py # Complete Helm v3 operations
  619. │ ├── operations.py # kubectl apply/patch/describe/etc
  620. │ ├── diagnostics.py # Metrics, namespace comparison
  621. │ ├── cost.py # Resource optimization & cost analysis
  622. │ ├── gitops.py # GitOps (Flux/ArgoCD)
  623. │ ├── certs.py # Cert-Manager
  624. │ ├── policy.py # Policy (Kyverno/Gatekeeper)
  625. │ ├── backup.py # Backup (Velero)
  626. │ ├── keda.py # KEDA autoscaling
  627. │ ├── cilium.py # Cilium/Hubble network observability
  628. │ ├── rollouts.py # Argo Rollouts/Flagger
  629. │ ├── capi.py # Cluster API
  630. │ ├── kubevirt.py # KubeVirt VMs
  631. │ ├── kiali.py # Istio/Kiali service mesh
  632. │ ├── vind.py # vCluster (virtual clusters)
  633. │ ├── kind.py # kind local clusters
  634. │ └── custom_resources.py # CRD discovery
  635. ├── resources/ # 8 MCP Resources for data exposure
  636. ├── prompts/ # 14 MCP Prompts for workflows
  637. └── cli/ # CLI interface
  638. ```
  639. ## Agent Skills (25 Skills for AI Coding Agents)
  640. Extend your AI coding agent with Kubernetes expertise using the skills in [`kubernetes-skills/`](kubernetes-skills/). Skills provide specialized knowledge and workflows that agents load on demand, and each one names the toolsets it needs.
  641. ### Quick Install
  642. ```bash
  643. # Any agent (Claude Code, Codex, Cursor, OpenCode, Gemini CLI, ...) via the skills CLI
  644. npx skills add rohitg00/kubectl-mcp-server
  645. # A single skill for a single agent
  646. npx skills add rohitg00/kubectl-mcp-server --skill k8s-helm --agent claude-code
  647. # OpenClaw, from ClawHub (synced from this repo on every merge)
  648. openclaw skills install @rohitg00/k8s-helm
  649. # Or copy into Claude Code directly
  650. cp -r kubernetes-skills/claude/* ~/.claude/skills/
  651. ```
  652. Browse them on [ClawHub](https://clawhub.ai/rohitg00) or list them with `npx skills add rohitg00/kubectl-mcp-server --list`.
  653. ### Available Skills (25)
  654. | Category | Skills |
  655. |----------|--------|
  656. | **Core Resources** | k8s-core, k8s-networking, k8s-storage |
  657. | **Workloads** | k8s-deploy, k8s-operations, k8s-helm |
  658. | **Observability** | k8s-diagnostics, k8s-troubleshoot, k8s-incident |
  659. | **Security** | k8s-security, k8s-policy, k8s-certs |
  660. | **GitOps** | k8s-gitops, k8s-rollouts |
  661. | **Scaling** | k8s-autoscaling, k8s-cost, k8s-backup |
  662. | **Multi-Cluster** | k8s-multicluster, k8s-capi, k8s-kubevirt |
  663. | **Development** | k8s-vind, k8s-kind |
  664. | **Networking** | k8s-service-mesh, k8s-cilium |
  665. | **Tools** | k8s-cli |
  666. ### Convert to Other Agents
  667. Use [SkillKit](https://github.com/rohitg00/skillkit) to convert skills to your preferred AI agent format:
  668. ```bash
  669. npm install -g skillkit
  670. # Convert to Cursor format
  671. skillkit translate kubernetes-skills/claude --to cursor --output .cursor/rules/
  672. # Convert to Codex format
  673. skillkit translate kubernetes-skills/claude --to codex --output ./
  674. ```
  675. **Supported agents:** Claude, Cursor, Codex, Gemini CLI, GitHub Copilot, Goose, Windsurf, Roo, Amp, and more.
  676. See [kubernetes-skills/README.md](kubernetes-skills/README.md) for full documentation.
  677. ## Multi-Cluster Support
  678. Seamlessly manage multiple Kubernetes clusters through natural language. **Every tool** supports an optional `context` parameter to target any cluster without switching contexts.
  679. ### Context Parameter (v1.15.0)
  680. Most kubectl-backed tools accept an optional `context` parameter to target specific clusters.
  681. Note: vCluster (vind) and kind tools run via their local CLIs and do not accept the `context` parameter.
  682. **Talk to your AI assistant:**
  683. ```
  684. "List pods in the production cluster"
  685. "Get deployments from staging context"
  686. "Show logs from the api-pod in the dev cluster"
  687. "Compare namespaces between production and staging clusters"
  688. ```
  689. **Direct tool calls with context:**
  690. ```bash
  691. # Target a specific cluster context
  692. kubectl-mcp-server call kubectl_get '{"resource_type": "pods", "namespace": "default", "context": "production"}'
  693. # Get deployments from staging
  694. kubectl-mcp-server call kubectl_get '{"resource_type": "deployments", "namespace": "app", "context": "staging"}'
  695. # Install Helm chart to production cluster
  696. kubectl-mcp-server call install_helm_chart '{"name": "redis", "chart": "bitnami/redis", "namespace": "cache", "context": "production"}'
  697. # Compare resources across clusters
  698. kubectl-mcp-server call compare_namespaces '{"namespace1": "prod-ns", "namespace2": "staging-ns", "context": "production"}'
  699. ```
  700. ### Context Management
  701. **Talk to your AI assistant:**
  702. ```
  703. "List all available Kubernetes contexts"
  704. "Switch to the production cluster"
  705. "Show me details about the staging context"
  706. "What's the current cluster I'm connected to?"
  707. ```
  708. **Or use the CLI directly:**
  709. ```bash
  710. kubectl-mcp-server context # Show current context
  711. kubectl-mcp-server context production # Switch context
  712. kubectl-mcp-server call list_contexts # List all contexts via MCP
  713. ```
  714. ### How It Works
  715. - If `context` is omitted, the tool uses your current kubectl context
  716. - If `context` is specified, the tool targets that cluster directly
  717. - Response includes `"context": "production"` or `"context": "current"` for clarity
  718. - Works with all kubeconfig setups and respects `KUBECONFIG` environment variable
  719. - No need to switch contexts for cross-cluster operations
  720. ## Development & Testing
  721. ### Setup Development Environment
  722. ```bash
  723. # Clone the repository
  724. git clone https://github.com/rohitg00/kubectl-mcp-server.git
  725. cd kubectl-mcp-server
  726. # Create virtual environment
  727. python -m venv venv
  728. source venv/bin/activate # On Windows: venv\Scripts\activate
  729. # Install development dependencies
  730. pip install -r requirements-dev.txt
  731. ```
  732. ### Running Tests
  733. ```bash
  734. # Run all tests
  735. pytest tests/ -v
  736. # Run specific test file
  737. pytest tests/test_tools.py -v
  738. # Run with coverage
  739. pytest tests/ --cov=kubectl_mcp_tool --cov-report=html
  740. # Run only unit tests
  741. pytest tests/ -v -m unit
  742. ```
  743. ### Test Structure
  744. ```
  745. tests/
  746. ├── __init__.py # Test package
  747. ├── conftest.py # Shared fixtures and mocks
  748. ├── test_tools.py # Unit tests for all MCP tools
  749. ├── test_stateless_security.py # Both protocol eras, confirmation, redaction, injection guard
  750. ├── test_resources.py # Tests for 8 MCP Resources
  751. ├── test_prompts.py # Tests for 8 MCP Prompts
  752. └── test_server.py # Server initialization tests
  753. ```
  754. **555 tests covering**: tool registration, resource exposure, prompt generation, both MCP protocol eras end to end, safety modes, confirmation rounds, Secret redaction, flag injection, network exposure, CLI commands, and ecosystem tools.
  755. ### Code Quality
  756. ```bash
  757. # Format code
  758. black kubectl_mcp_tool tests
  759. # Sort imports
  760. isort kubectl_mcp_tool tests
  761. # Lint
  762. flake8 kubectl_mcp_tool tests
  763. # Type checking
  764. mypy kubectl_mcp_tool
  765. ```
  766. ## Contributing
  767. We ❤️ contributions! Whether it's bug reports, feature requests, documentation improvements, or code contributions.
  768. **Ways to contribute:**
  769. - 🐛 Report bugs via [GitHub Issues](https://github.com/rohitg00/kubectl-mcp-server/issues)
  770. - 💡 Suggest features or improvements
  771. - 📝 Improve documentation
  772. - 🔧 Submit pull requests
  773. - ⭐ Star the project if you find it useful!
  774. **Development setup**: See [Development & Testing](#development--testing) section above.
  775. **Before submitting a PR:**
  776. 1. Run tests: `pytest tests/ -v`
  777. 2. Format code: `black kubectl_mcp_tool tests`
  778. 3. Check linting: `flake8 kubectl_mcp_tool tests`
  779. ## Support & Community
  780. - 📖 [Documentation](https://github.com/rohitg00/kubectl-mcp-server#readme)
  781. - 💬 [GitHub Discussions](https://github.com/rohitg00/kubectl-mcp-server/discussions)
  782. - 🐛 [Issue Tracker](https://github.com/rohitg00/kubectl-mcp-server/issues)
  783. - 🎯 [Feature Requests](https://github.com/rohitg00/kubectl-mcp-server/issues/new)
  784. - 🌟 [agentregistry Profile](https://aregistry.ai)
  785. ## License
  786. MIT License - see [LICENSE](LICENSE) for details.
  787. ## Links & Resources
  788. **Package Repositories:**
  789. - 🐍 [PyPI Package](https://pypi.org/project/kubectl-mcp-server/)
  790. - 📦 [npm Package](https://www.npmjs.com/package/kubectl-mcp-server)
  791. - 🐳 [Docker Hub](https://hub.docker.com/r/rohitghumare64/kubectl-mcp-server)
  792. **Project:**
  793. - 🔧 [GitHub Repository](https://github.com/rohitg00/kubectl-mcp-server)
  794. - 🐛 [Issue Tracker](https://github.com/rohitg00/kubectl-mcp-server/issues)
  795. - 📋 [Changelog](https://github.com/rohitg00/kubectl-mcp-server/releases)
  796. **Ecosystem:**
  797. - 📚 [Model Context Protocol](https://modelcontextprotocol.io)
  798. - ☸️ [Kubernetes Documentation](https://kubernetes.io/docs)
  799. ---
  800. **Made with ❤️ for the Kubernetes and AI community**
  801. If **kubectl-mcp-server** makes your DevOps life easier, give it a ⭐ on [GitHub](https://github.com/rohitg00/kubectl-mcp-server)!

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.