How to add JavaLens to Cursor
Compiler-accurate Java code analysis for AI agents, built on Eclipse JDT with 75 semantic tools. Paste the config into ~/.cursor/mcp.json and restart Cursor.
Last updated June 14, 2026 · 31★ · stdio · no auth
Cursor 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 Cursor → Settings → MCP → Add new MCP server (or edit ~/.cursor/mcp.json directly).
- 2Paste the JavaLens config below into the "mcpServers" object.
- 3Fill in placeholder secrets, then save.
- 4Cursor reloads MCP servers automatically — check Settings → MCP for a green status dot.
- 5Ask Cursor to use one of JavaLens's tools to confirm it's connected.
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 Cursor
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 + Cursor FAQ
Where is the Cursor config file?
Cursor reads MCP servers from ~/.cursor/mcp.json. Paste the JavaLens config there under the "mcpServers" key and restart the client.
Is JavaLens safe to use with Cursor?
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.