Skip to main content
Glama
sid-stack001

DevContext

by sid-stack001

DevContext

Python MCP License: MIT

DevContext 是一个 Model Context Protocol(MCP)服务器和 CLI 工具的原型,为 AI 编程助手和工程师提供运行时可观测性数据(日志、部署和健康指标),以协助进行事件排查。


概述

编程助手可以检查源代码仓库并起草修复方案,但它们往往对运行时事件(如最近的部署、错误率飙升、磁盘占满或下游 API 中断)期间实际发生的情况缺乏可见性。DevContext 是一个概念验证工具,通过命令行界面(CLI)和标准 MCP 工具调用来暴露运行时上下文。


Related MCP server: AI Incident Monitoring RCA MCP Server

CLI 与工具命令

DevContext 可以直接从命令行运行,也可以注册为 MCP 服务器。

1. devcontext diagnose

针对内置数据集或自定义文件/文件夹运行自动化事件排查:

# 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-llm

2. devcontext serve

启动 stdio MCP 服务器,用于连接 MCP 主机(例如 Claude Desktop、Antigravity):

devcontext serve

日志解析选项

  1. 确定性解析器(parser.py:使用启发式规则对日志行进行采样,并尝试进行结构匹配(JSON-lines、CSV、键值对或基本的括号/空格分隔时间戳)。

    • 限制:最适合简单的单行日志。复杂的多行堆栈跟踪或非标准自定义格式可能会回退到基本行匹配。

  2. 实验性 LLM 提取(extraction.py:可选择将日志块发送到 Groq 的 API(response_format={"type": "json_object"})以提取结构化事件对象。

    • 限制:会产生 API 延迟(约 200–400 毫秒)和 token 成本;如果缺少 API 密钥或调用超时,则会回退到确定性解析器。


数据源选项

  • 内置模拟数据:传入服务名称(例如 service_name="order-processing")以查询随附的演示数据。

  • 自定义文件或目录路径

    • log_path:指向某个日志文件或包含多个 .log / .txt 分片文件的目录。

    • deploys_path:指向自定义 deploys.json 文件的路径。

    • health_path:指向自定义 health.json 文件的路径。


评估与测试场景

该仓库包含一个评估框架(eval.py),已针对 5 个合成测试场景进行了验证:

场景

服务

场景类型

预期结果

结果

scenario_1_bad_deploy

payment-service

资源限额降低

定位部署 f8a1c92

通过

scenario_2_disk_full

storage-service

磁盘已满(无近期部署)

定位磁盘耗尽(98%)

通过

scenario_3_memory_leak

analytics-worker

内存泄漏 / OOM

定位内存饱和(97%)

通过

scenario_4_downstream_outage

notification-service

外部 API 中断

定位 SendGrid 503 错误

通过

scenario_5_bad_migration

user-service

数据库迁移失败

定位部署 d4e912f

通过

局限性及范围

  • 测试套件较小:该评估套件包含 5 个为验证而创建的合成测试用例。它并非详尽的生成式基准测试集。

  • 启发式匹配diagnose() 使用简单规则(如检查首次错误发生后 10 分钟内是否发生过部署)。现实世界的基础设施事件往往更为复杂,可能涉及多个相互作用因素。


架构

┌─────────────────────────────────────────────────────────┐
│              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)         │
└─────────────────────────────────────────────────┘

快速入门与设置

1. 安装

git clone https://github.com/your-username/devcontext.git
cd devcontext
pip install -e .

2. 通过 CLI 诊断服务

devcontext diagnose --service order-processing

3. 注册为 MCP 服务器(Claude Desktop)

将 DevContext 添加到你的 claude_desktop_config.json

{
  "mcpServers": {
    "devcontext": {
      "command": "devcontext",
      "args": [
        "serve"
      ]
    }
  }
}

4. 运行评估套件

python eval.py

5. 可选 API 密钥设置

如果你使用 Groq 进行实验性 LLM 日志提取,请将 .env.example 复制为 .env

cp .env.example .env

依赖项与要求

  • Python 3.10+

  • mcp(Model Context Protocol SDK)

  • groq(可选,用于 LLM 提取)


未来扩展

  • 可插拔适配器:直接连接 CloudWatch、Datadog、Grafana Loki 或 Prometheus API。

  • 概率置信度分数:输出根因概率分布(例如 95% confidence: bad deploy),而不是单一的确定性字符串。

  • 自动回滚建议:与诊断结果一起生成经过验证的 git revert 提交或 Kubernetes 补丁规范。


许可证

根据 MIT License 进行分发。

A
license - permissive license
Not graded
quality - not tested
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • F
    license
    Not graded
    quality
    B
    maintenance
    Provides telemetry tools for retrieving recent logs and system metrics to support root-cause analysis of infrastructure incidents. Enables autonomous incident triage with grounded verification and human-in-the-loop remediation.
    1
  • F
    license
    Not graded
    quality
    C
    maintenance
    Enables AI agents to investigate production incidents by exposing service health, logs, and deployment data through MCP tools.
    8

View all related MCP servers

Related MCP Connectors

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/sid-stack001/devcontext'

If you have feedback or need assistance with the MCP directory API, please join our Discord server