karellen-rr-mcp
Enables LLM-powered debugging with rr reverse execution, allowing record and replay of program execution via GDB/MI for forward and reverse state inspection.
README
MCP Server for rr Reverse Debugging (karellen-rr-mcp)
Overview
karellen-rr-mcp is an MCP (Model Context Protocol)
server that enables any MCP-compliant LLM client to use rr for
reverse debugging. Instead of iteratively adding debug output and rebuilding, the LLM can
record a failing test with rr, then replay it with full forward and reverse debugging via
GDB/MI, inspecting program state without modifying source code.
Requirements
- Linux on x86-64 (rr only supports Linux; aarch64 is experimental)
- rr installed and on PATH
- GDB installed and on PATH (used by rr for debugging)
- Python >= 3.10
perf_event_paranoidset to1to allow recording:sudo sysctl kernel.perf_event_paranoid=1
Installing rr and GDB
Via pip (using karellen-rr):
pip install karellen-rr-mcp[rr]
This installs rr as a pip package alongside karellen-rr-mcp. GDB must still be installed separately via your system package manager.
Fedora / RHEL / CentOS:
sudo dnf install rr gdb
Ubuntu / Debian:
sudo apt install rr gdb
Arch Linux:
sudo pacman -S rr gdb
Configuring perf_event_paranoid
rr requires access to hardware performance counters. Set perf_event_paranoid to 1:
sudo sysctl kernel.perf_event_paranoid=1
To make this persistent across reboots:
echo 'kernel.perf_event_paranoid=1' | sudo tee /etc/sysctl.d/50-rr.conf
Verify the setup
rr record /bin/true && echo "rr is working"
If this fails with a permissions error, check perf_event_paranoid. If it fails inside
a container or VM, note that rr requires access to CPU performance counters — it does
not work in most containers (Docker, Podman) or VMs unless hardware PMU passthrough is
configured.
Installation
pip install karellen-rr-mcp
Or with pipx for an isolated environment:
pipx install karellen-rr-mcp
Claude Code Integration
Claude Code plugin (recommended)
The plugin automatically configures the MCP server and includes:
- Crash detection hook that suggests rr when a Bash command exits with a signal (SIGSEGV, SIGABRT, SIGBUS, etc.) or output contains crash/sanitizer signatures
/karellen-rr-mcp:rr-debugskill that walks through the full record-replay-analyze workflow step by steprr-investigatoragent that Claude can spawn to autonomously investigate crashes using rr reverse execution
From the Karellen plugins marketplace:
claude plugin marketplace add karellen/claude-plugins
claude plugin install karellen-rr-mcp@karellen-plugins
Or from the official Anthropic marketplace (if accepted):
claude plugin install karellen-rr-mcp@claude-plugins-official
Or load directly from a local checkout for testing:
claude --plugin-dir /path/to/karellen-rr-mcp
Manual MCP server configuration
If you prefer not to use the plugin, you can configure the MCP server directly. This gives you the MCP tools but not the skill, agent, or crash detection hook.
Using the CLI:
claude mcp add --transport stdio karellen-rr-mcp -- karellen-rr-mcp
Or manually add to ~/.claude.json (user scope) or .mcp.json in your project root
(project scope, shared via version control):
{
"mcpServers": {
"karellen-rr-mcp": {
"type": "stdio",
"command": "karellen-rr-mcp"
}
}
}
If installed with pipx:
claude mcp add --transport stdio karellen-rr-mcp -- pipx run karellen-rr-mcp
or manually:
{
"mcpServers": {
"karellen-rr-mcp": {
"type": "stdio",
"command": "pipx",
"args": ["run", "karellen-rr-mcp"]
}
}
}
Auto-approve rr tools
By default Claude Code will prompt for confirmation before each rr_* tool call.
You can approve individually by selecting "Yes, and don't ask again" when prompted.
To auto-approve all tools upfront, add a permission rule to your user settings
(~/.claude/settings.json):
{
"permissions": {
"allow": [
"mcp__plugin_karellen-rr-mcp_karellen-rr-mcp__*",
"mcp__karellen-rr-mcp__*"
]
}
}
The first rule covers plugin-loaded tools, the second covers manual MCP configuration.
Or for a project-scoped setting, add the same rule to .claude/settings.json in your
project root (this file can be committed to version control so all team members get it).
Available Tools
Session Lifecycle
| Tool | Description |
|---|---|
rr_record |
Record a command with rr. Returns trace directory path. |
rr_replay_start |
Start replay session (launches rr gdbserver + GDB/MI). |
rr_replay_stop |
Stop current replay session, clean up. |
rr_list_recordings |
List available rr trace recordings. |
rr_ps |
List processes in a trace recording (PID, PPID, exit code, command). |
rr_traceinfo |
Get trace metadata (header info in JSON format). |
rr_rm |
Remove an rr trace recording. |
rr_when |
Get current rr event number (position in trace). |
Breakpoints
| Tool | Description |
|---|---|
rr_breakpoint_set |
Set breakpoint at function/file:line/address. |
rr_breakpoint_remove |
Remove a breakpoint. |
rr_breakpoint_list |
List all breakpoints. |
rr_watchpoint_set |
Set hardware watchpoint (write/read/access). |
Execution Control
| Tool | Description |
|---|---|
rr_continue |
Continue forward or backward. |
rr_step |
Step into (forward or reverse). |
rr_next |
Step over (forward or reverse). |
rr_finish |
Run to function return (or call site if reverse). |
rr_run_to_event |
Jump to specific rr event number. |
Thread and Frame Navigation
| Tool | Description |
|---|---|
rr_thread_list |
List all threads with state and location. |
rr_thread_select |
Switch to a different thread. |
rr_select_frame |
Select a stack frame for inspection (locals/evaluate use that frame). |
State Inspection
| Tool | Description |
|---|---|
rr_backtrace |
Get call stack. |
rr_evaluate |
Evaluate C/C++ expression in current context. |
rr_locals |
List local variables with values. |
rr_read_memory |
Read raw memory bytes. |
rr_registers |
Read CPU registers. |
rr_source_lines |
List source code around current position. |
Checkpoints
| Tool | Description |
|---|---|
rr_checkpoint_save |
Save checkpoint at current position. |
rr_checkpoint_restore |
Restore to saved checkpoint. |
Configuration
Timeouts
All timeouts are configurable via environment variables (in seconds). Set them in your MCP server configuration:
{
"mcpServers": {
"karellen-rr-mcp": {
"type": "stdio",
"command": "karellen-rr-mcp",
"env": {
"RR_MCP_TIMEOUT_FORWARD": "300",
"RR_MCP_TIMEOUT_REVERSE": "600"
}
}
}
}
| Variable | Default | Description |
|---|---|---|
RR_MCP_TIMEOUT_STARTUP |
30 | Waiting for rr gdbserver to start listening |
RR_MCP_TIMEOUT_CONNECT |
60 | GDB connecting to rr (includes symbol loading) |
RR_MCP_TIMEOUT_FORWARD |
120 | Forward execution (continue, step, next, finish) |
RR_MCP_TIMEOUT_REVERSE |
300 | Reverse execution |
RR_MCP_TIMEOUT_BREAKPOINT |
30 | Breakpoint/watchpoint operations |
RR_MCP_TIMEOUT_EVAL |
30 | State inspection (backtrace, evaluate, locals, etc.) |
For large binaries (e.g. MariaDB, Firefox), you may need to increase RR_MCP_TIMEOUT_CONNECT
(symbol loading can take 20+ seconds) and RR_MCP_TIMEOUT_FORWARD (replaying to a
breakpoint deep in execution can take minutes).
Troubleshooting
AMD Zen CPUs
rr does not work reliably on AMD Zen CPUs unless the hardware SpecLockMap optimization is disabled. When running rr on Zen you may see:
On Zen CPUs, rr will not work reliably unless you disable the hardware SpecLockMap optimization.
Workaround: run the zen_workaround.py script from the
rr source tree as root:
sudo python3 scripts/zen_workaround.py
This fix must be reapplied after each reboot or suspend. To make it persist, you must also stabilize the Speculative Store Bypass (SSB) mitigation by adding one of the following kernel command-line parameters:
spec_store_bypass_disable=on— fully enables SSB mitigation (has performance implications)nospec_store_bypass_disable— fully disables SSB mitigation (has security implications)
Alternatively, build and load the zen_workaround.ko kernel module from the rr source
tree, which prevents SSB mitigation from resetting the workaround without requiring
kernel parameters.
See the rr Zen wiki page for full details.
MSR kernel module not loaded
The zen_workaround.py script accesses CPU model-specific registers via /dev/cpu/0/msr,
which requires the msr kernel module. On many distributions this module is not loaded
by default. If the script fails, load it manually:
sudo modprobe msr
To make this persistent across reboots:
echo 'msr' | sudo tee /etc/modules-load.d/msr.conf
Note: on systems with Secure Boot enabled, the msr module may fail to load because
it is not signed. You may need to either disable Secure Boot in your UEFI/BIOS settings,
or sign the module with your own Machine Owner Key (MOK).
MADV_GUARD_INSTALL crash on kernel 6.13+ with glibc 2.42+
Linux 6.13 introduced MADV_GUARD_INSTALL (madvise advice 102) for lightweight stack
guard pages. glibc 2.42+ (e.g. Fedora 43) uses this in pthread_create. rr 5.9.0
(the latest release, from February 2025) does not recognize this madvise advice value
and crashes with:
Assertion `t->regs().syscall_result_signed() == -syscall_state.expect_errno' failed to hold.
Expected EINVAL for 'madvise' but got result 0 (errno SUCCESS); unknown madvise(102)
This was fixed in rr git master (commit 34ff3a7, August 2025) but has not been included in a release yet. You must build rr from source to get the fix:
git clone https://github.com/rr-debugger/rr.git
cd rr
mkdir build && cd build
cmake ..
make -j$(nproc)
sudo make install
See rr-debugger/rr#4044 and rr-debugger/rr#3995 for details.
License
Apache-2.0
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。