Get the FREE Ultimate OpenClaw Setup Guide →

java

Model Context Protocol server for Java code analysis with Eclipse JDT integration

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio mwgreen-java-mcp-server node java-mcp-jdtls.js \
  --env JAVA_HOME="Path to Java installation" \
  --env JDTLS_HOME="Path to Eclipse JDT Language Server installation (defaults to ./jdtls)"

How to use

This MCP server provides Java code analysis capabilities by interfacing with the Eclipse JDT Language Server via a Node.js bridge. It exposes a suite of tools to inspect, navigate, refactor, and diagnose Java projects. You can load this server into an MCP-compatible AI workflow or Claude-like assistant, enabling operations such as retrieving class information, locating references, exploring call and type hierarchies, getting symbol details, code completion suggestions, and applying refactorings like renaming symbols or formatting code. The server communicates using JSON-RPC over stdin/stdout, translating MCP requests into LSP calls and returning MCP-formatted responses.

To use it, start the server (or connect Claude/your assistant to the running process). The server will initialize Eclipse JDT.LS in the background and index the detected project (Gradle, Maven, or multi-module Gradle). Once indexed, you can perform tools like get_class_info, list_classes, find_references, get_call_hierarchy, get_type_hierarchy, get_hover_info, get_completion, get_definition, rename_symbol, format_code, and get_diagnostics. Tools will respond with the appropriate analysis results, including symbol details, references, hierarchies, and diagnostic messages.

How to install

Prerequisites

  • Node.js 18 or higher
  • Java 17 or higher
  • Git

Setup and installation steps

  1. Clone the repository
git clone https://github.com/yourusername/java-mcp-server.git
cd java-mcp-server
  1. Install and set up Eclipse JDT Language Server
./setup-jdtls.sh

This script downloads and installs Eclipse JDT.LS (approximately 44MB).

  1. Build the Java components
mvn clean package
  1. Run the MCP bridge (example)
node java-mcp-jdtls.js

Prerequisites recap: ensure Java is installed and available on your PATH, and that you have Maven set up to build the Java components. If you plan to integrate with Claude or another assistant, ensure the bridge script path is accessible and network permissions allow standard I/O for JSON-RPC communication.

Additional notes

Tips and common issues:

  • Java 17+ and JDT.LS installation are required for full Java language features.
  • If the server fails to start, verify JAVA_HOME points to a valid JDK and that JDT.LS is installed (look for a jdtls directory).
  • Large Maven/Gradle projects may take time to index; initial responses may be delayed until indexing completes.
  • When using Gradle multi-module projects, the server detects project roots via settings.gradle/settings.gradle.kts or pom.xml for Maven; ensure these files are present in project roots.
  • Environment variable configuration can be overridden at runtime; use JAVA_HOME and JDTLS_HOME to customize installations.
  • If tools return empty results, ensure indexing has finished and that source paths are correctly configured in your project.
  • The project includes a standalone Java MCP server for simple, direct AST analysis as an alternative to the JDT.LS bridge.

Related MCP Servers

Sponsor this space

Reach thousands of developers