What is 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. It supports decompiling Java .class files from file paths, package names, and JAR files, with a full MCP-compatible API and clean error handling.
Documentation
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:
npx -y @idachev/mcp-javadc
Option 2: Global Installation
npm install -g @idachev/mcp-javadc
# Run the server
mcpjavadc
Option 3: From Source
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):
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-package tool with explicit classpath
Using the decompile-from-jar tool 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 .class to 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
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: