使用 MCP 控制 Recaf4.0,实现诸如反编译/重命名等方法
概览
通过模型上下文协议(MCP)使AI助手能够控制Recaf 4.x——反编译、搜索、分析、编辑字节码、编译Java、组装/反汇编JASM、diff类、修补工作区、去混淆并直接从AI工作流程导出Java字节码。 该插件采用双进程架构,将AI助手与Recaf强大的字节码分析引擎连接起来: - — 运行于 Recaf 进程内。通过 CDI(雅加达)注入 Recaf 服务,并将其作为 HTTP 端点暴露于 localhost:9847。- — 由 AI 客户端启动的独立胖 JAR 服务器。通过 STDIO JSON-RPC 与 AI 通信,并通过 HTTP 向桥接服务器转发工具调用。 这种分离是必要的,因为 Recaf 作为一个拥有自身模块系统的 JavaFX 桌面应用程序运行,而 MCP 需要基于 STDIO 的进程,AI 客户端可以生成和管理。 - — Recaf 4.x 要求。确保你的 PATH 上的 Java 是 JDK 22 或更高。- — 该插件基于快照 d07958a5c7 构建。
概述(AI 翻译)
通过模型上下文协议(MCP)使AI助手能够控制Recaf 4.x——反编译、搜索、分析、编辑字节码、编译Java、组装/反汇编JASM、diff类、修补工作区、去混淆并直接从AI工作流程导出Java字节码。
中文文档
工作原理
该插件采用双进程架构,将AI助手与Recaf强大的字节码分析引擎连接起来:
- Recaf 插件(桥服务器) — 运行于 Recaf 进程内。通过 CDI(雅加达)注入 Recaf 服务,并将其作为 HTTP 端点暴露于
localhost:9847。 - MCP 服务器 — 由 AI 客户端启动的独立胖 JAR 服务器。通过 STDIO JSON-RPC 与 AI 通信,并通过 HTTP 向桥接服务器转发工具调用。
这种分离是必要的,因为 Recaf 作为一个拥有自身模块系统的 JavaFX 桌面应用程序运行,而 MCP 需要基于 STDIO 的进程,AI 客户端可以生成和管理。
可用MCP工具(28)
工作区管理
| 工具 | 说明 | 关键参数 |
|---|---|---|
open_jar |
打开JAR、APK或类文件进行分析 | path — 绝对文件路径。返回workspaceId。 |
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
Recaf MCP Plugin
Enable AI assistants to control Recaf 4.x through the Model Context Protocol (MCP) — decompile, search, analyze, edit bytecode, compile Java, assemble/disassemble JASM, diff classes, patch workspaces, deobfuscate, and export Java bytecode directly from your AI workflow.
How It Works
The plugin uses a dual-process architecture to bridge AI assistants with Recaf’s powerful bytecode analysis engine:
┌─────────────────┐ STDIO / JSON-RPC ┌─────────────────┐ HTTP :9847 ┌─────────────────┐
│ AI Assistant │ ◄──────────────────────► │ MCP Server │ ◄────────────────► │ Recaf Plugin │
│ (Claude Code, │ │ (Standalone JAR) │ │ (Bridge Server) │
│ Cursor, etc.) │ └─────────────────┘ └────────┬────────┘
└─────────────────┘ │
┌────────┴────────┐
│ Recaf 4.x │
│ (Analysis Engine)│
└─────────────────┘
- Recaf Plugin (Bridge Server) — Runs inside Recaf’s process. Injects Recaf services via CDI (Jakarta) and exposes them as HTTP endpoints on
localhost:9847. - MCP Server — A standalone fat JAR launched by the AI client. Communicates with the AI via STDIO JSON-RPC and forwards tool calls to the Bridge Server over HTTP.
This separation is necessary because Recaf runs as a JavaFX desktop application with its own module system, while MCP requires a STDIO-based process that the AI client can spawn and manage.
Available MCP Tools (28)
Workspace Management
| Tool | Description | Key Parameters |
|---|---|---|
open_jar |
Open a JAR, APK, or class file for analysis | path — absolute file path. Returns workspaceId. |
close_workspace |
Close the current or a specific workspace | workspaceId (optional) — close by ID |
switch_workspace |
Switch to a previously opened workspace | workspaceId — ID returned by open_jar |
list_workspaces |
List all registered workspaces | — |
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →配置
{
"mcpServers": {
"recaf": {
"command": "java",
"args": ["-jar", "/absolute/path/to/build/mcp/recaf-mcp-server-1.3.0.jar"]
}
}
}