# infiniv/android-ui-mcp architecture

> Architecture diagram of the GitHub repository infiniv/android-ui-mcp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/infiniv/android-ui-mcp
- Repository: https://github.com/infiniv/android-ui-mcp

## Overview

This repository is an MCP server that gives AI coding agents two Android UI capabilities: list connected devices and capture a screenshot for visual analysis. The main flow starts with an agent request over stdio, dispatches through the MCP server, and either lists ADB devices or captures, formats, and returns an image with dimensions. The README also describes integrations with several MCP-capable agents and development environments; these are clients of the server, not separate runtime subsystems. Source excerpts show the main handlers and ADB/screenshot implementation; broader workflow claims are based on README documentation.

Main entry points: [`src/server.ts`](https://github.com/infiniv/android-ui-mcp/blob/main/src/server.ts) (MCP Server), [`src/utils/adb.ts`](https://github.com/infiniv/android-ui-mcp/blob/main/src/utils/adb.ts) (ADB Commands), [`src/utils/screenshot.ts`](https://github.com/infiniv/android-ui-mcp/blob/main/src/utils/screenshot.ts) (Screenshot Formatting), [`src/types.ts`](https://github.com/infiniv/android-ui-mcp/blob/main/src/types.ts) (Tool Schemas)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mcp["MCP Interface"]
  node_entry["Process Entry<br/>[index.ts]"]
  node_server["MCP Server<br/>[server.ts]"]
  node_stdio["Stdio Transport"]
end

subgraph group_android["Android Operations"]
  node_device_tools["Device Listing<br/>[server.ts]"]
  node_screenshot_tools["Screenshot Tool<br/>[server.ts]"]
  node_screenshot_format["Screenshot Formatting<br/>[screenshot.ts]"]
  node_adb["ADB Commands<br/>[adb.ts]"]
end

subgraph group_contracts["Schemas and Errors"]
  node_schemas["Tool Schemas<br/>[types.ts]"]
  node_error_format["Error Formatting<br/>[error.ts]"]
end

node_agent(("AI Agent"))
node_android_device["Android Device"]

node_agent -->|"sends requests"| node_stdio
node_entry -->|"starts"| node_server
node_server -->|"connects"| node_stdio
node_stdio -->|"delivers requests"| node_server
node_server -->|"validates inputs"| node_schemas
node_server -->|"dispatches screenshot"| node_screenshot_tools
node_server -->|"dispatches listing"| node_device_tools
node_screenshot_tools -->|"requests capture"| node_screenshot_format
node_screenshot_format -->|"captures image"| node_adb
node_device_tools -->|"lists devices"| node_adb
node_adb -->|"queries device"| node_android_device
node_screenshot_tools -->|"validates result"| node_schemas
node_server -->|"formats failures"| node_error_format
node_screenshot_tools -->|"returns image"| node_agent
node_device_tools -->|"returns device list"| node_agent

click node_entry "https://github.com/infiniv/android-ui-mcp/blob/main/src/index.ts"
click node_server "https://github.com/infiniv/android-ui-mcp/blob/main/src/server.ts"
click node_device_tools "https://github.com/infiniv/android-ui-mcp/blob/main/src/server.ts"
click node_screenshot_tools "https://github.com/infiniv/android-ui-mcp/blob/main/src/server.ts"
click node_screenshot_format "https://github.com/infiniv/android-ui-mcp/blob/main/src/utils/screenshot.ts"
click node_adb "https://github.com/infiniv/android-ui-mcp/blob/main/src/utils/adb.ts"
click node_schemas "https://github.com/infiniv/android-ui-mcp/blob/main/src/types.ts"
click node_error_format "https://github.com/infiniv/android-ui-mcp/blob/main/src/utils/error.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entry,node_server,node_stdio toneBlue
class node_device_tools,node_screenshot_tools,node_screenshot_format,node_adb toneAmber
class node_schemas,node_error_format toneMint
class node_agent,node_android_device toneIndigo
```

## Components

### MCP Interface

- [Process Entry](https://github.com/infiniv/android-ui-mcp/blob/main/src/index.ts): `src/index.ts`
- [MCP Server](https://github.com/infiniv/android-ui-mcp/blob/main/src/server.ts): `src/server.ts`
- **Stdio Transport**

### Android Operations

- [Device Listing](https://github.com/infiniv/android-ui-mcp/blob/main/src/server.ts): `src/server.ts`
- [Screenshot Tool](https://github.com/infiniv/android-ui-mcp/blob/main/src/server.ts): `src/server.ts`
- [Screenshot Formatting](https://github.com/infiniv/android-ui-mcp/blob/main/src/utils/screenshot.ts): `src/utils/screenshot.ts`
- [ADB Commands](https://github.com/infiniv/android-ui-mcp/blob/main/src/utils/adb.ts): `src/utils/adb.ts`

### Schemas and Errors

- [Tool Schemas](https://github.com/infiniv/android-ui-mcp/blob/main/src/types.ts): `src/types.ts`
- [Error Formatting](https://github.com/infiniv/android-ui-mcp/blob/main/src/utils/error.ts): `src/utils/error.ts`

### Other components

- **AI Agent**
- **Android Device**

## Connections

- AI Agent → Stdio Transport: sends requests (evidence: `README.md`)
- Process Entry → MCP Server: starts (evidence: `src/index.ts`)
- MCP Server → Stdio Transport: connects (evidence: `src/server.ts`)
- Stdio Transport → MCP Server: delivers requests (evidence: `src/server.ts`)
- MCP Server → Tool Schemas: validates inputs (evidence: `src/server.ts`)
- MCP Server → Screenshot Tool: dispatches screenshot (evidence: `src/server.ts`)
- MCP Server → Device Listing: dispatches listing (evidence: `src/server.ts`)
- Screenshot Tool → Screenshot Formatting: requests capture (evidence: `src/server.ts`)
- Screenshot Formatting → ADB Commands: captures image (evidence: `src/utils/screenshot.ts`)
- Device Listing → ADB Commands: lists devices (evidence: `src/server.ts`)
- ADB Commands → Android Device: queries device (evidence: `src/utils/adb.ts`)
- Screenshot Tool → Tool Schemas: validates result (evidence: `src/server.ts`)
- MCP Server → Error Formatting: formats failures (evidence: `src/server.ts`)
- Screenshot Tool → AI Agent: returns image (evidence: `src/server.ts`)
- Device Listing → AI Agent: returns device list (evidence: `src/server.ts`)
