# jarvis-eyes-mcp ``` jarvis-eyes-mcp/ v0.1 ──────────────────────────────────────────────── ``` A **macOS-native MCP server** that gives [Claude Code](https://claude.ai/code) (or any MCP-compatible client) low-latency eyes on your desktop — read the active app's accessibility tree, capture targeted screenshots, navigate windows. > [!NOTE] > macOS only. Built on the macOS Accessibility framework via a small native Swift binary. The TypeScript layer drives MCP, the Swift binary handles the AX queries. > [!IMPORTANT] > Requires Accessibility permissions. The first time you run it, macOS will prompt you to add the host process (Terminal, iTerm, Claude Code) to **System Settings → Privacy & Security → Accessibility**. This is a one-time grant. --- ## What it does Lets an AI agent see and reason about what's on your Mac without screenshot OCR. Reads the structured accessibility tree directly — element labels, roles, positions, hierarchy — at the same level a screen reader does. Plus targeted screenshot capture and window navigation. ``` ┌───────────────┐ │ Claude Code │ │ (or any MCP │ │ client) │ └───────┬───────┘ │ stdio (MCP) ▼ ┌────────────────────┐ │ jarvis-eyes-mcp │ │ (TypeScript) │ └─────────┬──────────┘ │ child_process ▼ ┌────────────────────┐ │ ax-tree (Swift) │ └─────────┬──────────┘ │ Accessibility framework ▼ ┌────────────────────┐ │ macOS apps │ └────────────────────┘ ``` --- ## Why use this over OCR + screenshots? | | OCR + screenshots | jarvis-eyes-mcp | |---|---|---| | Latency | 200ms–2s per query | <50ms typical | | Accuracy on UI text | Lossy, font-dependent | Exact strings as the app emits them | | Element relationships | Lost — flat 2D image | Preserved — full role/parent/child tree | | Hidden / off-screen elements | Invisible | Visible to AX queries | | Token cost | High (vision tokens) | Low (structured text) | --- ## Tools | Tool | Description | |---|---| | `tree_get_active` | Accessibility tree of the active (frontmost) app window | | `tree_get_app` | Accessibility tree of a specific running app by name | | `tree_get_window` | Accessibility tree of a specific window by id | | `screen_capture` | Capture a region or full screen as base64 PNG | | `window_list` | List all windows across running apps | | `window_focus` | Bring a specific window to the front | | `window_move` | Move/resize a window | | `nav_click` | Click an element by AX path | | `nav_type` | Type text into the focused element | | `cache_clear` | Clear the local AX-tree cache | (See `src/index.ts` for the canonical, zod-validated tool list.) --- ## Install Requires: - Node.js 20+ - macOS 12 (Monterey) or newer - Xcode Command Line Tools (`xcode-select --install`) — only needed at install time, to compile the Swift binary ```bash npm install -g jarvis-eyes-mcp ``` For development: ```bash git clone https://github.com/harshil1502/jarvis-eyes-mcp.git cd jarvis-eyes-mcp npm install npm run build:swift # compiles swift/ax-tree → ./swift/ax-tree binary npm run build # tsc to dist/ npm test # vitest run ``` --- ## Setup ### 1. Grant Accessibility permission The first time you call any `tree_*` tool, macOS will prompt you. Open: **System Settings → Privacy & Security → Accessibility** …and toggle on the host process (Terminal, iTerm, your Claude Code GUI, etc.). Without this, AX queries return empty. ### 2. Wire into Claude Code Add to `~/.claude/mcp.json`: ```json { "mcpServers": { "jarvis-eyes": { "command": "jarvis-eyes-mcp" } } } ``` Restart Claude Code. --- ## Example session ``` You: What app is in the foreground and what's on screen? Claude: [calls tree_get_active] Active app: Safari · window "GitHub" - Address bar (focused) — "github.com/harshil1502" - Toolbar with Reload, Share, Bookmarks - Main content: 1 article element with 3 sections, first heading "Pinned" You: Click the link that says "tradingview-mcp". Claude: [calls nav_click with path /Window/.../Link[label="tradingview-mcp"]] Clicked. Page navigated. ``` --- ## Architecture ``` src/ ├── index.ts MCP server, tool registration ├── accessibility.ts AX-tree wrapping, app/window resolution ├── navigation.ts click / type / focus ├── window.ts window list / move / focus ├── screen.ts screen capture (base64 PNG) ├── cache.ts short-TTL cache for AX queries └── types.ts shared types swift/ ├── ax-tree.swift compiled CLI: outputs JSON AX tree for given app/window ├── ax-element.swift AX element traversal helpers └── ax-tree.js thin Node bridge (legacy, kept for reference) ``` The TypeScript layer never touches the Accessibility framework directly — it spawns the Swift binary, reads JSON over stdout, validates with Zod. This keeps the type-safety in one place and the OS-specific work in another. --- ## Tests ```bash npm test # vitest run npm run test:coverage # with v8 coverage report ``` 7 test files covering accessibility, navigation, window, screen, and cache behavior. Tests stub the Swift binary's output so they run without macOS Accessibility permissions. --- ## Disclaimer This software is provided "as is" without warranty of any kind. - macOS Accessibility access is broad. Only grant it to processes you trust. - AX queries can read text from apps that handle sensitive information (password managers, banking, etc.). Be deliberate about which apps your AI agent inspects. - The Swift binary is small and auditable — read `swift/ax-tree.swift` (~150 lines) before granting access. --- ## License [MIT](LICENSE) © 2026 Harshil Patel