返回市场
雷达2-MCP

雷达2-MCP

作者:radareorg108 星标更新:2025-11-05

项目介绍

Radare2 MCP Server

ci radare2

<img width="400" alt="r2mcp logo" src="./r2mcp.png" />

一个使用AI代理(如OpenCode、Mai、VSCode、Claude、CLION等)与radare2配合工作的MCP服务器。

功能

此实现提供:

  • 💻 完全使用C语言编写,并使用原生r2 API
  • 🧩 可从命令行、作为r2插件或作为MCP服务器运行
  • 🔍 无缝集成二进制分析功能
  • 🔗 通过r2pipe连接到任何本地或远程的r2/iaito会话
  • 🔒 支持只读模式、沙箱锁定和工具限制
  • 🔩 细粒度工具配置
  • 🔁 直接的stdin/stdout通信模型
  • 🛠️ 可选的原始访问权限,用于执行r2命令或r2js脚本

安装

<img width="400" alt="Screenshot_2025-03-22_at_5 34 47_PM" src="https://gips3.baidu.com/it/u=958247845,1431349846&fm=3081&app=3081&f=PNG?w=1434&h=1132" /> <img width="400" alt="Screenshot_2025-03-22_at_5 36 17_PM" src="https://gips0.baidu.com/it/u=3300552666,1221514382&fm=3081&app=3081&f=PNG?w=1496&h=1392" />

使用r2pm

最简单的安装方式是使用r2pm

$ r2pm -Uci r2mcp

r2mcp可执行文件将被复制到您家目录下的r2pm的bindir中。然而,这个二进制文件不应直接从shell执行;它只能在由您选择的语言模型的MCP服务处理器启动时工作。

$ r2pm -r r2mcp

这是常见的mcpServer JSON配置文件:

{
  "mcpServers": {
    "radare2": {
      "command": "r2pm",
      "args": ["-r", "r2mcp"]
    }
  }
}

使用Docker

或者,您可以构建Docker镜像:

docker build -t r2mcp .

更新您的MCP客户端配置文件(见下文),以使用Docker镜像:

  • "command": "docker"
  • "args": ["run", "--rm", "-i", "-v", "/tmp/data:/data", "r2mcp"].

配置

Claude Desktop集成

在Claude Desktop应用中,按CMD + ,打开开发者设置。编辑配置文件并在编辑JSON文件后重启客户端:

  1. 找到您的Claude Desktop配置文件:

    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
  2. 在您的配置文件中添加以下内容:

{
  "mcpServers": {
    "radare2": {
      "command": "r2pm",
      "args": ["-r", "r2mcp"]
    }
  }
}

VS Code集成

要使用GitHub Copilot Chat中的r2mcp,请将其添加到您的用户配置中(参见其他选项此处):

  1. 使用CMD + Shift + P(macOS)或Ctrl + Shift + P(Windows/Linux)打开命令面板。
  2. 搜索并选择Copilot: Open User Configuration(通常位于macOS的~/Library/Application Support/Code/User/mcp.json)。
  3. 在您的配置文件中添加以下内容:
{
  "servers": {
    "radare2": {
      "type": "stdio",
      "command": "r2pm",
      "args": ["-r", "r2mcp"]
    }
  },
  "inputs": []
}

Zed集成

您也可以通过添加到您的配置来使用Zed中的r2mcp:

  1. 打开命令面板:CMD + Shift + P(macOS)或Ctrl + Shift + P(Windows/Linux)。
  2. 搜索agent: open configuration或搜索settings
  3. 添加您的服务器如下所示:
  "context_servers": {
    "r2-mcp-server": {
      "source": "custom",
      "command": "r2pm",
      "args": ["-r", "r2mcp"],
      "env": {}
    }
  }

注意:您需要另一个LLM代理,如Claude、Gemini或其他,才能使用它。

开发者指南

从源代码构建

Linux/macOS

要本地测试服务器,可以使用make进行编译和安装:

make install

这将在macOS上编译服务器并将r2mcp二进制文件放置在/usr/local/bin

Windows

对于Windows,只需像CI中那样使用meson和ninja:

meson b
ninja -C b