崩溃转储分析服务器

基于MCP协议的服务器,提供系统崩溃转储分析功能,集成Linux crash和drgn调试工具,支持远程分析和多传输模式。

  • by yup-21
  • Python
  • 本地部署
  • 7 星标
  • 更新于
在 GitHub 查看 yup-21/crash-mcp

使用说明

Crash MCP Server

A server based on MCP (Model Context Protocol), used for System crash dump analysis.

Integrated Linux crash Practical programs and drgn Programmable debugger, providing a unified analysis interface.

Features

  • Unified conversationSimultaneously supporting crash and drgn engine
  • Conversations to be repeatedAutomatically reuse existing sessions within the same vmcore
  • Command persistenceOutput automatic disk dropping, supporting pagination and search
  • remote analysisConnect to remote host via SSH without downloading vmcore
  • Multi transmission mode: Stdio (default)/SSE (HTTP)
  • Intelligent architecture recognitionAutomatically detect vmcore architecture and select the corresponding crash version
  • auto-compilationBuilt in crash tool compiler, supporting multiple architectures and compression formats

install

prerequisite

  • Python 3.10+
  • crash Tools (can be installed through built-in compiler)
  • python3-dev (Compiled PyKdump requires)
  • drgn Tools (automatically installed through pip)

Quick Installation

chmod +x install.sh && ./install.sh

Compile Crash Tool

# 激活虚拟环境
source venv/bin/activate

# 查看依赖安装说明
compile-crash --deps

# 编译 x86_64 版本
compile-crash

# 编译 ARM64 版本(在 x86_64 上分析 ARM64 vmcore)
compile-crash --arch ARM64

# 编译带 PyKdump 支持的版本
compile-crash --pykdump-from-source

use

Start the server

# Stdio 模式
crash-mcp

# SSE 模式
crash-mcp --transport sse --port 8000

MCP tool

Tools Instructions
open_vmcore_session Open the vmcore crash dump file for analysis
run_crash_command Execute crash command, supports PyKdump extension
run_drgn_command Execute drgn Python code
close_vmcore_session Close the current analysis session
get_command_output Paging to obtain long command output
search_command_output Regular search command output
run_analysis_script Run predefined analysis script (requires configuration) DRGN_SCRIPTS_PATH)
list_analysis_scripts List available analysis scripts (requiring configuration) DRGN_SCRIPTS_PATH)
get_crash_info Obtain crash diagnosis report (requires configuration) GET_DUMPINFO_SCRIPT)

configuration

Environment Variables Default Values Description
CRASH_EXTENSION_LOAD true Whether to automatically load extensions
CRASH_MCP_TRUNCATE_LINES 20 Output truncated rows
CRASH_MCP_WORKDIR /tmp/crash-mcp-sessions Session working directory
CRASH_MCP_CACHE true Enable command caching
LOG_LEVEL INFO Log level
GET_DUMPINFO_SCRIPT (Empty) Automated diagnostic script command template (such as python3 script.py {vmcore} {vmlinux})
DRGN_SCRIPTS_PATH (Empty) External drgn script search path (colon separated)

Client configuration

Claude Desktop (claude_desktop_config.json):

{
  "mcpServers": {
    "crash-analysis": {
      "command": "/path/to/crash-mcp/venv/bin/crash-mcp"
    }
  }
}

example

# 本地分析
open_vmcore_session("/var/crash/vmcore", "/usr/lib/debug/vmlinux")
run_crash_command("bt")
run_crash_command("sys")
run_drgn_command("prog['init_task'].comm")

# 分页获取长输出
run_crash_command("ps")  # 返回 command_id
get_command_output("crash:ps", offset=20, limit=50)

# 搜索输出
search_command_output("crash:bt", "schedule")

# 远程分析
open_vmcore_session("/var/crash/vmcore", "/usr/lib/debug/vmlinux", 
              ssh_host="server-01", ssh_user="root")

Frequently Asked Questions

one no lzo compression support error

The vmcore file is compressed using LZO, but LZO support is not enabled during compilation by the crash tool.

sudo apt-get install liblzo2-dev
compile-crash --clean

2. Lack of GMP/MPFR library

sudo apt-get install libgmp-dev libmpfr-dev

3. View all compilation dependencies

compile-crash --deps

license

MIT License