Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

MCP tools

binscout-mcp serves 43 tools over stdio (newline-delimited JSON-RPC). Each takes binary plus an optional db path, an optional raw mapping object or fat_arch slice selection, and optional pdb / debug_file debug inputs (diff takes binary_a/binary_b plus optional db_a/db_b with one shared raw/fat_arch selection and default debug options; batch takes one envelope plus a list of read-only ops) and returns one JSON document as text; failures are tool errors. Attach it to any MCP client:

{
  "mcpServers": {
    "binscout": { "command": "/path/to/binscout-mcp" }
  }
}
ToolParametersDoes
project_infobinaryOpen a binary and report arch, format, entry, mapping (mode, base), diagnostic totals, and analysis_revision; read-only, never saves the snapshot — call load once to persist the sidecar so later opens replay it instead of re-analyzing
loadbinaryPersist the analysis snapshot to the project DB (binary untouched); CLI load parity, warms the sidecar so later opens replay it instead of re-analyzing
functionsbinary, query/caller/callee/range_lo/range_hi or range_start/range_end, offset/limitList functions with rename-resolved names, filtered (query case-insensitive substring; caller/callee addresses resolving to call-graph neighbors; exactly one range pair: range_lo + range_hi bounding entries inclusive, or range_start + range_end bounding them half-open) and paged under the protocol-1 page envelope with an exact total; rows carry the compact calls_count instead of the calls target array (use callees at depth 1 for the targets; the envelope parameter is accepted but ignored)
funcbinary, addrCompact metadata of one function: entry, name, block/insn/call counts, discovery reasons
blocksbinary, addr, offset?/limit?Block summaries of the containing function by block start, under the page envelope
block_insnsbinary, addr, block, offset?/limit?That block’s instructions in address order, under the page envelope; block must belong to the function
disasmbinary, addr, lenDisassemble len bytes at addr with the binary architecture; the valid prefix plus error_at for the first bad opcode (ranges cap at 1 MiB)
bytesbinary, addr, len, as?/endian?/as_type?Raw bytes at addr (len caps at 1 MiB, BSS tails read as zeros) with VA/file provenance (file_off null for zero-fill, section null when section-less) plus bytes_hex and typed values (u8/u16/u32/u64/ptr/cstr/utf16, le/be byte order) with the exact 0x-hex twin values_hex on integer views (absent on string views); as_type takes a stored type-hint address and renders its struct fields over the range start (len must cover the struct size)
cfgbinary, addrControl-flow graph of one function: block nodes plus block edges; inferred_edges holds provenance-marked indirect-jump resolutions (single-slot absolutes and guarded scaled-index tables; raw-only, same-function); query_addr echoes the address passed in addr
structurebinary, addrApproximate control-flow structure of one function: syntactic loops (back-edge headers with latches) and ifs (two-successor branch sites with then/else targets) plus an approximation warning; addr snaps to its containing function, query_addr echoes it
pseudobinary, addrApproximate pseudo-C of one function: one lossy C-like line per IR row plus assembled text, with an approximation warning; addr snaps to its containing function, query_addr echoes it
calleesbinary, addr, depth?/offset?/limit?Transitive callees out to depth hops (direct are depth 1), ordered by entry with shortest distance, under the page envelope; addr snaps to its containing function
callersbinary, addr, depth?/offset?/limit?Transitive callers out to depth hops, ordered by entry with shortest distance, under the page envelope; addr snaps to its containing function
slicebinary, addr, depth?/offset?/limit?Backward slice of addr: every instruction that can reach it via xref edges (any kind) and intra-function CFG predecessors out to depth hops (direct are depth 1, default 8, zero yields an empty page, past the 64-hop cap is an Invalid error), ordered by address with shortest distance, under the page envelope; any mapped address is a valid root (unmapped roots are a NotFound error)
diagnosticsbinary, kind?, func?, offset/limitProvenance records (unresolved indirect sites, decode failures) ordered by (kind, addr) under the page envelope, filtered by kind and containing-function func; queries never write a sidecar
xrefsbinary, to/from/kind, offset/limitCross-references filtered by endpoint and kind (code, data, string, import, inferred-code), paged under the protocol-1 page envelope (items) with an exact total; rows carry listing context (from_func/from_func_name, to_name, to_string for string-kind rows)
stringsbinary, pattern/min_len/section/include_code/decode/with_xrefs, start/limitExtracted strings ordered by address, filtered and paged under the protocol-1 page envelope with an exact total; executable-memory hits hidden unless pattern, section, or include_code is given (offset is a deprecated alias of start, warning on stderr; the envelope parameter is accepted but ignored); decode (xor:<byte>, xor:0x<HEXKEY> rolling multi-byte key, add:<byte>, rot:<0-7>, or bare base64) re-extracts over a read-only in-memory transform with original offsets; with_xrefs adds the bounded per-row xrefs reference list
stack_stringsbinary, offset?/limit?Recovered stack-constructed strings: runs of mov [rsp/rbp+off], imm within one block, reassembled with function and address, paged under the protocol-1 page envelope; read-only, never writes the binary or the sidecar
symbolsbinaryImports, exports, and symbol-table code addresses of the binary (symbols: one name/address/address_hex row per defined text symbol, locals included, deduplicated by address); Mach-O imports carry the address/address_hex of their __stubs/__auth_stubs entry (null when unmapped), and each mapped stub seeds its own import-named function; symbol addresses seed symbol-reasoned functions named below exports and above stubs
sectionsbinarySection table: name, virtual address (IMAGE_BASE + RVA on PE), in-memory/file sizes, Shannon entropy (bits per byte), permissions
irbinary, addr, lenLift len bytes at addr to P-code-inspired IR (error_at on trailing bad bytes, ranges cap at 1 MiB)
ir_coveragearch, binary?/addr?/len?Machine-readable lift coverage for one arch (implemented families, partial mappings, limitations); no binary is opened without the range, which adds decoded/lifted/unlifted counts from actual lifts plus a bounded mnemonic summary
flirt_hintsbinary, addr?, sigs?, offset?/limit?FLIRT-like library hints: corpus signature matches over each function’s leading bytes, paged under the protocol-1 envelope; addr keeps only the containing function’s hints; sigs adds a user signature file path (our JSON, as emitted by sig_gen, or an IDA .pat file by extension); suggested names stay hints, querying never writes a sidecar
sig_genbinaryEmit a JSON signature document for the binary’s named functions (masked leading bytes with len/crc): the sigs input that flirt_hints reads back; read-only, never writes the binary or the sidecar
go_funcsbinary, offset?/limit?Recover Go functions from the pclntab table (linker names plus exact entry/end ranges) for stripped Go binaries, paged under the protocol-1 page envelope; empty table reads as an empty items page; read-only, never writes the binary or the sidecar
statsbinaryStorage stats: binary size, sidecar DB size, and analysis counts
headersbinaryHeader metadata: triage staples (PE mitigations/imphash/PDB, ELF interp/needed/RELRO/NX/PIE, Mach-O load commands/codesign) plus sha256/md5; computed on demand, never persisted
renamebinary, addr, nameRename a function in the project DB (binary untouched); empty name clears
annotationbinary, addrRead the annotation at one address (rename/comment with addr twins; nulls when unset); read-only, never creates or modifies the sidecar; CLI annotate without flags parity
commentbinary, addr, commentComment any address in the project DB (binary untouched); empty comment clears; structured struct-layout hints (type-hint:{...}, see JSON protocol) pass through opaquely
set_type_hintbinary, addr, hintStore a structured struct-layout hint at any address from wire JSON ({"kind":"struct","name":..,"size":..,"fields":[..]}) in the project DB (binary untouched); empty hint clears the hint, plain comments are left alone
get_type_hintbinary, addrRead the structured struct-layout hint at one address ({"addr", "addr_hex", "hint"} with the wire object or null; corrupt hints error, plain comments read as null); read-only, never creates or modifies the sidecar
define_funcbinary, addr, mode?Assert “there is code here”: store a user function seed and re-analyze so it materializes; mode (arm/thumb) selects the 32-bit ARM decode, other arches reject it
undefine_funcbinary, addrAssert “this isn’t a function”: exclude the seed (kept as data) and re-analyze
search_bytesbinary, pattern, section?/range_lo?/range_hi? or range_start?/range_end?, offset?/limit?Paged ??-wildcard byte-pattern matches ordered by virtual address (exactly one range pair: range_lo + range_hi bound the inclusive [lo, hi] range, range_start + range_end bound the half-open [lo, hi) range); scans cap at 256 MiB of mapped bytes with an explicit Limit error
crypto_scanbinary, name?/section?, offset?/limit?Paged crypto-constant matches (addr/addr_hex, name, file_off, section, len, xrefs_count) for the static table (AES/SHA/MD5/CRC-32 tables, ChaCha sigma, Blowfish P-array, TEA delta, LE/BE word orders)
annotations_exportbinaryEmit the portable annotation interchange document; read-only, never creates a sidecar
annotations_importbinary, document, overwrite?Atomically merge a document; returns row/change counts, default fails on conflicts
diffbinary_a, binary_b, db_a?/db_b?, raw?/fat_arch?, offset?/limit?, transfer_renames?Function-level diff between two binaries (matched/added/removed/changed with match reason, plus BinDiff-style neighbour propagation); each list pages under the protocol-1 envelope; transfer_renames embeds the side-B rename document for annotations_import; both projects open read-only, never creating or modifying a sidecar; the shared raw/fat_arch selection (if any) applies to both
diff_funcbinary_a, binary_b, addr_a, addr_b, db_a?/db_b?, raw?/fat_arch?Block- and instruction-level delta between two functions (blocks match by hash then by position, each matched block carries a bounded edit script); addresses snap to their containing entries; read-only like diff
patchbinary, addr, asm?/bytes?, out?/format?Assemble replacement bytes at one x86 or aarch64 address and export the patch (va/va_hex, file_off null when not file-backed, old_hex, new_hex, size_ok) without writing the binary; exactly one of asm (x86: one of nop, ret, int3, jmp ADDR, call ADDR; aarch64: one of nop, ret, brk #IMM, b ADDR, bl ADDR, at a 4-aligned address with a byte count that is a multiple of 4, encoded at the address) or bytes (whitespace-separated hex pairs); shorter replacements NOP-pad to the instruction boundary (x86), longer ones report size_ok:false; out writes a json (default) or ips patch file that must differ from the binary; overflowing or non-file-backed patches refuse the file write; rejected in batch
batchbinary, db?/raw?/fat_arch?/pdb?/debug_file?, ops (1–32)Up to 32 read-only ops over one open project, run in order; returns {"results": [{"ok"} | {"error"}]} with per-op limits unchanged and total output capped at 1 MiB (see below)

Addresses are 0x-hex or decimal strings. kind filters accept code, data, string, import, and inferred-code (case-insensitive); stored rows keep the historical Code/Data/String spelling while inferred rows serialize as kebab-case inferred-code. One server process keeps a 4-entry LRU of open projects keyed by binary, sidecar, mapping, and debug inputs and revalidated by file length plus mtime, so repeat calls skip re-analysis; each entry has its own lock and each sidecar file its own handle mutex, so calls on different binaries proceed concurrently while calls sharing a binary or sidecar serialize (redb allows a single open handle per file per process).

Errors

Failures are tool errors carrying the JSON-RPC code plus data: {"kind": ...}: invalid_params for bad inputs and over-cap ranges (kind invalid or limit — narrow the query), resource_not_found for unknown functions and addresses (kind not_found — retry with a snapped address), and internal_error for unsupported inputs plus sidecar and filesystem failures (kind unsupported, storage, or io — give up or retry nothing). See JSON protocol for the full variant table.

Batch

One MCP round trip for the func → cfg → pseudo → xrefs per-function loop: the envelope opens the binary once and every op runs in order under that entry lock, so results come back positionally in results:

{"binary": "fw.elf", "ops": [
  {"tool": "func", "params": {"addr": "0x401000"}},
  {"tool": "xrefs", "params": {"to": "0x402000"}},
  {"tool": "func", "params": {"addr": "0xdead"}}
]}
{"results": [
  {"ok": {"entry": 4198400, "entry_hex": "0x401000", "blocks": 1, "insns": 3, "calls": 0}},
  {"ok": {"protocol": 1, "total": 0, "offset": 0, "limit": 50, "next_offset": null, "items": []}},
  {"error": "not found: no function contains 0xdead"}
]}

Rules:

  • Ops carry only tool-specific parameters: the envelope owns the binary identity, so binary/db/raw/fat_arch/pdb/debug_file (and diff’s binary_a and friends) are rejected inside params. (ir_coverage takes arch plus optional addr/len; the binary always comes from the envelope.)
  • Read-only tools only: load, rename, comment, set_type_hint, define_func, undefine_func, and annotations_import are rejected per op (writes stay explicit top-level calls), as are the two-binary diff and diff_func, patch, nested batch, and unknown names. Per-op failures are {"error"} elements with the same message text the single tool would report; only envelope misuse (empty or over-32 op lists, open failures) is a tool error.
  • Per-op row and range limits apply unchanged; the sum of the compact-serialized results caps at 1 MiB. The op that would overflow returns a limit error and every later op returns a skipped error, so a 32-wide cfg fan-out degrades from the tail instead of failing the call.

Raw mapping and inferred edges

Every binary-taking tool accepts an optional raw object (arch/base/entry?) with the same rules as the CLI flags: arch and base are required in raw mode, and raw-only options without raw are errors. Fat Mach-O containers take an optional fat_arch string with the same arch names as the CLI flag; without it a fat input errors listing the available archs, and with it a thin input errors. func returns the compact metadata shape; cfg separates direct edges from provenance-marked inferred_edges. Inferred edges come from the indirect-jump resolver: single-slot absolute jumps plus guarded scaled-index tables (x86-only, 2–8 consecutive valid slots per table site), raw mappings only, same-function targets only. Anything the resolver cannot prove keeps its unresolved-indirect-jump diagnostic and stays edgeless. See JSON protocol for the full request/response definitions.