How to add JavaLens to Claude Desktop
Compiler-accurate Java code analysis for AI agents, built on Eclipse JDT with 75 semantic tools. Paste the config into ~/Library/Application Support/Claude/claude_desktop_config.json and restart Claude Desktop.
Last updated June 14, 2026 ยท 31โ ยท stdio ยท no auth
Claude Desktop config for JavaLens
npx -y javalens-mcp{
"mcpServers": {
"javalens": {
"command": "npx",
"args": [
"-y",
"javalens-mcp"
],
"env": {
"JAVA_PROJECT_PATH": "/path/to/your/java/project"
}
}
}
}Setup steps
- 1Open Claude Desktop โ Settings โ Developer โ Edit Config (this opens ~/Library/Application Support/Claude/claude_desktop_config.json).
- 2Paste the JavaLens config below under the top-level "mcpServers" key.
- 3Fill in any placeholder secrets (API keys, paths) in the snippet.
- 4Save the file, then fully quit and reopen Claude Desktop.
- 5Open a chat and confirm JavaLens's tools appear under the ๐ tools menu.
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
What JavaLens can do in Claude Desktop
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.
Security
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 + Claude Desktop FAQ
Where is the Claude Desktop config file?
Claude Desktop reads MCP servers from ~/Library/Application Support/Claude/claude_desktop_config.json. Paste the JavaLens config there under the "mcpServers" key and restart the client.
Is JavaLens safe to use with Claude Desktop?
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+.
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.