java
Model Context Protocol server for Java code analysis with Eclipse JDT integration
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
- Clone the repository
git clone https://github.com/yourusername/java-mcp-server.git
cd java-mcp-server
- Install and set up Eclipse JDT Language Server
./setup-jdtls.sh
This script downloads and installs Eclipse JDT.LS (approximately 44MB).
- Build the Java components
mvn clean package
- 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
zen
Selfhosted notes app. Single golang binary, notes stored as markdown within SQLite, full-text search, very low resource usage
MCP -Deepseek_R1
A Model Context Protocol (MCP) server implementation connecting Claude Desktop with DeepSeek's language models (R1/V3)
mcp-fhir
A Model Context Protocol implementation for FHIR
mcp
Inkdrop Model Context Protocol Server
mcp-appium-gestures
This is a Model Context Protocol (MCP) server providing resources and tools for Appium mobile gestures using Actions API..
dubco -npm
The (Unofficial) dubco-mcp-server enables AI assistants to manage Dub.co short links via the Model Context Protocol. It provides three MCP tools: create_link for generating new short URLs, update_link for modifying existing links, and delete_link for removing short links.