kube-assistant-mcp
Agentic Kubernetes troubleshooting — as a CLI and as an MCP server.
kube-assistant-mcp connects a local LLM (via Ollama) or a hosted one (OpenAI-compatible) to your Kubernetes cluster. It scans for failing Pods (CrashLoopBackOff, OOMKilled, ImagePullBackOff, ...), correlates logs + events, explains the root cause in plain language, and proposes concrete, runnable fixes — or generates ready-to-use Deployment/Helm manifests.
It ships two ways to use it:
- CLI —
kube-assistant scan / diagnose / fix / generate - MCP server — the same capabilities exposed as tools for Cursor or Claude Desktop, so an AI agent can diagnose and (with your explicit confirmation) fix your cluster in natural language.
$ kube-assistant scan -n production
┏━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━┓
┃ Namespace ┃ Pod ┃ Issue ┃ Restarts ┃ Severity ┃
┡━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━┩
│ production │ api-7f8c9d │ CrashLoopBackOff │ 14 │ critical │
│ production │ worker-2 │ OOMKilled │ 3 │ high │
└────────────┴──────────────┴──────────────────┴──────────┴──────────┘
Why
Debugging a failing Pod is a repetitive, mechanical loop: describe → logs --previous → get events → guess → fix. This tool automates the mechanical part and hands the LLM only the relevant, structured context it needs to actually help — instead of dumping a whole terminal session into a chat window.
Features
- Detection — classifies container states (
waiting/terminatedreasons) into known failure types with a severity score. - Log analysis — regex-based pattern matching for common root causes (OOM, connection refused, DNS failure, missing env vars, permission errors, bad config, port conflicts, unhandled exceptions) — works even with the LLM turned off.
- LLM diagnosis — sends a compact, structured JSON payload (issue + log tail + recent events) to Ollama or an OpenAI-compatible endpoint and gets back a plain-language explanation plus a list of concrete fixes.
- Guarded auto-fix — every mutating action (pod restart, resource patch) is dry-run by default and requires an explicit
confirm=True/--yesbefore it touches the cluster. - Manifest generation — emits a Deployment+Service YAML pair, or a minimal, valid Helm chart skeleton.
- MCP server — built with FastMCP; drop it into Cursor or Claude Desktop and diagnose your cluster conversationally.
Installation
Option A — from PyPI
pip install kube-assistant-mcp
kube-assistant doctor # checks Python/kubectl/cluster/Ollama and tells you what's missing
Option B — from source (one command)
git clone https://github.com/yonatani94/kube-assistant-mcp
cd kube-assistant-mcp
make setup # creates a venv, installs everything, runs the doctor check
source .venv/bin/activate
Either way, kube-assistant doctor is the entry point: it verifies Python 3.10+,
kubectl + cluster connectivity, and your configured LLM backend (Ollama or
OpenAI) in one shot, and tells you exactly what to install or run next —
no guessing required.
Requires Python 3.10+ and a working kubeconfig (the same one kubectl uses).
For LLM-powered diagnosis, either run Ollama locally
(ollama pull llama3.1) or export OPENAI_API_KEY and pass --llm-backend openai.
New to any of this? See PREREQUISITES.md for full install instructions (Python, kubectl, Ollama) and a hardware/model-size guide.
CLI usage
# List every failing pod in the cluster (or one namespace)
kube-assistant scan -n production
# Deep-dive: logs + events + LLM root-cause explanation + fix suggestions
kube-assistant diagnose api-7f8c9d -n production
# Same, but skip the LLM call and only use the rule-based fixes
kube-assistant diagnose api-7f8c9d -n production --no-llm
# Preview a fix (default: dry-run, no cluster mutation)
kube-assistant fix api-7f8c9d -n production --strategy restart
# Actually apply it (still asks for interactive confirmation unless -y)
kube-assistant fix api-7f8c9d -n production --strategy restart --no-dry-run
# Raise a Deployment's memory limit
kube-assistant fix api-7f8c9d -n production --strategy memory-patch \
--deployment api --memory-limit 1Gi --no-dry-run
# Generate a plain manifest or a Helm chart
kube-assistant generate myapp --image myrepo/myapp:1.4.0 --kind manifest
kube-assistant generate myapp --image myrepo/myapp:1.4.0 --kind helm
Using it as an MCP server (Cursor / Claude Desktop)
Start it directly:
kube-assistant serve
Or point your MCP client config at it. Example for Claude Desktop
(claude_desktop_config.json):
{
"mcpServers": {
"kube-assistant": {
"command": "kube-assistant",
"args": ["serve"]
}
}
}
Exposed tools: list_failing_pods, get_pod_logs, diagnose_pod, apply_fix (dry-run by default, needs confirm=true), generate_manifest.
Configuration
| Env var | Default | Purpose |
|---|---|---|
KUBE_ASSISTANT_LLM_BACKEND |
ollama |
ollama or openai |
KUBE_ASSISTANT_LLM_MODEL |
llama3.1 |
Model name |
KUBE_ASSISTANT_LLM_BASE_URL |
http://localhost:11434 |
Ollama endpoint |
OPENAI_API_KEY |
— | Required when backend=openai |
Architecture
CLI (Typer) ──┐
├──> K8sClient (kubernetes python client)
MCP (FastMCP)─┘ │
▼
LogAnalyzer (regex patterns)
│
▼
RuleBasedFixer + LLMClient (Ollama / OpenAI)
│
▼
AutoFixer (dry-run gated apply)
│
▼
ManifestGenerator (YAML / Helm)
Development
git clone https://github.com/yonatani94/kube-assistant-mcp
cd kube-assistant-mcp
make setup
pytest
The test suite mocks the Kubernetes API and the LLM backend, so pytest runs with no cluster and no network access.
Safety notes
This tool can delete Pods and patch Deployments. It is designed defensively:
- Every write path defaults to
dry_run=True. - A mutation only happens when the caller passes both
dry_run=Falseandconfirm=True(CLI:--no-dry-run+ interactive confirm or--yes; MCP:confirm=true). - It never deletes namespaces, PVCs, or Secrets.
Still, review the generated plan before confirming, especially in production namespaces.
License
MIT — see LICENSE.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kube_assistant_mcp-0.1.2.tar.gz.
File metadata
- Download URL: kube_assistant_mcp-0.1.2.tar.gz
- Upload date:
- Size: 31.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
511140c328ad868cf3ae6cfbcac7607f38dbc3b3f9b6c2afc09ac99ff868170d
|
|
| MD5 |
db88fa72ba3784c0345a6f999fdef9ae
|
|
| BLAKE2b-256 |
6e5ac8d716134eff96903ab79416d200a71688ae12a496a96b883c061b633864
|
Provenance
The following attestation bundles were made for kube_assistant_mcp-0.1.2.tar.gz:
Publisher:
ci.yml on yonatani94/kube-assistant-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kube_assistant_mcp-0.1.2.tar.gz -
Subject digest:
511140c328ad868cf3ae6cfbcac7607f38dbc3b3f9b6c2afc09ac99ff868170d - Sigstore transparency entry: 2340508442
- Sigstore integration time:
-
Permalink:
yonatani94/kube-assistant-mcp@de702a5fb57f06cefcfb87926f2505afa5313a7c -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/yonatani94
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@de702a5fb57f06cefcfb87926f2505afa5313a7c -
Trigger Event:
push
-
Statement type:
File details
Details for the file kube_assistant_mcp-0.1.2-py3-none-any.whl.
File metadata
- Download URL: kube_assistant_mcp-0.1.2-py3-none-any.whl
- Upload date:
- Size: 26.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07c59e48bcc7aea2b550948c752f8a1b1e060c4a444ccb6e4e4883959ddb5485
|
|
| MD5 |
31d861984730fefdd7c910814d410b02
|
|
| BLAKE2b-256 |
4c1642ac596902595f7f750e9acfb21463dcb398349375c84e226eb6d95d70af
|
Provenance
The following attestation bundles were made for kube_assistant_mcp-0.1.2-py3-none-any.whl:
Publisher:
ci.yml on yonatani94/kube-assistant-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kube_assistant_mcp-0.1.2-py3-none-any.whl -
Subject digest:
07c59e48bcc7aea2b550948c752f8a1b1e060c4a444ccb6e4e4883959ddb5485 - Sigstore transparency entry: 2340508458
- Sigstore integration time:
-
Permalink:
yonatani94/kube-assistant-mcp@de702a5fb57f06cefcfb87926f2505afa5313a7c -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/yonatani94
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@de702a5fb57f06cefcfb87926f2505afa5313a7c -
Trigger Event:
push
-
Statement type: