MCP Java Decompiler Server
Decompile Java class files from file paths, package names, or JAR files using a JavaScript port of the CFR decompiler.
MCP Java Decompiler Server (v1.2.4)
A Model Context Protocol (MCP) server for decompiling Java class files. This server allows AI assistants and tools that implement the MCP protocol to decompile Java bytecode into readable source code.
Features
- Decompile Java .class files from file path
- Decompile Java classes from package name (e.g., java.util.ArrayList)
- Decompile Java classes from JAR files
- Specify which class to extract from JAR files
- Full MCP-compatible API
- Stdio transport for seamless integration
- Clean error handling
- Temporary file management
Prerequisites
- Node.js 16+
- npm
- No Java requirement (using JavaScript port of CFR decompiler)
Installation
Option 1: Using npx (Recommended)
You can run the server directly with npx without installing:
# Run the server
npx -y @idachev/mcp-javadc
Option 2: Global Installation
# Install globally
npm install -g @idachev/mcp-javadc
# Run the server
mcpjavadc
Option 3: From Source
# Clone the repository
git clone https://github.com/idachev/mcp-javadc.git
cd mcp-javadc
# Install dependencies
npm install
# Run the server
npm start
Usage
Quick Start
The easiest way to run the server:
npm start
Integrating with MCP Clients
To use with an MCP client (like Claude or another MCP-compatible AI assistant):
# Configure the MCP client to use this server
npx some-mcp-client --server "node /path/to/mcp-javadc/index.js"
Adding to Claude Code
To add this tool to Claude Code:
claude mcp add javadc -s project -- npx -y @idachev/mcp-javadc
Example MCP client configuration:
{
"mcpServers": {
"javaDecompiler": {
"command": "npx",
"args": ["-y", "@idachev/mcp-javadc"],
"env": {
"CLASSPATH": "/path/to/java/classes"
}
}
}
}
MCP Tools
The server provides three main tools:
1. decompile-from-path
Decompiles a Java .class file from a file path.
Parameters:
classFilePath: Absolute path to the Java .class file
Example request:
{
"jsonrpc": "2.0",
"id": "1",
"method": "mcp.tool.execute",
"params": {
"tool": "decompile-from-path",
"args": {
"classFilePath": "/path/to/Example.class"
}
}
}
2. decompile-from-package
Decompiles a Java class from a package name.
Parameters:
packageName: Fully qualified Java package and class name (e.g., java.util.ArrayList)classpath: (Optional) Array of classpath directories to search
Example request:
{
"jsonrpc": "2.0",
"id": "2",
"method": "mcp.tool.execute",
"params": {
"tool": "decompile-from-package",
"args": {
"packageName": "java.util.ArrayList",
"classpath": ["/path/to/rt.jar", "/path/to/classes"]
}
}
}
3. decompile-from-jar
Decompiles a Java class from a JAR file.
Parameters:
jarFilePath: Absolute path to the JAR file (required)className: Fully qualified class name to extract from the JAR (required) (e.g., "com.example.MyClass")
Example request:
{
"jsonrpc": "2.0",
"id": "3",
"method": "mcp.tool.execute",
"params": {
"tool": "decompile-from-jar",
"args": {
"jarFilePath": "/path/to/example.jar",
"className": "com.example.MyClass"
}
}
}
Known Issues
Java Class Decompilation
The CFR decompiler (@run-slicer/cfr) is a JavaScript port of the popular CFR Java decompiler. It works well with:
- Standard Java class files
- Classes that are part of a known package structure
- Modern Java features (all Java versions)
- JAR files containing Java classes
If you encounter issues with a specific class file, try:
- Using the
decompile-from-packagetool with explicit classpath - Using the
decompile-from-jartool with explicit class name - Ensuring the class file is a valid Java bytecode file
- Checking for corrupt class files or JAR archives
Maven Repository Usage
When working with JAR files from Maven repositories:
- Use the
find ~/.m2 -name "*dependency-name*jar"command to locate JAR files - Filter out source and javadoc JARs using
grep -v source | grep -v javadoc - Use
jar tf your-jar-file.jar | grep .classto list available classes in a JAR - Check that class names match the package structure in the JAR
Configuration
Environment Variables
CLASSPATH: Java classpath for finding class files (used when no classpath is specified)
Development
# Run in development mode
npm run dev
# Create test fixtures (creates sample Java class for testing)
npm run test:setup
# Run tests
npm test
# Run linting
npm run lint
# Fix linting issues
npm run lint:fix
# Format code
npm run format
# Run with MCP Inspector for interactive testing
npx @modelcontextprotocol/inspector node ./index.js
Testing with MCP Inspector
You can use the official MCP Inspector tool to test the server functionality interactively:
# Install and run the MCP Inspector with the decompiler server
npx @modelcontextprotocol/inspector node ./index.js
The Inspector provides a user-friendly web interface that allows you to:
- List all available tools
- Execute the decompilation tools with custom parameters
- View and explore the decompiled output
- Test different inputs and error scenarios
This is especially useful for debugging and understanding the MCP server's capabilities before integrating it with other applications.
How It Works
- The server uses the CFR decompiler (@run-slicer/cfr - a JavaScript port of the popular CFR Java decompiler)
- When a decompile request is received, the server:
- Reads the class file data directly or extracts it from a JAR file
- Processes the class file with CFR decompiler
- Returns the formatted source code
- For JAR files, the server:
- Creates a temporary directory for extraction
- Extracts the JAR contents
- Decompiles the specified class (or first class if none specified)
- Cleans up the temporary directory
License
ISC
Related Servers
Scout Monitoring MCP
sponsorPut performance and error data directly in the hands of your AI assistant.
Alpha Vantage MCP Server
sponsorAccess financial market data: realtime & historical stock, ETF, options, forex, crypto, commodities, fundamentals, technical indicators, & more
Bazaar MCP Server
MCP server providing x402 micropayment-powered developer tools including screenshot capture, AI analysis, PDF generation, code security scanning, and dependency auditing via USDC payments on Base.
FAL FLUX.1 Kontext [Max]
A frontier image generation and editing model with advanced text rendering and contextual understanding, powered by the FAL AI API.
Change8
Breaking Change Alerts for Humans and AI Agents.
Remote MCP Server (Authless)
An authentication-free, remote MCP server deployable on Cloudflare Workers. Customize tools directly in the source code and deploy via Cloudflare or locally.
IBM wxflows
Tool platform by IBM to build, test and deploy tools for any data source
P4 MCP Server
Perforce P4MCP Server is a Model Context Protocol (MCP) server that integrates with the Perforce P4 version control system.
Storybook MCP
A universal MCP server that connects to any Storybook site and extracts documentation in real-time using Playwright. Use it with any AI or client that supports MCP (Model Context Protocol)—Cursor, Claude Desktop, Windsurf, or other MCP hosts.
EdgeOne Pages MCP
An MCP server implementation using EdgeOne Pages Functions for intelligent chat applications.
ABP.IO MCP Server
An MCP server for ABP.IO that enables AI models to interact with your ABP applications and framework.
Luskad MCP
Provides access to coding rules and examples for your projects.