JavaLens
io.github.pzalutski-pixelPublished by GitHub account pzalutski-pixelv1.5.3Updated Oct 24, 2026
75 semantic Java analysis tools via Eclipse JDT: navigation, refactoring, code intelligence.
Overview
JavaLens gives an AI assistant 75 compiler-accurate Java analysis tools built on Eclipse JDT: navigation, reference search, refactoring edits and code metrics.
- What you can do
- Search and navigate symbols: glob symbol search, go to definition, references, implementations, type hierarchy, symbols in a file, and symbol/type/method/field info at a position
- Find fine-grained references: annotations, instantiations, casts, instanceof checks, throws and catch clauses, method references, type arguments, reflection calls
- Analyze code: diagnostics, syntax validation, call hierarchies, field writes, tests, unused and unreachable code, affected tests, possible bugs, Javadoc, data and control flow, Spring DI, JPA model and HTTP endpoints
- Run compound queries that bundle imports, types, diagnostics, members, hierarchy and usages in one call
- Produce refactoring text edits…
- When to use it
- Use it when an assistant works on a Java codebase and text search is not precise enough: overloaded methods, inheritance, generics, or safe refactorings. It suits tasks like finding real usages before a change, checking which tests a change affects, or reviewing architecture and complexity.
- Requirements
- Runs locally over stdio. Java 21 or later must be on PATH or set via JAVA_HOME; the npm path (npx javalens-mcp) also needs Node.js 18+. A workspace directory is passed with the -data argument. Optional environment variables: JAVA_PROJECT_PATH to auto-load a project, JAVALENS_TIMEOUT_SECONDS, JAVALENS_DISK_SYNC, JAVALENS_LOG_LEVEL, JVM and build-tool arguments.
Installation
In SourceWeft
- Open JavaLens in the dashboard and add it to a workspace.
- Enable the server for the chats that should use its tools.
Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.
Other MCP clients
Follow the launch instructions in the repository.
README
JavaLens: AI-First Code Analysis for Java
[GitHub release] [License: MIT] [Java 21]
An MCP server providing 75 semantic analysis tools for Java, built directly on Eclipse JDT for compiler-accurate code understanding.
Built for AI Agents
JavaLens exists because AI systems need compiler-accurate insights that reading source files cannot provide. When an AI uses grep or Read to find usages of a method, it cannot distinguish:
- A method call from a method with the same name in an unrelated class
- A field read from a field write
- An interface implementation from an unrelated class
- A cast to a type from other references to that type
This leads to incorrect refactorings, missed usages, and incomplete understanding of code behavior.
Compiler-Accurate Analysis
JavaLens provides compiler-accurate code analysis through Eclipse JDT—the same engine that powers Eclipse IDE. Unlike text search, JDT understands:
- Type resolution across inheritance hierarchies
- Method overloading and overriding
- Generic type arguments
- Import resolution and classpath dependencies
- Java source from version 1.1 through Java 25 (markdown Javadoc, module imports, compact source files, flexible constructor bodies)
- Lombok-generated members — a bundled agent makes
@Dataaccessors and the like resolve, so code using them is not flagged as undefined
Example: Finding all places where UserService.save() is called:
AI Training Bias Warning
⚠️ Important for AI developers and users
AI models may exhibit trained bias toward native tools (Grep, Read, LSP) over MCP server tools, even when semantic analysis provides better results. This happens because:
- Training data contains extensive grep/text-search patterns
- Native tools are "always available" in the model's experience
- The model may not recognize when semantic analysis is superior
To get the best results:
Add guidance to your project instructions or system prompt (e.g., CLAUDE.md for Claude Code):
What is JavaLens?
JavaLens is an MCP server that gives AI assistants deep understanding of Java codebases. It provides semantic analysis, navigation, refactoring, and code intelligence tools that go beyond simple text search.
Why Not LSP?
Language Server Protocol was designed for IDE autocomplete and basic navigation—not for AI agent workflows that require deep semantic analysis.
JavaLens wraps Eclipse JDT Core directly via OSGi, providing:
- Fine-grained reference types: Find specifically casts, annotations, throws clauses, catch blocks, instanceof checks, method references, type arguments
- Read vs write access distinction: Track where fields are mutated vs just read
- Indexed search: JDT pre-builds an index at load time, so symbol/reference queries do not walk source files
- Full AST access: Direct manipulation for complex refactorings
Installation
Prerequisites
- Java 21 or later (must be on PATH or set
JAVA_HOME) — required for both install paths. - Node.js 18+ — required only if you use the npm/
npxinstall 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.
Install from GitHub Releases (recommended — Java only)
This is the simplest path if you already have Java 21 and don't have Node.js. Download from Releases:
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.
Install via npm (requires Node.js 18+)
If you already have Node.js, npx will download and cache the JavaLens distribution (~23 MB) on first run:
Configure MCP Client
Add to your MCP configuration (e.g., .mcp.json for Claude Code):
The -data argument specifies where JavaLens stores its workspace metadata. See How Workspaces Work below.
Auto-Load a Project
Set JAVA_PROJECT_PATH to auto-load a project when the server starts:
Note: Project loading happens asynchronously in the background. The MCP server responds immediately while the project loads. Use
health_checkto monitor loading status—it will show"project.status": "loading"until complete, then"loaded"when ready.
How Workspaces Work
Unlike in-memory code models, Eclipse JDT requires a workspace directory to store:
- Search indexes for fast symbol lookup
- Compilation state and caches
- Project metadata
Workspaces Are Outside Your Source
JavaLens creates its workspace outside your source project to keep your codebase clean:
Why this matters:
- No pollution: Your source tree stays clean—no
.projector.classpathfiles - No conflicts: Works alongside any build system without interference
- Session isolation: Each MCP session gets its own workspace, enabling concurrent analysis
Session Lifecycle
- JavaLens starts and creates a unique workspace:
{base}/{uuid}/ load_projectcreates linked folders pointing to your source- JDT builds indexes in the workspace (not in your project)
- When the session ends, the workspace is cleaned up
Tools
Navigation (10 tools)
Fine-Grained Reference Search (9 tools)
These use JDT's unique reference type constants—not available through LSP:
Analysis (20 tools)
Compound Analysis (4 tools)
Combine multiple queries to reduce round-trips:
Refactoring (16 tools)
All refactoring tools return text edits (and new-file content where a refactoring creates one) rather than applying changes directly:
Quick Fixes (5 tools)
Metrics (5 tools)
Project & Infrastructure (6 tools)
Usage
Basic Workflow
Coordinate System
All line/column parameters are zero-based:
- Line 0, Column 0 = first character of file
Path Handling
- Response paths are relative by default
- All paths use forward slashes for cross-platform consistency
- Input paths can be relative or absolute
Important Notes
Disk Synchronization
Every answer is verified against the files on disk at query time. Before any tool logic runs, JavaLens content-hashes the known source files, detects edits, additions, and deletions (the agent reports nothing — the server discovers changes itself), repairs exactly what changed, waits for the search index to absorb the repair, and only then answers. There is no file watcher and no background thread — verification is synchronous inside the query the agent issued, so there are no race conditions.
The agent's loop is just: edit → query.
load_project is needed only on first use, when a response reports RELOAD_REQUIRED (a build file like pom.xml changed, so the classpath must be rebuilt), or to rebuild everything from scratch. If verification itself fails, the query returns VERIFICATION_FAILED rather than an unverified answer.
Cost: verification is hash-based and parallel — measured per query at ~2 ms for a 72-file project, ~25 ms at 1,000 files, ~180 ms at 10,000 files. Repairs cost only what changed (one edited file reconciles in well under a second), never a full reindex.
Manual mode: set JAVALENS_DISK_SYNC=manual to restore the pre-1.5.0 contract — answers reflect the last load and the agent calls load_project after editing files. Tool descriptions and the MCP instructions field always state the active contract, and health_check reports it as diskSync.
Refactoring Returns Edits
Refactoring tools return text edits but don't modify files. This gives visibility into what would change before applying.
Session Isolation
Each MCP session is independent with its own workspace UUID. Multiple sessions can analyze the same project concurrently.
Build System Support
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).
JavaLens asks the build tool itself during the load and takes the model from its answer, writing nothing into the project tree:
- Maven: one run (
--fail-at-end) ofhelp:effective-pomanddependency: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 aBUILD_TOOL_FAILED; the rest of the model is still Maven's. Modules declared only in an inactive profile, and Gradle projects of asettings.gradlebeside the root pom, stay linked withINCLUDED_OUTSIDE_BUILD. - Gradle: one run with an init script that reports projects, custom
projectDirs, included builds, source sets, generated-source directories, classpath and per-project levels. - Bazel:
bazel queryfor the Java targets and sources and the build files,bazel aqueryfor 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:
Configuration
Building from Source
Distributions are output to org.javalens.product/target/products/.
Build Requirements
- Java 21+ (server runtime)
- Maven 3.9+ (wrapper included as
./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:
- Maven (provided by the wrapper)
- Gradle 8+
- Bazel 9+ (or
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.
Testing
Build-system coverage is structured as focused per-bug tests plus realistic end-to-end tests. The end-to-end tests load a single representative project per build system that exercises every fix in one pass — multi-module Maven with Lombok APT and cross-module references; multi-project Gradle with annotation processors; multi-target Bazel with cross-target deps. CI runs them on Linux and macOS; Windows line endings are covered by tests that write CRLF files explicitly.
Architecture
License
MIT License - see LICENSE for details.
Source: README.md at commit aa55d29
Tools
0Version history
2- v1.5.3LatestOct 18, 2026
- v1.5.1Sep 16, 2026
Score
50% of the applicable checks met
How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.
- Reached in the last 30 days25 pts
Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.
- Auth declared10 pts
Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.
- Tools listed15 pts
Answer tools/list without a credential, or ship a package that starts in a sandbox without one.
- DescriptionRequired15 pts
- Logo10 pts
- Documentation15 pts
- License10 pts