Skip to main content
Glama
jar-inspector-mcp

jar-inspector-mcp

jar-inspector-mcp

Claude Code が Java アーカイブの内部を読み取れるようにする MCP サーバー — クラス、API、ソース、リソース、バイトコード — 展開せずに。

問題

Claude Code が JVM プロジェクトで作業していて、jar の中身を知る必要がある場合、シェルツールに頼ってしまいます:

unzip -l target/lib/jackson-databind-2.16.1.jar     # 780 lines of entry listing
unzip -o app.jar -d /tmp/x && cat /tmp/x/…/Foo.java # a whole file to answer one question
javap -p -c -cp app.jar com.acme.Foo                # 300 KB of bytecode

そのすべてがコンテキストウィンドウに流れ込み、そのほとんどはノイズで、一部はワーキングツリーに一時ファイルを書き込みます。

Related MCP server: dejared-mcp

解決策

10 個の焦点を絞ったツールが実際の質問 — 「この jar には何が入っているか」「このクラスの API は何か」「この文字列はどこで設定されているか」— に答え、その情報だけを返します。

jackson-databind-2.16.1.jar (779 クラス、展開時 4.1 MB) で測定:

代わりに

jar-inspector

unzip -l <jar>

79,674 文字

jar_overview

2,632 文字

97% 削減

javap <class>

36,008 文字

jar_class_outline

18,061 文字

50% 削減

javap -p -c <class>

303,105 文字

jar_class_outline

21,409 文字

93% 削減

ディスクに書き込まれることは一切なく、JDK も不要です — クラスファイルパーサーは純粋な Python です。(jar_disassemble だけが例外で、javap を外部コマンドとして実行します。)

インストール

uv と Python 3.10+ が必要です。

# from GitHub, nothing to clone
claude mcp add jar-inspector -- uvx --from git+https://github.com/pgatzka/jar-inspector-mcp jar-inspector-mcp

# or from a local clone
git clone https://github.com/pgatzka/jar-inspector-mcp && cd jar-inspector-mcp
claude mcp add jar-inspector -- uv run --directory "$PWD" jar-inspector-mcp

--scope project を追加すると .mcp.json を通じてリポジトリと共有でき、--scope user を追加するとどこでも有効になります。代わりに手動で設定する場合:

// .mcp.json
{
  "mcpServers": {
    "jar-inspector": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/pgatzka/jar-inspector-mcp", "jar-inspector-mcp"]
    }
  }
}

claude mcp list、または Claude Code 内の /mcp で確認します。

他の MCP クライアント: このサーバーは stdio で通信するため、uvx --from … jar-inspector-mcp をコマンドとしてどこでも使用できます。

ツール

Tool

回答

jar_overview

このアーティファクトは何か? マニフェスト、パッケージ、クラス数、バイトコードレベル、ソースが添付されているか

jar_list

中にはどのエントリがあるか? グロブと種類でフィルタリング、ページング対応

jar_find_class

HttpClient はどこにあるか? 単純名、FQCN、またはグロブ → クラス名

jar_class_outline

このクラスの API は何か? 宣言、アノテーション、フィールド、メソッドシグネチャ

jar_read_source

実際には何をするか? 添付された .java/.kt ソースを行ウィンドウ単位で

jar_read_entry

この設定には何が入っているか? 1 つのテキストエントリ: MANIFEST、META-INF/services/…、XML

jar_search

この文字列はどこにあるか? テキストエントリとコンパイル済み文字列定数を横断して grep

jar_class_dependencies

このクラスは何に触れているか? 内部参照と外部参照

jar_disassemble

このメソッドは何にコンパイルされるか? javap による 1 つのメソッドのバイトコード

jar_find

jar はどこにあるか? ビルド出力、Maven リポジトリ、Gradle キャッシュを検索

すべてのツールは読み取り専用で、以下を受け付ける jar 引数を取ります:

  • アーカイブ — .jar、.war、.ear、.aar、.zip、.jmod

  • 展開済みクラスディレクトリ — target/classes、build/classes/java/main

  • ネストされたアーカイブ — app.jar!BOOT-INF/lib/dep-1.0.jar (Spring Boot のファット jar)

出力例

jar_class_outline の出力をそのまま示します (テストが検証する正確な出力です):

com.acme.demo.UserService  [class, Java 21, UserService.java]
// source is attached -- jar_read_source(jar, 'com.acme.demo.UserService') shows it

@Deprecated
@Marker(enabled=true, code='z', tags={"alpha", "beta"})
public class UserService implements Repository<String, Integer>

  // fields (2)
  public static final String CACHE_KEY = "user.cache"
  protected volatile boolean dirty

  // constructors (1)
  public UserService(Map<Integer, String> users)

  // methods (5)
  public long count()
  public List<String> findAll()
  public Optional<String> findById(Integer id) throws IllegalStateException
  public <R extends Comparable<R>> List<R> mapAll(Function<String, R> fn)
  public void rename(int id, String newName, String... aliases)

  // nested (1)
  UserService.Builder

  // 4 more member(s) hidden (visibility below 'protected', synthetic or bridge)

ジェネリックシグネチャ、パラメータ名 (-g 付きでコンパイルされた場合)、可変長引数、宣言済み例外、定数値、レコード、enum、default メソッドはすべて保持されます。メソッド本体、ブリッジメソッド、定数プールは保持されません。

設定

環境変数

効果

JAR_INSPECTOR_ALLOW

サーバーが読み取り可能なパス区切り形式のルート。未設定の場合は制限なし

JAR_INSPECTOR_SEARCH_PATH

jar_find が最初にスキャンする追加ディレクトリ

MAVEN_REPO_LOCAL

Maven リポジトリの場所 (~/.m2/repository でない場合)

jar_find は次の順序で検索します: ./target、./build/libs、./libs、./lib、Maven リポジトリ、Gradle モジュールキャッシュ、Ivy キャッシュ、Coursier キャッシュ。

サーバーを 1 つのツリーに制限するには:

claude mcp add jar-inspector --env JAR_INSPECTOR_ALLOW="$HOME/work:$HOME/.m2" \
  -- uvx --from git+https://github.com/pgatzka/jar-inspector-mcp jar-inspector-mcp

Claude に使うよう促す

このサーバーには MCP の instructions が同梱されており、これらのツールが unzip、jar xf、javap の代わりになることをクライアントに伝えます。それでも Claude がシェルを使おうとする場合は、プロジェクトの CLAUDE.md に 1 行追加してください:

To inspect jars, use the jar-inspector MCP tools instead of unzip/jar/javap.

仕組み

  • クラス解析は、クラスファイル形式に対する依存関係のないリーダーです: 定数プール、アクセスフラグ、Signature、MethodParameters、LocalVariableTable、Exceptions、Record、InnerClasses、実行時アノテーション属性。メソッド本体は jar_disassemble が要求しない限りスキップされます。

  • アーカイブは zipfile を通じてメモリ上で読み取られます。ネストされた jar は外側のエントリのバイトから開かれるため、Spring Boot のファット jar を展開する必要はありません。

  • ソースは、アーカイブ自体、次に Maven レイアウトの兄弟 -sources.jar、次に Gradle のキャッシュが使用する隣接するハッシュディレクトリから解決されます。

  • 出力は常に上限が設定され、切り詰められた場合とページング方法が必ず示されます。

開発

uv sync
uv run pytest          # 49 tests

テストは tests/java 内の Java を javac でコンパイルし、実際のバイトコードに対して検証するため、ジェネリクス、ブリッジメソッド、レコードが実際にテストされます。JDK がない場合はスキップされます。さらに、パーサーは Maven と Gradle に同梱されているすべての jar 内のすべてのクラスに対してチェックされています — 65,573 クラス、失敗なし。

ライセンス

MIT

Available Tools

10 tools
jar_class_dependenciesA
Read-only

List the classes a compiled class references, split into internal and external.

Useful for tracing what a class actually touches, and for spotting which dependency supplies a type, without decompiling anything.

Args: jar: Archive path, classes directory, or outer.jar!nested.jar. class_name: FQCN, simple name or glob. include_jdk: Include java.*/javax.*/jdk.* references. limit: Maximum references to list.

Inputs: jar (required), class_name (required), limit, include_jdk. Returns: result

jar_class_outlineA
Read-only

Show a class's API: declaration, annotations, fields and method signatures.

This is the cheap alternative to decompiling or reading source. Signatures keep generics, parameter names (when compiled with -g), thrown exceptions and constant values; method bodies are not included.

Args: jar: Archive path, classes directory, or outer.jar!nested.jar. class_name: FQCN, simple name or glob (resolved like jar_find_class). visibility: Lowest visibility to include: public, protected, package, private. include_synthetic: Include compiler-generated bridge/synthetic members. fully_qualified_types: Print java.util.List instead of List.

Inputs: jar (required), class_name (required), visibility, include_synthetic, +1 more. Returns: result

jar_disassembleA
Read-only

Disassemble one method's bytecode with javap (needs a JDK on PATH).

Reach for this only when the API outline and the source are not enough -- for example when checking what a method compiles to, or reading a class that has no sources attached. Always pass method to keep it small.

Args: jar: Archive path or classes directory (nested ! specs are not supported). class_name: FQCN, simple name or glob. method: Method name to keep; empty returns every method (often large). limit: Maximum lines of disassembly to return.

Inputs: jar (required), class_name (required), limit, method. Returns: result

jar_findA
Read-only

Find jar files on this machine by name: build output, Maven repo, Gradle cache.

Use it to turn "the Jackson databind jar" into a path you can pass to the other tools.

Args: query: Part of the file name, or a glob such as jackson-databind-*.jar. search_path: Extra directories to scan first, separated by the path separator. include_classifiers: Also list -sources, -javadoc and -tests jars. limit: Maximum jars to return.

Inputs: query (required), limit, search_path, include_classifiers. Returns: result

jar_find_classA
Read-only

Find classes in an archive by simple name, fully-qualified name or glob.

Use this to turn "where does HttpClient live" into a concrete class name you can pass to jar_class_outline or jar_read_source.

Args: jar: Archive path, classes directory, or outer.jar!nested.jar. name: HttpClient, com.acme.HttpClient, or a glob like com.acme.*Repo. limit: Maximum matches to return.

Inputs: jar (required), name (required), limit. Returns: result

jar_listA
Read-only

List entries in an archive, filtered by glob and kind.

Prefer this over unzip -l. Use kind='text' to find configuration, kind='archive' to find jars bundled inside a fat jar.

Args: jar: Archive path, classes directory, or outer.jar!nested.jar. pattern: Comma-separated globs matched against the entry path, e.g. META-INF/* or *.properties. Empty matches everything. kind: One of all, class, source, text, binary, archive. limit: Maximum entries to return. offset: Entries to skip, for paging.

Inputs: jar (required), kind, limit, offset, +1 more. Returns: result

jar_overviewA
Read-only

Summarize a Java archive: manifest, size, packages, class count, and whether sources are attached.

Start here when you meet an unfamiliar jar, instead of unzipping it or listing every entry.

Args: jar: Path to a .jar/.war/.aar/.zip, an exploded classes directory, or a nested archive such as app.jar!BOOT-INF/lib/dep-1.0.jar.

Inputs: jar (required). Returns: result

jar_read_entryA
Read-only

Read one text entry from an archive: MANIFEST, service files, XML, config.

Prefer this over unzip -p. Binary entries are described, not dumped.

Args: jar: Archive path, classes directory, or outer.jar!nested.jar. entry: Exact entry path, e.g. META-INF/spring.factories. start_line: 1-based first line to show. line_count: How many lines to show.

Inputs: jar (required), entry (required), line_count, start_line. Returns: result

jar_read_sourceA
Read-only

Read attached Java/Kotlin source for a class, one line window at a time.

Looks inside the archive itself, then the matching -sources.jar next to it (Maven layout) or beside it in the Gradle cache. If no source is available, say so and fall back to jar_class_outline.

Args: jar: Archive path, classes directory, or outer.jar!nested.jar. target: FQCN (com.acme.Foo) or an entry path (com/acme/Foo.java). start_line: 1-based first line to show. line_count: How many lines to show; use a window rather than whole files. sources_jar: Explicit sources archive, when auto-detection misses it.

Inputs: jar (required), target (required), line_count, start_line, +1 more. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.4/5.0

    Scored across 10 tools

    Disambiguation5/5

    Each tool targets a distinct inspection task: overview, listing, class lookup, API outline, source reading, entry reading, search, dependency analysis, disassembly, and jar discovery. There is no meaningful overlap that would make an agent likely to pick the wrong tool.

    Naming Consistency3/5

    All tools share the jar_ prefix, which helps, but the grammatical pattern is mixed: jar_list and jar_search are bare verbs, jar_find_class and jar_read_source are verb_noun, while jar_overview and jar_class_outline are noun phrases. The names are readable but not consistently verb_noun.

    Tool Count5/5

    Ten tools is well within the ideal range and each tool covers a distinct facet of archive inspection. The count feels neither bloated nor thin for the stated purpose.

    Completeness5/5

    The read-only jar inspection domain is covered thoroughly: overview, listing, class lookup, API outline, source reading, arbitrary text entries, grep-like search, class dependency analysis, bytecode disassembly, and locating jars on disk. An agent can move from finding a jar to reading its source or bytecode without obvious dead ends.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      An MCP server for intelligently reading Java source code, supporting extraction from Maven dependencies and local projects with dual decompilers.
      2
      154
      Apache 2.0
    • A
      license
      Not graded
      quality
      B
      maintenance
      A Model Context Protocol (MCP) server for exploring, analyzing, and decompiling Java JAR files.
      281 npm
      11
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      MCP server that indexes your codebase's public API at startup and serves it via compact tool responses, saving tokens vs reading source files.
      5
      69 PyPI
      21
      MIT
    • A
      license
      B
      quality
      C
      maintenance
      MCP server for searching, browsing, and analyzing decompiled Minecraft source code locally. Supports symbol lookup, text search, reference lookup, and lightweight RAG.
      11
      Apache 2.0