When an AI coding agent needs to know what a dependency jar actually contains, it usually reaches for the tools a human would: unzip -l, javap, grep, sed. That works, but it is expensive. javap -c dumps the whole class, the agent pages through it with head, and a lot of tokens go to output it never needed.
jdx is an open-source (Apache-2.0) command line tool and MCP server that answers IDE-style questions about any JVM jar, -sources.jar, class directory, Maven coordinate or the JDK itself, and returns only the part you asked for.
The cost of the javap route
The jdx README has a reproducible benchmark (sh docs/bench-compare.sh) for one task: list Gson's API, then show only toJson(Object) on gson-2.14.0.
| Route | Calls | Output |
|---|---|---|
| unzip + javap + grep + sed | 5 | ~17.5 KB (~4.4k tokens), and head -200 misses the method (it is at line 542 of 1265) |
jdx members + jdx body
|
2 | ~4.6 KB (~1.2k tokens) |
The method body alone is 267 bytes from jdx, versus 60,590 bytes for javap -c on the class (226x) or 58,251 bytes for the full Gson.java (218x).
What a targeted answer looks like
$ jdx body 'com.google.gson.Gson#toJson(Object)' --coord com.google.code.gson:gson:2.14.0
com.google.gson.Gson#toJson(java.lang.Object)
source: gson-2.14.0-sources.jar · com/google/gson/Gson.java:542-547
public String toJson(Object src) {
if (src == null) {
return toJson(JsonNull.INSTANCE);
}
return toJson(src, src.getClass());
}
next: jdx show com.google.gson.Gson
Every answer says where it came from (source: line). When there is no sources jar, jdx decompiles with Vineflower and labels the output ⚠ reconstructed; --engine javap still gives you raw bytecode when you want it.
It also refuses to guess. Ask for Gson#toJson without a signature and it exits with code 2 and lists all 8 overloads as paste-ready references, so an agent can pick the right one instead of reading the wrong method.
Using it as an MCP server
jdx mcp exposes 27 typed tools (v1.7.0): jdx_members, jdx_body, jdx_source, jdx_signature, jdx_usages, jdx_callers, jdx_implementors, jdx_hierarchy, jdx_diff, jdx_literals, jdx_resources and more. Generic config:
{"mcpServers":{"jdx":{"command":"jdx","args":["mcp"]}}}
Or wire it into your agent in one command:
jdx setup --agent claude-code --scope project
Supported agents: Claude Code, Cursor, Codex CLI, GitHub Copilot CLI, OpenCode, Kilo Code, Cline (--scope system), Antigravity, Windsurf and Aider. Per-agent guides: integrations.
Through the daemon/MCP server answers are warm (about 20 ms, per the docs), versus roughly 250 ms for a cold one-shot CLI call.
Safe to point at unknown jars
jdx parses bytecode with ASM and never loads or executes the classes it inspects. It only touches the network when you pass --fetch (or run jdx upgrade / jdx kotlin install). Inside a Gradle or Maven project it finds sources and dependency jars from the local caches without running the build.
Kotlin and Minecraft mods too
For Kotlin jars it reads @Metadata and shows true signatures (suspend, properties, default arguments, nullability). Minecraft modders can inspect mod jars from the terminal; jdx does not remap, so pass the Loom-remapped jar with --jars. There is a guide: Inspect Minecraft mod jars from the terminal.
Try it
curl -fsSL https://raw.githubusercontent.com/MohammadMD1383/jdx/main/install-release.sh | bash
jdx members java.util.HashMap --limit 5
Needs a Java 21+ runtime; works on Linux, macOS and Windows. Docs and quickstart: https://mohammadmd1383.github.io/jdx/ · Source: https://github.com/MohammadMD1383/jdx
Top comments (0)