- Home
- MCP servers
- Java Class Analyzer
Java Class Analyzer
- typescript
21
GitHub Stars
typescript
Language
6 months ago
First Indexed
2 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
Installation
Add the following to your MCP client configuration file.
Configuration
View docs{
"mcpServers": {
"handsomestwei-java-class-analyzer-mcp-server": {
"command": "java-class-analyzer-mcp",
"args": [
"start"
],
"env": {
"NODE_ENV": "production",
"JAVA_HOME": "C:/Program Files/Java/jdk-11",
"MAVEN_REPO": "D:/maven/repository"
}
}
}
}This MCP server provides a Java class analysis service that scans Maven project dependencies, decompiles .class files, and exposes detailed class information for large language models to analyze Java code accurately. It makes it practical to inspect external dependencies without opening source jars, improving code synthesis and reducing errors when combining internal and external code.
How to use
You run the Java Class Analyzer MCP Server locally and connect your MCP client to it. Start the server using either a globally installed command or a locally installed package, then use the MCP tools to scan dependencies, decompile specific classes, and analyze class structures. The MCP server offers three primary tools: scan_dependencies to build a class-to-jar index, decompile_class to obtain Java source from a class, and analyze_class to inspect a class’s structure, fields, methods, and inheritance.
Typical usage pattern: start the MCP server, ensure your Maven repository is accessible, and perform the following actions as needed: - Scan dependencies for a given Maven project to build or refresh the class index. - Decompile a target class to obtain its Java source. - Analyze a class to retrieve its full structure and metadata for downstream code analysis.
How to install
Prerequisites: Node.js and npm must be available on your system. You may also need a Java Runtime to support CFR decompilation if running in environments without built-in CFR.
Step-by-step installation options follow.
# Global installation (recommended)
npm install -g java-class-analyzer-mcp-server
# After global install, you can start the MCP server with:
# This is the runtime command to use for the MCP server
java-class-analyzer-mcp start
Configuration and runtime options
Configure how you run the MCP server in your MCP client configuration. The server can be started in two ways: through a globally installed command or via a local package. Use either configuration depending on your setup.
Global install configuration example (mcp client config):
{
"mcpServers": {
"java_class_analyzer": {
"command": "java-class-analyzer-mcp",
"args": ["start"],
"env": {
"NODE_ENV": "production",
"MAVEN_REPO": "D:/maven/repository",
"JAVA_HOME": "C:/Program Files/Java/jdk-11"
}
}
}
}
Local install configuration example (mcp client config):
{
"mcpServers": {
"java_class_analyzer": {
"command": "node",
"args": [
"node_modules/java-class-analyzer-mcp-server/dist/index.js"
],
"env": {
"NODE_ENV": "production",
"MAVEN_REPO": "D:/maven/repository",
"JAVA_HOME": "C:/Program Files/Java/jdk-11"
}
}
}
}
Available MCP tools and their purpose
Use these tools to interact with the MCP server for specific tasks.
-
scan_dependencies: Build an index mapping fully-qualified class names to JAR paths by scanning a Maven project’s dependencies.
-
decompile_class: Decompile a specific Java class to Java source code, optionally using a cache and a configurable CFR decompiler path.
-
analyze_class: Analyze a class’s structure, including its methods, fields, and inheritance information.
Caching and indexing
The server automatically creates an index and caches decompiled results to improve performance. It caches class indices in .mcp-class-index.json and stores decompiled sources under .mcp-decompile-cache/ following a package-based directory structure. Temporary files are kept under .mcp-class-temp/ for intermediate processing.
Troubleshooting and notes
Common issues include Maven command failures, CFR decompilation problems, or class-not-found errors. Ensure Maven is installed and available in PATH, provide a CFR path if you need a specific version, and verify that the target class name is correct and present in the project dependencies.
Available tools
scan_dependencies
Scans a Maven project to enumerate dependencies and builds a class-to-jar index for fast lookup.
decompile_class
Decompiles a specific Java class to Java source, with optional caching and configurable CFR path.
analyze_class
Analyzes a Java class to reveal its structure, methods, fields, and inheritance relationships.