MCP Directory

JavaLens

Compiler-accurate Java code analysis for AI agents, built on Eclipse JDT with 75 semantic tools.

Unverified
stdio (local)
No auth
Java

Add to your client

Copy the config for your MCP client and paste it into its config file.

Install / run
npx -y javalens-mcp

Paste into ~/Library/Application Support/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "javalens": {
      "command": "npx",
      "args": [
        "-y",
        "javalens-mcp"
      ],
      "env": {
        "JAVA_PROJECT_PATH": "/path/to/your/java/project"
      }
    }
  }
}

Step-by-step guides: Add to Claude Desktop · Add to Cursor · Add to Windsurf

Before you start

  • Java 21 or later on PATH or via JAVA_HOME (server runtime)
  • Node.js 18+ (only for the npm/npx install path)
  • A Maven, Gradle, Bazel, or plain Java project to analyze

About JavaLens

JavaLens wraps Eclipse JDT Core directly via OSGi/Equinox to provide AI agents with compiler-accurate semantic analysis of Java codebases. It exposes 75 tools spanning navigation, fine-grained reference search, analysis, compound queries, refactoring, quick fixes, metrics, and project infrastructure. JDT pre-builds a search index at load time so symbol and reference queries do not walk source files. Each MCP session gets an isolated workspace (outside your source tree, keyed by UUID) so it never pollutes your project with .project/.classpath files and supports concurrent analysis. In strict disk-sync mode, every answer is verified against the on-disk files via content hashing before tool logic runs, so the agent only needs to edit then query.

Tools & capabilities (75)

search_symbols

Search types, methods, and fields by glob pattern.

go_to_definition

Navigate to a symbol's definition.

find_references

Find all usages of a symbol.

find_implementations

Find interface/class implementations.

get_type_hierarchy

Get a type's inheritance chain.

get_document_symbols

Get all symbols in a file.

get_symbol_info

Get detailed symbol information at a position.

get_type_at_position

Get type details at the cursor.

get_method_at_position

Get method details at the cursor.

get_field_at_position

Get field details at the cursor.

find_annotation_usages

Find all usages of an @Annotation.

find_type_instantiations

Find all `new Type()` calls.

find_casts

Find all `(Type) expr` casts.

find_instanceof_checks

Find all `x instanceof Type` checks.

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.

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_unreachable_code

Project-wide dead code: members unreachable from any main method or test over the whole-program call graph.

find_affected_tests

The tests that exercise a symbol directly or transitively — the set to run after changing it.

find_possible_bugs

Detect null risks, empty catches, and resource leaks.

get_hover_info

Get documentation/signature for a symbol.

get_javadoc

Get parsed Javadoc.

get_signature_help

Get method signature at a call site.

get_enclosing_element

Get the containing method/class at a position.

analyze_change_impact

Blast radius: direct call sites by depth, or full transitive closure over the project graph.

analyze_data_flow

Variable read/write/declaration tracking within a method; opt-in followCalls tracks null/taint facts across calls to sinks.

analyze_control_flow

Branching, loops, return/throw points, and nesting depth.

get_di_registrations

Find Spring DI registrations (@Component, @Bean, @Autowired, @Inject).

get_jpa_model

Assembled JPA entity model: tables, id fields, relationships with resolved targets and mappedBy sides.

get_http_endpoints

Assembled HTTP route table: Spring and JAX-RS paths composed from class prefixes, mapped to handler methods.

analyze_file

Get imports, types, and diagnostics for a file in one call.

analyze_type

Get a type's members, hierarchy, usages, and diagnostics.

analyze_method

Get a method's signature, callers, callees, and overrides.

get_type_usage_summary

Get instantiation, cast, and instanceof counts for a type.

rename_symbol

Rename a symbol across the entire project.

organize_imports

Sort and clean imports.

extract_variable

Extract an expression to a local variable.

extract_method

Extract a code block to a new method.

extract_constant

Extract an expression to a static final field.

extract_interface

Create an interface from a class's methods.

extract_superclass

Move a member into a newly created superclass.

inline_variable

Replace a variable with its initializer.

inline_method

Replace a call with the method body.

change_method_signature

Modify params/return and update all callers.

convert_anonymous_to_lambda

Convert an anonymous class to a lambda.

encapsulate_field

Generate accessors and rewrite all direct field accesses.

pull_up

Move a member into the superclass.

push_down

Move a member into the subclasses.

introduce_parameter_object

Bundle a method's parameters into a new class, updating callers.

move_type_to_new_file

Move a nested type into its own top-level file.

suggest_imports

Find import candidates for an unresolved type.

get_quick_fixes

List available fixes for a problem at a position.

apply_quick_fix

Apply a fix by ID (add import, remove import, add throws, try-catch).

apply_cleanup

Apply one of 10 JDT clean-ups (loop conversion, pattern matching, switch expressions, text blocks, ...) and return rewritten source.

diagnose_and_fix

Diagnose a file and return each problem's top quick-fix edits in one call.

get_complexity_metrics

Cyclomatic/cognitive complexity and LOC per method.

get_dependency_graph

Package/type dependencies as nodes and edges.

find_circular_dependencies

Detect package cycles using Tarjan's SCC algorithm.

find_large_classes

Find types exceeding method/field/line count thresholds.

find_naming_violations

Check against Java naming conventions.

health_check

Report server status, capabilities, project loading status, and active disk-sync contract.

load_project

Load a Maven/Gradle/Bazel/plain Java project.

get_project_structure

Get the package hierarchy.

get_classpath_info

Get classpath entries.

get_type_members

Get members by type name.

get_super_method

Find the overridden method in a superclass.

What this server can do

JavaLens provides tools for these capabilities — tap one to see every MCP server that does the same:

When to use it

  • Find exact usages of an overloaded or inherited method without grep false positives before refactoring.
  • Perform safe project-wide refactorings (rename, extract method, change signature) that return reviewable text edits.
  • Identify the precise set of tests to run after changing a symbol via transitive affected-test analysis.
  • Detect project-wide dead code, circular package dependencies, and possible null/resource-leak bugs.
  • Understand Spring DI wiring, JPA entity models, and HTTP route tables assembled from annotations.

Security notes

Runs locally over stdio with no authentication. During project load, JavaLens may invoke `mvn`/`gradle` subprocesses to resolve classpaths; failures surface as structured LoadWarnings rather than silently degrading analysis. Refactoring tools return text edits and do not modify files directly. Requires Java 21+ on PATH (or JAVA_HOME); the npm path additionally needs Node.js 18+.

JavaLens FAQ

How do I install JavaLens?

Two paths. With Node.js 18+, point your MCP client at `npx -y javalens-mcp`, which downloads and caches the ~23 MB distribution on first run. Without Node, download `javalens.zip`/`javalens.tar.gz` from GitHub Releases, extract it, and point your client at the bundled jar with `java -jar /path/to/javalens.jar -data /path/to/javalens-workspaces`. Both paths require Java 21+ on PATH or JAVA_HOME.

Why use JavaLens instead of LSP or grep?

LSP targets IDE autocomplete and basic navigation, and grep is purely textual. JavaLens uses Eclipse JDT for compiler-accurate analysis: it distinguishes field reads from writes, finds specific reference kinds (casts, annotations, instanceof, throws), computes cyclomatic complexity, detects circular dependencies and dead code, and resolves types across inheritance and generics — capabilities LSP and text search lack.

Do I have to reload the project after editing files?

Not in the default strict disk-sync mode. JavaLens content-hashes known source files before every query, repairs exactly what changed, waits for the index to absorb the repair, and only then answers, so the agent loop is just edit → query. `load_project` is needed only on first use, when a response reports RELOAD_REQUIRED (e.g. pom.xml changed), or to rebuild from scratch. Set JAVALENS_DISK_SYNC=manual to restore the pre-1.5.0 behavior.

Does it modify my files or pollute my project?

No. Refactoring and quick-fix tools return text edits (and new-file content where applicable) rather than writing to disk, giving you visibility before applying. JavaLens also stores its JDT indexes and workspace metadata in a separate UUID-keyed directory specified by `-data`, outside your source tree, so no `.project` or `.classpath` files are added.

Which build systems and Java versions are supported?

It loads Maven (pom.xml), Gradle (build.gradle/.kts), Bazel (MODULE.bazel/WORKSPACE), and plain Java `src/` directories, including multi-module/multi-project setups with cross-module navigation, generated sources, and annotation processors. It parses Java source from version 1.1 through Java 25, with bundled Lombok support; Java 21 is required only as the server runtime.

Alternatives to JavaLens

Compare all alternatives →

Microsoft's official browser-automation MCP using Playwright's accessibility tree (no vision model).

Featured
Verified
stdio (local)
No auth
TypeScript
12 tools
Updated 21 days agoRepo

Up-to-date, version-specific library documentation injected into your coding agent.

Verified
stdio (local)
API key
TypeScript
2 tools
Updated 25 days agoRepo

Code intelligence engine that indexes repos into a persistent knowledge graph for AI coding agents.

Unverified
stdio (local)
No auth
C
14 tools
Updated 11 hours agoRepo