angr.mcp.server¶
Main MCP server for angr binary analysis.
- class angr.mcp.server.StdoutGuardMiddleware¶
Bases:
MiddlewareKeep analysis output off of stdout.
Under the stdio transport, stdout is the JSON-RPC channel. This middleware redirects stdout to stderr to avoid messing with the stdio transport.
- angr.mcp.server.load_binary(binary_path, auto_load_libs=False, arch=None, backend=None, base_address=None, entry_point=None)¶
Load a binary file as an angr Project for analysis.
This is typically the first tool to call. It creates a new analysis session and returns a project_id that must be used for subsequent operations.
Headered ELF, PE, and Mach-O files need no loader options. A universal (fat) Mach-O loads every supported slice unless arch selects one. A headerless raw image needs backend “blob” plus arch, and usually base_address and entry_point. 16-bit DOS executables are not supported.
- Parameters:
binary_path (
str) – Absolute path to the binary file to analyzeauto_load_libs (
bool) – Whether to automatically load shared libraries (default: False)arch (
str|None) – Architecture identifier (e.g. “x86_64”, “aarch64”, “armel”, “mips32”). Selects the matching slice of a universal Mach-O, or overrides the architecture of a headered file.backend (
str|None) – Loader backend override; “blob” loads a headerless raw image (requires arch)base_address (
str|None) – Load address for a raw image, as a hex string (e.g. “0x8000000”)entry_point (
str|None) – Entry point for a raw image, as a hex string
- Return type:
- Returns:
Project information including project_id, the file’s SHA-256, architecture, entry point, and, for a universal Mach-O, the architectures its container offers
- angr.mcp.server.get_cfg(project_id, normalize=True, data_references=True)¶
Build or retrieve the Control Flow Graph (CFG) for a project.
The CFG is required for most analysis operations including function discovery, decompilation, and cross-reference analysis.
- Parameters:
- Return type:
- Returns:
CFG statistics including node/edge counts and functions discovered
- angr.mcp.server.recover_calling_conventions(project_id, workers=0, force=False)¶
Recover calling conventions and prototypes for every function in the binary.
Requires CFG to be built first via get_cfg. This improves the quality of decompilation output, especially the arguments shown at call sites.
- Parameters:
- Return type:
- Returns:
Number of functions for which a calling convention was recovered
- angr.mcp.server.list_functions(project_id, filter_plt=None, filter_syscall=None, name_pattern=None, limit=100, offset=0)¶
List all functions discovered in the binary.
Requires CFG to be built first via get_cfg.
- Parameters:
project_id (
str) – The project IDfilter_plt (
bool|None) – If True, only show PLT stubs; if False, exclude themfilter_syscall (
bool|None) – If True, only show syscalls; if False, exclude themname_pattern (
str|None) – Filter functions by name substring (case-insensitive)limit (
int) – Maximum number of functions to return (default: 100)offset (
int) – Number of functions to skip (for pagination)
- Return type:
- Returns:
List of function summaries with addresses and names
- angr.mcp.server.get_function_info(project_id, address=None, name=None, include_blocks=False)¶
Get detailed information about a specific function.
Specify either address (hex string like “0x401000”) or function name.
- Parameters:
- Return type:
- Returns:
Detailed function information including size, complexity, etc. “num_blocks” against “decompilation_block_limit” tells you up front whether decompile_function will refuse this function as too complex.
- angr.mcp.server.get_decompilation_flavor(project_id)¶
Report the project-wide decompilation flavor and the language angr detected in the binary.
The flavor selects how decompile_function renders code: “pseudocode” (C-like, the default), “rust”, or “go”. Decompilation caches, prototypes, and edits are kept per flavor. The detected language is a hint for choosing a flavor; it does not change the setting.
- angr.mcp.server.set_decompilation_flavor(project_id, flavor)¶
Set the project-wide decompilation flavor used by decompile_function and the edit tools.
- angr.mcp.server.decompile_function(project_id, address=None, name=None, max_function_blocks=None, max_ail_statements=None, flavor=None)¶
Decompile a function to C-like pseudocode, or to Rust- or Go-flavored code.
Specify either address (hex string) or function name.
Pathologically large functions (e.g. packer filler that linear disassembly turns into thousands of blocks) can keep the decompiler busy indefinitely, so two size limits are checked before the expensive work starts. Exceeding either one fails with an error naming the limit and the measured size, so you can retry with a larger limit or move on to another function.
- Parameters:
project_id (
str) – The project IDaddress (
str|None) – Function address as hex string (e.g., “0x401000”)max_function_blocks (
int|None) – Refuse to decompile a function whose CFG has more basic blocks than this (default: 50000; 0 disables the check). get_function_info reports a function’s block count as “num_blocks” and this default as “decompilation_block_limit”.max_ail_statements (
int|None) – Refuse to decompile a function whose AIL graph has more statements than this (default: 1000000; 0 disables the check)flavor (
str|None) – Decompilation flavor for this call only: “pseudocode”, “rust”, or “go”. Defaults to the project-wide flavor (see get_decompilation_flavor / set_decompilation_flavor).
- Return type:
- Returns:
Decompiled code, the flavor it was rendered in, and function metadata
- angr.mcp.server.get_xrefs(project_id, address, direction='to')¶
Get cross-references to or from a specific address.
- Parameters:
- Return type:
- Returns:
List of cross-references with source/destination and type
- angr.mcp.server.get_strings(project_id, min_length=4, limit=100)¶
Extract strings from the binary.
Requires CFG with data_references=True.
- angr.mcp.server.get_imports(project_id)¶
List imported symbols (external functions/variables the binary depends on).
- angr.mcp.server.get_exports(project_id)¶
List exported symbols (functions/variables this binary provides).
- angr.mcp.server.get_basic_blocks(project_id, function_address, include_disasm=True)¶
Get all basic blocks for a function.
- angr.mcp.server.get_callgraph(project_id, max_depth=None, root_address=None)¶
Get the function call graph.
- angr.mcp.server.find_functions_by_pattern(project_id, pattern, search_type='contains')¶
Search for functions by name pattern.
- angr.mcp.server.list_projects()¶
List all currently loaded projects/sessions.
- angr.mcp.server.close_project(project_id)¶
Close a project and free its resources.
- angr.mcp.server.create_server()¶
Create and return the configured MCP server instance.
- Return type:
FastMCP