Get the FREE Ultimate OpenClaw Setup Guide →

LSP4J

A Java MCP (Model Context Protocol) server that wraps JDTLS (Eclipse JDT Language Server) using LSP4J to provide Java IDE features to AI assistants like Claude.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio stephanj-lsp4j-mcp java -jar /path/to/LSP4J-MCP/target/lsp4j-mcp-1.0.0-SNAPSHOT.jar /path/to/your/java/project jdtls \
  --env LOG_FILE="/tmp/lsp4j-mcp.log"

How to use

The LSP4J-MCP Server wraps the Eclipse JDT Language Server (JDTLS) through LSP4J to expose Java IDE capabilities to an AI assistant via the MCP protocol. It provides tools for exploring and navigating Java code such as finding symbols by name, locating references, jumping to definitions, listing all symbols in a file, and discovering interfaces that declare a given method. Once running, you can query these tools through Claude Code or any MCP-enabled client by prompting with natural language requests that map to these tools. For example, you can ask the assistant to find all methods named 'save', locate where a particular class is defined, or retrieve a list of all symbols defined in a given Java file. The server communicates with JDTLS to perform the underlying language analysis and returns structured results that the AI assistant can present to you.

How to install

Prerequisites:

  • Java 21+ installed
  • Maven 3.8+ installed
  • JDTLS installed (e.g., via Homebrew: brew install jdtls)

Install steps:

  1. Clone or download the LSP4J-MCP project.
  2. Build the project with Maven:
mvn clean package
  1. Locate the generated JAR at target/lsp4j-mcp-1.0.0-SNAPSHOT.jar.
  2. Run the MCP server using one of the supported configurations. Example using the included runtime:
./run.sh /path/to/your/java/project

Alternatively, run directly with Java:

java -jar target/lsp4j-mcp-1.0.0-SNAPSHOT.jar /path/to/your/java/project jdtls
  1. If you want to configure Claude Code, create an MCP configuration entry like the one below (adjust paths as needed).

Additional notes

Notes:

  • Logs are written to the file specified by the LOG_FILE environment variable (default: /tmp/lsp4j-mcp.log). stdout is reserved for MCP protocol communication.
  • Ensure JDTLS is available on the system PATH or adjust the command/args to point to the exact JDTLS launcher if using the direct Java command option.
  • The MCP server starts JDTLS as a subprocess and communicates via LSP4J (JSON-RPC over stdio). If you run into port or I/O issues, verify the Java process has permissions to read the workspace and the JDTLS resources.
  • Replace /path/to/your/java/project with the workspace you want to analyze and /path/to/LSP4J-MCP/target/lsp4j-mcp-1.0.0-SNAPSHOT.jar with the actual build artifact path.
  • The provided tools (find_symbols, find_references, find_definition, document_symbols, find_interfaces_with_method) cover common code navigation tasks helpful for AI-assisted code understanding.

Related MCP Servers

Sponsor this space

Reach thousands of developers