loading…
Search for a command to run...
loading…
An MCP-based Java decompilation tool that uses the CFR decompiler to convert .class and .jar files into readable Java source code. It features multi-threaded ba
An MCP-based Java decompilation tool that uses the CFR decompiler to convert .class and .jar files into readable Java source code. It features multi-threaded batch processing and direct file system output to handle large-scale decompilation while bypassing token limits.
一个基于 MCP (Model Context Protocol) 的 Java 反编译工具,使用 CFR 反编译器对 .class 和 .jar 文件进行反编译。
问题: 当反编译大量文件时,如果将所有结果作为字符串返回,可能超过 MCP 的 token 限制(例如 413,072 字符)。
解决方案:
直接保存到文件系统(推荐)
save_to_file 参数(默认 true)实时进度显示
show_progress 参数(默认 true)[1/46] 处理中: Controller.class详细统计报告
场景 1:反编译大量文件(推荐方式)
# 使用 8 个线程并发处理,大幅提升速度
decompile_directory(
directory_path="/path/to/classes",
output_dir="/path/to/output",
save_to_file=True, # 默认值
show_progress=True, # 显示进度
max_workers=8 # 8 线程并发
)
场景 2:反编译少量文件并查看内容
# 返回反编译内容(仅适用于小文件)
decompile_file(
file_path="/path/to/MyClass.class",
save_to_file=False # 返回内容而不是保存
)
场景 3:静默批量处理
# 不显示详细进度,仅返回统计,单线程处理
decompile_files(
file_paths=[...],
show_progress=False, # 仅显示统计信息
max_workers=1 # 单线程
)
无需安装,直接在 MCP 配置中使用(可让ai自动下载cfr-0.152.jar然后你手动配置路径):
{
"mcpServers": {
"java-decompiler": {
"type": "stdio",
"command": "uvx",
"args": ["java-decompile-mcp"],
"env": {
"CFR_PATH": "/你的路径/cfr-0.152.jar"
},
"disabled": false
}
}
}
# 克隆项目
git clone <repository-url>
cd java-decompile-mcp
# 创建虚拟环境并安装依赖
uv venv
source .venv/bin/activate # macOS/Linux
# 或 .venv\Scripts\activate # Windows
uv pip install "mcp>=1.0.0"
在 .kiro/settings/mcp.json 或 claude_desktop_config.json 中添加:
{
"mcpServers": {
"java-decompiler": {
"command": "uvx",
"args": ["java-decompile-mcp"],
"disabled": false
}
}
}
在 .kiro/settings/mcp.json 中添加:
{
"mcpServers": {
"java-decompiler": {
"command": "uv",
"args": [
"--directory",
"/项目路径",
"run",
"main.py"
],
"disabled": false,
"autoApprove": []
}
}
}
⚠️ 本地开发模式需要将路径替换为实际的项目路径
GitHub: https://github.com/RuoJi6/java-decompile-mcp
反编译单个文件
参数:
file_path (必需): 要反编译的文件路径output_dir (可选): 输出目录,默认为文件所在目录下的 decompiled 文件夹save_to_file (可选): 是否直接保存到文件系统,默认 true(推荐)示例:
反编译 /path/to/MyClass.class 到 /output/dir
返回结果:
✅ 反编译成功
源文件: /path/to/MyClass.class
输出目录: /output/dir
生成文件数: 1
提示: 反编译结果已保存到文件系统
批量反编译多个文件(支持多线程)
参数:
file_paths (必需): 文件路径列表output_dir (可选): 输出目录save_to_file (可选): 是否直接保存到文件系统,默认 trueshow_progress (可选): 是否显示详细进度,默认 truemax_workers (可选): 最大并发线程数,默认 4(设为 1 则单线程)示例:
反编译以下文件:
- /path/to/Class1.class
- /path/to/Class2.class
- /path/to/app.jar
使用 8 个线程并发处理
返回结果:
✅ [1/3] 成功: Class1.class
✅ [2/3] 成功: Class2.class
✅ [3/3] 成功: app.jar
============================================================
📊 反编译完成统计
============================================================
✅ 成功: 3
❌ 失败: 0
⏭️ 跳过: 0
📁 总计: 3 个文件
📄 生成: 46 个 .java 文件
📂 输出目录: /output/dir
🔧 并发线程: 4
============================================================
💾 反编译结果已保存到文件系统
反编译目录下所有 .class 和 .jar 文件(支持多线程)
参数:
directory_path (必需): 目录路径output_dir (可选): 输出目录recursive (可选): 是否递归子目录,默认 truesave_to_file (可选): 是否直接保存到文件系统,默认 trueshow_progress (可选): 是否显示详细进度,默认 truemax_workers (可选): 最大并发线程数,默认 4示例:
反编译 /path/to/classes 目录下的所有 class 文件,使用 8 个线程
返回结果:
📂 扫描目录: /path/to/classes
🔍 找到 46 个文件待反编译
📤 输出目录: /path/to/classes/decompiled
🔧 并发线程: 4
✅ [1/46] 成功: Controller1.class
✅ [2/46] 成功: Controller2.class
...
✅ [46/46] 成功: Utils.class
============================================================
📊 反编译完成统计
============================================================
✅ 成功: 46
❌ 失败: 0
⏭️ 跳过: 0
📁 总计: 46 个文件
📄 生成: 46 个 .java 文件
📂 输出目录: /path/to/classes/decompiled
🔧 并发线程: 4
============================================================
💾 反编译结果已保存到文件系统
下载 CFR 反编译器
参数:
target_dir (可选): 下载目标目录,默认当前工作目录检查 CFR 反编译器状态
获取 Java 版本信息
CFR 反编译器查找顺序:
CFR_PATHcfr-*.jar在 mcp.json 的 env 中设置:
{
"mcpServers": {
"java-decompiler": {
"command": "uv",
"args": ["--directory", "/项目路径", "run", "main.py"],
"env": {
"CFR_PATH": "/你的路径/cfr-0.152.jar"
}
}
}
}
将 cfr-*.jar 文件放到项目根目录,会自动识别。
调用 download_cfr_tool 工具,会自动从镜像下载到项目目录。
# 激活虚拟环境
source .venv/bin/activate
# 运行 MCP 服务器
uv run main.py
MIT License
Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"java-decompiler-mcp-server": {
"command": "npx",
"args": []
}
}
}