# zinja-coder/jadx-ai-mcp architecture

> Architecture diagram of the GitHub repository zinja-coder/jadx-ai-mcp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zinja-coder/jadx-ai-mcp
- Repository: https://github.com/zinja-coder/jadx-ai-mcp

## Overview

##### Project Type and Purpose
- This is a Java‐based plugin for the JADX Android decompiler (“JADX-AI-MCP”), packaged and published via Maven (pom.xml).
- Its purpose is to integrate the Model Context Protocol (MCP) into the JADX GUI, enabling live AI-driven reverse engineering and static analysis of Android APKs by talking to an external Python MCP server (JADX-MCP-SERVER) and LLMs like Claude.

##### File Structure Analysis
- Top Level
- pom.xml — Maven build descriptor for the Java plugin
- README.md, LICENSE, CODE_OF_CONDUCT.md, CONTRIBUTING.md — project documentation & governance
- docs/ — screenshots, video demos and asset files for documentation
- src/main/java/jadx/gui/plugins
- JadxAIMCP.java — plugin entry point implementing MCP integration
- META-INF/services/jadx.api.plugins.JadxPlugin — service loader descriptor ensures the plugin is discovered by JADX
- No backend code here; the Python server is in a separate repo (referenced in README).

##### Key Architectural Insights from README
- The plugin registers MCP commands in the GUI, such as fetch_current_class(), get_method_by_name(), etc.
- The external Python server receives MCP requests, forwards them to an LLM via HTTP or stdio, and returns responses.
- The plugin consumes AI analysis and renders inline suggestions in the GUI.

##### Main Components
a. Host Application: JADX GUI
b. Plugin Module: JADX-AI-MCP (Java)
- Service loader integration (META-INF)
- MCP client layer embedded in the plugin
c. MCP Transport Layer
- Protocol boundary (JSON-RPC over stdin/stdout or sockets)
d. Python MCP Server: jadx_mcp_server.py (external repo)
- HTTPX / fastmcp dependency
- MCP server loop listening to plugin
e. Language Model Service (External AI)
- Claude (hosted) or Local LLM via Ollama + Zin MCP Client
f. Android APK Under Analysis
- Decompiled code & resources loaded in JADX

##### Component Relationships and Data Flows
1. User loads APK in JADX GUI.
3. Plugin extracts context (class, method, smali, manifest) via internal API.
4. Plugin serializes request as an MCP command over stdout/stdin or socket.
5. Python MCP server receives command, translates it to an HTTP or stdio call to the LLM.
6. LLM processes the prompt and returns an analysis.
7. Server sends JSON-RPC response back to the plugin.
8. Plugin parses the response and injects annotations or suggestions into the GUI.

##### Architectural Patterns and Design Principles
- Plugin Architecture: Uses Java SPI (`META-INF/services`) to discover and load plugin at runtime.
- Adapter Pattern: The plugin adapts between the JADX internal API and the MCP protocol.
- Client-Server Pattern: The plugin is an MCP client; the Python server is the MCP server.
- Loose Coupling: Plugin knows only the MCP protocol; it is decoupled from LLM specifics.
- Extensibility: New MCP commands can be added in JadxAIMCP.java and picked up by the server.

- Clear component labels (JADX GUI, AI Plugin, MCP Server, LLM)

- Out each Java class/package in the plugin: e.g., JadxAIMCP.java → registers MCP handlers
- Build/deploy pipeline: Maven packaging outputs a JAR that lives in the JADX plugins folder
- Detail the Python server’s entrypoint and dependency graph (httpx, fastmcp)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% APK Artifact
    APK["Android APK Under Analysis"]:::apk

    %% Host Process
    subgraph "Host Process" 
        direction TB
        JADX_GUI["JADX GUI"]:::plugin
        subgraph "Plugin Module (JADX-AI-MCP)"
            direction TB
            JadxAIMCP["JadxAIMCP.java"]:::plugin
            SPI["META-INF/services/jadx.api.plugins.JadxPlugin"]:::plugin
        end
    end

    %% External Process
    subgraph "External Process"
        direction TB
        MCP_Server["Python MCP Server"]:::external
    end

    %% External Service
    subgraph "External Service"
        direction TB
        LLM["LLM Service (Claude / Local)"]:::external
    end

    %% Documentation & Build
    subgraph "Project Docs & Build"
        direction TB
        POM["pom.xml"]:::plugin
        README["README.md"]:::plugin
        LICENSE["LICENSE"]:::plugin
        COC["CODE_OF_CONDUCT.md"]:::plugin
        CONTRIB["CONTRIBUTING.md"]:::plugin
        DOCS["docs/"]:::plugin
    end

    %% Flows
    APK -->|"Loaded into"| JADX_GUI
    JADX_GUI -->|"User clicks hammer"| JadxAIMCP
    JadxAIMCP -->|"MCP JSON-RPC over stdin/stdout or socket"| MCP_Server
    MCP_Server -->|"HTTP to LLM"| LLM
    LLM -->|"Response JSON"| MCP_Server
    MCP_Server -->|"MCP JSON-RPC Response"| JadxAIMCP
    JadxAIMCP -->|"Inject annotations"| JADX_GUI

    %% Click Events
    click POM "https://github.com/zinja-coder/jadx-ai-mcp/blob/jadx-ai/pom.xml"
    click README "https://github.com/zinja-coder/jadx-ai-mcp/blob/jadx-ai/README.md"
    click LICENSE "https://github.com/zinja-coder/jadx-ai-mcp/tree/jadx-ai/LICENSE"
    click COC "https://github.com/zinja-coder/jadx-ai-mcp/blob/jadx-ai/CODE_OF_CONDUCT.md"
    click CONTRIB "https://github.com/zinja-coder/jadx-ai-mcp/blob/jadx-ai/CONTRIBUTING.md"
    click DOCS "https://github.com/zinja-coder/jadx-ai-mcp/tree/jadx-ai/docs/"
    click JadxAIMCP "https://github.com/zinja-coder/jadx-ai-mcp/blob/jadx-ai/src/main/java/jadx/gui/plugins/JadxAIMCP.java"
    click SPI "https://github.com/zinja-coder/jadx-ai-mcp/blob/jadx-ai/src/main/resources/META-INF/services/jadx.api.plugins.JadxPlugin"

    %% Styles
    classDef plugin fill:#e0ffe0,stroke:#009900,color:#000;
    classDef external fill:#e0e0ff,stroke:#0000cc,color:#000;
    classDef apk fill:#cccccc,stroke:#666,color:#000;
```
