DEV Community

Mohammad Mostafa Dastjerdi
Mohammad Mostafa Dastjerdi

Posted on Originally published at mohammadmd1383.github.io

Classpath MCP without a workspace: let an AI agent read Java jars in jdx v1.8.0

When I first shipped the jdx MCP server, an AI coding agent could already ask IDE questions about a JVM jar — members, one method body, usages, implementors — but only after I had created a stored workspace. That is a good setup for a long-lived project. It is the wrong setup when you just want Claude Desktop or Cursor to look at one jar, a Maven coordinate already in your cache, or the Gradle project in the working directory.

jdx v1.8.0 changes that. Classpath MCP tools now take optional jars, coord, and discover arguments. If the call does not name a workspace and the server does not have one, those arguments are enough on their own.

jdx is an open-source (Apache-2.0) command-line tool and MCP server I built for Java and Kotlin. It parses bytecode with ASM and never loads or executes the classes it inspects. It needs a Java 21+ runtime and runs on Linux, macOS, and Windows.

Install

curl -fsSL https://raw.githubusercontent.com/MohammadMD1383/jdx/main/install-release.sh | bash
Enter fullscreen mode Exit fullscreen mode

Windows (PowerShell):

irm https://raw.githubusercontent.com/MohammadMD1383/jdx/main/install-release.ps1 | iex
Enter fullscreen mode Exit fullscreen mode

Or download jdx-1.8.0-windows.zip from the release assets and run install-release.ps1, or sh install-release.sh --tarball jdx-1.8.0-windows.zip. After that, jdx upgrade self-updates. Releases are unsigned, so expect a first-run warning: Unblock-File on Windows, or xattr -d com.apple.quarantine <install-dir>/jdx on macOS.

Wire it into Claude Desktop, Cursor, or another MCP client

Any MCP client, including Claude Desktop, can use this config:

{"mcpServers":{"jdx":{"command":"jdx","args":["mcp"]}}}
Enter fullscreen mode Exit fullscreen mode

Cursor, Claude Code, Codex CLI, GitHub Copilot CLI, OpenCode, and the other supported agents can be wired with one command:

jdx setup --agent cursor --scope project
Enter fullscreen mode Exit fullscreen mode

Desktop clients that install an MCP Bundle can use jdx-mcp-1.8.0.mcpb from the same release instead of a PATH entry. The bundle launches bin/jdx mcp over stdio, and bin/jdx.bat mcp on Windows. A Java 21+ runtime must still be on PATH or in JAVA_HOME.

Pass a jar, a Maven coordinate, or discover the project

jars and coord accept a comma-separated string or a JSON array, the same shape as CLI --jars and --coord.

Point a tool call at jars you already have:

"jars": "build/libs/app.jar,libs/dep.jar"
Enter fullscreen mode Exit fullscreen mode

or as an array:

"jars": ["build/libs/app.jar", "libs/dep.jar"]
Enter fullscreen mode Exit fullscreen mode

Ask from a Maven coordinate that is already in ~/.gradle/caches or ~/.m2:

"coord": "com.google.code.gson:gson:2.14.0"
Enter fullscreen mode Exit fullscreen mode

or:

"coord": ["com.google.code.gson:gson:2.14.0"]
Enter fullscreen mode Exit fullscreen mode

MCP does not download. An uncached coordinate is exit 5, and the message names a cold CLI --fetch. Prime the cache once from the terminal, then the agent can keep using coord.

For a Gradle or Maven checkout, turn project auto-discovery on for the session:

jdx mcp --discover
Enter fullscreen mode Exit fullscreen mode
{"mcpServers":{"jdx":{"command":"jdx","args":["mcp", "--discover"]}}}
Enter fullscreen mode Exit fullscreen mode

Discovery walks up from the server's working directory and never runs Gradle or Maven. A per-call discover argument overrides that session flag. Explicit jars and coordinate jars merge in front of workspace or discovered jars.

A few rules keep this predictable:

  • If a call sets workspace, that stored name must exist. A miss is exit 4 even when jars or discover are also set.
  • When the call does not name a workspace and the server's workspace is missing, jars, coord, or discovery answer on their own.
  • diff, version, doctor, and health do not take these arguments. The unix daemon and HTTP API are unchanged.

Read-only by design

The v1 daemon, HTTP, and MCP wire stays read-only (issue #19). There is no workspace or cache tool on that wire. jdx_doctor is refused with exit 6; MCP tells you to run jdx doctor in a shell. jdx doctor and jdx batch still answer doctor in-process.

Every MCP tool is annotated readOnlyHint: true, destructiveHint: false, idempotentHint: true, and openWorldHint: false. No tool declares fetch. Inspected classes are parsed with ASM and never loaded. That is the contract I want an agent to see: it can read a jar, and it cannot change your machine through this server.

Minecraft mod jars

If the jar is a Minecraft mod, the same jars argument is how you pass the Loom-mapped jar that Fabric Loom or NeoForge ModDevGradle already wrote. jdx does not remap. A diff is only meaningful when both sides already share one mapping namespace. The Minecraft mods guide and the new blog post cover those limits.

Try it

jdx mcp --discover
Enter fullscreen mode Exit fullscreen mode

Or, from the CLI, the same classpath shapes:

jdx members com.google.gson.Gson --coord com.google.code.gson:gson:2.14.0
Enter fullscreen mode Exit fullscreen mode

The longer MCP walkthrough is An MCP server for Java and Kotlin bytecode. Release notes: jdx v1.8.0. Source: github.com/MohammadMD1383/jdx.

Top comments (0)