javalens-mcp

MCP.Pizza Chef: pzalutski-pixel

JavaLens is a tool that lets your AI assistant understand Java code deeply and accurately. Instead of just searching text, it uses the same technology as the Eclipse IDE to find exact method calls, references, and code structures. This helps you safely refactor, navigate, and analyze Java projects from version 1.1 up to 25, including code using Lombok. You can use it with MCP-compatible apps by setting it up with Java 21 or later and a simple config.

Coding
Other

Use This MCP server To

Find all exact calls to a Java method in my project Rename a Java class or method safely across files Analyze where fields are read versus written Detect unused private methods in my codebase Calculate code complexity and find dead code Navigate Java inheritance and interface implementations Search for all uses of a specific annotation

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 @Data accessors and the like resolve, so code using them is not flagged as undefined

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()

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:

  1. Training data contains extensive grep/text-search patterns
  2. Native tools are "always available" in the model's experience
  3. 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):

javalens-mcp FAQ

Can I use this to find all places a Java method is called?
Yes — JavaLens provides precise, compiler-accurate search to find exact method calls, avoiding false matches from text search.
Can I use this to safely rename or refactor Java code?
Yes — it offers refactoring tools like rename symbol and extract method with semantic understanding.
Which apps or clients work with JavaLens?
It works with any MCP-compatible client configured to connect to the JavaLens server, such as Claude Code or other IDEs supporting MCP.
Do I need an API key or account to use JavaLens?
No — it runs locally or on your server without requiring external accounts or keys.
How hard is it to set up JavaLens?
Setup involves copying a small configuration snippet and ensuring Java 21+ is installed, so it's a copy-paste-config level.
What prerequisites are required?
Java 21 or later must be installed and on your system path; Node.js 18+ is needed only if installing via npm/npx.
Can JavaLens analyze Java code using Lombok annotations?
Yes — it includes support to resolve Lombok-generated members so they are correctly understood.
Does JavaLens support all Java versions?
It supports Java source code from version 1.1 through 25, covering modern and legacy code.