Get the FREE Ultimate OpenClaw Setup Guide →

java-class-analyzer

java class反编译mcp server

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio handsomestwei-java-class-analyzer-mcp-server node node_modules/java-class-analyzer-mcp-server/dist/index.js \
  --env NODE_ENV="production" \
  --env JAVA_HOME="C:/Program Files/Java/jdk-11" \
  --env MAVEN_REPO="D:/maven/repository"

How to use

The Java Class Analyzer MCP Server provides an MCP-based service to analyze and decompile Java classes from Maven dependencies. It scans a Maven project's dependencies, builds an index mapping fully-qualified class names to their JAR locations, and uses CFR to decompile class files on demand. It also offers an analysis tool that inspects class structures, methods, fields, and inheritance, and caches results to speed up repeated queries. This enables LLM workflows to access accurate Java source representations for dependencies that aren’t open in the current workspace. Tools exposed via MCP include: scan_dependencies, which builds or refreshes the class index by traversing the project’s Maven dependencies; decompile_class, which fetches and decompiles a specific class to Java source, with optional caching and an adjustable CFR path; and analyze_class, which analyzes a class’s structure and metadata. To use these tools, run the MCP server locally and invoke the tools with the required arguments (e.g., projectPath, className) through your MCP client or the provided test utilities. The server is designed to auto-index on first use, cache decompiled sources by package, and allow external CFR paths for custom decompilation behavior.

How to install

Prerequisites:

  • Node.js and npm installed
  • Java installed (required for CFR and running Java-dependent tasks)
  • Maven installed or available if you want to trigger Maven-based dependency scanning

Installation steps:

  1. Global installation (recommended for quick start):
npm install -g java-class-analyzer-mcp-server

This enables the java-class-analyzer-mcp CLI which can start the MCP server.

  1. Local installation (for project-level usage):
npm install java-class-analyzer-mcp-server
  1. Build from source (optional if you clone the repo):
git clone https://github.com/handsomestWei/java-class-analyzer-mcp-server.git
cd java-class-analyzer-mcp-server
npm install
npm run build
  1. Start the MCP server locally (example using the local install):
node_modules/.bin/java-class-analyzer-mcp start

Or, if you installed globally and configured PATH, you can use:

java-class-analyzer-mcp config -o mcp-client-config.json

Additional notes

Environment variables:

  • NODE_ENV controls logging verbosity (development for debugging, production for performance).
  • MAVEN_REPO specifies the local Maven repository path; if unset, defaults to ~/.m2/repository.
  • JAVA_HOME can be set to point CFR and Java tooling to a specific JDK installation.
  • CFR_PATH can be provided to force a specific CFR jar version.

Common issues and tips:

  • Ensure Maven is installed and reachable if you rely on mvn dependency:tree for indexing.
  • If CFR fails to decompile, verify the CFR jar exists and is accessible; you can override with CFR_PATH.
  • The first use of analyze_class or decompile_class will trigger indexing; subsequent calls will use the cached index unless you disable caching.
  • For large Maven projects, indexing may take time; consider increasing allowed time in your MCP client configuration.

Related MCP Servers

Sponsor this space

Reach thousands of developers