Softwareologists/java-codegraph-mcp-server
If you are the rightful owner of java-codegraph-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
A Java-based multi-module project that uses ClassGraph to scan JARs, persists the resulting class-dependency graph in an embedded Neo4j database, and exposes it over the MCP protocol via both a CLI folder-watcher and an IntelliJ plugin.
CodeGraph MCP Server for Java applications(java-codegraph-mcp-server)
A Java-based multi-module project that uses ClassGraph to scan JARs (and IntelliJ PSI), persists the resulting class-dependency graph in an embedded Neo4j database, and exposes it over the MCP protocol via both a CLI folder-watcher and an IntelliJ plugin.
Features
- Core Engine: Scans JAR files or IntelliJ project classes, builds a class-dependency graph, and stores it in an embedded Neo4j instance.
- CLI Module: Watches a specified directory for new JARs and serves MCP requests over STDIO or SSE.
- IntelliJ Plugin: Hooks into the IDE to scan open projects, incrementally update the graph on code changes, and serves MCP over HTTP.
- Manifest Generation: Automatically generates an MCP manifest reflecting available query capabilities.
- Default Query Options: The manifest shows defaults
{ "limit": 100, "page": 1, "pageSize": 50 }that apply when these values are omitted in a query. - Examples: Sample scripts for CLI usage and IntelliJ sandbox setup.
Repository Structure
java-codegraph-mcp-server/
├── core/ # Core engine, graph model, Neo4j integration
├── cli/ # CLI watcher & MCP stdio/SSE server
├── intellij/ # IntelliJ plugin source and resources
├── examples/ # Sample scripts and artifacts for smoke tests
├── AGENTS.md # Guidelines for AI agents
├── Task_breakdown.md # Feature list for task-driven development
├── README.md # Project overview and setup
└── settings.gradle.kts
Getting Started
-
Clone the repository
git clone https://github.com/<your-org>/java-codegraph-mcp-server.git cd java-codegraph-mcp-server -
Build all modules
./gradlew build -
Run Core Engine Tests
./gradlew :core:test
CLI Usage
-
Package the CLI
./gradlew :cli:shadowJar -
Check the built jar
java -jar cli/build/libs/cli-all.jar --help -
Run the watcher
java -jar cli/build/libs/cli-all.jar --watch-dir /path/to/jars --stdioor start the SSE server:
java -jar cli/build/libs/cli-all.jar --watch-dir /path/to/jars --sse-port 8080 -
Send MCP Requests
-
At startup, the manifest JSON is printed.
-
Send JSON queries on stdin; responses appear on stdout.
-
Example with paging parameters:
echo '{"findCallers":{"className":"com.example.A","limit":10,"page":2,"pageSize":5}}' \ | java -jar cli/build/libs/cli-all.jar --watch-dir /path/to/jars --stdio
-
-
Omitted values fallback to the defaults printed in the manifest.
-
When using the SSE server:
curl -X POST -H "Content-Type: application/json" \ -d '{"findCallers":"com.example.A"}' \ http://localhost:8080/mcp/query
For a full demonstration:
- Run
examples/build-example-jar.shto createexamples/example.jar. - Execute
examples/sample-cli.shwhich builds the CLI, imports that JAR, and runs a sample query. - For SSE usage run
examples/sample-sse.sh.
IntelliJ Plugin
-
Install locally
- In IntelliJ IDEA, go to Settings > Plugins > ⚙️ > Install Plugin from Disk...
- Select
intellij/build/distributions/intellij-*.zip.
-
Configure
- Open Settings > Tools > CodeGraph MCP and set the HTTP port and optional package filters.
-
Use
-
On project open, the plugin scans classes and exposes
/mcp/manifestand/mcp/query. -
Example HTTP request with paging:
curl -X POST -H "Content-Type: application/json" \ -d '{"findCallers":{"className":"com.example.A","limit":10,"page":2,"pageSize":5}}' \ http://localhost:9090/mcp/query -
Omitting these parameters uses the defaults shown in the manifest.
-
For detailed setup steps see .
Configuring OpenHands
Add to your openhands.toml:
[mcp]
# for CLI stdio tool
stdio_servers = [ { name = "codegraph", command = "java", args = ["-jar","/path/to/cli-all.jar","--stdio"] } ]
# or for IntelliJ HTTP server
sse_servers = ["http://localhost:9090/mcp/query"]
License
This project is released under the MIT License. See for details.