kubectl-mcp
Provides read-only tools for inspecting Kubernetes clusters, including listing namespaces, pods, deployments, services, recent events, and pod logs, as well as querying for restarted pods.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@kubectl-mcpwhich pods restarted in the last hour?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
kubectl-mcp
An MCP (Model Context Protocol) server that lets AI agents inspect Kubernetes clusters in plain English — ask "which pods restarted in the last hour?" and get a real answer.
Built by Teresa Tran.
Why
LLM assistants are great at explaining kubectl commands and terrible at
actually running them safely. kubectl-mcp exposes read-only cluster
inspection as a set of MCP tools an agent can call — turning "check my cluster"
from copy-paste-and-hope into a real conversation.
Read-only by design. No
apply, nodelete, noexec. The server only ever inspects.Mock mode by default. Ships with a seeded fake cluster so you can try it in 30 seconds without a real cluster.
Real mode when you're ready. Point it at your
KUBECONFIGand it queries a live cluster via the official Kubernetes Python client.
Related MCP server: Kubernetes MCP Server
Install
pip install kubectl-mcp # mock mode (default)
pip install "kubectl-mcp[real]" # + real-cluster support (kubernetes client)Or from source:
git clone https://github.com/teresa-tran/kubectl-mcp.git
cd kubectl-mcp
pip install -e ".[real,dev]"Run it standalone (sanity check)
kubectl-mcp --help # show flags
kubectl-mcp --list-tools # print every MCP tool + its schema
kubectl-mcp --demo list_pods # run a tool once against the mock cluster
kubectl-mcp --demo find_restarted_pods --arg since_minutes=120Wire it into an MCP client
Claude Desktop
Add to ~/Library/Application Support/Claude/claude_desktop_config.json (mac)
or %APPDATA%\Claude\claude_desktop_config.json (Windows):
{
"mcpServers": {
"kubectl": {
"command": "kubectl-mcp"
}
}
}For real-cluster mode:
{
"mcpServers": {
"kubectl": {
"command": "kubectl-mcp",
"env": {
"KUBECTL_MCP_MODE": "real",
"KUBECONFIG": "/Users/you/.kube/config"
}
}
}
}Restart Claude Desktop. You should now be able to ask "list pods in the production namespace" and get a real answer.
Other MCP-compatible clients
Any client that speaks stdio MCP (Cursor, Cline, Continue, custom agents) works
the same way — point it at the kubectl-mcp binary.
Tools exposed
Tool | What it does |
| All namespaces in the cluster |
| Pods in a namespace, with phase + restart count |
| Full detail for one pod (containers, statuses, events) |
| Deployments in a namespace, with ready/desired replicas |
| Full detail for one deployment |
| Services in a namespace, with type + endpoints |
| Events in the last N minutes, most recent first |
| Last N lines of a pod's logs (read-only, no |
| Pods that restarted in the last N minutes (high-level query) |
Every tool has a JSON Schema — LLMs get proper argument validation for free.
Configuration
Environment variables:
Var | Values | Default | What |
|
|
| Cluster backend |
| path |
| Real-mode kubeconfig path |
| path | (bundled) | Override the mock cluster JSON |
|
|
| Log verbosity to stderr |
The mock cluster
The default mock cluster ships in src/kubectl_mcp/mock_data.json and includes:
3 namespaces:
default,production,staging~15 pods spanning healthy, crashlooping, and recently-restarted states
Deployments, services, and a stream of recent events
Some pods have restart counts > 0 so
find_restarted_podsreturns real results
You can override it by setting KUBECTL_MCP_MOCK_DATA=/path/to/your.json if
you want to demo a specific scenario.
Design notes
Read-only by construction. The
KubernetesBackendprotocol only defines read methods. There's no code path that can mutate cluster state — even in real mode.Backend is swappable.
MockBackendandRealBackendimplement the same protocol. Adding a third (e.g., a cached snapshot) is one file.Errors are exceptions, not silent nulls.
ResourceNotFound,NamespaceNotFound, etc., propagate asMcpErrorwith helpful messages so the agent can course-correct.stdio transport. All MCP tool calls are JSON-RPC over stdio, matching the MCP spec exactly.
Development
pip install -e ".[real,dev]"
pytest # run tests
ruff check src tests # lint
kubectl-mcp --demo list_pods --arg namespace=production # smoke testRoadmap
Mock backend with seeded data
Real backend via
kubernetespython clientRead-only tool surface
Standalone
--demomode for CI/smoke testsMulti-cluster support (
--contextflag)Metrics tools (CPU/memory via
metrics.k8s.io)Optional caching layer for high-frequency queries
License
MIT © 2026 Teresa Tran
This server cannot be deployed
Maintenance
Related MCP Connectors
Fail-closed policy guardrails for AI agents running kubectl, terraform, helm, and argocd.
The Google GKE MCP server is a managed Model Context Protocol server that provides AI applications with tools to manage Google Kubernetes Engine (GKE) clusters and Kubernetes resources. It exposes a structured, discoverable interface that allows AI agents to interact with GKE and Kubernetes APIs, enabling them to inspect cluster configurations, retrieve Kubernetes resource YAMLs, monitor operations like cluster upgrades, diagnose issues, and optimize costs—all without needing to parse text output or use complex kubectl commands.
- mcpOAuthcom.vibgrate
Query your team's drift, vulnerability, and upgrade data from any AI assistant. OAuth 2.1, 51 tools.
Unified API to query AWS, GCP, Azure and generate Terraform/CLI execution kits for AI agents.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceProvides read-only access to Kubernetes clusters for AI assistants.23MIT
- FlicenseBqualityDmaintenanceEnables managing Kubernetes clusters through natural language by providing tools to list resources, view logs, port-forward services, scale deployments, and execute kubectl operations via AI assistants.81-
- FlicenseNot gradedqualityBmaintenanceExposes Kubernetes cluster management tools to LLMs, enabling querying pods, deployments, logs, metrics, and managing port forwards via natural language.1-
- FlicenseNot gradedqualityCmaintenanceProvides a read-only interface to Kubernetes clusters, enabling LLMs to list pods, get pod status and logs, fetch deployment manifests, and perform pod health analysis with resource trend tracking.-