java-jdtls-mcp-server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@java-jdtls-mcp-server Show me the definition of the main method in App.java"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Java MCP Server & Gemini Extension
This project is a high-performance bridge between AI agents and Java codebases. It functions as both a Model Context Protocol (MCP) server and a Gemini CLI Extension, providing professional-grade Java language intelligence through Eclipse JDT.LS.
đ Key Features
Gemini Extension & Agent Skills: Pre-packaged with structured Agent Skills for Navigation, Verification, and Lifecycle management, ensuring AI agents follow optimal workflows.
Native JDT.LS Launch: Directly spawns the Java Language Server via JVM for maximum stability and performance.
Enterprise-Grade Analysis: Supports loading entire Maven projects to resolve dependencies and symbols across the whole codebase.
Diagnostics Support: Real-time retrieval of compilation errors and warnings to help AI agents verify their code changes.
Environment & Instance Isolation: Uses workspace path hashing for isolated data directories and automatically clears conflicting environment variables (like
PORT) for reliable communication.Full LSP Capabilities: Supports Go to Definition, Find References, Hover documentation, Global Symbol Search, and Document Symbol extraction.
Related MCP server: JDTLS-MCP
đ ī¸ Prerequisites
Node.js: v18.0.0 or higher.
Java Development Kit (JDK): Java 17 or higher (Java 21+ recommended).
Eclipse JDT.LS: An installation of Eclipse JDT.LS.
đ Installation & Setup
For Gemini CLI (Extension Mode)
This project is optimized for use as a Gemini CLI extension.
# Clone the repository
git clone <repository-url>
cd java-jdtls-mcp-server
npm install && npm run build
# Install as Gemini extension
gemini extensions install .For Claude Code / Other MCP Clients
For Claude Code, Claude Desktop, or other MCP clients, you'll need to configure the server explicitly as an MCP tool.
Build the project as shown above.
Edit your client's configuration file (e.g.,
claude_desktop_config.jsonfor Claude Desktop).Add the server configuration and define your global environment variables directly within the
envsection:
{
"mcpServers": {
"java-mcp-server": {
"command": "node",
"args": [
"/absolute/path/to/java-jdtls-mcp-server/dist/index.js"
],
"env": {
"JDTLS_HOME": "D:/software/jdt-language-server-latest",
"JDTLS_JAVA_HOME": "D:/software/java/jdk-23.0.1",
"JDTLS_JAVA_RUNTIMES": "[{\"name\":\"JavaSE-1.8\",\"path\":\"C:/Program Files/Java/jdk1.8.0_361\"},{\"name\":\"JavaSE-17\",\"path\":\"D:/software/jdk-17.0.7\"}]",
"JDTLS_MAVEN_USER_SETTINGS": "D:/software/apache-maven-3.9.3/conf/settings.xml",
"JDTLS_MAVEN_GLOBAL_SETTINGS": "D:/software/apache-maven-3.9.3/conf/settings.xml"
}
}
}
}Note: When using Claude Code, the project-level .env file logic (like JAVA_PROJECT=true) might not be loaded natively unless supported by the specific MCP client implementation. You may need to manage project-specific variables within the client's configuration directly.
1. Global Setup (User-level .env)
Global environment variables are recommended for common paths to avoid repeating them in every project. The global configuration file is typically located at: USER_HOME\.gemini\extensions\java-jdtls-mcp-server\.env (where USER_HOME is your user directory, e.g., C:\Users\User1).
How to Configure:
During Installation (Recommended): If you have enabled the
experimental.extensionConfigsetting in Gemini CLI, you will be prompted to input these environment variables during the initial installation. Gemini CLI will then auto-generate the.envfile at the path above.Manual Configuration: Alternatively, you can manually create the user-level
.envfile at this location and fill in the recommended information.
Recommended Configuration Example:
JDTLS_HOME=D:/software/jdt-language-server-latest
JDTLS_JAVA_HOME=D:/software/java/jdk-23.0.1
JAVA_WORKSPACE_PATH=
JDTLS_JAVA_RUNTIMES=[{"name":"JavaSE-1.8","path":"C:/Program Files/Java/jdk1.8.0_361"},{"name":"JavaSE-17","path":"D:/software/jdk-17.0.7"}]
JDTLS_MAVEN_USER_SETTINGS=D:/software/apache-maven-3.9.3/conf/settings.xml
JDTLS_MAVEN_GLOBAL_SETTINGS=D:/software/apache-maven-3.9.3/conf/settings.xmlVariable | Description | Required | Default |
| Path to JDT.LS installation root directory | Yes | - |
| Dedicated JDK path for JDT.LS (Overrides | No | System |
| Root path of your Java project | No | Current Working Directory |
| JSON list of Java Runtimes for different project versions | No | - |
| Path to custom Maven user | No | - |
| Path to custom Maven global | No | - |
| Enable Maven offline mode ( | No |
|
2. Project-Level Activation (Project-level .env)
Project-level env info is loaded and read by agent tools like Gemini CLI. For example, when using Gemini CLI, the project-level env path is usually: [Project Root]/.gemini/.env.
To prevent the Java language server from starting unnecessarily in non-Java projects, you must enable it explicitly per project. Please add the following to your project-level .env file:
# REQUIRED: Activates the Java Language Server for this specific workspace
JAVA_PROJECT=true(Optional) You can also place any of the global settings in this local .env file to override them for a specific project.
đ§Š Expert Skills & AI Rules
This project provides a set of high-level Expert Skills (located in skills/) that guide AI agents on the most efficient ways to interact with the Java Language Server. These skills prevent common pitfalls (like redundant server restarts) and improve code intelligence accuracy.
Skill | Expert Guide | Key Benefit |
| Server management | Standardizes JDT.LS startup, status checks, and error recovery. |
| Code intelligence | Optimizes finding definitions, references, and symbols. |
| Project indexing | Speeds up Maven project loading without manual file scanning. |
| Diagnostics | Enforces real-time error checking and verification. |
đ Usage in Gemini CLI
Gemini CLI can install these skills as part of the extension. Once installed, they are activated automatically or on-demand:
activate_skill java-lifecycleactivate_skill java-navigation
đ¤ Usage in Claude Code / Other MCP Clients
While Claude Code doesn't support Gemini's extension packaging, it can still leverage these skills through its Rules system:
Project-Level Rules: Copy the contents (or relevant parts) of the
SKILL.mdfiles from theskills/directory into a.clauderulesfile in your Java project's root.Global Rules: Alternatively, you can add these instructions to your global Claude configuration.
By placing these rules in .clauderules, Claude Code will automatically adopt these "expert workflows" whenever it detects it is working within this project environment.
đ§° Available Tools
Tool Name | Description | Key Parameters |
| Initializes JDT.LS. Restarts if already running. |
|
| Forces a fresh restart of the JDT.LS process. |
|
| New! Loads an entire Maven project and indexes symbols. |
|
| New! Performs global symbol search across the workspace. |
|
| New! Extracts all symbols (classes/methods) from a file. |
|
| Notifies the server about file content (required for diagnostics). |
|
| Retrieves errors and warnings for a specific file. |
|
| Retrieves the definition location for a symbol. |
|
| Finds all references for a symbol. |
|
| Gets type info and documentation for a symbol. |
|
đ§ Agent Skills
The folder skills/ contains specialized Markdown files that guide AI agents on how to use these tools effectively:
Navigation: Strategies for exploring codebases and using symbol search.
Verification: Workflows for checking code correctness via diagnostics.
Lifecycle: Handling server initialization and auto-start configuration.
đ Design Documentation
This project follows a structured design process. Detailed technical documents can be found in the design/ directory:
High-level Design: Describes the system architecture, core modules, and external interfaces.
Detailed Design: Covers class models, sequence diagrams, and internal implementation details of the
JavaLanguageServer.
đ License
This project is licensed under the ISC License.
Available Tools
15 toolsconfigure_jdt_lsB
Dynamically update JDT.LS configuration (e.g. enable source downloading).
Inputs: settings (required).
find_referencesA
Find references for a symbol. This is an enhanced version of java_get_references that marks external library results.
Inputs: filePath (required), line (required), character (required).
java_get_definitionB
Get definition location for a symbol.
Inputs: filePath (required), line (required), character (required).
java_get_diagnosticsA
Get diagnostics (errors/warnings) for a file. This tool now attempts to pull diagnostics actively from the server if supported (LSP 3.17+), otherwise falls back to cached results from asynchronous publishing.
Inputs: filePath (required).
java_get_file_symbolsB
Get all symbols (classes, methods, fields) defined in a specific file.
Inputs: filePath (required).
java_get_hoverB
Get hover information for a symbol.
Inputs: filePath (required), line (required), character (required).
java_get_referencesC
Get references for a symbol.
Inputs: filePath (required), line (required), character (required).
java_get_statusA
Get the current status of the Java Language Server.
Inputs: no named parameters.
java_get_workspace_diagnosticsA
Pull diagnostics for the entire workspace (LSP 3.17+). Note: This may not be supported by all language server versions.
Inputs: no named parameters.
java_load_maven_projectA
Load a Maven Java project into the language server workspace. This causes JDTLS to index the project, resolving dependencies and symbols across the entire project without needing to open files individually.
Inputs: projectPath (required).
java_open_fileB
Notify the language server that a file is open (didOpen).
Inputs: filePath (required), content (required).
java_restartB
Restart the Java Language Server (JDT.LS).
Inputs: jdtlsHome (required), workspacePath, javaHome, javaRuntimes, +1 more.
java_search_symbolsA
Search for symbols (classes, methods, fields) across the entire workspace by name.
Inputs: query (required).
java_startA
Start the Java Language Server (JDT.LS). Required before other commands. If already running, it will restart.
Inputs: jdtlsHome (required), workspacePath, javaHome, javaRuntimes, +1 more.
read_java_contentA
Read the content of a Java file, including local files and external library source code (jdt:// or jrt:// URIs).
Inputs: uri (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogâĻ
TDQS
Scored across 15 tools
Most tools have distinct purposes, but 'find_references' and 'java_get_references' are very similar and could cause confusion. 'java_get_diagnostics' and 'java_get_workspace_diagnostics' also overlap somewhat. Overall, descriptions help differentiate, but ambiguity exists.
The majority of tools follow the 'java_verb_noun' pattern (12 out of 15). However, 'configure_jdt_ls', 'find_references', and 'read_java_content' deviate from this convention, breaking perfect consistency.
15 tools is well-scoped for a Java language server integration. The set covers key operations like startup, diagnostics, symbol queries, references, and project loading without being overly large or trivial.
The tool set covers common LSP operations (hover, definition, references, diagnostics, symbols) and includes workspace-level diagnostics. Missing features like code completion, formatting, or rename, but the set is sufficient for typical agent interactions with JDT LS.
Maintenance
Related MCP Connectors
An MCP server that gives your AI access to the source code and docs of all public github repos
Official Duck Framework MCP server for AI-assisted development and project scaffolding.
Official MCP server for Agentwork â delegate tasks to AI agents with human-in-the-loop
MCP server for OpenAI API (chat completions, image generation, embeddings) via AceDataCloud
Related MCP Servers
- AlicenseBqualityDmaintenanceA lightweight MCP server that enables AI agents to perform deep codebase analysis by leveraging Gemini's massive context window for cross-file analysis and intelligent file selection.428MIT
- AlicenseNot gradedqualityDmaintenanceExposes Eclipse JDT Language Server to AI agents via MCP. Embedded OSGi architecture runs jdtls in the same JVM â no subprocess, no network hop. Tools: hover, definition, references, completion, diagnostics, document & workspace symbols.5Eclipse Public 2.0
- AlicenseNot gradedqualityDmaintenanceAn MCP server that gives AI agents structured code understanding and precise code intelligence via local indexing of AST, call graphs, and semantic search.77 npm4Apache 2.0
- AlicenseBqualityDmaintenanceA high-performance MCP server for intelligent documentation search, proactive bug detection, and semantic analysis of codebases.2515 npmMIT