jar-inspector-mcp
jar-inspector-mcp
MCP-сервер, который позволяет Claude Code читать внутри Java-архивов — классы, API, исходники, ресурсы, байткод — без их извлечения.
Проблема
Когда Claude Code работает над JVM-проектом и ему нужно узнать, что внутри jar-файла, он прибегает к shell-инструментам:
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
Решение
Десять узконаправленных инструментов, которые отвечают на фактические вопросы — «что в этом jar», «каков API этого класса», «где задаётся эта строка» — и возвращают только это.
Измерено на jackson-databind-2.16.1.jar (779 классов, 4.1 МБ в распакованном виде):
Вместо | jar-inspector | |||
| 79 674 симв. |
| 2 632 симв. | на 97% меньше |
| 36 008 симв. |
| 18 061 симв. | на 50% меньше |
| 303 105 симв. |
| 21 409 симв. | на 93% меньше |
Ничего не записывается на диск, и JDK не требуется — парсер class-файлов написан на чистом 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 или /mcp внутри Claude Code.
Другие MCP-клиенты: сервер говорит по stdio, так что uvx --from … jar-inspector-mcp работает как команда где угодно.
Инструменты
Инструмент | Ответы |
| Что это за артефакт? Манифест, пакеты, количество классов, уровень байткода, приложены ли исходники |
| Какие записи в нём есть? Фильтрация по glob и типу, постранично |
| Где живёт |
| Каков API этого класса? Объявление, аннотации, поля, сигнатуры методов |
| Что он на самом деле делает? Приложенный исходник |
| Что в этом конфиге? Одна текстовая запись: MANIFEST, |
| Где эта строка? Поиск по текстовым записям и скомпилированным строковым константам |
| Что затрагивает этот класс? Внутренние и внешние ссылки |
| Во что компилируется этот метод? Байткод одного метода через |
| Где находится 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(толстые jar-файлы Spring Boot)
Как выглядит вывод
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), varargs, объявленные исключения, константные значения, записи (records), перечисления и методы default сохраняются. Тела методов, мостовые методы и пулы констант — нет.
Конфигурация
Переменная окружения | Эффект |
| Корни, разделённые разделителем путей, которые сервер может читать. Если не задано — без ограничений |
| Дополнительные каталоги, которые |
| Расположение репозитория Maven, если не |
jar_find ищет по порядку: ./target, ./build/libs, ./libs, ./lib, репозиторий Maven, кэш модулей Gradle, кэш Ivy и кэш Coursier.
Чтобы ограничить сервер одним деревом:
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 тянется к shell, добавьте строку в CLAUDE.md вашего проекта:
To inspect jars, use the jar-inspector MCP tools instead of unzip/jar/javap.Как это работает
Разбор классов — это независимый от зависимостей читатель формата class-файлов: пул констант, флаги доступа,
Signature,MethodParameters,LocalVariableTable,Exceptions,Record,InnerClassesи атрибуты аннотаций времени выполнения. Тела методов пропускаются, если толькоjar_disassembleне запрашивает их.Архивы читаются через
zipfileв памяти. Вложенные jar-файлы открываются из байтов внешней записи, поэтому толстый jar Spring Boot не требует распаковки.Исходники ищутся в самом архиве, затем в соседнем
-sources.jarв структуре Maven, затем в соседнем хэш-каталоге, который использует кэш Gradle.Вывод всегда ограничен и всегда сообщает, когда он был обрезан и как листать дальше.
Разработка
uv sync
uv run pytest # 49 testsТесты компилируют Java-код в tests/java с помощью javac и проверяют реальный байткод, так что обобщения, мостовые методы и записи проверяются по-настоящему; они пропускаются, если JDK отсутствует. Парсер дополнительно проверяется на каждом классе в каждом jar-файле, поставляемом с Maven и Gradle — 65 573 класса, без сбоев.
Лицензия
MIT
Available Tools
10 toolsjar_class_dependenciesARead-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_outlineARead-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_disassembleARead-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_findARead-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_classARead-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_listARead-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_overviewARead-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_entryARead-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_sourceARead-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
jar_searchARead-only
Grep text and source entries inside an archive, returning matching lines.
Use it to find a property key, a bean name, an SQL fragment or a log
message without extracting anything. With include_class_strings=True it
also searches string constants compiled into .class files.
Args:
jar: Archive path, classes directory, or outer.jar!nested.jar.
query: Literal text, or a Python regular expression when regex=True.
regex: Treat query as a regular expression.
ignore_case: Case-insensitive matching.
path: Comma-separated globs limiting which entries are searched.
include_class_strings: Also search string constants inside .class files.
limit: Maximum matches to report.
Inputs: jar (required), query (required), path, limit, +3 more. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 10 tools
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.
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.
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.
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
Related MCP Connectors
Augments MCP Server - A comprehensive framework documentation provider for Claude Code
An MCP server that gives your AI access to the source code and docs of all public github repos
A MCP server built for developers enabling Git based project management with project and personal…
MCP server for developer documentation, generated by doc2mcp.
Related MCP Servers
- AlicenseAqualityBmaintenanceAn MCP server for intelligently reading Java source code, supporting extraction from Maven dependencies and local projects with dual decompilers.2154Apache 2.0
- AlicenseNot gradedqualityBmaintenanceA Model Context Protocol (MCP) server for exploring, analyzing, and decompiling Java JAR files.281 npm11MIT
- AlicenseAqualityDmaintenanceMCP server that indexes your codebase's public API at startup and serves it via compact tool responses, saving tokens vs reading source files.569 PyPI21MIT
- AlicenseBqualityCmaintenanceMCP server for searching, browsing, and analyzing decompiled Minecraft source code locally. Supports symbol lookup, text search, reference lookup, and lightweight RAG.11Apache 2.0