本地jar包阅读
一个MCP服务器,允许LLM浏览JAR内容、附加源JAR文件、使用CFR反编译类文件,并运行Maven/Gradle依赖解析。
MCP 服务配置
复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用
{
"mcpServers": {
"jar-viewer": {
"args": [
"-y",
"jar-viewer-mcp@latest"
],
"command": "npx"
}
}
}
服务介绍
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.
Chinese doc: README.zh-CN.md.
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
Quick start (npx)
npx -y jar-viewer-mcp@latest
MCP config snippet
Use this in your MCP client/registry (example format):
{
"mcpServers": {
"jar-viewer": {
"command": "npx",
"args": ["-y", "jar-viewer-mcp@latest"]
}
}
}
Install options
Global install
npm install -g jar-viewer-mcp
jar-viewer-mcp
Local development
npm install
npm run build
node dist/index.js
Tools
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.