Claude Ops Investigator
Enables read-only Kubernetes incident investigation through MCP tools for listing pods, describing resources, fetching logs, and searching runbooks.
README
Claude Ops Investigator
A context-aware Kubernetes incident investigation assistant built with Claude Code, MCP, live cluster signals, Prometheus, log search, runbooks, evidence memory, and structured incident reports.
Claude Ops Investigator helps engineers investigate Kubernetes incidents safely by combining read-only operational tools, external evidence storage, compact investigation memory, and human-controlled remediation boundaries.
The goal is not to give an AI unrestricted production access. The goal is to expose narrow, auditable, read-only interfaces that help engineers gather evidence, form hypotheses, rule out causes, and produce reliable incident reports faster.
What this project provides
- Narrow MCP-style tools instead of generic
kubectl - Read-only live Kubernetes investigation
- Claude Code project instructions
- MCP resources, tools, and prompts
- Skills, slash commands, and scoped project rules
- Coordinator/subagent-style investigation workflows
- Structured tool errors
- Hooks and gates for destructive actions
- Structured incident-report output
- Human escalation for risky or ambiguous actions
Safety rule
Start read-only. Do not give Claude unrestricted shell, kubectl, Helm, or production mutation permissions.
Allowed operations in this scaffold:
kubectl getkubectl describekubectl logskubectl top
Blocked operations include:
kubectl deletekubectl applykubectl patchkubectl scalekubectl rollout restarthelm upgradekubectl execby default
Quick start
cd claude-ops-investigator
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
Check Kubernetes access:
kubectl config current-context
kubectl auth can-i get pods -n si
kubectl auth can-i get pods/log -n si
Run a read-only snapshot:
python -m claude_ops.main investigate --namespace si --service event-data --since-minutes 60
Run tests:
pytest
Claude Code slash command
The main interactive workflow is the /investigate-incident slash command:
/investigate-incident namespace=<namespace> service=<service> symptom="<specific symptom>" since_minutes=<minutes>
symptom is required — this workflow is symptom-driven, not a generic
service health check. If no symptom is given, Claude asks for one before
investigating anything.
Examples:
/investigate-incident namespace=si service=multi-system-processor symptom="readiness probe failures during recent rollout" since_minutes=60
/investigate-incident namespace=si service=event-data symptom="KafkaConsumerCommitRateLow alert fired" since_minutes=120
/investigate-incident namespace=si service=multi-system-processor symptom="OOMKilled restarts observed" since_minutes=180
What it does:
- Delegates to the
incident-coordinatorsubagent (falls back to a single agent, with that fallback stated explicitly, only if subagents aren't available) - The coordinator reads the service catalog and runbook catalog, then routes
the symptom to the narrowest relevant specialist subagents:
k8s-evidence-collector— pod listing, describe, live logs, namespace events, current resource usageprometheus-analyst— restart counts/increase, CPU, memory, HTTP error rate, latency p95log-analyst— historical IBM Cloud Logs search (errors, probe failures, arbitrary text) spanning restarts/deploymentsrunbook-analyst— matches the symptom against local runbooks
- Every specialist stores raw evidence as an
evidence_refand hands back only summaries/findings — the coordinator never gathers evidence directly incident-reporterruns last, synthesizing all subagents' findings (never its own) into a single evidence-grounded, schema-valid report- The final output includes a "Subagent usage audit" table: which subagent ran, what it did, which tools/evidence_refs it used, and its result
What it does not do:
- Does not mutate Kubernetes resources
- Does not restart pods
- Does not apply fixes
- Does not run destructive commands
- Does not fetch raw evidence detail unless needed
Environment for optional tools
Prometheus:
PROMETHEUS_URLPROMETHEUS_AUTO_PORT_FORWARDPROMETHEUS_PF_SERVICEPROMETHEUS_PF_NAMESPACE
IBM Cloud Logs:
IBM_LOGS_ENDPOINTIBM_CLOUD_API_KEY
Copy .env.example to .env and fill in local values. Never commit .env.
The MCP server loads it automatically at startup so these tools have access
without any secrets going into .mcp.json.
No-token local tests
These exercise the tools and structured error paths without any real Prometheus, IBM Cloud, or Kubernetes credentials:
python -m pytest
python scripts/mcp_smoke_client.py
Direct tool checks:
python - <<'PY'
from claude_ops.tools.prometheus_preflight import ensure_prometheus
import json
print(json.dumps(ensure_prometheus(), indent=2))
PY
python - <<'PY'
from claude_ops.tools.ibm_logs_tools import ibm_logs_search_errors
import json
print(json.dumps(ibm_logs_search_errors("si", "multi-system-processor", limit=1), indent=2))
PY
Local environment
The MCP server needs environment variables for the optional Prometheus and
IBM Cloud Logs tools (PROMETHEUS_URL, IBM_LOGS_ENDPOINT,
IBM_CLOUD_API_KEY, etc.). Configure them locally with a .env file — it is
gitignored and loaded automatically, no secrets ever need to go in
.mcp.json.
cp .env.example .env
# edit .env with your local values
source .venv/bin/activate
claude
src/claude_ops/mcp/server.py calls load_dotenv() at startup, so the MCP
server picks up .env automatically when Claude Code launches it — no
manual export needed. Missing .env is fine; tools that need a variable
that still isn't set return a structured config error instead of failing
silently.
Recommended first live use
Use a non-production namespace first.
python -m claude_ops.main investigate --namespace si --service multi-system-processor --since-minutes 120
Then paste the generated JSON snapshot into Claude/Claude Code and ask it to produce an incident report using the schema in src/claude_ops/schemas/incident_report_schema.py.
MCP client/server map
In this project:
Claude Code = MCP client
src/claude_ops/mcp/server.py = local MCP server
.mcp.json = project-level MCP client configuration for Claude Code
Start the MCP server manually for a quick syntax check:
python -m claude_ops.mcp.server
For Claude Code, keep .mcp.json in the project root. Claude Code reads the config and launches the server over STDIO.
Optional smoke test:
pip install -e ".[dev,mcp]"
python scripts/mcp_smoke_client.py
The MCP server exposes:
Resources:
ops://runbook-catalogops://service-catalog
Tools:
k8s_list_podsk8s_describe_podk8s_get_pod_logsk8s_get_recent_namespace_eventsk8s_top_podsrunbook_searchprom_query_instantprom_get_pod_restart_countsprom_get_pod_restart_increaseprom_get_pod_cpu_usageprom_get_pod_memory_usageprom_get_http_error_rateprom_get_latency_p95prom_ensure_connectionibm_logs_searchibm_logs_search_errorsibm_logs_search_probe_failuresibm_logs_search_textevidence_get_detail
Prompt:
investigate_incident
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。