Java反编译工具

vineflower-mcp 是一个通过CLI或下载的jar文件运行Vineflower的服务,用于无头反编译Java JAR文件并索引源代码。

  • by Bardioc1977
  • TypeScript
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 Bardioc1977/vineflower-mcp

使用说明

长春花mcp

MCP stdio服务器,通过CLI或下载的jar运行Vineflower,以无头反编译Java jar并索引源代码。

设置

npm i
npm run dev

可选预取(仅在以下情况下下载葡萄花罐 MCP_VINEFLOWER_AUTO_DOWNLOAD=1 已设置):

MCP_VINEFLOWER_AUTO_DOWNLOAD=1 npm run setup:vineflower

MCP客户端注册

服务器使用stdio,因此每个客户端都需要一个启动命令和args dist/server.js示例 下面假设本地结账和macOS路径。根据需要调整路径和环境。

Codex CLI

在中添加服务器条目 ~/.codex/config.toml:

[mcp_servers.vineflower-mcp]
command = "node"
args = ["/path/to/vineflower-mcp/dist/server.js"]
env = { VINEFLOWER_BIN = "vineflower", VINEFLOWER_THREADS = "4" }

Gemini CLI

创建或更新Gemini MCP配置(通常 ~/.config/gemini-cli/mcp.json):

{
  "mcpServers": {
    "vineflower-mcp": {
      "command": "node",
      "args": ["/path/to/vineflower-mcp/dist/server.js"],
      "env": {
        "VINEFLOWER_BIN": "vineflower",
        "VINEFLOWER_THREADS": "4"
      }
    }
  }
}

克劳德代码

Claude Code使用与Claude Desktop相同的MCP JSON格式。配置位置:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json
  • 窗户: %APPDATA%\\Claude\\claude_desktop_config.json

例子:

{
  "mcpServers": {
    "vineflower-mcp": {
      "command": "node",
      "args": ["/path/to/vineflower-mcp/dist/server.js"],
      "env": {
        "VINEFLOWER_BIN": "vineflower",
        "VINEFLOWER_THREADS": "4"
      }
    }
  }
}

发布版本控制

标签驱动释放。版本格式为 YYYY.MM.DD-N (UTC日期+该日期的提交计数)。

# Update package.json/package-lock.json and server version to match the computed version.
npm run tag:version

# Print the computed tag for HEAD without changing files.
./scripts/get_tag_version.sh

# Update version and create a matching tag.
npm run tag:release

# Push the computed tag to origin.
npm run tag:push

# Apply version, create tag, and push it.
npm run tag:release:push

# Create a matching tag for release.
git tag "$(npm run -s tag:version)"

发布工作流验证推送的标记是否与计算版本匹配。 本地标记脚本需要一个干净的工作树;唯一允许的本地更改是 package.json 和 package-lock.json 由版本凹凸创建。

环境

export VINEFLOWER_BIN="vineflower"
export VINEFLOWER_JAR="/path/to/vineflower.jar"
export MCP_TIMEOUT_MS="1800000"
export MCP_MAX_CAPTURE_CHARS="200000"
export MCP_MAX_JARS="500"
export VINEFLOWER_THREADS="4"
export MCP_VINEFLOWER_AUTO_DOWNLOAD="1"
export VINEFLOWER_VERSION="1.10.1"

如果找不到Vineflower二进制文件,服务器会将安装选项记录到stderr。允许一次性下载 从Maven Central到 .vineflower/vineflower.jar,set MCP_VINEFLOWER_AUTO_DOWNLOAD=1 (需要Java)。

示例工具调用

java_decompile_plan

{
  "searchDir": "/path/to/workspace/jars",
  "jarGlobHint": "service",
  "maxResults": 2000
}

java_decompile_vineflower

{
  "inputJars": ["/path/to/workspace/jars/app.jar"],
  "libraryJars": ["/path/to/workspace/jars/lib.jar"],
  "outputDir": "/path/to/workspace/decompiled/app",
  "overwrite": true,
  "mode": "sources+meta",
  "options": {
    "threads": 4,
    "extraArgs": ["--decompile-generics", "--log-level=info"]
  }
}

java_sources_index

{
  "sourceRoot": "/path/to/workspace/decompiled/app",
  "maxFileBytes": 500000,
  "maxFiles": 50000
}