Java Class Analyzer▌
by handsomestwei
Analyze and decompile Java class files online with our Java decompiler software, featuring JD decompiler and JD GUI inte
Analyzes and decompiles Java class files with CFR decompiler integration, Maven repository support, and dependency scanning to enable reverse engineering, security auditing, and understanding of compiled bytecode when source code is unavailable.
Both formats append explainx.ai attribution and the canonical URL for this MCP server listing.
best for
- / Java developers using AI coding assistants
- / Reverse engineering compiled Java libraries
- / Security auditing of Java dependencies
capabilities
- / Scan Maven project dependencies
- / Decompile .class files to Java source code
- / Index classes from JAR packages
- / Analyze class structure and methods
- / Cache decompiled results intelligently
what it does
Decompiles and analyzes Java class files from Maven projects and JAR dependencies using the CFR decompiler. Helps AI tools understand third-party library code when source code isn't available.
about
Java Class Analyzer is a community-built MCP server published by handsomestwei that provides AI assistants with tools and capabilities via the Model Context Protocol. Analyze and decompile Java class files online with our Java decompiler software, featuring JD decompiler and JD GUI inte It is categorized under developer tools.
how to install
You can install Java Class Analyzer in your AI client of choice. Use the install panel on this page to get one-click setup for Cursor, Claude Desktop, VS Code, and other MCP-compatible clients. This server runs locally on your machine via the stdio transport.
license
Apache-2.0
Java Class Analyzer is released under the Apache-2.0 license. This is a permissive open-source license, meaning you can freely use, modify, and distribute the software.
readme
Java Class Analyzer MCP Server
一个基于Model Context Protocol (MCP)的Java类分析服务,可以扫描Maven项目依赖、反编译Java类文件、获取class方法列表等详细信息,并提供给LLM进行代码分析。
适用场景
Cursor等AI工具直接生成调用二方(内部调用)、三方包(外部调用)接口的代码,但因AI无法读取未在当前工程中打开的依赖源码,导致生成的代码错误频出,甚至出现幻觉式编码。
为解决此问题,一般会直接拷贝源码内容喂给LLM;或者先将源码文件放到当前工程内,再在对话中引用。
而使用本地反编译MCP方案最有效,能精准解析jar包中的类与方法,显著提升代码生成的准确性和可用性。
功能特性
- 🚀使用方便:mcp服务基于TypeScript实现,使用npm打包,方便分发和安装,弱环境依赖。
- 🔍 依赖扫描: 自动扫描Maven项目的所有依赖JAR包
- 📦 类索引: 建立类全名到JAR包路径的映射索引
- 🔄 反编译: 使用CFR工具(已内置有)实时反编译.class文件为Java源码
- 📊 类分析: 分析Java类的结构、方法、字段、继承关系等
- 💾 智能缓存: 按包名结构缓存反编译结果,支持缓存控制
- 🚀 自动索引: 执行分析前自动检查并创建索引
- ⚙️ 灵活配置: 支持外部指定CFR工具路径
- 🤖 LLM集成: 通过MCP协议为LLM提供Java代码分析能力
使用示例
在IDE中注册mcp服务

在智能体对话中使用mcp

使用说明
mcp服务安装
全局安装(推荐)
npm install -g java-class-analyzer-mcp-server
安装后可以直接使用 java-class-analyzer-mcp 命令。
本地安装
npm install java-class-analyzer-mcp-server
从源码安装
git clone https://github.com/handsomestWei/java-class-analyzer-mcp-server.git
cd java-class-analyzer-mcp-server
npm install
npm run build
MCP服务配置
方法1:使用生成的配置(推荐)
运行以下命令生成配置模板:
java-class-analyzer-mcp config -o mcp-client-config.json
然后将生成的配置内容添加到你的MCP客户端配置文件中。
方法2:手动配置
参考以下配置示例,添加到MCP客户端配置文件中:
全局安装后的配置:
{
"mcpServers": {
"java-class-analyzer": {
"command": "java-class-analyzer-mcp",
"args": ["start"],
"env": {
"NODE_ENV": "production",
"MAVEN_REPO": "D:/maven/repository",
"JAVA_HOME": "C:/Program Files/Java/jdk-11"
}
}
}
}
本地安装后的配置:
{
"mcpServers": {
"java-class-analyzer": {
"command": "node",
"args": [
"node_modules/java-class-analyzer-mcp-server/dist/index.js"
],
"env": {
"NODE_ENV": "production",
"MAVEN_REPO": "D:/maven/repository",
"JAVA_HOME": "C:/Program Files/Java/jdk-11"
}
}
}
}
参数说明
command: 运行MCP服务器的命令,这里使用nodeargs: 传递给Node.js的参数,指向npm run build编译后的dist文件夹内文件env: 环境变量设置
环境变量说明
NODE_ENV: 运行环境标识production: 生产环境,减少日志输出,启用性能优化development: 开发环境,输出详细调试信息test: 测试环境
MAVEN_REPO: Maven本地仓库路径(可选)- 如果设置,程序会使用指定的仓库路径扫描JAR包
- 如果未设置,程序会使用默认的
~/.m2/repository路径
JAVA_HOME: Java安装路径(可选)- 如果设置,程序会使用
${JAVA_HOME}/bin/java执行Java命令(用于CFR反编译) - 如果未设置,程序会使用PATH中的
java命令
- 如果设置,程序会使用
CFR_PATH: CFR反编译工具的路径(可选,程序会自动查找)
可用的工具
1. scan_dependencies
扫描Maven项目的所有依赖,建立类名到JAR包的映射索引。
参数:
projectPath(string): Maven项目根目录路径forceRefresh(boolean, 可选): 是否强制刷新索引,默认false
示例:
{
"name": "scan_dependencies",
"arguments": {
"projectPath": "/path/to/your/maven/project",
"forceRefresh": false
}
}
2. decompile_class
反编译指定的Java类文件,返回Java源码。
参数:
className(string): 要反编译的Java类全名,如:com.example.QueryBizOrderDOprojectPath(string): Maven项目根目录路径useCache(boolean, 可选): 是否使用缓存,默认true。避免每次都重复生成。cfrPath(string, 可选): CFR反编译工具的jar包路径。已内置有,可以额外指定版本。
示例:
{
"name": "decompile_class",
"arguments": {
"className": "com.example.QueryBizOrderDO",
"projectPath": "/path/to/your/maven/project",
"useCache": true,
"cfrPath": "/path/to/cfr-0.152.jar"
}
}
3. analyze_class
分析Java类的结构、方法、字段等信息。
参数:
className(string): 要分析的Java类全名projectPath(string): Maven项目根目录路径
示例:
{
"name": "analyze_class",
"arguments": {
"className": "com.example.QueryBizOrderDO",
"projectPath": "/path/to/your/maven/project",
}
}
缓存文件
在当前工程,会生成以下缓存目录和文件。
.mcp-class-index.json: 类索引缓存文件.mcp-decompile-cache/: 反编译结果缓存目录(按包名结构).mcp-class-temp/: 临时文件目录(按包名结构)
工作流程
- 自动索引: 首次调用
analyze_class或decompile_class时,自动检查并创建索引 - 智能缓存: 反编译结果按包名结构缓存,支持缓存控制
- 分析类: 使用
analyze_class或decompile_class获取类的详细信息 - LLM分析: 将反编译的源码提供给LLM进行代码分析
技术架构
核心组件
- DependencyScanner: 负责扫描Maven依赖和建立类索引
- DecompilerService: 负责反编译.class文件
- JavaClassAnalyzer: 负责分析Java类结构
- MCP Server: 提供标准化的MCP接口
依赖扫描流程
- 执行
mvn dependency:tree获取依赖树 - 解析每个JAR包,提取所有.class文件
- 建立"类全名 -> JAR包路径"的映射索引
- 缓存索引到
.mcp-class-index.json文件
反编译流程
- 根据类名查找对应的JAR包路径
- 检查缓存,如果存在且启用缓存则直接返回
- 从JAR包中提取.class文件到
.mcp-class-temp目录(按包名结构) - 使用CFR工具反编译.class文件
- 保存反编译结果到缓存
.mcp-decompile-cache目录(按包名结构) - 返回Java源码
故障排除
常见问题
-
Maven命令失败
- 确保Maven已安装并在PATH中
- 检查项目是否有有效的pom.xml文件
-
CFR反编译失败
- 确保CFR jar包已下载(支持任意版本号)
- 检查Java环境是否正确配置
- 可通过
cfrPath参数指定CFR路径
-
类未找到
- 程序会自动检查并创建索引
- 检查类名是否正确
- 确保项目依赖已正确解析
测试说明
构建项目
npm install
npm run build
测试工具使用
项目提供了独立的测试工具,可以直接测试MCP服务的各个功能,无需通过MCP客户端。
# 测试所有工具
node test-tools.js
# 测试特定工具
node test-tools.js --tool decompile_class --class com.alibaba.excel.EasyExcelFactory --project /path/to/project
# 不使用缓存
node test-tools.js --tool decompile_class --no-cache
# 指定CFR路径
node test-tools.js --tool decompile_class --cfr-path /path/to/cfr.jar
测试工具参数
-t, --tool <工具名>: 指定要测试的工具 (scan|decompile|analyze|all)-p, --project <路径>: 项目路径-c, --class <类名>: 要分析的类名--no-refresh: 不强制刷新依赖索引--no-cache: 不使用反编译缓存--cfr-path <路径>: 指定CFR反编译工具的jar包路径-h, --help: 显示帮助信息
日志级别控制
通过 NODE_ENV 环境变量控制日志输出:
development: 输出详细调试信息production: 只输出关键信息
FAQ
- What is the Java Class Analyzer MCP server?
- Java Class Analyzer is a Model Context Protocol (MCP) server profile on explainx.ai. MCP lets AI hosts (e.g. Claude Desktop, Cursor) call tools and resources through a standard interface; this page summarizes categories, install hints, and community ratings.
- How do MCP servers relate to agent skills?
- Skills are reusable instruction packages (often SKILL.md); MCP servers expose live capabilities. Teams frequently combine both—skills for workflows, MCP for APIs and data. See explainx.ai/skills and explainx.ai/mcp-servers for parallel directories.
- How are reviews shown for Java Class Analyzer?
- This profile displays 34 aggregated ratings (sample rows for discoverability plus signed-in user reviews). Average score is about 4.6 out of 5—verify behavior in your own environment before production use.
Use Cases▌
Extended AI Capabilities
Add new capabilities to Claude beyond text generation
Example
Access external data sources, execute code, interact with tools and services
Transform Claude from chatbot to action-taking agent
Context Enhancement
Provide Claude with access to relevant context and data
Example
Load project documentation, access knowledge bases, query databases
Get more accurate, context-aware responses
Workflow Automation
Automate multi-step workflows combining AI and external tools
Example
Research → Summarize → Create document → Send notification
Complete complex tasks end-to-end without manual steps
Implementation Guide▌
Prerequisites
- ›Claude Desktop 0.7.0+ or Cursor IDE with MCP support
- ›Basic understanding of MCP architecture and capabilities
- ›Access credentials for integrated services (if required)
- ›Willingness to experiment and iterate on configuration
Time Estimate
15-60 minutes depending on server complexity
Installation Steps
- 1.Install MCP server: npm install -g [package-name] or via GitHub
- 2.Add server configuration to ~/.claude/mcp.json
- 3.Provide required credentials and configuration
- 4.Restart Claude Desktop to load new server
- 5.Test basic functionality with simple prompts
- 6.Explore capabilities and experiment with use cases
- 7.Document successful patterns for reuse
Troubleshooting
- ⚠MCP server not loading: Check config syntax, verify installation
- ⚠Connection errors: Check network, firewall, credentials
- ⚠Feature not working: Read server docs, check required parameters
- ⚠Performance issues: Monitor resource usage, check for network latency
- ⚠Conflicts with other servers: Check port assignments, namespace collisions
Best Practices▌
✓ Do
- +Read server documentation thoroughly before setup
- +Start with simple use cases to validate functionality
- +Test in non-production environment first
- +Monitor resource usage and performance
- +Keep servers updated for bug fixes and new features
- +Document configuration for team members
- +Use environment variables for sensitive configuration
✗ Don't
- −Don't grant overly permissive access to MCP servers
- −Don't skip reading security considerations in docs
- −Don't expose sensitive data without proper controls
- −Don't run untrusted MCP servers without code review
- −Don't ignore error messages—investigate root cause
💡 Pro Tips
- ★Combine multiple MCP servers for powerful workflows
- ★Create custom MCP servers for your specific needs
- ★Share successful configurations with team
- ★Use MCP inspector for debugging
- ★Join MCP community for tips and troubleshooting
Technical Details▌
Architecture
Model Context Protocol standardizes how AI hosts (Claude, Cursor) communicate with external tools and data sources through server implementations.
Protocols
- Model Context Protocol (MCP)
- JSON-RPC 2.0
- stdio or HTTP transport
Compatibility
- Claude Desktop
- Cursor IDE
- Custom MCP clients
When to Use This▌
✓ Use When
Use when you need Claude to access external data, execute actions, or integrate with tools. Best for extending AI capabilities beyond conversation.
✗ Avoid When
Avoid when native integrations exist (use official APIs directly), for real-time critical systems, or when security/compliance requires zero external dependencies.
Integration▌
- →Tool composition: Chain multiple MCP tools in workflows
- →Context augmentation: Provide AI with relevant external data
- →Action delegation: Let AI execute tasks on external systems
- →Bidirectional sync: Keep AI context and external systems in sync
Discussion
Product Hunt–style comments (not star reviews)- No comments yet — start the thread.
List & Promote Your MCP Server
Share your MCP server with the developer community
Ratings
4.6★★★★★34 reviews- ★★★★★Zaid Abbas· Dec 16, 2024
According to our notes, Java Class Analyzer benefits from clear Model Context Protocol framing — fewer ambiguous “AI plugin” claims.
- ★★★★★Ama Brown· Dec 8, 2024
Java Class Analyzer is a well-scoped MCP server in the explainx.ai directory — install snippets and categories matched our Claude Code setup.
- ★★★★★Ganesh Mohane· Dec 4, 2024
Java Class Analyzer has been reliable for tool-calling workflows; the MCP profile page is a good permalink for internal docs.
- ★★★★★Isabella White· Nov 27, 2024
We wired Java Class Analyzer into a staging workspace; the listing’s GitHub and npm pointers saved time versus hunting across READMEs.
- ★★★★★Rahul Santra· Nov 23, 2024
We evaluated Java Class Analyzer against two servers with overlapping tools; this profile had the clearer scope statement.
- ★★★★★Noah Perez· Nov 7, 2024
Useful MCP listing: Java Class Analyzer is the kind of server we cite when onboarding engineers to host + tool permissions.
- ★★★★★Omar Garcia· Oct 26, 2024
Strong directory entry: Java Class Analyzer surfaces stars and publisher context so we could sanity-check maintenance before adopting.
- ★★★★★Liam Yang· Oct 18, 2024
We evaluated Java Class Analyzer against two servers with overlapping tools; this profile had the clearer scope statement.
- ★★★★★Pratham Ware· Oct 14, 2024
We wired Java Class Analyzer into a staging workspace; the listing’s GitHub and npm pointers saved time versus hunting across READMEs.
- ★★★★★Ama Johnson· Sep 5, 2024
We wired Java Class Analyzer into a staging workspace; the listing’s GitHub and npm pointers saved time versus hunting across READMEs.
showing 1-10 of 34