Boost Java Microservice Analysis with Easy Code Reader MCP
This article explains how the Easy Code Reader MCP server integrates with large language models to automatically locate, read, and analyze Java source code across multiple micro‑services and JAR files, improving code‑agent accuracy and developer productivity through a set of practical tools and step‑by‑step examples.
Introduction
Easy Code Reader is an MCP (Model Context Protocol) server that helps developers retrieve relevant Java source code from multiple projects or JAR packages based on call‑chain analysis, allowing AI code agents such as Claude or ChatGPT to understand logic without manually copying files.
Best‑Practice Scenarios
1. Cross‑project RPC analysis
In complex micro‑service architectures, a single business operation may span several services. By cloning the relevant code locally and invoking the Easy Code Reader MCP tools, developers can let the AI agent trace the implementation of an RPC method such as submitOrderPaaS. The article provides a concrete prompt that asks the agent to locate the method in YbServiceSubmitOrderRpcImpl.java and explain its logic.
@Slf4j
@Service
public class YbServiceSubmitOrderRpcImpl implements YbServiceSubmitOrderRpc {
@Resource
private YbServiceSubmitOrderPaasResource ybServiceSubmitOrderPaasResource;
@Override
public String newSubmitOrder(YbSubmitOrderReq submitOrderReq) {
if (log.isInfoEnabled()) {
log.info("[提交订单]请求开始,参数-submitOrderReq:" + JSON.toJSONString(submitOrderReq));
}
// ... method body omitted for brevity ...
}
}2. Reading JAR source code
When a dependency is packaged as a JAR, the AI cannot read its code directly. Easy Code Reader provides the read_jar_source tool, which first tries to extract the source from a -sources.jar and falls back to decompilation if necessary. An example prompt asks the agent to fetch the source of com.jd.xxx.OfflineInsureOrderResource without specifying the Maven coordinates; the tool infers the correct artifact from the local pom.xml.
3. Cross‑project source reading for implementation
For features that rely on code in another module, a prompt can request the AI to read the target project's files (using list_all_project, list_project_files, and read_project_code) and then generate the missing implementation in the current project.
Additional Use Cases
Quick exception root‑cause tracing by reading the offending JAR source.
Assessing impact of dependency upgrades by comparing old and new source versions.
Code‑review assistance across multiple repositories.
Accelerating onboarding for new developers by visualising call chains.
Environment Requirements
Python 3.10+ (install via uv or system package manager).
JDK 8+ for the built‑in decompiler.
Quick Start
Method 1 – Using uvx (recommended)
Configure the MCP client with the Maven repository path ( --maven-repo) and the root directory of all local projects ( --project-dir). Example JSON configuration:
{
"mcpServers": {
"Easy Code Reader": {
"command": "uvx",
"args": [
"easy-code-reader",
"--maven-repo",
"/customer/maven-repository",
"--project-dir",
"/customer/path/to/project-dir"
]
}
}
}Method 2 – Installing locally
If uvx fails, install the binary with uv tool install easy-code-reader, locate it (e.g., /Users/you/.local/bin/easy-code-reader), and reference the absolute path in the MCP configuration.
Tool Details
list_all_project
Lists every sub‑directory under the configured project root, optionally filtered by project_name_pattern. It helps the AI discover available services and validates project existence.
list_project_files
Returns all source and configuration files for a given project, supporting both full‑project and focused sub‑path modes. File‑name fuzzy matching ( file_name_pattern) speeds up locating specific classes.
read_project_code
Retrieves the full content of a specified file or Java class, automatically searching common source locations (e.g., src/main/java, src/main/resources). Supports multi‑module Maven/Gradle layouts.
read_jar_source
Extracts a class from a Maven artifact. By default it prefers the -sources.jar; if unavailable it decompiles the binary using CFR for Java 8‑20 or Fernflower for Java 21+. The response includes a source_type field indicating whether the code came from a sources JAR, a fresh decompilation, or a cached decompilation.
Implementation Overview
The four tools cooperate to enable the AI to:
Discover all local projects ( list_all_project).
Identify relevant files ( list_project_files).
Read the exact source content ( read_project_code or read_jar_source).
Smart hint mechanisms guide the AI when patterns are too strict, suggesting a broader query.
Images
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
JD Cloud Developers
JD Cloud Developers (Developer of JD Technology) is a JD Technology Group platform offering technical sharing and communication for AI, cloud computing, IoT and related developers. It publishes JD product technical information, industry content, and tech event news. Embrace technology and partner with developers to envision the future.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
