Content
# Easy Code Reader
<div align="center">
<img src="https://raw.githubusercontent.com/FangYuan33/easy-code-reader/master/icon.png" alt="Easy Code Reader Icon" width="200"/>
</div>
<div align="center">
A powerful MCP (Model Context Protocol) server for intelligently reading Java source code. Supports extracting source code from Maven dependencies and local projects, equipped with dual decompiler (CFR/Fernflower) auto-selection mechanism, intelligent SNAPSHOT version handling, and perfect multi-module project support. Empowers AI assistants to deeply understand your Java codebase.
</div>
---
---
## Features
- 📁 **Local Project Code Reading**: Supports reading source code from local project directories, including multi-module Maven/Gradle projects.
- 📋 **Project Listing**: Lists all projects in a directory for quick searching and locating, supports fuzzy matching of project names.
- 🗂️ **Intelligent File Filtering**: Automatically filters test directories, build artifacts, and IDE configurations, displaying only source code and configuration files, supports fuzzy matching of file names.
- 🎯 **Module Focus Mode**: Supports listing files in specific subdirectories of a project for precise code targeting.
- 🤖 **AI-Friendly Smart Prompts**: All tools have intelligent error prompting mechanisms, proactively guiding AI assistants to adjust strategies when queries fail, effectively reducing hallucinations and repeated attempts.
- 📦 **Reading Source Code from Maven Repository**: Automatically finds and reads JAR package source code from the local Maven repository (defaults to **MAVEN_HOME** directory or `~/.m2/repository`, configurable).
- 🔍 **Intelligent Source Code Extraction**: Prioritizes extracting source code from sources jar, and automatically decompiles class files if it does not exist.
- 🛠️ **Dual Decompiler Support**: Supports CFR and Fernflower decompilers, automatically selecting the best decompiler based on Java version.
- ⚡ **Intelligent Caching Mechanism**: Decompilation results are cached in the `easy-code-reader/` directory in the same directory as the JAR package to avoid repeated decompilation.
- 🔄 **SNAPSHOT Version Support**: Intelligently handles SNAPSHOT versions, automatically finds the latest version with timestamps and manages the cache.
## Best Practices
Easy Code Reader is particularly suitable for use with large models such as Claude and ChatGPT. The following uses VSCode combined with Copilot as an example to introduce some best practices:
### 1. Cross-Project Calls, Analyze Source Code Based on Call Chain
In more complex projects, multiple microservices are generally split. The implementation of certain functions may involve calls across multiple projects. If it takes a lot of time to sort out the relevant logic, you can clone the involved code to the local and use Easy Code Reader MCP combined with Code Agent for analysis. Next, we will take the Nacos project as an example. Suppose we want to understand how the Nacos service registration function is implemented. We can operate according to the following steps.
First, for example, we create a Nacos Client client, and execute service registration in this logic:
```java
public class Main {
private static final Logger logger = LoggerFactory.getLogger(Main.class);
public static void main(String[] args) throws NacosException, InterruptedException {
logger.info("开始初始化 Nacos 客户端...");
Properties properties = new Properties();
properties.put(PropertyKeyConst.SERVER_ADDR, "127.0.0.1:8848");
properties.put(PropertyKeyConst.NAMESPACE, "7430d8fe-99ce-4b20-866e-ed021a0652c9");
NamingService namingService = NacosFactory.createNamingService(properties);
System.out.println("=== 注册服务实例 ===");
try {
// 注册一个服务实例
namingService.registerInstance("test-service0", "127.0.0.1", 8080);
// 添加事件监听器
namingService.subscribe("test-service", event -> {
System.out.println("服务实例变化: " + event);
});
} catch (Exception e) {
System.out.println("服务注册失败(预期,因为服务器可能未启动): " + e.getMessage());
}
TimeUnit.HOURS.sleep(3);
}
}
```
Because we create the Nacos Client to execute service registration, it is implemented by the Nacos SDK directly calling the `NamingService#registerInstance` method. We don’t know how it is implemented at the bottom layer. If we want to understand the implementation details, we need to Clone the Nacos source code and use Easy Code Reader to read the relevant source code. The following is an example Prompt:
```text
You are a Java expert, please help me analyze the logic of the namingService.registerInstance method in #file:Main.java. The implementation of this logic is in nacos in the local project, so you need to read a series of related source codes in nacos to understand its core logic. To read the code of the nacos project, you can use easy-code-reader MCP, which contains tools that you can use to obtain project information, all file information in the project, and a file.
```
<img src="https://raw.githubusercontent.com/FangYuan33/easy-code-reader/master/imges/img.png" alt="img.png">
As shown in the figure, it will continuously read and analyze related source code according to the source code call chain. Finally, we can understand the implementation details of service registration. It will use multiple tools provided by MCP Easy Code Reader `list_all_project`, `list_project_files` and `read_project_code`. The specific call details are shown in the figure below:
<img src="https://raw.githubusercontent.com/FangYuan33/easy-code-reader/master/imges/img1.png" alt="img.png">
Finally, get the analysis results and save a lot of time:
<img src="https://raw.githubusercontent.com/FangYuan33/easy-code-reader/master/imges/img2.png" alt="img.png">
### 2. Read the source code of the jar package and complete the code writing according to the source code
When using third-party or other external dependencies, Copilot or other Code Agents cannot directly read the source code in the jar package. Often we need to manually copy the source code content into the prompt to complete it, which is time-consuming and laborious. Easy Code Reader provides the `read_jar_source` tool to read the source code in the jar package and help us complete the development implementation. We still take the following code as an example. Now I want to implement the registration of multiple service instances, but I don’t understand the implementation of `NamingService`, so I can use `read_jar_source` to complete it:
```java
public class Main {
private static final Logger logger = LoggerFactory.getLogger(Main.class);
public static void main(String[] args) throws NacosException, InterruptedException {
logger.info("开始初始化 Nacos 客户端...");
Properties properties = new Properties();
properties.put(PropertyKeyConst.SERVER_ADDR, "127.0.0.1:8848");
properties.put(PropertyKeyConst.NAMESPACE, "7430d8fe-99ce-4b20-866e-ed021a0652c9");
NamingService namingService = NacosFactory.createNamingService(properties);
System.out.println("=== 注册服务实例 ===");
try {
// 注册一个服务实例
namingService.registerInstance("test-service0", "127.0.0.1", 8080);
// 添加事件监听器
namingService.subscribe("test-service", event -> {
System.out.println("服务实例变化: " + event);
});
// 注册多个服务实例
} catch (Exception e) {
System.out.println("服务注册失败(预期,因为服务器可能未启动): " + e.getMessage());
}
TimeUnit.HOURS.sleep(3);
}
}
```
```text
You are a Java technical expert and proficient in the Nacos framework. Please help me complete the logic of registering multiple service instances in #file:Main.java. Before writing the code, you need to try the read_jar_source tool of easy-code-reader to read the source code information of com.alibaba.nacos.api.naming.NamingService to understand the method of registering multiple service instances.
```
The processing process is as follows:
<img src="https://raw.githubusercontent.com/FangYuan33/easy-code-reader/master/imges/img3.png" alt="img.png">
In this way, we can quickly understand the implementation details of `NamingService` and complete the code writing work, saving a lot of time.
### 3. Read the source code across projects and complete the implementation of this project according to the source code
In large projects, the implementation of certain functions may span multiple modules or microservices. If some logic has been implemented and the logic of other applications needs to rely on this part of the logic in the future, you can use Easy Code Reader to read the source code of related modules to help us better understand and implement the functions of the current project. The example Prompt is as follows:
```text
You are a Java technical expert. Now I want to implement the business logic of XXX. The implementation of this part of the logic needs to call the interface and implementation of XXX in local project A. Please use MCP easy-code-reader to help me read the source code in project A and help me implement the business logic of XXX.
```
Of course, in addition to these three application scenarios, Easy Code Reader can also be used to complete the following tasks:
- Quick source tracing of abnormal problems: If the exception information is thrown from external jar package dependencies, you can use the `read_jar_source` tool to quickly locate the exception point based on the exception stack log.
- Dependency upgrade impact assessment (old/new version difference verification): Similarly, use the `read_jar_source` tool to complete the implementation differences between the old and new versions and assess the upgrade impact.
- Business code logic review: If the business logic development is implemented in multiple projects, you can use the tools for reading local project code `list_all_project`, `list_project_files` and `read_project_code` to analyze whether the added logic meets the business requirements.
- Newcomers can quickly get started with multiple microservices: With the help of tools for reading local project code, you can quickly sort out the relationship between microservice project codes based on the interface call chain and improve the speed of getting started.
---
<a id="quick-start-env"></a>
## Environment Requirements
- [uv](https://github.com/astral-sh/uv) - Python package and project management tool
- Python 3.10 or higher
- Java Development Kit (JDK) - Used to run the decompiler, requires at least Java 8
## Quick Access (Method 1): Use uvx (Recommended)
If you have not installed uv, you can quickly install it in the following ways:
```bash
# macOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
# Windows
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
```
Or refer to the [uv official website](https://github.com/astral-sh/uv) for installation, and configure the uv installation path to the system PATH so that you can directly use the `uvx` command. [uv](https://github.com/astral-sh/uv) is an extremely fast Python package and project management tool. Using `uvx` can be run directly without pre-installation. Refer to the following MCP client configuration:
- `--maven-repo`: Specify the Maven repository path, replace the `/custom/path/to/maven/repository` content with the local Maven repository path, the default is **MAVEN_HOME** directory or `~/.m2/repository` if not configured
- `--project-dir`: Specify the local project directory path, replace `/path/to/projects` with the actual path to save all projects
```json
{
"mcpServers": {
"easy-code-reader": {
"command": "uvx",
"args": [
"easy-code-reader",
"--maven-repo",
"/custom/path/to/maven/repository",
"--project-dir",
"/path/to/projects"
],
"env": {}
}
}
}
```
After configuring the above content, the AI assistant can call the tools provided by Easy Code Reader through the MCP protocol to complete the Java source code reading work of multiple projects and multiple dependencies.
<a id="quick-start-uv"></a>
## Quick Access (Method 2): Install Locally Using uv
If the installation and running fails using **Quick Access (Method 1)**, you can use the method of installing directly to the local, run the following command:
```bash
uv tool install easy-code-reader
```
After the installation is successful, execute the following command to get the installation directory:
```bash
which easy-code-reader
```
For example, if the output result is: /Users/fangyuan/.local/bin/easy-code-reader, then you need to configure the MCP client as follows, **pay attention to the `args` parameter configuration**, **pay attention to the `args` parameter configuration**, **pay attention to the `args` parameter configuration**:
```json
{
"mcpServers": {
"easy-code-reader": {
"command": "/Users/fangyuan/.local/bin/easy-code-reader",
"args": [
"--maven-repo",
"/custom/path/to/maven/repository",
"--project-dir",
"/path/to/projects"
],
"env": {}
}
}
}
```
Generally, this operation can complete the installation. If there are any version updates in the future, you can upgrade through the following command:
```bash
uv tool install --upgrade easy-code-reader
```
## Common Issues
### Q1: spawn uvx ENOENT spawn uvx ENOENT
The uv command was not found. Make sure that uv has been installed correctly and its path has been added to the system PATH. Refer to [Environment Requirements](#quick-start-env) and try restarting the IDE before starting the MCP Server.
### Q2: Downloading cpython-3.10.19-macos-aarch64-none (download) (17.7MiB) MCP error -32001: Request timed out
Python environment download failed, try to download manually or retry the download, or refer to [Quick Access (Method 2)](#quick-start-uv).
---
## Tool Description
Easy Code Reader provides 5 main tools, divided into two main usage scenarios:
### Scenario 1: Read Maven JAR Package Source Code
#### search_artifact
Search for the specified artifact in the local Maven repository and return the complete Maven coordinates.
**Purpose:**
- Quickly find when only the artifact ID is known but the complete Maven coordinates are uncertain.
- Infer complete coordinates from the classpath (e.g., `xxx.jar!/com/example/...`) or JAR file name.
- Explore available dependency versions in the local Maven repository.
**Parameters:**
- `artifact_id` (required): Maven artifact ID, e.g., `spring-core`
- `version_pattern` (optional): Fuzzy matching pattern for version numbers, e.g., `1.0.0`, `SNAPSHOT`, `20251110`
- `group_id_hint` (optional): groupId hint to narrow the search scope, e.g., `org.springframework`, `com.alibaba`
**How it works:**
1. Recursively traverse the Maven repository directory structure (groupId/artifactId/version).
2. Find directories matching the artifact_id.
3. Apply optional filtering conditions (version_pattern, group_id_hint).
4. Return all matching Maven coordinates and their JAR file information.
**Performance optimization tips:**
- If the repository is large, it is strongly recommended to provide the `group_id_hint` parameter to narrow the search scope.
- All filtering conditions are case-insensitive.
**Intelligent prompting mechanism:**
Based on the number of search results, the tool provides different AI-friendly prompts:
- **No results found**: Provides detailed troubleshooting suggestions, including checking spelling, downloading dependencies, adjusting filtering conditions, etc.
- **Found a unique match**: Directly displays the complete coordinates and next step guidance (calling read_jar_source).
- **Found a small number of matches (2-5)**: Lists all coordinates for selection and provides version selection suggestions.
- **Found a large number of matches (>5)**: Suggests using filtering parameters to narrow the scope and provides specific filtering examples.
**Example 1 - Basic search:**
```json
{
"artifact_id": "spring-core"
}
```
**Example 2 - Using version filtering:**
```json
{
"artifact_id": "nacos-client",
"version_pattern": "2.0.0"
}
```
**Example 3 - Using groupId hint:**
```json
{
"artifact_id": "dubbo",
"group_id_hint": "com.alibaba"
}
```
**Return format:**
```json
{
"artifact_id": "spring-core",
"version_pattern": "none",
"group_id_hint": "none",
"total_matches": 3,
"searched_dirs": 42,
"elapsed_seconds": 0.15,
"matches": [
{
"group_id": "org.springframework",
"artifact_id": "spring-core",
"version": "5.3.21",
"coordinate": "org.springframework:spring-core:5.3.21",
"jar_count": 1,
"jar_files": [
{
"name": "spring-core-5.3.21.jar",
"size_mb": 1.52
}
],
"path": "/Users/xxx/.m2/repository/org/springframework/spring-core/5.3.21"
}
],
"hint": "🎯 Found 3 matching artifacts..."
}
```
**Typical workflow:**
1. Use `search_artifact` to search for the artifact (only the artifact_id needs to be provided).
2. Select the correct Maven coordinates from the search results.
3. Use the `read_jar_source` tool to read the source code.
💡 **Usage suggestions**:
- When `read_jar_source` reports an error "JAR file not found", use this tool first to find the correct coordinates.
- For large Maven repositories, it is recommended to provide the `group_id_hint` parameter to improve search speed.
- Search results are automatically sorted by version, with the latest version at the top.
#### read_jar_source
Read the source code of a Java class from a Maven dependency (prioritize sources jar, otherwise decompile).
**Parameters:**
- `group_id` (required): Maven group ID, e.g., `org.springframework`
- `artifact_id` (required): Maven artifact ID, e.g., `spring-core`
- `version` (required): Maven version, e.g., `5.3.21`
- `class_name` (required): Fully qualified class name, e.g., `org.springframework.core.SpringVersion`
- `prefer_sources` (optional, default `true`): Prioritize using sources jar instead of decompilation
**How it works:**
1. First try to extract the source code from `-sources.jar` (if `prefer_sources=true`).
2. If the sources jar does not exist or extraction fails, automatically fall back to decompiling the main JAR file.
3. Supports intelligent processing of SNAPSHOT versions.
**Intelligent error prompts:**
When the JAR file is not found, the tool provides detailed troubleshooting suggestions:
- Prompt possible reasons (dependency not installed, Maven coordinates error)
- Suggest using the `read_project_code` tool to read the project's `pom.xml` file
- Guide to check the correct Maven coordinates in the `<dependencies>` section
- Prompt to re-call the tool after confirming the coordinates
- Explain that you may need to execute a Maven build command to install dependencies
This intelligent prompting mechanism is especially suitable for use with AI assistants, and can effectively reduce repeated attempts caused by Maven coordinate errors.
**Example:**
```json
{
"group_id": "org.springframework",
"artifact_id": "spring-core",
"version": "5.3.21",
"class_name": "org.springframework.core.SpringVersion"
}
```
**Return format:**
```json
{
"class_name": "org.springframework.core.SpringVersion",
"artifact": "org.springframework:spring-core:5.3.21",
"source_type": "sources.jar",
"code": "package org.springframework.core;\n\npublic class SpringVersion {\n // ...\n}"
}
```
**source_type field description:**
The `source_type` field identifies the source of the source code, helping the AI assistant understand the reliability and freshness of the code:
- `"sources.jar"`: Extracted from the Maven sources JAR file (most reliable, completely consistent with the released version)
- `"decompiled"`: Newly decompiled by a decompiler (decompilation may be incomplete)
- `"decompiled_cache"`: Read from the previously decompiled cache (avoid repeated decompilation and improve performance)
💡 **Usage suggestions**:
- Code from `sources.jar` is the most accurate and can be used directly as a basis for analysis
- Code from `decompiled` may have decompilation features such as syntax sugar recovery and generic erasure
- `decompiled_cache` has the same quality as `decompiled`, but is read from the cache to improve efficiency
### Scenario 2: Read local project source code
#### list_all_project
Lists all project folder names in the project directory.
**Purpose:**
- View all available projects
- When an incomplete project name is entered, help infer the closest project name
- Verify that the project exists
- Supports fuzzy matching of project names to quickly find specific projects
**Parameters:**
- `project_dir` (optional): Project directory path. If not provided, the path configured at startup is used.
- `project_name_pattern` (optional): Fuzzy matching pattern for project names (case-insensitive), used to filter the project list
- Supports left and right fuzzy matching, for example, `nacos` will match project names containing `nacos`, `Nacos`, `NACOS`
- ⚠️ **Usage suggestions**: If the matching pattern is too strict, it may cause the target project to be missed
- 💡 **Best Practices**: If the expected result is not found, it is recommended not to pass this parameter and re-query the complete list
**Intelligent prompting mechanism:**
- When `project_name_pattern` is used but no project is matched, the returned result will contain a prompt message
- It is recommended that the AI assistant not pass the `project_name_pattern` parameter and re-query when the expected project is not found
- Effectively reduce query failures caused by over-filtering
**Example 1 - List all projects:**
```json
{}
```
**Example 2 - Use fuzzy matching of project names:**
```json
{
"project_name_pattern": "spring"
}
```
**Return format:**
```json
{
"project_dir": "/path/to/projects",
"project_name_pattern": "spring",
"total_projects": 2,
"projects": [
"spring-boot",
"spring-cloud-demo"
],
"hint": "The project name pattern 'spring' has been used for filtering. If the expected project is not found, the pattern matching may be too strict. Suggestion: Do not pass the project_name_pattern parameter and re-call the list_all_project tool to view the complete project list.",
"total_all_projects": 5
}
```
**Prompt message description:**
- When `project_name_pattern` is used but no project is matched, the `hint` field will prompt that the pattern may be too strict, and the total number of projects `total_all_projects` will be displayed
- When `project_name_pattern` is used and there are matching results, the `hint` field will remind you that if the results do not meet expectations, you can re-query without passing parameters, and also display the total number of projects
- This intelligent prompting mechanism helps the AI assistant better adjust the query strategy and avoid missing the target project due to over-filtering
#### list_project_files
Lists the source code files and configuration file paths in the Java project.
**Purpose:**
- Understand the project structure and file organization
- Find specific classes or configuration files
- Analyze the relationships and dependencies between classes
- Focus on specific modules when there are too many project files
- Supports fuzzy matching of file names to quickly locate target files
**Supports two modes:**
1. **Full project mode** (without specifying `sub_path`): Lists all files in the entire project
2. **Focus mode** (specifying `sub_path`): Lists only files under the specified subdirectory
**Parameters:**
- `project_name` (required): Project name, e.g., `nacos`
- `sub_path` (optional): Specifies the subdirectory path within the project, e.g., `core` or `address/src/main/java`
- `file_name_pattern` (optional): Fuzzy matching pattern for file names (case-insensitive), used to further filter the file list
- Supports left and right fuzzy matching, for example, `Service` will match file names containing `service`, `Service`, `SERVICE`
- ⚠️ **Usage suggestions**: If the matching pattern is too strict, it may cause the target file to be missed
- 💡 **Best Practices**: If the expected result is not found, it is recommended not to pass this parameter and re-query the complete list
- `project_dir` (optional): The parent directory path where the project is located. If not provided, the path configured at startup is used.
**Automatically filtered content:**
- ✅ Includes: Java source code (.java), configuration files (.xml, .properties, .yaml, .json, etc.), build scripts, documentation
- ❌ Excludes: Test directory (`src/test`), compiled products (`target`, `build`), IDE configuration, version control files
**Intelligent prompting mechanism:**
- When `file_name_pattern` is used but no file is matched, the returned result will contain a prompt message
- It is recommended that the AI assistant not pass the `file_name_pattern` parameter and re-query when the expected file is not found
- Effectively reduce query failures caused by over-filtering
**Example 1 - List the entire project:**
```json
{
"project_name": "nacos"
}
```
**Example 2 - List only the core module:**
```json
{
"project_name": "nacos",
"sub_path": "core"
}
```
**Example 3 - Use fuzzy matching of file names:**
```json
{
"project_name": "nacos",
"file_name_pattern": "Service"
}
```
**Return format:**
```json
{
"project_name": "nacos",
"project_dir": "/path/to/projects/nacos",
"search_scope": "core",
"file_name_pattern": "Service",
"total_files": 15,
"files": [
"core/src/main/java/com/alibaba/nacos/core/service/NacosService.java",
"api/src/main/java/com/alibaba/nacos/api/naming/NamingService.java",
"..."
],
"hint": "The file name pattern 'Service' has been used for filtering. If the expected file is not found, the pattern matching may be too strict. Suggestion: Do not pass the file_name_pattern parameter and re-call the list_project_files tool to view the complete file list."
}
```
**Prompt message description:**
- When `file_name_pattern` is used but no file is matched, the `hint` field will prompt that the pattern may be too strict
- When `file_name_pattern` is used and there are matching results, the `hint` field will remind you that if the results do not meet expectations, you can re-query without passing parameters
- This intelligent prompting mechanism helps the AI assistant better adjust the query strategy and avoid missing the target file due to over-filtering
#### read_project_code
Reads the source code or configuration file content of the specified file from the local project directory.
**Purpose:**
- Read the complete source code of specific classes or files
- View configuration file content (pom.xml, application.yml, application.properties, etc.)
- Read project documentation (README.md, SQL scripts, etc.)
- Supports multi-module Maven/Gradle projects
- Automatically searches for common source code and configuration file paths
**Parameters:**
- `project_name` (required): Project name, e.g., `my-project`
- `file_path` (required): File identifier: can be a fully qualified Java class name or a relative file path
- Java class name format: `com.example.MyClass` (automatically find the corresponding .java file)
- Relative path format: `src/main/java/com/example/MyClass.java`
- Module relative path: `core/src/main/java/com/example/MyClass.java`
- Configuration file path: `src/main/resources/application.yml`, `pom.xml`
- Document files: `README.md`, `docs/setup.md`
- `project_dir` (optional): Project directory path. If not provided, the path configured at startup is used.
**Supported file types:**
- Java source code (.java)
- Configuration files (.xml, .properties, .yaml, .yml, .json, .conf, .config)
- Build scripts (.gradle, .gradle.kts, pom.xml)
- Document files (.md, .txt)
- SQL scripts (.sql)
- Shell scripts (.sh, .bat)
**Automatic search path:**
- For Java class names: `src/main/java/{class_path}.java`, `src/{class_path}.java`, `{class_path}.java`
- For configuration files: project root directory, `src/main/resources/`, `src/`, `config/` and submodules
- Supports submodule paths in multi-module projects
**Recommended workflow:**
1. Use `list_all_project` to confirm that the project exists
2. Use `list_project_files` (recommended with the `file_name_pattern` parameter) to view the file list
3. Use this tool to read the specific file content
**Example 1 - Read Java source code using class name:**
```json
{
"project_name": "my-spring-app",
"file_path": "com.example.service.UserService"
}
```
**Example 2 - Read Java files using relative paths:**
```json
{
"project_name": "nacos",
"file_path": "address/src/main/java/com/alibaba/nacos/address/component/AddressServerGeneratorManager.java"
}
```
**Example 3 - Read configuration files:**
```json
{
"project_name": "my-spring-app",
"file_path": "src/main/resources/application.yml"
}
```
**Example 4 - Read files in the project root directory:**
```json
{
"project_name": "my-spring-app",
"file_path": "pom.xml"
}
```
**Return format:**
```json
{
"project_name": "my-spring-app",
"class_name": "com.example.service.UserService",
"file_path": "/path/to/projects/my-spring-app/src/main/java/com/example/service/UserService.java",
"code": "package com.example.service;\n\nimport ...\n\npublic class UserService {\n // ...\n}"
}
```
---
## Technical details
### Project Structure
```
easy-code-reader/
├── src/easy_code_reader/
│ ├── __init__.py
│ ├── __main__.py # Program entry point
│ ├── server.py # MCP Server implementation
│ ├── config.py # Configuration management
│ ├── decompiler.py # Decompiler integration
│ └── decompilers/ # Decompiler JAR files directory
│ ├── fernflower.jar # Fernflower decompiler
│ └── cfr.jar # CFR decompiler
├── tests/ # Test files
├── pyproject.toml # Python project configuration
├── requirements.txt # Python dependencies
└── README.md # This document
```
### Decompilers
Easy Code Reader supports multiple decompilers and automatically selects the most suitable one based on the Java version:
| Java Version | Recommended Decompiler | Description |
|--------------|------------------------|-------------------------------------------------------------------------------------------------------------------|
| 8 - 20 | CFR | Automatically uses the **CFR** decompiler (compatible with Java 8+), included in the package: `src/easy_code_reader/decompilers/cfr.jar` |
| 21+ | Fernflower | Automatically uses the **Fernflower** decompiler (the decompiler used by IntelliJ IDEA), included in the package: `src/easy_code_reader/decompilers/fernflower.jar` |
#### Decompilation Cache Mechanism
Decompiled files are cached in the `easy-code-reader/` subdirectory of the JAR package's directory, for example:
If the JAR package location is:
```
~/.m2/repository/org/springframework/spring-core/5.3.21/spring-core-5.3.21.jar
```
The decompiled source files will be stored in:
```
~/.m2/repository/org/springframework/spring-core/5.3.21/easy-code-reader/spring-core-5.3.21.jar
```
The cache file itself is also a JAR format compressed package, containing all decompiled `.java` files. This avoids repeatedly decompiling the same JAR package, improving performance. However, **SNAPSHOT versions require special handling:** Because Maven generates JARs with timestamps for snapshot versions (e.g., `artifact-1.0.0-20251030.085053-1.jar`), Easy Code Reader automatically finds the latest timestamped version for decompilation and caches it with the name `artifact-1.0.0-20251030.085053-1.jar`, providing a basis for version judgment. When a new version is detected, the old SNAPSHOT cache is automatically cleaned, and a new cache file is generated.
## License
Apache License 2.0, see [LICENSE](LICENSE) file.
## Acknowledgments
- [Github: maven-decoder-mcp](https://github.com/salitaba/maven-decoder-mcp)
- [Github: fernflower](https://github.com/JetBrains/fernflower)
- [Github: Model Context Protocol(MCP) 编程极速入门](https://github.com/liaokongVFX/MCP-Chinese-Getting-Started-Guide)
Connection Info
You Might Also Like
markitdown
MarkItDown-MCP is a lightweight server for converting URIs to Markdown.
servers
Model Context Protocol Servers
Time
A Model Context Protocol server for time and timezone conversions.
Filesystem
Node.js MCP Server for filesystem operations with dynamic access control.
Sequential Thinking
A structured MCP server for dynamic problem-solving and reflective thinking.
git
A Model Context Protocol server for Git automation and interaction.