How radareorg/radare2-mcp works
Project Type and Purpose
• This is a small, C-based CLI application that implements an MCP (Model-Client Protocol) server adapter for radare2.
• Purpose: allow AI assistants (e.g., Claude Desktop) to communicate with radare2 via stdin/stdout, enabling binary analysis and file inspection.
• Key indicators: single C source file (r2mcp.c), Dockerfile, Makefile, README describing “MCP server for radare2 with AI assistants.”
File Structure Analysis
• Top-level files:
• r2mcp.c: core server implementation.
• indent.py, .clang-format: coding style tooling.
• Makefile, Dockerfile: build and containerization.
• INSTALL.md, README.md: installation and usage docs.
• debug.txt: runtime logs or development notes.
• No “frontend” or “backend” directories—this is a single-bin service.
• Presence of Dockerfile indicates optional container deployment.
Readme Insights
• Integration points: stdin/stdout message passing using JSON over pipes.
• External service: radare2 CLI (r2pm wraps r2mcp).
• Hosts: client is Claude Desktop, server is r2mcp (or Docker container).
• Configuration: Claude JSON config file specifies command+args.
Main Components
a. Claude Desktop (AI assistant client)
b. MCP Configuration File (claude_desktop_config.json)
c. r2mcp Process (C executable)
d. radare2 Process / Library (spawned or invoked by r2mcp)
e. File System (for binary/file exploration)
f. Optional Docker Container (hosts r2mcp + radare2)
Interactions and Data Flow
• Claude Desktop → (reads JSON config) → launches r2mcp
• Claude Desktop ↔ r2mcp over STDIN/STDOUT (JSON messages, commands & responses)
• r2mcp → spawns / pipes commands to radare2 → receives radare2 output
• r2mcp ↔ File System for directory/file listing or binary inspection
• (Optional) all of the above occur inside Docker container when configured
Architectural Patterns & Design Principles
• “Adapter” pattern: r2mcp adapts the MCP protocol to radare2’s CLI API
• Single-process, pipe-based RPC model (no HTTP or sockets)
• Separation of concerns:
• Client (AI assistant) concerns vs
• Server (r2mcp) mediation vs
• Analysis engine (radare2)
Technologies & Frameworks
• Language: C
• Build: Makefile
• Container: Docker
• Communication: JSON over stdin/stdout
• Integration: radare2 CLI via r2pm / direct binary
Essential Elements to Capture
• Clear component names & roles
• Data flows and directions (JSON, CLI commands, FS access)
• Optional vs mandatory paths (native launch vs Docker)
• Config file ingestion
• Distinction between AI client, adapter, and analysis engine