java-class-analyzer-mcp
Enables AI to analyze Java classes from Maven project dependencies, with support for decompilation strategies and configurable groupId mappings.
README
Java Class Analyzer MCP
通用Java类分析MCP工具,让AI自动分析Maven项目依赖中的类。
核心特性
✅ 完整JavaDoc支持 - 自动从sources.jar读取原始源码
✅ 智能降级 - sources.jar → CFR → javap 四级降级
✅ 通用可配置 - 支持任何Maven项目和groupId
✅ 灵活配置 - 通过mcp.json或config.json配置
✅ 自动化 - CFR反编译器可选自动下载
快速开始
1. 安装
cd .cursor/java-class-analyzer
npm install
2. 配置(可选)
有三种配置方式,按优先级:
方式一:通过 .cursor/mcp.json(推荐)
{
"mcpServers": {
"java-class-analyzer": {
"command": "node",
"args": [".cursor/java-class-analyzer/index.js"],
"env": {
"MAVEN_REPO": "${HOME}/.m2/repository",
"GROUP_ID_MAPPINGS": "[{\"groupId\":\"com/mycompany\",\"prefix\":\"com.mycompany.\"}]"
}
}
}
}
方式二:本地config.json
复制 config.example.json 为 config.json 并修改:
cp config.example.json config.json
方式三:使用默认配置
默认支持常见的groupId:
com.ql.*com.qinglusaas.*io.quarkus.*io.quarkiverse.*org.apache.commons.*org.springframework.*
3. 使用
- 重启Cursor
- 在对话中: "请初始化Java类索引"
- 开始使用: "请分析 [类名]"
配置选项
Maven仓库路径
环境变量: MAVEN_REPO
默认值: ${HOME}/.m2/repository
{
"env": {
"MAVEN_REPO": "/custom/path/to/.m2/repository"
}
}
GroupId映射
环境变量: GROUP_ID_MAPPINGS (JSON数组)
说明: 用于识别JAR文件名中的groupId前缀
{
"env": {
"GROUP_ID_MAPPINGS": "[{\"groupId\":\"com/mycompany\",\"prefix\":\"com.mycompany.\"}]"
}
}
或在config.json中:
{
"groupIdMappings": [
{ "groupId": "com/mycompany", "prefix": "com.mycompany." },
{ "groupId": "org/example", "prefix": "org.example." }
]
}
CFR路径
环境变量: CFR_JAR_PATH
默认值: cfr.jar(当前目录)
{
"env": {
"CFR_JAR_PATH": "/path/to/cfr.jar"
}
}
反编译策略
在config.json中配置:
{
"decompile": {
"enableSourcesJar": true,
"enableCFR": true,
"enableJavap": true
}
}
反编译优先级
工具会按以下优先级获取源码:
| 优先级 | 方式 | JavaDoc | 质量 | 说明 |
|---|---|---|---|---|
| 1 | sources.jar | ✅ | 最高 | Maven源码包 |
| 2 | CFR | ❌ | 高 | 反编译器 |
| 3 | javap | ❌ | 中 | JDK工具 |
| 4 | 基本信息 | ❌ | 低 | 兜底 |
MCP工具
java_class_indexer- 构建类索引java_class_analyzer- 分析反编译类java_class_search- 搜索类
适用项目
- ✅ 所有Maven项目
- ✅ 任何groupId
- ✅ 公司内部二方包
- ✅ 开源第三方库
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.