JavaLens
Compiler-accurate Java code analysis for AI agents, built on Eclipse JDT with 75 semantic tools.
Add to your client
Copy the config for your MCP client and paste it into its config file.
npx -y javalens-mcpPaste 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_symbolsSearch types, methods, and fields by glob pattern.
go_to_definitionNavigate to a symbol's definition.
find_referencesFind all usages of a symbol.
find_implementationsFind interface/class implementations.
get_type_hierarchyGet a type's inheritance chain.
get_document_symbolsGet all symbols in a file.
get_symbol_infoGet detailed symbol information at a position.
get_type_at_positionGet type details at the cursor.
get_method_at_positionGet method details at the cursor.
get_field_at_positionGet field details at the cursor.
find_annotation_usagesFind all usages of an @Annotation.
find_type_instantiationsFind all `new Type()` calls.
find_castsFind all `(Type) expr` casts.
find_instanceof_checksFind all `x instanceof Type` checks.
find_throws_declarationsFind all `throws Exception` in signatures.
find_catch_blocksFind all `catch(Exception e)` blocks.
find_method_referencesFind all `Type::method` expressions.
find_type_argumentsFind all `List<Type>` usages.
find_reflection_usageFind Class.forName(), Method.invoke(), and other reflection calls.
get_diagnosticsGet compilation errors and warnings.
validate_syntaxFast syntax-only validation.
get_call_hierarchy_incomingFind all callers of a method.
get_call_hierarchy_outgoingFind all methods called by a method.
find_field_writesFind where fields are mutated.
find_testsDiscover JUnit/TestNG test methods.
find_unused_codeFind unused private members.
find_unreachable_codeProject-wide dead code: members unreachable from any main method or test over the whole-program call graph.
find_affected_testsThe tests that exercise a symbol directly or transitively — the set to run after changing it.
find_possible_bugsDetect null risks, empty catches, and resource leaks.
get_hover_infoGet documentation/signature for a symbol.
get_javadocGet parsed Javadoc.
get_signature_helpGet method signature at a call site.
get_enclosing_elementGet the containing method/class at a position.
analyze_change_impactBlast radius: direct call sites by depth, or full transitive closure over the project graph.
analyze_data_flowVariable read/write/declaration tracking within a method; opt-in followCalls tracks null/taint facts across calls to sinks.
analyze_control_flowBranching, loops, return/throw points, and nesting depth.
get_di_registrationsFind Spring DI registrations (@Component, @Bean, @Autowired, @Inject).
get_jpa_modelAssembled JPA entity model: tables, id fields, relationships with resolved targets and mappedBy sides.
get_http_endpointsAssembled HTTP route table: Spring and JAX-RS paths composed from class prefixes, mapped to handler methods.
analyze_fileGet imports, types, and diagnostics for a file in one call.
analyze_typeGet a type's members, hierarchy, usages, and diagnostics.
analyze_methodGet a method's signature, callers, callees, and overrides.
get_type_usage_summaryGet instantiation, cast, and instanceof counts for a type.
rename_symbolRename a symbol across the entire project.
organize_importsSort and clean imports.
extract_variableExtract an expression to a local variable.
extract_methodExtract a code block to a new method.
extract_constantExtract an expression to a static final field.
extract_interfaceCreate an interface from a class's methods.
extract_superclassMove a member into a newly created superclass.
inline_variableReplace a variable with its initializer.
inline_methodReplace a call with the method body.
change_method_signatureModify params/return and update all callers.
convert_anonymous_to_lambdaConvert an anonymous class to a lambda.
encapsulate_fieldGenerate accessors and rewrite all direct field accesses.
pull_upMove a member into the superclass.
push_downMove a member into the subclasses.
introduce_parameter_objectBundle a method's parameters into a new class, updating callers.
move_type_to_new_fileMove a nested type into its own top-level file.
suggest_importsFind import candidates for an unresolved type.
get_quick_fixesList available fixes for a problem at a position.
apply_quick_fixApply a fix by ID (add import, remove import, add throws, try-catch).
apply_cleanupApply one of 10 JDT clean-ups (loop conversion, pattern matching, switch expressions, text blocks, ...) and return rewritten source.
diagnose_and_fixDiagnose a file and return each problem's top quick-fix edits in one call.
get_complexity_metricsCyclomatic/cognitive complexity and LOC per method.
get_dependency_graphPackage/type dependencies as nodes and edges.
find_circular_dependenciesDetect package cycles using Tarjan's SCC algorithm.
find_large_classesFind types exceeding method/field/line count thresholds.
find_naming_violationsCheck against Java naming conventions.
health_checkReport server status, capabilities, project loading status, and active disk-sync contract.
load_projectLoad a Maven/Gradle/Bazel/plain Java project.
get_project_structureGet the package hierarchy.
get_classpath_infoGet classpath entries.
get_type_membersGet members by type name.
get_super_methodFind 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).
Up-to-date, version-specific library documentation injected into your coding agent.
Code intelligence engine that indexes repos into a persistent knowledge graph for AI coding agents.
Compare JavaLens with: