Content
# Crash MCP Server
MCP (Model Context Protocol) based server for **Crash Dump** analysis.
Integrates Linux `crash` utility and `drgn` programmable debugger, providing a unified analysis interface.
## Features
- **Unified Session**: Supports both `crash` and `drgn` engines
- **Session Deduplication**: Automatically reuses existing sessions for the same vmcore
- **Command Persistence**: Output is automatically saved to disk, supporting pagination and search
- **Remote Analysis**: Connects to remote hosts via SSH, no need to download vmcore
- **Multi-Transmission Mode**: Stdio (default) / SSE (HTTP)
- **Intelligent Architecture Identification**: Automatically detects vmcore architecture and selects the corresponding crash version
- **Automatic Compilation**: Built-in crash tool compiler, supporting multiple architectures and compression formats
## Installation
### Prerequisites
- Python 3.10+
- `crash` tool (can be installed through the built-in compiler)
- `python3-dev` (required for compiling PyKdump)
- `drgn` tool (automatically installed via pip)
### Quick Installation
```bash
chmod +x install.sh && ./install.sh
```
### Compiling Crash Tool
```bash
# Activate virtual environment
source venv/bin/activate
# View dependency installation instructions
compile-crash --deps
# Compile x86_64 version
compile-crash
# Compile ARM64 version (for analyzing ARM64 vmcore on x86_64)
compile-crash --arch ARM64
# Compile version with PyKdump support
compile-crash --pykdump-from-source
```
## Usage
### Start Server
```bash
# Stdio mode
crash-mcp
# SSE mode
crash-mcp --transport sse --port 8000
```
### MCP Tools
| Tool | Description |
|------|-------------|
| `open_vmcore_session` | Open vmcore crash dump file for analysis |
| `run_crash_command` | Execute crash command, supporting PyKdump extensions |
| `run_drgn_command` | Execute drgn Python code |
| `close_vmcore_session` | Close current analysis session |
| `get_command_output` | Paginate long command output |
| `search_command_output` | Search command output with regular expression |
| `run_analysis_script` | Run predefined analysis script (requires `DRGN_SCRIPTS_PATH` configuration) |
| `list_analysis_scripts` | List available analysis scripts (requires `DRGN_SCRIPTS_PATH` configuration) |
| `get_crash_info` | Get crash diagnosis report (requires `GET_DUMPINFO_SCRIPT` configuration) |
### Configuration
| Environment Variable | Default Value | Description |
|---------------------|---------------|-------------|
| `CRASH_EXTENSION_LOAD` | `true` | Automatically load extensions |
| `CRASH_MCP_TRUNCATE_LINES` | `20` | Output truncate lines |
| `CRASH_MCP_WORKDIR` | `/tmp/crash-mcp-sessions` | Session working directory |
| `CRASH_MCP_CACHE` | `true` | Enable command cache |
| `LOG_LEVEL` | `INFO` | Log level |
| `GET_DUMPINFO_SCRIPT` | (empty) | Automated diagnosis script command template (e.g., `python3 script.py {vmcore} {vmlinux}`) |
| `DRGN_SCRIPTS_PATH` | (empty) | External drgn script search path (colon-separated) |
### Client Configuration
**Claude Desktop** (`claude_desktop_config.json`):
```json
{
"mcpServers": {
"crash-analysis": {
"command": "/path/to/crash-mcp/venv/bin/crash-mcp"
}
}
}
```
## Example
```python
# Local analysis
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")
# Paginate long output
run_crash_command("ps") # Returns command_id
get_command_output("crash:ps", offset=20, limit=50)
# Search output
search_command_output("crash:bt", "schedule")
# Remote analysis
open_vmcore_session("/var/crash/vmcore", "/usr/lib/debug/vmlinux",
ssh_host="server-01", ssh_user="root")
```
## FAQ
### 1. `no lzo compression support` error
vmcore file uses LZO compression, but crash tool was compiled without LZO support.
```bash
sudo apt-get install liblzo2-dev
compile-crash --clean
```
### 2. Missing GMP/MPFR library
```bash
sudo apt-get install libgmp-dev libmpfr-dev
```
### 3. View all compilation dependencies
```bash
compile-crash --deps
```
## License
[MIT License](LICENSE)