# theguywithouth/mac-computer-use architecture

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

- Interactive diagram: https://gitdiagram.com/theguywithouth/mac-computer-use
- Repository: https://github.com/theguywithouth/mac-computer-use

## Overview

mac-use exposes desktop-control tools through an MCP stdio server. The main workflow is an MCP client request routed to the selected backend, then to macOS app discovery, accessibility inspection, screenshots, or UI actions; results return through the server. The native helper is the documented default, with a CLI fallback. The Swift helper excerpt is partial, so feature-level links rely on README statements and some internal implementation boundaries remain intentionally broad.

Main entry points: [`helper/ComputerUseNativeHelper.swift`](https://github.com/theguywithouth/mac-computer-use/blob/main/helper/ComputerUseNativeHelper.swift) (Native Helper), [`src/server.ts`](https://github.com/theguywithouth/mac-computer-use/blob/main/src/server.ts) (Stdio MCP Server), [`src/native-helper-backend.ts`](https://github.com/theguywithouth/mac-computer-use/blob/main/src/native-helper-backend.ts) (Native Backend), [`src/cli-backend.ts`](https://github.com/theguywithouth/mac-computer-use/blob/main/src/cli-backend.ts) (CLI Backend)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mcp["MCP Interface"]
  node_server["Stdio MCP Server<br/>[server.ts]"]
end

subgraph group_backend["Backend Runtime"]
  node_native_backend["Native Backend"]
  node_cli_backend["CLI Backend<br/>[cli-backend.ts]"]
  node_protocol["Helper Protocol<br/>[helper-protocol.ts]"]
end

subgraph group_native["Native Desktop Control"]
  node_helper["Native Helper"]
  node_app_inventory["App Discovery"]
  node_accessibility["Accessibility State"]
  node_ui_actions["UI Actions"]
  node_cursor_overlay["Cursor Overlay"]
  node_capture["Window Capture"]
end

subgraph group_contracts["Contracts and Parsing"]
  node_contract["Tool Contracts<br/>[contract.ts]"]
  node_backend_api["Backend Interface<br/>[backend.ts]"]
  node_parser["Observed Output Parser<br/>[observed-parser.ts]"]
end

node_client(("MCP Client"))
node_macos["macOS Apps and APIs"]

node_client -->|"sends tools"| node_server
node_server -->|"uses contract"| node_backend_api
node_server -->|"routes by default"| node_native_backend
node_server -->|"routes optionally"| node_cli_backend
node_server -->|"returns results"| node_client
node_native_backend -->|"formats requests"| node_protocol
node_native_backend -->|"dispatches requests"| node_helper
node_cli_backend -.->|"runs desktop operations"| node_macos
node_helper -->|"provides listing"| node_app_inventory
node_helper -->|"inspects UI"| node_accessibility
node_helper -->|"performs actions"| node_ui_actions
node_helper -->|"uses for screenshots"| node_capture
node_helper -->|"renders cursor"| node_cursor_overlay
node_app_inventory -->|"enumerates apps"| node_macos
node_accessibility -->|"reads accessibility"| node_macos
node_ui_actions -->|"synthesizes input"| node_macos
node_capture -->|"captures windows"| node_macos
node_parser -->|"builds snapshots"| node_contract

click node_server "https://github.com/theguywithouth/mac-computer-use/blob/main/src/server.ts"
click node_contract "https://github.com/theguywithouth/mac-computer-use/blob/main/src/contract.ts"
click node_backend_api "https://github.com/theguywithouth/mac-computer-use/blob/main/src/backend.ts"
click node_native_backend "https://github.com/theguywithouth/mac-computer-use/blob/main/src/native-helper-backend.ts"
click node_cli_backend "https://github.com/theguywithouth/mac-computer-use/blob/main/src/cli-backend.ts"
click node_protocol "https://github.com/theguywithouth/mac-computer-use/blob/main/src/helper-protocol.ts"
click node_helper "https://github.com/theguywithouth/mac-computer-use/blob/main/helper/ComputerUseNativeHelper.swift"
click node_app_inventory "https://github.com/theguywithouth/mac-computer-use/blob/main/helper/ComputerUseNativeHelper.swift"
click node_accessibility "https://github.com/theguywithouth/mac-computer-use/blob/main/helper/ComputerUseNativeHelper.swift"
click node_ui_actions "https://github.com/theguywithouth/mac-computer-use/blob/main/helper/ComputerUseNativeHelper.swift"
click node_cursor_overlay "https://github.com/theguywithouth/mac-computer-use/blob/main/helper/ComputerUseNativeHelper.swift"
click node_capture "https://github.com/theguywithouth/mac-computer-use/blob/main/helper/WindowCaptureHelper.swift"
click node_parser "https://github.com/theguywithouth/mac-computer-use/blob/main/src/observed-parser.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_server,node_client toneBlue
class node_native_backend,node_cli_backend,node_protocol toneAmber
class node_helper,node_app_inventory,node_accessibility,node_ui_actions,node_cursor_overlay,node_capture,node_macos toneMint
class node_contract,node_backend_api,node_parser toneRose
```

## Components

### MCP Interface

- [Stdio MCP Server](https://github.com/theguywithouth/mac-computer-use/blob/main/src/server.ts): `src/server.ts`

### Backend Runtime

- [Native Backend](https://github.com/theguywithouth/mac-computer-use/blob/main/src/native-helper-backend.ts): `src/native-helper-backend.ts`
- [CLI Backend](https://github.com/theguywithouth/mac-computer-use/blob/main/src/cli-backend.ts): `src/cli-backend.ts`
- [Helper Protocol](https://github.com/theguywithouth/mac-computer-use/blob/main/src/helper-protocol.ts): `src/helper-protocol.ts`

### Native Desktop Control

- [Native Helper](https://github.com/theguywithouth/mac-computer-use/blob/main/helper/ComputerUseNativeHelper.swift): `helper/ComputerUseNativeHelper.swift`
- [App Discovery](https://github.com/theguywithouth/mac-computer-use/blob/main/helper/ComputerUseNativeHelper.swift): `helper/ComputerUseNativeHelper.swift`
- [Accessibility State](https://github.com/theguywithouth/mac-computer-use/blob/main/helper/ComputerUseNativeHelper.swift): `helper/ComputerUseNativeHelper.swift`
- [UI Actions](https://github.com/theguywithouth/mac-computer-use/blob/main/helper/ComputerUseNativeHelper.swift): `helper/ComputerUseNativeHelper.swift`
- [Cursor Overlay](https://github.com/theguywithouth/mac-computer-use/blob/main/helper/ComputerUseNativeHelper.swift): `helper/ComputerUseNativeHelper.swift`
- [Window Capture](https://github.com/theguywithouth/mac-computer-use/blob/main/helper/WindowCaptureHelper.swift): `helper/WindowCaptureHelper.swift`

### Contracts and Parsing

- [Tool Contracts](https://github.com/theguywithouth/mac-computer-use/blob/main/src/contract.ts): `src/contract.ts`
- [Backend Interface](https://github.com/theguywithouth/mac-computer-use/blob/main/src/backend.ts): `src/backend.ts`
- [Observed Output Parser](https://github.com/theguywithouth/mac-computer-use/blob/main/src/observed-parser.ts): `src/observed-parser.ts`

### Other components

- **MCP Client**
- **macOS Apps and APIs**

## Connections

- MCP Client → Stdio MCP Server: sends tools (evidence: `README.md`)
- Stdio MCP Server → Backend Interface: uses contract (evidence: `src/server.ts`)
- Stdio MCP Server → Native Backend: routes by default (evidence: `src/server.ts`)
- Stdio MCP Server → CLI Backend: routes optionally (evidence: `src/server.ts`)
- Stdio MCP Server → MCP Client: returns results (evidence: `src/server.ts`)
- Native Backend → Helper Protocol: formats requests (evidence: `src/native-helper-backend.ts`)
- Native Backend → Native Helper: dispatches requests (evidence: `src/native-helper-backend.ts`)
- CLI Backend → macOS Apps and APIs: runs desktop operations
- Native Helper → App Discovery: provides listing (evidence: `README.md`)
- Native Helper → Accessibility State: inspects UI (evidence: `README.md`)
- Native Helper → UI Actions: performs actions (evidence: `README.md`)
- Native Helper → Window Capture: uses for screenshots (evidence: `helper/ComputerUseNativeHelper.swift`)
- Native Helper → Cursor Overlay: renders cursor (evidence: `README.md`)
- App Discovery → macOS Apps and APIs: enumerates apps (evidence: `README.md`)
- Accessibility State → macOS Apps and APIs: reads accessibility (evidence: `README.md`)
- UI Actions → macOS Apps and APIs: synthesizes input (evidence: `README.md`)
- Window Capture → macOS Apps and APIs: captures windows (evidence: `README.md`)
- Observed Output Parser → Tool Contracts: builds snapshots (evidence: `src/observed-parser.ts`)
