How hojat-gazestani/k8s-ai-assistant works
Kubernetes AI Assistant is an interactive observability triage application. The principal workflow validates settings, connects to three MCP backends, fetches frequent firing alerts from VictoriaMetrics, lets an operator select one, and asks an agent to investigate it using metrics, Kubernetes state, and Elasticsearch logs before printing a report. The repository also includes a separate cluster-analysis agent. The README documents the MCP server roles; unsampled backend implementation details are represented only at the integration boundary.
Main entry points: main.py Application entry · mcp_client.py MCP client manager · victoria_tools.py Metrics tools · investigation_handler.py Alert investigation
Components 18
Assistant workflow
- Application entry
app/main.py - Settings
app/config/settings.py - Alert selection
app/handlers/alert_handler.py - Alert investigation
app/handlers/investigation_handler.py - Cluster analysis
app/handlers/analysis_handler.py
Tool providers
- Tool discovery
app/tools/base.py - Metrics tools
app/tools/victoria_tools.py - Kubernetes tools
app/tools/k8s_tools.py - Log tools
app/tools/elasticsearch_tools.py
MCP connections
- MCP client manager
app/clients/mcp_client.py - VictoriaMetrics client config
app/clients/victoria_metric.py - Kubernetes client config
app/clients/k8s.py - Elasticsearch client config
app/clients/elasticsearch.py
External systems
- LLM endpoint
- VictoriaMetrics MCP
- Kubernetes MCP
- Elasticsearch MCP
Other components
- Operator
Connections 33
- Operator → Application entry: starts
README.md - Application entry → Settings: validates
app/main.py - Application entry → VictoriaMetrics client config: loads config
app/main.py - Application entry → Kubernetes client config: loads config
app/main.py - Application entry → Elasticsearch client config: loads config
app/main.py - Application entry → MCP client manager: creates clients
app/main.py - Application entry → Alert selection: fetches alerts
app/main.py - Application entry → Alert investigation: starts investigation
app/main.py - Application entry → Metrics tools: creates provider
app/main.py - Application entry → Kubernetes tools: creates provider
app/main.py - Application entry → Log tools: creates provider
app/main.py - Alert selection → Metrics tools: queries alerts
app/handlers/alert_handler.py - Operator → Alert selection: selects alert
app/handlers/alert_handler.py - Alert investigation → LLM endpoint: invokes agent
app/handlers/investigation_handler.py - Alert investigation → Metrics tools: registers tools
app/handlers/investigation_handler.py - Alert investigation → Kubernetes tools: registers tools
app/handlers/investigation_handler.py - Alert investigation → Log tools: registers tools
app/handlers/investigation_handler.py - Cluster analysis → LLM endpoint: invokes agent
app/handlers/analysis_handler.py - Cluster analysis → Metrics tools: registers tools
app/handlers/analysis_handler.py - Cluster analysis → Kubernetes tools: registers tools
app/handlers/analysis_handler.py - Cluster analysis → Log tools: registers tools
app/handlers/analysis_handler.py - Metrics tools → Tool discovery: decorates methods
app/tools/victoria_tools.py - Kubernetes tools → Tool discovery: decorates methods
app/tools/k8s_tools.py - Log tools → Tool discovery: decorates methods
app/tools/elasticsearch_tools.py - Metrics tools → MCP client manager: gets MCP tools
app/tools/victoria_tools.py - Kubernetes tools → MCP client manager: gets MCP tools
app/tools/k8s_tools.py - Log tools → MCP client manager: gets MCP tools
app/tools/elasticsearch_tools.py - MCP client manager → VictoriaMetrics MCP: connects via MCP
README.md - MCP client manager → Kubernetes MCP: connects via MCP
README.md - MCP client manager → Elasticsearch MCP: connects via MCP
README.md - VictoriaMetrics client config → VictoriaMetrics MCP: configures endpoint
app/clients/victoria_metric.py - Kubernetes client config → Kubernetes MCP: configures endpoint
- Elasticsearch client config → Elasticsearch MCP: configures endpoint
app/clients/elasticsearch.py