DevContext is a prototype Model Context Protocol (MCP) server and CLI tool that provides AI coding assistants and engineers with runtime observability data (logs, deploys, and health metrics) to assist in incident triage.
Coding assistants can inspect source repositories and draft fixes, but they often lack visibility into what happens during runtime incidents (such as recent deployments, error rate spikes, disk saturation, or downstream API outages). DevContext is a proof-of-concept tool that exposes runtime context via a command-line interface (CLI) and standard MCP tool calls.
DevContext can be run directly from the command line or registered as an MCP server.
Runs automated incident triage against built-in datasets or custom files/folders:
# Diagnose built-in service dataset
devcontext diagnose --service order-processing
# Output raw JSON format
devcontext diagnose --service order-processing --json
# Point at custom log, deploy, and health paths (files or log directories)
devcontext diagnose --log-path /var/log/app/ --deploys-path deploys.json --health-path health.json
# Enable experimental Groq LLM extraction
devcontext diagnose --service order-processing --use-llmStarts the stdio MCP server for connection to MCP hosts (e.g. Claude Desktop, Antigravity):
devcontext serve
- Deterministic Parser (
parser.py): Uses heuristics to sample log lines and attempt structure matching (JSON-lines, CSV, key-value pairs, or basic bracketed/space-delimited timestamps).- Limitation: Best suited for simple single-line logs. Complex multi-line stack traces or non-standard custom formats may fall back to basic line matching.
- Experimental LLM Extraction (
extraction.py): Optionally sends log chunks to Groq's API (response_format={"type": "json_object"}) to extract structured event objects.- Limitation: Incurs API latency (~200–400ms) and token costs; falls back to the deterministic parser if the API key is missing or calls time out.
- Built-in Mock Data: Pass a service name (e.g.
service_name="order-processing") to query the included demo data. - Custom File or Directory Paths:
log_path: Path to a single log file or a directory containing split.log/.txtfiles.deploys_path: Path to a customdeploys.jsonfile.health_path: Path to a customhealth.jsonfile.
eval.py scores any diagnosis method against 50 scenarios: 5 handwritten (easy) and 45 generated by a seeded script (benchmark/generate.py). Scoring is strict: the predicted root-cause type must match ground truth, and for bad deploys the blamed commit must match too. There is no pass-by-default branch, and a crash counts as a failure.
python eval.py # all 50, rule-based method
python eval.py --set generated --verbose --json results/rule.jsonGenerated scenarios cover 5 root causes (bad deploy, disk, memory leak, downstream outage, DB connection pool) across variants:
| Variant | What it tests |
|---|---|
clean |
One clear signal, sparse logs |
noisy |
300+ lines, benign WARNs right before the incident, decoy health metrics |
red_herring_deploy |
Unrelated deploy 2-8 minutes before a non-deploy incident |
delayed |
Bad deploy whose errors only start 25-90 minutes later |
Logs alternate between plain text and JSON-lines.
| Set | Accuracy |
|---|---|
| Handwritten (5) | 100% (5/5) |
clean (15) |
80% (12/15) |
noisy (15) |
40% (6/15) |
red_herring_deploy (12) |
0% (0/12) |
delayed (3) |
0% (0/3) |
| Overall (50) | 46% (23/50) |
What this shows:
- Deploy-blaming is too eager: any deploy within 10 minutes of the first flagged line gets blamed, so an unrelated deploy beats clear disk, memory, or outage evidence (0/12).
- Benign WARNs break correlation:
first_error_timestampcounts WARN lines, so a harmless warning before a deploy hides a real regression. - Keyword rules misfire: a moderately high disk metric (86-89%) trips the disk branch on unrelated incidents.
- No DB-pool rule exists: all 9 connection-pool scenarios fail by design (0/9), a coverage gap rather than a bug.
- The parser is not the bottleneck: JSON-lines and plain text score the same within each variant.
agent.py adds three LLM methods, all scored by the same strict, zero-pass-by-default benchmark harness. The LLM layer is provider-agnostic, using the openai SDK to connect to any OpenAI-compatible endpoint (e.g. self-hosted vLLM on Kaggle/local GPU, or cloud endpoints).
| Method | What it is |
|---|---|
llm_raw |
Baseline: last 150 log lines + deploys + health pasted into one prompt, no tools |
agent |
Tool-calling investigator over get_recent_errors / get_recent_deploys / get_service_health, ending in a structured submit_diagnosis with quoted evidence |
agent_verified |
Investigator plus a skeptical verifier pass that checks evidence grounding and can overturn the draft |
The agent deliberately does NOT receive diagnose(), so it cannot echo the rule-based heuristic.
The LLM layer requires three environment variables (with a clear error naming any missing variable):
DEVCONTEXT_BASE_URL: Base URL of the OpenAI-compatible endpoint (e.g.http://localhost:8000/v1for vLLM).DEVCONTEXT_API_KEY: API key for the endpoint (usedummyfor local vLLM).DEVCONTEXT_MODEL: Model name (do not assume or hardcode; verify viapython eval.py --list-models).
Optional configuration:
DEVCONTEXT_MIN_INTERVAL: Optional delay in seconds between consecutive API calls to prevent rate limits.DEVCONTEXT_CACHE: Directory for cached responses (defaults to.llm_cache/). Cache keys includebase_url + model + prompt + tools.
To maintain scientific and empirical rigor:
- Tune Prompts Only on Dev: Tune system instructions and few-shot guidance strictly on
--split dev(handwritten scenarios + seed 0). - Freeze Prompts: Once finalized, freeze all prompt templates.
- Evaluate on Test: Run
--split test(seeds 1 and 2, which were never seen during development) once per method with--runs 3to assess variance and stability. - Fair Comparison: All methods (
llm_raw,agent,agent_verified) must be evaluated against the exact same model and endpoint. - Report Complete Metadata: Every reported benchmark table must specify:
- Model Name
- Provider / Serving Engine (e.g. vLLM on Kaggle T4 GPU)
- Evaluation Date
- No Hand Edits: Benchmark results must be generated directly by
eval.pywithout manual modification.
# Query available model IDs from the endpoint
python eval.py --list-models
# Run evaluation on test split (3 runs per scenario)
python eval.py --method llm_raw --runs 3 --split test --json results/llm_raw.json
python eval.py --method agent --runs 3 --split test --json results/agent.json
python eval.py --method agent_verified --runs 3 --split test --json results/agent_verified.jsonTo benchmark without API rate limits or commercial token costs, run on a Kaggle GPU (T4 x 2 or P100):
- Script:
scripts/kaggle_vllm.sh - Notebook:
notebooks/kaggle_vllm.ipynb
- Model Selection: Uses
Qwen/Qwen2.5-7B-Instruct-AWQon Hugging Face (4-bit AWQ, ~5.3 GB VRAM weights). It fits easily on a 16GB Kaggle GPU with generous KV-cache headroom. - vLLM Serving: Starts an OpenAI-compatible server with native Hermes tool calling:
vllm serve Qwen/Qwen2.5-7B-Instruct-AWQ \ --quantization awq \ --enable-auto-tool-choice \ --tool-call-parser hermes \ --port 8000 - Health Check Polling: Waits for
http://127.0.0.1:8000/healthbefore initiating benchmark runs. - Resumable Cache: Restores any previously saved
.llm_cache/from an attached Kaggle dataset (/kaggle/input/**/.llm_cache). If a 9-hour Kaggle GPU session times out, the next run resumes instantly from where it left off. - Artifact Export: Copies
.llm_cache/andresults/to/kaggle/workingfor persistence and dataset creation.
RESULTS_PLACEHOLDER
Treat this as a synthetic benchmark. Scenarios are generated from templates, so it measures robustness to noise and misleading signals, not real-world accuracy.
┌─────────────────────────────────────────────────────────┐
│ CLI / MCP Clients │
│ (devcontext CLI / Claude Desktop / Antigravity) │
└───────────────────────────┬─────────────────────────────┘
│ CLI Args / stdio JSON-RPC
┌───────────────────────────▼─────────────────────────────┐
│ DevContext Entry Point │
│ (cli.py / server.py) │
└───────────────────────────┬─────────────────────────────┘
│
┌───────────────────────────▼─────────────────────────────┐
│ Diagnostic Core (tools.py) │
└───────┬───────────────────┬─────────────────────┬───────┘
│ │ │
┌───────▼───────────┐ ┌─────▼─────────────┐ ┌─────▼─────────────┐
│ Structure Parser │ │ Deployment Engine │ │ Health Observer │
│ (parser.py) │ │ (deploys.json) │ │ (health.json) │
└───────┬───────────┘ └───────────────────┘ └───────────────────┘
│
┌───────┴─────────────────────────────────────────┐
│ Groq API (Optional LLM log extraction) │
└─────────────────────────────────────────────────┘
git clone https://github.com/sid-stack001/devcontext.git
cd devcontext
pip install -e .devcontext diagnose --service order-processingAdd DevContext to your claude_desktop_config.json:
{
"mcpServers": {
"devcontext": {
"command": "devcontext",
"args": [
"serve"
]
}
}
}pip install -e .[dev]
pytest
python eval.pyCopy .env.example to .env to configure your OpenAI-compatible endpoint:
cp .env.example .env- Python 3.10+
mcp(Model Context Protocol SDK)openai(Provider-agnostic API client)pytest(Optional, for test execution)
- Pluggable Adapters: Connect directly to CloudWatch, Datadog, Grafana Loki, or Prometheus APIs.
- Probabilistic Confidence Scores: Output root-cause probability distributions (e.g.
95% confidence: bad deploy) instead of single deterministic strings. - Automated Rollback Proposals: Generate validated git revert commits or Kubernetes patch specs alongside the diagnosis.
Distributed under the MIT License.