An MCP server providing 56 semantic analysis tools for Java, built directly on Eclipse JDT for compiler-accurate code understanding. 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 fie
Add this skill
npx mdskills install pzalutski-pixel/javalens-mcpComprehensive compiler-accurate Java analysis with 56 semantic tools via Eclipse JDT
An MCP server providing 56 semantic analysis tools for Java, built directly on Eclipse JDT for compiler-accurate code understanding.
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:
This leads to incorrect refactorings, missed usages, and incomplete understanding of code behavior.
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() |
⚠️ 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:
To get the best results:
Add guidance to your project instructions or system prompt (e.g., CLAUDE.md for Claude Code):
## Code Analysis Preferences
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.
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.
Language Server Protocol was designed for IDE autocomplete and basic navigation—not for AI agent workflows that require deep semantic analysis.
| Capability | Native LSP | JavaLens |
|---|---|---|
Find all @Annotation usages | ❌ | ✅ |
Find all new Type() instantiations | ❌ | ✅ |
| Find all casts to a type | ❌ | ✅ |
| Distinguish field reads from writes | ❌ | ✅ |
| Detect circular package dependencies | ❌ | ✅ |
| Calculate cyclomatic complexity | ❌ | ✅ |
| Find unused private methods | ❌ | ✅ |
| Detect possible null pointer bugs | ❌ | ✅ |
JavaLens wraps Eclipse JDT Core directly via OSGi, providing:
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).
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.
Set JAVA_PROJECT_PATH to auto-load a project when the server starts:
{
"mcpServers": {
"javalens": {
"command": "java",
"args": ["-jar", "/path/to/javalens/javalens.jar", "-data", "/path/to/javalens-workspaces"],
"env": {
"JAVA_PROJECT_PATH": "/path/to/your/java/project"
}
}
}
}
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.
Unlike in-memory code models, Eclipse JDT requires a workspace directory to store:
JavaLens creates its workspace outside your source project to keep your codebase clean:
Your Java Project (unchanged)
├── src/main/java/
├── pom.xml
└── (no Eclipse files added)
JavaLens Workspace (specified by -data)
└── {session-uuid}/
├── .metadata/ ` usages |
### Analysis (12 tools)
| Tool | Description |
|------|-------------|
| `get_diagnostics` | Get compilation errors and warnings |
| `validate_syntax` | Fast syntax-only validation |
| `get_call_hierarchy_incoming` | Find all callers of a method |
| `get_call_hierarchy_outgoing` | Find all methods called by a method |
| `find_field_writes` | Find where fields are mutated |
| `find_tests` | Discover JUnit/TestNG test methods |
| `find_unused_code` | Find unused private members |
| `find_possible_bugs` | Detect null risks, empty catches, resource leaks |
| `get_hover_info` | Get documentation/signature for symbol |
| `get_javadoc` | Get parsed Javadoc |
| `get_signature_help` | Get method signature at call site |
| `get_enclosing_element` | Get containing method/class at position |
### Compound Analysis (4 tools)
Combine multiple queries to reduce round-trips:
| Tool | Description |
|------|-------------|
| `analyze_file` | Get imports, types, diagnostics in one call |
| `analyze_type` | Get members, hierarchy, usages, diagnostics |
| `analyze_method` | Get signature, callers, callees, overrides |
| `get_type_usage_summary` | Get instantiations, casts, instanceof counts |
### Refactoring (10 tools)
All refactoring tools return **text edits** rather than applying changes directly:
| Tool | Description |
|------|-------------|
| `rename_symbol` | Rename across entire project |
| `organize_imports` | Sort and clean imports |
| `extract_variable` | Extract expression to local variable |
| `extract_method` | Extract code block to new method |
| `extract_constant` | Extract to `static final` field |
| `extract_interface` | Create interface from class methods |
| `inline_variable` | Replace variable with its initializer |
| `inline_method` | Replace call with method body |
| `change_method_signature` | Modify params/return, update all callers |
| `convert_anonymous_to_lambda` | Convert anonymous class to lambda |
### Quick Fixes (3 tools)
| Tool | Description |
|------|-------------|
| `suggest_imports` | Find import candidates for unresolved type |
| `get_quick_fixes` | List available fixes for problem at position |
| `apply_quick_fix` | Apply fix by ID (add import, remove import, add throws, try-catch) |
### Metrics (3 tools)
| Tool | Description |
|------|-------------|
| `get_complexity_metrics` | Cyclomatic/cognitive complexity, LOC per method |
| `get_dependency_graph` | Package/type dependencies as nodes and edges |
| `find_circular_dependencies` | Detect package cycles using Tarjan's SCC algorithm |
### Project & Infrastructure (6 tools)
| Tool | Description |
|------|-------------|
| `health_check` | Server status and capabilities |
| `load_project` | Load Maven/Gradle/plain Java project |
| `get_project_structure` | Get package hierarchy |
| `get_classpath_info` | Get classpath entries |
| `get_type_members` | Get members by type name |
| `get_super_method` | Find overridden method in superclass |
## 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
### No Live File Watching
JavaLens analyzes code at load time and does **not** watch for file changes. This is by design—the AI coding agent is responsible for maintaining synchronization:
| Event | Agent Action |
|-------|--------------|
| After writing/editing files | Call `load_project` to refresh indexes |
| Before complex refactoring | Call `load_project` to ensure fresh state |
| After external changes (git pull, etc.) | Call `load_project` to resync |
**Why not automatic watching?**
1. AI agents make discrete edits with clear boundaries—auto-sync adds complexity without benefit
2. The agent controls when analysis should reflect changes
3. Avoids race conditions between file writes and index updates
**Recommended pattern:**
### 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
| System | Detection |
|--------|-----------|
| Maven | `pom.xml` |
| Gradle | `build.gradle` / `build.gradle.kts` |
| Plain Java | `src/` directory |
## Configuration
| 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 |
## Building from Source
```bash
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/.
┌─────────────────────────────────────────────────────────┐
│ MCP Client │
└─────────────────────────────────────────────────────────┘
│ JSON-RPC over stdio
┌─────────────────────────────────────────────────────────┐
│ org.javalens.mcp │
│ McpProtocolHandler → ToolRegistry → 56 Tools │
└─────────────────────────────────────────────────────────┘
│
┌─────────────────────────────────────────────────────────┐
│ org.javalens.core │
│ JdtServiceImpl → WorkspaceManager, SearchService │
└─────────────────────────────────────────────────────────┘
│
┌─────────────────────────────────────────────────────────┐
│ Eclipse JDT Core (via OSGi/Equinox) │
│ IWorkspace, IJavaProject, SearchEngine, ASTParser │
└─────────────────────────────────────────────────────────┘
MIT License - see LICENSE for details.
Install via CLI
npx mdskills install pzalutski-pixel/javalens-mcpJavaLens: AI-First Code Analysis for Java is a free, open-source AI agent skill. An MCP server providing 56 semantic analysis tools for Java, built directly on Eclipse JDT for compiler-accurate code understanding. 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 fie
Install JavaLens: AI-First Code Analysis for Java with a single command:
npx mdskills install pzalutski-pixel/javalens-mcpThis downloads the skill files into your project and your AI agent picks them up automatically.
JavaLens: AI-First Code Analysis for Java works with Claude Code, Claude Desktop, Cursor, Vscode Copilot, Windsurf, Continue Dev, Gemini Cli, Amp, Roo Code, Goose. Skills use the open SKILL.md format which is compatible with any AI coding agent that reads markdown instructions.