Java语义分析MCP服务 是 AI Skill Hub 本期精选MCP工具之一。综合评分 8.0 分,整体质量较高。我们强烈推荐将其纳入你的 AI 工具库,帮助提升工作效率。
基于Eclipse构建的开源MCP服务器,为AI代理提供Java代码的深层语义分析能力。支持代码智能理解、结构化解析和上下文感知,适合Java开发者、AI应用开发者和代码分析平台集成使用。
Java语义分析MCP服务 是一款遵循 MCP(Model Context Protocol)标准协议的 AI 工具扩展。通过 MCP 协议,它可以让 Claude、Cursor 等主流 AI 客户端直接访问和操作外部工具、数据源和服务,实现 AI 能力的无缝扩展。无论是文件操作、数据库查询还是 API 调用,都可以通过自然语言在 AI 对话中直接触发,极大提升生产效率。
基于Eclipse构建的开源MCP服务器,为AI代理提供Java代码的深层语义分析能力。支持代码智能理解、结构化解析和上下文感知,适合Java开发者、AI应用开发者和代码分析平台集成使用。
Java语义分析MCP服务 是一款遵循 MCP(Model Context Protocol)标准协议的 AI 工具扩展。通过 MCP 协议,它可以让 Claude、Cursor 等主流 AI 客户端直接访问和操作外部工具、数据源和服务,实现 AI 能力的无缝扩展。无论是文件操作、数据库查询还是 API 调用,都可以通过自然语言在 AI 对话中直接触发,极大提升生产效率。
# 方式一:通过 Claude Code CLI 一键安装
claude skill install https://github.com/pzalutski-pixel/javalens-mcp
# 方式二:手动配置 claude_desktop_config.json
{
"mcpServers": {
"java----mcp--": {
"command": "npx",
"args": ["-y", "javalens-mcp"]
}
}
}
# 配置文件位置
# macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
# Windows: %APPDATA%/Claude/claude_desktop_config.json
# 安装后在 Claude 对话中直接使用 # 示例: 用户: 请帮我用 Java语义分析MCP服务 执行以下任务... Claude: [自动调用 Java语义分析MCP服务 MCP 工具处理请求] # 查看可用工具列表 # 在 Claude 中输入:"列出所有可用的 MCP 工具"
// claude_desktop_config.json 配置示例
{
"mcpServers": {
"java____mcp__": {
"command": "npx",
"args": ["-y", "javalens-mcp"],
"env": {
// "API_KEY": "your-api-key-here"
}
}
}
}
// 保存后重启 Claude Desktop 生效
An MCP server providing 63 semantic analysis tools for Java, built directly on Eclipse JDT for compiler-accurate code understanding.
JAVA_HOME) — required for both install paths.npx install path below. Skip if you use the direct-download path.JavaLens is an analytical server, not a compiler. It uses Eclipse JDT 2024-09 to parse and understand Java source code from version 1.1 through 23. Java 21 is required only as the server runtime.
If you already have Node.js, npx will download and cache the JavaLens distribution (~23 MB) on first run:
{
"mcpServers": {
"javalens": {
"command": "npx",
"args": ["-y", "javalens-mcp"],
"env": {
"JAVA_PROJECT_PATH": "/path/to/your/java/project"
}
}
}
}
./mvnw)To run the full test suite (which includes end-to-end tests against real Maven, Gradle, and Bazel builds), the corresponding tools must also be on PATH:
bazelisk)Tests gracefully skip when a tool is missing on a developer machine. Set JAVALENS_TESTS_REQUIRE_TOOLS=true to flip the gate: missing tools cause a hard failure instead of a skip. CI runs with this flag set so any provisioning gap surfaces as a real failure rather than weakening the suite silently.
JavaLens provides compiler-accurate code analysis through Eclipse JDT—the same engine that powers Eclipse IDE. Unlike text search, JDT understands:
Example: Finding all places where UserService.save() is called:
| Approach | Result |
|---|---|
grep "save(" | Returns 47 matches including orderService.save(), saveButton, comments |
find_references | Returns exactly 12 calls to UserService.save() |
This is the simplest path if you already have Java 21 and don't have Node.js. Download from Releases:
| Platform | File |
|---|---|
| All platforms | javalens.zip or javalens.tar.gz |
Extract to a location of your choice (e.g., /opt/javalens or C:\javalens). Then point your MCP client at the bundled jar — see Configure MCP Client below.
JavaLens loads three real build systems plus plain Java directories. Each is exercised end-to-end in CI against synthetic real-shaped fixtures (multi-module reactors with cross-module deps, real external libraries, annotation processors).
| System | Detection | Single-module | Multi-module / multi-project | Compiler compliance from build files | Generated sources | Annotation processors |
|---|---|---|---|---|---|---|
| Maven | pom.xml | ✅ | ✅ (reactor classpath aggregation, cross-module navigation) | ✅ (maven.compiler.release/source/target) | ✅ (target/generated-sources/*) | ✅ (<annotationProcessorPaths> across the whole reactor) |
| Gradle | build.gradle / build.gradle.kts | ✅ | ✅ (settings.gradle include parsed; per-subproject classpaths unioned) | ✅ (sourceCompatibility) | ✅ (build/generated/sources/<task>/main/java) | ✅ (annotationProcessor configuration) |
| Bazel | MODULE.bazel / WORKSPACE.bazel / WORKSPACE | ✅ | ✅ (every BUILD.bazel package scanned for sources; bazel-bin ↔ bazel-out symlink dedup) | ✅ (javacopts -source/-target/--release parsed across BUILD.bazel files) | n/a (Bazel actions write into bazel-bin/, not target/generated-sources/) | ✅ (any classpath jar with META-INF/services/javax.annotation.processing.Processor is auto-registered) |
| Plain Java | src/ directory | ✅ | n/a | ✅ (falls back to Runtime.version().feature() when no build file) | n/a | n/a |
Subprocess invocations of mvn / gradle happen during project load. If a tool is missing or fails, JavaLens surfaces a structured LoadWarning (e.g. MAVEN_SUBPROCESS_FAILED, GRADLE_SUBPROCESS_FAILED, COMPLIANCE_LEVEL_UNKNOWN) in the load_project response so callers know analysis quality is degraded rather than silently getting an empty classpath.
git clone https://github.com/pzalutski-pixel/javalens-mcp.git
cd javalens-mcp
./mvnw clean verify
Distributions are output to org.javalens.product/target/products/.
Add to your MCP configuration (e.g., .mcp.json for Claude Code):
{
"mcpServers": {
"javalens": {
"command": "java",
"args": ["-jar", "/path/to/javalens/javalens.jar", "-data", "/path/to/javalens-workspaces"]
}
}
}
The -data argument specifies where JavaLens stores its workspace metadata. See How Workspaces Work below.
| Environment Variable | Description | Default |
|---|---|---|
JAVA_PROJECT_PATH | Auto-load project on startup | (none) |
JAVALENS_TIMEOUT_SECONDS | Operation timeout | 30 |
JAVALENS_LOG_LEVEL | TRACE/DEBUG/INFO/WARN/ERROR | INFO |
JAVA_TOOL_OPTIONS | JVM options, e.g. -Xmx2g for large projects | (default: 512m via eclipse.ini) |
For Java code analysis, prefer JavaLens MCP tools over text search: - Use find_references instead of grep for finding usages - Use find_implementations instead of text search for implementations - Use analyze_type to understand a class before modifying it - Use refactoring tools (rename_symbol, extract_method) for safe changes
Semantic analysis from JDT is more accurate than text-based search, especially for overloaded methods, inheritance, and generic types. ```
These use JDT's unique reference type constants—not available through LSP:
| Tool | Description |
|---|---|
find_annotation_usages | Find all @Annotation usages |
find_type_instantiations | Find all new Type() calls |
find_casts | Find all (Type) expr casts |
find_instanceof_checks | Find all x instanceof Type |
find_throws_declarations | Find all throws Exception in signatures |
find_catch_blocks | Find all catch(Exception e) blocks |
find_method_references | Find all Type::method expressions |
find_type_arguments | Find all List<Type> usages |
find_reflection_usage | Find Class.forName(), Method.invoke(), and other reflection calls |
1. load_project(projectPath="/path/to/java/project")
2. search_symbols(query="*Service", kind="Class")
3. find_references(filePath="...", line=10, column=15)
4. analyze_type(typeName="com.example.UserService")
JavaLens 是一个专为 Java 开发设计的 AI-First 代码分析 MCP Server。它通过集成 63 种语义分析工具,为 AI 助手提供深度理解 Java 代码的能力。不同于传统的文本搜索,JavaLens 能够理解复杂的代码逻辑,是提升 AI 在 Java 项目中辅助编程能力的利器。
运行 JavaLens 需要满足以下环境要求:必须安装 Java 21 或更高版本,并确保其已添加到 PATH 或正确设置了 JAVA_HOME;若选择通过 npm/npx 方式安装,则需要 Node.js 18+ 环境。若仅使用直接下载的二进制包方式,则无需安装 Node.js。
您可以根据环境选择两种安装方式:1. 通过 npm 安装(需 Node.js 18+):使用 `npx -y javalens-mcp` 命令,首次运行会自动下载并缓存分发包。2. 通过 GitHub Releases 安装(推荐):直接下载适用于您平台的 `javalens.zip` 或 `javalens.tar.gz`,解压至指定目录后,在 MCP 客户端中指向 bundled jar 文件即可。
JavaLens 作为一个分析型服务器,通过 MCP 协议与 Claude Code 等客户端交互。用户可以通过配置 MCP 客户端来启动服务,利用其提供的语义分析工具进行精准的代码检索与理解,实现比传统 grep 搜索更智能的代码操作。
您需要在 MCP 配置文件(如 `.mcp.json`)中添加 JavaLens 配置,并使用 `-jar` 指向 jar 包路径,同时通过 `-data` 参数指定工作区元数据存储位置。此外,可以通过环境变量进行高级配置,例如使用 `JAVA_PROJECT_PATH` 自动加载项目,或通过 `JAVA_TOOL_OPTIONS` 设置 JVM 参数(如 `-Xmx2g`)以应对大型项目。
JavaLens 提供了超越 LSP(Language Server Protocol)能力的精细化引用搜索 API。开发者应优先使用 `find_references` 查找引用、`find_implementations` 查找实现,以及 `analyze_type` 进行类型分析。此外,它还支持针对注解(`find_annotation_usages`)、实例化(`find_type_instantiations`)和强制类型转换(`find_casts`)的专项搜索工具。
JavaLens 的标准工作流如下:首先通过 `load_project` 加载指定的 Java 项目路径;接着使用 `search_symbols` 按类型(如 Class)搜索符号;随后利用 `find_references` 定位具体的代码引用位置;最后通过 `analyze_type` 深入分析目标类型的详细信息,从而实现精准的 AI 辅助开发。
专业的Java语义分析工具,Eclipse基础保证质量。MCP协议设计合理,与AI代理集成度高。项目活跃度适中,适合生产环境使用。
AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。
建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。
✅ MIT 协议 — 最宽松的开源协议之一,可自由商用、修改、分发,仅需保留版权声明。
经综合评估,Java语义分析MCP服务 在MCP工具赛道中表现稳健,质量优秀。如果你已有明确的使用需求,可以直接上手体验;如果还在评估阶段,建议对比同类工具后再做决策。
| 原始名称 | javalens-mcp |
| 原始描述 | 开源MCP工具:MCP server providing semantic Java code analysis for AI agents. Built on Eclipse。⭐27 · Java |
| Topics | MCP服务器Java代码分析AI代理语义分析开发者工具 |
| GitHub | https://github.com/pzalutski-pixel/javalens-mcp |
| License | MIT |
| 语言 | Java |
收录时间:2026-05-21 · 更新时间:2026-05-30 · License:MIT · AI Skill Hub 不对第三方内容的准确性作法律背书。
选择 Agent 类型,复制安装指令后粘贴到对应客户端