angr.mcp.session

Session management for angr MCP server.

angr.mcp.session.parse_flavor(flavor)

Validate a decompilation flavor name, naming the valid ones on failure.

Return type:

str

Parameters:

flavor (str)

angr.mcp.session.parse_address_option(name, value)

Parse an optional hex-or-decimal address option, naming the option on failure.

Return type:

int | None

Parameters:
angr.mcp.session.parse_arch_option(arch)

Resolve an archinfo identifier such as “x86_64”, “aarch64”, “armel”, or “mips32”.

Return type:

Arch | None

Parameters:

arch (str | None)

angr.mcp.session.build_main_opts(*, arch=None, backend=None, base_address=None, entry_point=None)

Translate load_binary’s optional loader inputs into CLE main_opts.

arch selects the slice of a universal Mach-O or overrides a headered file. backend="blob" with arch loads a headerless raw binary at base_address with entry_point.

Return type:

dict[str, Any]

Parameters:
  • arch (str | None)

  • backend (str | None)

  • base_address (str | int | None)

  • entry_point (str | int | None)

angr.mcp.session.reject_dos_executable(path)

16-bit DOS MZ images share PE’s magic but have no lifter; report that instead of a loader crash.

Return type:

None

Parameters:

path (Path)

class angr.mcp.session.ProjectSession

Bases: object

Represents a loaded angr project with its associated analyses.

project_id: str
project: Project
binary_path: str
cfg: CFGModel | None = None
sha256: str = ''
flavor: str = 'pseudocode'
lock: RLock
set_flavor(flavor)

Set the project-wide decompilation flavor and return the previous one.

Return type:

str

Parameters:

flavor (str)

property has_cfg: bool

Check if CFG has been built for this project.

exclusive()

Serialize access to this project.

FastMCP runs synchronous tools on worker threads, so two calls can reach the same Project and KnowledgeBase at once. Neither is thread-safe, and the decompilation and variable caches spill to LMDB, where a concurrent eviction and reload can hand back a half-imported object. Read-only tools are not exempt: a read racing an eviction is exactly that hazard.

Return type:

Iterator[ProjectSession]

__init__(project_id, project, binary_path, cfg=None, sha256='', flavor=Flavors.DEFAULT_FLAVOR, lock=<factory>)
Parameters:
Return type:

None

class angr.mcp.session.SessionManager

Bases: object

Manages multiple angr project sessions.

This class maintains state across MCP tool invocations, allowing projects to persist between calls.

__init__()
Return type:

None

create_session(binary_path, **kwargs)

Load a binary and create a new project session.

Parameters:
  • binary_path (str) – Path to the binary to analyze

  • kwargs (Any) – Additional arguments passed to angr.Project

Return type:

ProjectSession

Returns:

The created ProjectSession with unique ID

get_session(project_id)

Get an existing session by ID.

Parameters:

project_id (str) – The project ID to look up

Return type:

ProjectSession

Returns:

The ProjectSession

Raises:

KeyError – If no project with that ID exists

list_sessions()

List all active sessions.

Return type:

list[dict[str, Any]]

Returns:

List of session metadata dictionaries

close_session(project_id)

Close and remove a session.

Parameters:

project_id (str) – The project ID to close

Return type:

bool

Returns:

True if closed, False if not found

angr.mcp.session.get_session_manager()

Get or create the global session manager.

Return type:

SessionManager