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 75 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 2025-12 to parse and understand Java source code from version 1.1 through 25. 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:
@Data accessors and the like resolve, so code using them is not flagged as undefinedExample: 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 | ✅ | ✅ (the reactor, ../ modules and per-module classpaths as Maven's effective model reports them; reactor modules are linked as sources, never as jars) | ✅ (each module's level as maven-compiler-plugin applies it: release before source, plugin configuration before properties, inherited from parents) | ✅ (subdirectories of each module's generated-sources under its effective build directory) | ✅ (<annotationProcessorPaths>, resolved in Maven's local repository) |
| Gradle | settings.gradle(.kts) / build.gradle(.kts) | ✅ | ✅ (projects, custom projectDirs, included builds, source sets and classpaths as Gradle reports them) | ✅ (each project's sourceCompatibility) | ✅ (the generated-source directories Gradle reports) | ✅ (annotationProcessor configuration) |
| Bazel | MODULE.bazel / WORKSPACE.bazel / WORKSPACE | ✅ | ✅ (the Java targets and their sources from bazel query; the classpath from each target's javac action) | ✅ (each javac action's level as javac takes it: the toolchain default, .bazelrc flags, then the target's javacopts) | n/a (Bazel actions write into bazel-bin/, not target/generated-sources/) | ✅ (each javac action's processor path) |
| Plain Java | src/ directory | ✅ | n/a | ✅ (falls back to Runtime.version().feature() when no build file) | n/a | n/a |
JavaLens asks the build tool itself during the load and takes the model from its answer, writing nothing into the project tree:
--fail-at-end) of help:effective-pom and dependency:build-classpath. A module Maven cannot resolve (one that depends on a module of the same build that is not installed, typically) is named by a BUILD_TOOL_FAILED; the rest of the model is still Maven's. Modules declared only in an inactive profile, and Gradle projects of a settings.gradle beside the root pom, stay linked with INCLUDED_OUTSIDE_BUILD.projectDirs, included builds, source sets, generated-source directories, classpath and per-project levels.bazel query for the Java targets and sources and the build files, bazel aquery for each javac action, bazel info execution_root, all with --lockfile_mode=off.When the tool cannot run or reports no model, JavaLens reads the build files itself as code (comments and strings declare nothing: poms as XML, Gradle settings and Bazel BUILD files through a lexer), lays modules out by convention where the files say nothing, and reports buildModel.source = static-read with a BUILD_MODEL_STATIC warning naming what such a read cannot see.
A change to any file the build reads, including one created after the load (gradle.properties, a version catalog, buildSrc, .mvn/maven.config, .bazelrc, a .bzl file, the pom of a module outside the root), makes the next query report RELOAD_REQUIRED naming it.
load_project and health_check both report a buildModel summary (build system, where the structure came from: build-tool, static-read or convention, analysis level, modules) and every load warning, so a degraded load is visible wherever the agent looks, including projects auto-loaded through JAVA_PROJECT_PATH. Warning codes:
| Code | Meaning |
|---|---|
BUILD_TOOL_UNAVAILABLE / BUILD_TOOL_FAILED / BUILD_TOOL_TIMEOUT | The build tool could not start, failed, or ran out of time; the message carries its last output |
BUILD_MODEL_STATIC | The build tool reported no model, so the build files were read statically; the message says what that cannot see |
MODULE_NOT_LOADED | A declared module or subproject was not loaded (directory missing, invalid path) |
MODULE_LAYOUT_ASSUMED | A module's source roots were assumed from the conventional layout |
INCLUDED_OUTSIDE_BUILD | A conventional source folder the build does not declare, a module of an inactive Maven profile, or a Gradle project beside a Maven build, stays linked |
COMPILED_OUTPUT_INCLUDED | A module's compiled output holds classes with no source and stays on the classpath |
COMPLIANCE_LEVEL_MIXED / COMPLIANCE_LEVEL_UNKNOWN / COMPLIANCE_LEVEL_UNSUPPORTED | Modules declare different levels, none, or one outside JDT's range |
APT_PROCESSOR_JARS_MISSING | Declared annotation-processor jars are missing |
BAZEL_NOT_BUILT | Bazel output the classpath needs has not been built |
INDEX_INCOMPLETE / LIBRARY_INDEX_INCOMPLETE | Source files or libraries JDT's search index still lacks after repair; index-backed tool responses name them while it lasts |
JRE_REGISTRATION_FAILED | The JDK could not be registered with JDT |
EARLIER_PROJECT_KEPT | An earlier load's workspace project could not be removed |
TIMEOUT_SECONDS_INVALID | JAVALENS_TIMEOUT_SECONDS is out of range or not a number |
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 | Time limit on each tool call, a whole number of seconds from 5 to 300 (values outside are clamped, other values ignored, each with a TIMEOUT_SECONDS_INVALID load warning); a call past it returns TIMEOUT. load_project and health_check are not limited | (none: no limit) |
JAVALENS_DISK_SYNC | strict (every answer verified against disk) or manual (agent calls load_project after edits) | strict |
JAVALENS_LOG_LEVEL | TRACE/DEBUG/INFO/WARN/ERROR (case-insensitive); logs go to stderr, stdout carries only JSON-RPC | INFO |
JAVA_TOOL_OPTIONS | JVM options, e.g. -Xmx2g for large projects | (default: 512m via eclipse.ini) |
JAVALENS_LOMBOK_JAR | Path to the Lombok agent jar attached at launch; overrides the bundled one | (bundled) |
JAVALENS_MAVEN_ARGS | Extra arguments for the Maven runs that read the model, e.g. -Pextras -Dskip.x=true (split like shell words) | (none) |
JAVALENS_GRADLE_ARGS | Extra arguments for the Gradle run that reads the model, e.g. -Penv=ci | (none) |
JAVALENS_BAZEL_ARGS | Extra build flags for bazel aquery and bazel info, e.g. --config=ci | (none) |
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 类型,复制安装指令后粘贴到对应客户端