jar-viewer-mcp
v0.1.0
Published
MCP server that lets LLMs browse and decompile Java JARs with optional source attachment.
Readme
Java Jar Viewer MCP
MCP server that lets an LLM browse JAR contents, attach *-sources.jar source, and decompile .class files with CFR. It also runs Maven/Gradle dependency resolution to surface absolute paths for local artifacts.
Prerequisites
- Node.js 18+
- Java 8+ (JDK with
javap) on PATH (for CFR and describe_class) - Maven on PATH when using
scan_project_dependenciesfor Maven projects - Gradle Wrapper (
./gradlew) or Gradle on PATH when usingscan_project_dependenciesfor Gradle projects
Install & Run
npm install
npm run build
node dist/index.js # or add to your MCP registryTools
list_jar_entries(jarPath, innerPath?): Lists up to 100 items from the JAR, folding by directory level for quick navigation.read_jar_entry(jarPath, entryPath): Reads the requested entry. For.class, it first looks for a sibling*-sources.jarand otherwise decompiles with CFR; falls back tojavapsignatures if needed.describe_class(jarPath, className?, entryPath?, memberVisibility?, methodQuery?, limit?): Returns method signatures for a class usingjavap(no decompilation). UsememberVisibility="public"(default) or"all"for all members.resolve_class(projectPath, className, dependencyQuery?, includeMembers?, memberVisibility?, methodQuery?, limit?): Locates the class inside project dependency jars. IfincludeMembers=true, also returns method signatures (same filters asdescribe_class).scan_project_dependencies(projectPath, excludeTransitive?, configurations?, includeLogTail?, query?): Detects Maven/Gradle projects (bypom.xmlorbuild.gradle(.kts)/settings.gradle(.kts)), then resolves absolute artifact paths. Usesmvn dependency:listfor Maven, and an injected Gradle init script (mcpListDeps) for Gradle. Results are cached per project root.querydoes a case-insensitive substring match ongroupId:artifactIdand the artifact path.excludeTransitive: set totrueto return only first-level dependencies.configurations: Gradle-only list of configuration names to include (e.g.["runtimeClasspath"]).includeLogTail: set totrueto include the last lines of build output for debugging.
lib/cfr-0.152.jar is bundled and copied into dist/lib during npm run build; paths are resolved at runtime via import.meta.url to avoid hard-coding.
