incident-triage
An MCP server that helps engineers investigate service incidents using semantic log search, error aggregation, RAG-based diagnosis, and runbook recommendations.
README
Incident Triage MCP Server
An AI-assisted Incident Triage MCP Server that helps engineers investigate service incidents using semantic log search, error aggregation, RAG-based diagnosis, and runbook recommendations.
The project demonstrates how Model Context Protocol (MCP) can be applied to a real-world operational engineering workflow rather than a generic chatbot.
The server operates against synthetic messaging/CPaaS service logs and exposes four MCP tools that can be invoked from an MCP client or directly from the terminal using the FastMCP CLI.
๐ What This Project Does
Instead of manually searching through hundreds of log lines, an engineer can ask questions such as:
Why is messaging-service failing?
Find logs related to queue backlog.
What's the runbook for a connection timeout?
What is the likely root cause of the messaging-service incident?
The MCP server converts these requests into structured tool calls against the incident data.
The important distinction is that the system does not ask an LLM to guess from nothing.
It combines:
- Deterministic log processing
- Semantic search
- Structured error aggregation
- Retrieval-Augmented Generation (RAG)
- LLM-based incident analysis
- Semantic runbook matching
๐๏ธ Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ MCP Client โ
โ โ
โ Claude / FastMCP CLI โ
โโโโโโโโโโโโโโฌโโโโโโโโโโโโโ
โ
โ MCP / stdio
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Incident Triage โ
โ MCP Server โ
โ server.py โ
โโโโโโโโโโโโโโฌโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ โ
โผ โผ โผ
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ
โ Log Search โ โ Error โ โ Runbook โ
โ โ โ Summary โ โ Search โ
โ Embeddings โ โ Plain Code โ โ Embeddings โ
โโโโโโโโฌโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโฌโโโโโโโโ
โ โ
โผ โผ
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ
โ logs.jsonl โ โrunbooks.json โ
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ Incident โ
โ Diagnosis โ
โ โ
โ Retrieve Logs โ
โ โ โ
โ Anthropic LLM โ
โ โ โ
โ Root Cause + โ
โ Next Steps โ
โโโโโโโโโโโโโโโโโโโ
๐ง MCP Tools
The server exposes four tools.
1. search_logs
Performs semantic search over service logs using sentence-transformers.
Example:
fastmcp call server.py search_logs query="queue backlog"
The query is converted into an embedding and compared with log embeddings.
This allows queries such as:
queue is stuck
to find logs containing concepts such as:
consumer lag
queue backlog
without depending entirely on exact keyword matching.
2. get_error_summary
Provides a deterministic aggregation of errors.
Example:
fastmcp call server.py get_error_summary
Example result:
Error summary:
db_deadlock: 38
rate_limit_exceeded: 37
queue_backlog: 37
auth_token_expired: 32
connection_timeout: 24
No LLM is involved here.
This is intentional.
Simple counting does not require AI.
3. diagnose_incident
Performs RAG-based incident diagnosis.
Example:
fastmcp call server.py diagnose_incident \
service="messaging-service" \
hours=24
The flow is:
Service
โ
โผ
Retrieve recent errors
โ
โผ
Build incident context
โ
โผ
Send context to Anthropic
โ
โผ
Root cause hypothesis
โ
โผ
Immediate next steps
The LLM receives retrieved incident evidence rather than being asked to diagnose the problem without context.
If ANTHROPIC_API_KEY is not available, the POC falls back to a raw error-frequency summary.
4. suggest_runbook
Uses semantic similarity to find the most relevant operational runbooks.
Example:
fastmcp call server.py suggest_runbook \
query="connection to provider keeps timing out"
Example:
Downstream Connection Timeout
Provider Auth Token Expired
Provider Rate Limiting
This allows engineers to describe an incident naturally instead of remembering the exact runbook title.
๐ง AI vs Traditional Logic
One of the goals of this POC is to demonstrate that not everything needs an LLM.
| Capability | Approach | Why |
|---|---|---|
search_logs |
Embeddings | Semantic matching |
get_error_summary |
Python aggregation | No AI required |
diagnose_incident |
RAG + Anthropic | Converts evidence into a diagnosis |
suggest_runbook |
Embeddings | Handles different incident phrasing |
This creates a practical hybrid architecture:
Incident Triage
โ
โโโโโโโโโโโโโโผโโโโโโโโโโโโโ
โ โ โ
Deterministic Semantic LLM
Logic Retrieval Reasoning
โ โ โ
Aggregation Embeddings RAG
๐ Project Structure
incident-mcp/
โ
โโโ server.py
โโโ requirements.txt
โโโ README.md
โโโ .gitignore
โ
โโโ data/
โโโ generate_logs.py
โโโ runbooks.json
logs.jsonl is generated locally and should not be committed to Git.
๐ ๏ธ Technology Stack
- Python 3.12
- FastMCP
- Model Context Protocol
- Sentence Transformers
all-MiniLM-L6-v2- PyTorch
- NumPy
- SciPy
- Anthropic API
- python-dotenv
- JSONL
- Synthetic operational logs
โ๏ธ Local Setup
1. Clone the repository
git clone git@github.com:balachoudry-tech/incident_mcp_ai.git
cd incident_mcp_ai
2. Create a virtual environment
Python 3.12 is recommended.
python3.12 -m venv .venv
Activate it:
macOS / Linux
source .venv/bin/activate
Windows
.venv\Scripts\activate
3. Install dependencies
pip install -r requirements.txt
The dependency versions are pinned to the versions used by the working POC environment.
๐ Generate Synthetic Logs
Generate the incident data:
python data/generate_logs.py
This creates:
data/logs.jsonl
The generated logs simulate operational failures across messaging/CPaaS services.
๐ Configure Anthropic
Create a .env file in the project root:
ANTHROPIC_API_KEY=your_api_key_here
The .env file is intentionally excluded from Git.
The application loads the key using python-dotenv.
Never commit your API key.
โถ๏ธ Run the MCP Server
The server uses stdio transport.
python server.py
When started directly, the server waits for an MCP client.
You may see:
Starting MCP server 'incident-triage'
with transport 'stdio'
This is expected.
The server is not a traditional HTTP API.
๐งช Test from Terminal
The POC can be tested without Claude Desktop using the FastMCP CLI.
List available tools
fastmcp list server.py
Expected tools:
search_logs
get_error_summary
diagnose_incident
suggest_runbook
Test error summary
fastmcp call server.py get_error_summary
Test semantic search
fastmcp call server.py search_logs \
query="queue backlog"
You can also specify the number of results:
fastmcp call server.py search_logs \
query="queue backlog" \
top_k=5
Test runbook search
fastmcp call server.py suggest_runbook \
query="connection to provider keeps timing out"
Test incident diagnosis
fastmcp call server.py diagnose_incident \
service="messaging-service" \
hours=24
With ANTHROPIC_API_KEY configured, this executes the RAG + Anthropic diagnosis flow.
๐ Incident Diagnosis Flow
A typical diagnosis follows this flow:
1. Engineer asks about a service
โ
โผ
2. Retrieve recent service errors
โ
โผ
3. Build incident context
โ
โผ
4. Send relevant context to LLM
โ
โผ
5. LLM analyzes relationships
โ
โผ
6. Generate root-cause hypothesis
โ
โผ
7. Recommend immediate next steps
For example:
Carrier timeout
โ
โผ
Delivery retries
โ
โผ
Rate limiting
โ
โผ
Retry contention
โ
โผ
Database deadlocks
โ
โผ
Queue backlog
The LLM can use these correlated signals to produce a higher-level incident hypothesis.
๐ฆ Why No Vector Database?
This POC intentionally does not use a vector database.
The log dataset is small enough that embeddings can be:
Loaded
โ
Computed
โ
Stored in memory
โ
Compared using similarity
For a small proof of concept, this keeps the architecture simple.
A persistent vector index would become useful as the dataset grows.
๐ Security Notes
This is a proof of concept.
The following production concerns are intentionally outside the scope:
- Authentication
- Authorization
- Multi-tenancy
- Secret management
- Tool-level permissions
- Audit logging
- Production observability
- Persistent vector storage
- Real log ingestion
- Production-grade error handling
API keys should never be committed to the repository.
๐ Production Evolution
The POC can later evolve toward:
โโโโโโโโโโโโโโโโโโโโโโโโ
โ Real Log Sources โ
โ โ
โ CloudWatch โ
โ Elasticsearch โ
โ Loki โ
โ OpenSearch โ
โโโโโโโโโโโโฌโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโ
โ Log Processing โ
โโโโโโโโโโโโฌโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโ
โ Persistent Vector DB โ
โโโโโโโโโโโโฌโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโ
โ MCP Server โ
โ โ
โ Search โ
โ Summarize โ
โ Diagnose โ
โ Runbooks โ
โโโโโโโโโโโโฌโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโ
โ MCP Client โ
โ / Incident Platform โ
โโโโโโโโโโโโโโโโโโโโโโโโ
Potential future improvements include:
- Real production log sources
- Persistent vector indexes
- Authentication and authorization
- Tool-level access control
- Structured tracing
- Incident correlation IDs
- Confidence scoring
- Better "insufficient evidence" handling
- Audit trails
- Production observability
- Multi-service incident correlation
๐ฏ What This POC Demonstrates
This project demonstrates several practical AI engineering patterns:
MCP
Building operational capabilities as reusable MCP tools.
Semantic Search
Using embeddings to search logs based on meaning rather than exact keywords.
RAG
Retrieving relevant operational evidence before asking an LLM to reason about an incident.
Tool Selection
Using deterministic code where deterministic code is sufficient and AI where reasoning provides additional value.
Operational AI
Applying GenAI to an engineering workflow where the output is grounded in actual incident evidence.
โ ๏ธ Disclaimer
The logs and incidents in this repository are synthetic and are intended only for demonstration and learning purposes.
The diagnosis generated by the LLM should not be treated as an authoritative production incident response.
๐ License
Add the project's license here if/when one is selected.
Author
Built as an engineering-focused MCP/RAG POC demonstrating AI-assisted incident triage for high-throughput messaging/CPaaS systems.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.