Purpose
radare2-mcp provides an MCP (Model Context Protocol) server for radare2, with the goal of enabling AI agents to use radare2 for binary analysis and reverse engineering. It supports AI agents such as OpenCode, Mai, VSCode, Claude, and CLION. This implementation is written entirely in C and is based on the native radare2 API.
Main Capabilities
- Can run as a CLI tool, an r2 plugin, and an MCP server.
- Enables seamless binary analysis through radare2.
- Connects to any local or remote r2/iaito session via r2pipe.
- Supports read-only mode, sandbox locking, and tool restrictions.
- Provides fine-grained tool configuration.
- Uses a direct stdin/stdout communication model.
- Supports HTTP MCP server mode, with optional multiplexing via X-Session-ID.
- Optionally provides raw access to run r2 commands or r2js scripts.
Usage
Installation
The simplest installation method is to use r2pm. The r2mcp executable will be copied to the r2pm bindir in the user's home directory. This binary should not be executed directly from the shell; it should only be run when the MCP service handler of the chosen language model starts it.
A Docker image can also be built and used in the MCP client configuration: "command": "docker" "args": ["run", "--rm", "-i", "-v", "/tmp/data:/data", "r2mcp"]
Installing the codex plugin runs the corresponding command, creates a personal marketplace in the home directory, and copies the files from dist/codex-plugin.
Building from source: you can use make to build and install locally; on macOS it places the r2mcp binary into /usr/local/bin; on Windows you can use meson and ninja as in CI.
HTTP Server Mode
Use -H [address:]port to run in HTTP MCP server mode instead of stdin/stdout. When onlya port is specified, it binds only to 127.0.0.1; you must explicitly use 0.0.0.0:port to make it accessible from the network. Enable per-session HTTP state via -X max[:idle_seconds], routed by the X-Session-ID request header. Enable HTTP bearer authentication via -a <token>; clients must send Authorization: Bearer <token> on every GET and POST request. Use -A or -a random to generate a random token at startup, which will be printed once to stderr. The same token setting can also be provided via R2MCP_AUTH_TOKEN; setting it to random generates one. Note: -X requires radare2 ABI 91 or newer, because earlier radare2 headers did not expose the HTTP request header API. On earlier ABIs, -H can still work as a single shared HTTP server, but -X will be ignored. Bearer authentication also requires that request header API.
r2 Core Plugin Mode
The r2 core plugin exposes the r2mcp command within an existing radare2 session. Starting HTTP mode from r2 reuses the current RCore, so MCP tools act on the file and analysis state already loaded in that session. Common subcommands include: r2mcp start or r2mcp http to start the HTTP MCP server in the background; r2mcp stop, r2mcp restart, and r2mcp status to manage the background server; r2mcp logs on|off and r2mcp logs file <path> to control plugin debug logging; r2mcp approve on|off and r2mcp approve url <url> to control supervisor approval; r2mcp yolo on|off to disable approval and expose dangerous run tools; r2mcp config to list the r2mcp.* eval keys. The plugin registers eval keys for the same server options exposed by the CLI, including r2mcp.port, r2mcp.log, r2mcp.logfile, r2mcp.auth, r2mcp.approve, r2mcp.svc, r2mcp.yolo, r2mcp.mini, r2mcp.permissive, r2mcp.run, r2mcp.readonly, r2mcp.ignore_analysis, r2mcp.prompts, r2mcp.prompts.dir, r2mcp.sandbox, r2mcp.sandbox.grain, r2mcp.content, r2mcp.enabled, r2mcp.disabled, r2mcp.session_tools, r2mcp.sessions, r2mcp.sessions.max, r2mcp.sessions.timeout, r2mcp.decompiler and r2mcp.baseurl. When manually loading the plugin with -i, these keys should be set after the plugin is loaded, for example -c 'e r2mcp.port=8765', because radare2 processes early -e options before the temporary plugin initialization.
Using SQL via r2xsql
Install the r2xsql core plugin for the same radare2 build used by r2mcp. In local mode, the sql tool can be used without -r. You can call open_file, analyze and sql and pass arguments. The sql tool passes a statement directly to the loaded SQL core plugin, preserving SQL operators and quoted text; the result is the plugin's text output. It supports SQL writes, so it is excluded from read-only mode (-R). Use it with a local r2mcp server or r2mcp's core plugin; the remote r2 HTTP client mode (-u) does not expose this tool. Installed plugins are loaded automatically; to explicitly load a specific build, you can add -c 'L /absolute/path/core_r2xsql.so' to the r2mcp command. Startup commands run in order before MCP requests or -T tests, and their output is discarded to ensure stdout is valid for MCP. On macOS/Windows, use the actual plugin filename.
Client Integration
Claude Desktop: press CMD + , to open developer settings, edit the configuration file, and restart the client after editing the JSONclient. Configuration file locations: on macOS, ~/Library/Application Support/Claude/claude_desktop_config.json; on Windows, %APPDATA%\Claude\claude_desktop_config.json.
VS Code: add r2mcp to the user configuration to use it with GitHub Copilot Chat. Open the command palette with CMD + Shift + P (macOS) or Ctrl + Shift + P (Windows/Linux), search for and select Copilot: Open User Configuration (on macOS this is usually located at ~/Library/Application Support/Code/User/mcp.json).
Zed: r2mcp can likewise be added to the Zed configuration. Open the command palette, search for agent: open configuration or settings, and add the server as instructed. Note: another LLM agent, such as Claude, Gemini, etc., is required to use it.
Applicable Scenarios
Suitable for scenarios where an AI agent is needed to assist with binary disassembly and reverse engineering analysis. It can connect to local or remote radare2/iaito sessions, and can also reuse already loaded files and analysis state in an existing radare2 session through the core plugin approach.
Limitations
The r2mcp binary should not be executed directly from the shell; it can only be started by the MCP service handler of the chosen language model. HTTP -X session reuse and Bearer authentication require radare2 ABI 91 or newer. The sql tool is unavailable in read-only mode, and the remote r2 HTTP client mode (-u) does not expose this tool. When manually loading the plugin with -i, eval keys need to be set after the plugin is loaded. The specific installation commands, complete examples of each client's configuration JSON, and more subcommand details are not fully given in the official text and are not provided here for now.