MCP Connector

Decompile Java Code with CFR

Java Decompiler MCP Server turns Java .class files, packages, or JAR entries into readable source, no JVM required.

Works with githubnpm

91
Spark score
out of 100
Updated Jun 2025
Version 1.2.4
Models

Add to Favorites

Why it matters

Decompile Java class files into readable source code. This asset integrates with the CFR decompiler to process files from paths, package names, or JAR archives.

Outcomes

What it gets done

01

Decompile Java .class files from a given file path.

02

Decompile Java classes by their package name (e.g., java.util.ArrayList).

03

Decompile Java classes from JAR files, specifying the exact class to extract.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/vb-java-decompiler | bash

Capabilities

Tools your agent gets

decompile-from-path

Decompiles a Java .class file from a file path

decompile-from-package

Decompiles a Java class by package name (e.g., java.util.ArrayList)

decompile-from-jar

Decompiles a Java class from a JAR file with the specified class name

Overview

Java Decompiler MCP Server

Java Decompiler MCP Server turns compiled Java class files, package classes, or JAR entries into readable source code, using a JavaScript port of CFR with no Java runtime required. Use it when an AI assistant needs to read the source of compiled Java code from a class file, package, or JAR.

What it does

Java Decompiler MCP Server is an MCP server for decompiling Java class files, letting AI assistants and other MCP clients turn compiled Java bytecode into readable source code. It uses a JavaScript port of the CFR decompiler, so it needs no Java runtime installed to do the decompiling itself.

When to use - and when NOT to

Use it when an AI assistant needs to read the source of a compiled Java class: from a standalone .class file, from a known package and class name such as java.util.ArrayList, optionally with a custom classpath, or from a specific class inside a JAR file. It requires Node.js 16+ but explicitly has no Java requirement, since decompilation runs through a JS port of CFR rather than a real JVM-based decompiler. It is a decompilation tool specifically, not a general Java build or dependency-management tool.

Capabilities

  • decompile-from-path: decompile a Java .class file given its absolute file path (classFilePath)
  • decompile-from-package: decompile a Java class from a fully qualified package and class name (packageName), with an optional classpath array of directories to search
  • decompile-from-jar: decompile a specific class (className) out of a JAR file (jarFilePath), both required
  • Stdio transport for MCP integration, clean error handling, and automatic temporary file management during decompilation

How to install

Easiest, via npx with no install:

npx -y @idachev/mcp-javadc

Or install globally:

npm install -g @idachev/mcp-javadc
mcpjavadc

Or from source:

git clone https://github.com/idachev/mcp-javadc.git
cd mcp-javadc
npm install
npm start

For Claude Code:

claude mcp add javadc -s project -- npx -y @idachev/mcp-javadc

Or configure it directly in an MCP client, optionally setting a CLASSPATH environment variable pointing at your Java classes:

{
  "mcpServers": {
    "javaDecompiler": {
      "command": "npx",
      "args": ["-y", "@idachev/mcp-javadc"],
      "env": {
        "CLASSPATH": "/path/to/java/classes"
      }
    }
  }
}

The CFR-based decompiler (@run-slicer/cfr) works well with standard class files, classes in a known package structure, all Java versions, and classes inside JAR files. For JAR files pulled from a Maven repository, the source suggests locating them under ~/.m2, filtering out source and javadoc JARs, and listing a JAR's contents with jar tf to confirm the class name before decompiling.

Who it's for

Developers and AI assistants that need to read the source of compiled Java code, whether a single class file, a JDK or library class, or a class buried inside a JAR, without a full Java toolchain or a separate GUI decompiler. It is released under the ISC License.

Source README

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:

  1. Standard Java class files
  2. Classes that are part of a known package structure
  3. Modern Java features (all Java versions)
  4. 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

# 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

  1. The server uses the CFR decompiler (@run-slicer/cfr - a JavaScript port of the popular CFR Java decompiler)
  2. 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
  3. 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

FAQ

Common questions

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.