# cnitlrt/headless-ida-mcp-server architecture

> Architecture diagram of the GitHub repository cnitlrt/headless-ida-mcp-server, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cnitlrt/headless-ida-mcp-server
- Repository: https://github.com/cnitlrt/headless-ida-mcp-server

## Overview

##### Project Type and Purpose
- This is a headless server application designed around IDA Pro’s headless mode. Its primary purpose is to facilitate remote binary analysis through the Multi-Client Protocol (MCP) and to manage various aspects of code (functions, variables, etc.) via a remote interface.
- The README and file structure indicate that it serves as a bridge between an MCP client and IDA Pro’s analysis capabilities.

##### Analyzing the File Structure
- Top-Level Files and Directories:
- The presence of configuration files such as .env_example, pyproject.toml, and uv.lock indicates dependency management and environment configuration.
- The src directory contains the core application code inside the "headless_ida_mcp_server" package. Key files include:
- __main__.py: Likely the application’s entry point.
- server.py: Presumably handles the MCP server functionality and orchestration with IDA's headless mode.
- helper.py: Contains utility functions that support the server’s operations.
- The test directory (with main.c and test files) suggests there is some testing of functionality with both Python and possibly C code elements for binary analysis.

##### Important Components
- Client Side:
- MCP Client(s) such as those initiated using npx (@modelcontextprotocol/inspector).
- Server Side:
- API Server Entry: Represented by __main__.py, which initiates the server.
- MCP Server Component: The main logic in server.py that handles requests over the assigned PORT and HOST.
- Helper Utilities: The helper.py functions that support core server operations.
- Third-party Integration: The use of IDA Pro’s headless mode (idat) driven by the configured IDA_PATH, and dependencies like headless-ida.
- External Dependencies:
- IDA Pro’s headless executable for binary analysis.
- Environment Variables that define configuration such as IDA_PATH, BINARY_PATH, and connection details.
- The test suite may be drawn to show validation of core functionality.

##### Relationships and Interactions
- An incoming request from an MCP client connects to the server (over network, using provided HOST/PORT).
- The server, through its main module and supporting helper code, processes the request and then internally calls command execution on IDA Pro (via idat in headless mode) for binary analysis.
- Results or analysis data is sent back through the MCP protocol to the client.

##### Architectural Patterns and Design Principles
- Modular Design: Clear separation between the entry point, server logic, and helper functions.
- Configuration Management: Use of environment variable configuration via .env, promoting separation of configuration from code.
- Client-Server Interaction: Use of the Multi-Client Protocol to interface with remote clients.
- Integration: Leveraging third-party dependencies (IDA Pro’s headless mode) demonstrates a layered integration approach.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        client["MCP Client"]:::client
    end

    %% Server Layer
    subgraph "Server Layer"
        main["__main__.py – Entry Point"]:::entry
        server["server.py – MCP Server Logic"]:::server
        helper["helper.py – Utilities"]:::helper
    end

    %% External and Configuration
    subgraph "External & Config"
        config["Configuration (.env)"]:::config
        idapro["IDA Pro Headless (idat)"]:::external
    end

    %% Testing Components
    subgraph "Testing"
        test["Testing Suite (test/test_ida_agent.py, test/main, test/main.c)"]:::test
    end

    %% Interactions and Data Flow
    client -->|"request"| main
    main -->|"initializes"| server
    server -->|"utilizes"| helper
    server -->|"calls_analysis"| idapro
    idapro -->|"returns_analysis"| server
    server -->|"sends_response"| client
    config -->|"feeds_config"| main
    config -->|"feeds_config"| server
    test -->|"validates"| server

    %% Click Events
    click main "https://github.com/cnitlrt/headless-ida-mcp-server/blob/main/src/headless_ida_mcp_server/__main__.py"
    click server "https://github.com/cnitlrt/headless-ida-mcp-server/blob/main/src/headless_ida_mcp_server/server.py"
    click helper "https://github.com/cnitlrt/headless-ida-mcp-server/blob/main/src/headless_ida_mcp_server/helper.py"
    click config "https://github.com/cnitlrt/headless-ida-mcp-server/blob/main/.env_example"
    click test "https://github.com/cnitlrt/headless-ida-mcp-server/blob/main/test/test_ida_agent.py"

    %% Styles
    classDef client fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef entry fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef server fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef helper fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef external fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef config fill:#e2e3e5,stroke:#d6d8db,stroke-width:2px;
    classDef test fill:#fefefe,stroke:#818182,stroke-width:2px;
```
