Skip to main content
Glama

re-kaitai

MCP server exposing Kaitai Struct for custom binary format reverse engineering.

Tools

Tool

What it does

check_compiler

Confirm kaitai-struct-compiler is installed

list_known_formats

List bundled .ksy formats

download_format

Download a .ksy from the kaitai-formats gallery

compile_format

Compile .ksy → Python at runtime

parse_with_format

Parse a binary with a compiled or precompiled format

visualize

Same as parse_with_format, named for the intent

diff_parses

Parse two files and return a structural diff

Related MCP server: mcp-pwntools

Install

# System dependency
brew install kaitai-struct-compiler   # macOS
scoop install kaitai-struct-compiler  # Windows
# Linux: download prebuilt from https://github.com/kaitai-io/kaitai_struct_compiler/releases

# Python
pip install kaitaistruct
pip install -e ./servers/re-kaitai

Usage pattern (in Claude Code)

1. "Decode this firmware blob"
2. Claude identifies the file magic (e.g. LZMA header)
3. Claude downloads the matching .ksy: download_format("lzma")
4. Claude compiles: compile_format("/path/lzma.ksy")
5. Claude parses: parse_with_format(path="/path/blob", ksy_path="/path/lzma.ksy")
6. Claude inspects the parse tree, iterates on the .ksy, re-parses

The Kaitai workflow is iterative: compile → parse → fix the schema → re-compile → parse again.

Available Tools

8 tools
check_compilerA

Return kaitai-struct-compiler version.

Inputs: no named parameters.

compile_formatC

Compile a .ksy file to a Python module.

Inputs: ksy_path (required), target.

diff_parsesC

Parse two files with the same format and return a structural diff.

Inputs: path_a (required), path_b (required), format_module, ksy_path.

download_formatC

Download a .ksy spec from the kaitai-formats gallery.

Inputs: name (required), target_dir.

list_known_formatsA

Return the list of bundled .ksy formats.

Inputs: no named parameters. Returns: result

parse_unityfsA

Parse a UnityFS / Addressables bundle, LZ4/LZMA-decompress the first block, and re-parse the directory from the decompressed stream.

The on-disk KSY parse covers the file header + bundle header

  • per-block size records; the directory actually lives inside the decompressed first block (the on-disk format stores compressed block payloads after the per-block size records, and the directory + asset bodies are in those compressed bytes). This helper LZ4 / LZMA-decompresses the requested block and re-parses the Directory sub-type from the decompressed stream.

Args: path: file to parse. ksy_path: optional path to a .ksy to compile on the fly. Defaults to the bundled data/ksy/unity_addressables.ksy (the v0.3 corrected layout). Pass data/ksy/unityfs.ksy for the older bundle_header-wrappered variant. decompress_block: index of the block to re-parse the directory from (default 0, the canonical directory block). Pass -1 to skip the directory re-parse.

Returns: A dict with file_header, bundle_header, decompressed_blocks[] (each with uncompressed_size / compressed_size / decompressed_size / data_b64), and directory (or None if decompress_block=-1).

Inputs: path (required), ksy_path, decompress_block.

parse_with_formatA

Parse a binary using either a precompiled module or a fresh .ksy.

Args: path: file to parse format_module: precompiled module (e.g. "kaitaistruct.gif") ksy_path: path to a .ksy file (will be compiled on the fly)

Inputs: path (required), format_module, ksy_path.

visualizeB

Return a tree-shaped dict suitable for visualization.

Same as parse_with_format but explicitly named for the "show me the structure of this file" intent.

Inputs: path (required), format_module, ksy_path.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    B3.2/5.0

    Scored across 8 tools

    Disambiguation4/5

    Most tools have distinct purposes, but visualize is explicitly described as identical to parse_with_format, causing confusion. One overlapping pair reduces clarity.

    Naming Consistency3/5

    Mix of verb_noun and verb patterns; 'visualize' is a single verb unlike others, and 'parse_with_format' uses 'with' breaking the convention. Inconsistent but still readable.

    Tool Count5/5

    8 tools is well-scoped for a Kaitai Struct parsing server, covering compilation, parsing, downloading, listing, diffing, and a specialized format. No unnecessary tools.

    Completeness4/5

    Covers core workflows (compile, parse, diff, download, list), but lacks tools for format creation or conversion. Minor gaps, e.g., no way to inspect precompiled modules.

    Related MCP Connectors

    Related MCP Servers