
agent-desktop-router
Three-tier macOS desktop & browser routing with PreToolUse and CoreGraphics safety guards for Claude Code, Codex, and Antigravity
Install with your AI
Paste into Claude Code, Cursor, or any agent — it reads the repo and wires the tool into your project.
Install and set up agent-desktop-router (git-clone project) into my current project. Found on https://claudeers.com/agent-desktop-router Repo: https://github.com/mcncarl/agent-desktop-router Homepage/docs: — Detected install method: git-clone → git clone https://github.com/mcncarl/agent-desktop-router Category: mcp-servers. Platforms: cli, api, desktop, web. Read the repo's README for exact setup and env vars, then install it and wire it into my project. Claudeers Health Verdict: unknown; community-verified: false. Confirm the source before running anything.
git clone https://github.com/mcncarl/agent-desktop-router
// compatibility
| Platforms | cli, api, desktop, web |
|---|---|
| Operating systems | — |
| AI compatibility | claude |
| License | AGPL-3.0 |
| Pricing | open-source |
| Language | Python |
Agent Desktop & Browser Router (agent-desktop-router)
English | 简体中文
Prefer native APIs over UI clicks, and structured trees over screenshots.
A unified three-tier macOS desktop & browser routing layer — backed by deterministic
PreToolUsehooks, a CLI wrapper, and a native CoreGraphics window/coordinate safety guard — for Claude Code, Codex, and Google Antigravity.
Why agent-desktop-router?
Giving an AI coding agent raw Computer Use or desktop access creates three painful problems in daily work:
- Everything becomes a slow screenshot loop: Agents click around UIs for tasks that could be done in 50ms via CLI, API, or local file edits.
- Your cursor and window focus get hijacked: Traditional GUI automation steals focus and breaks whenever you switch browser tabs.
- Prompt-only safety boundaries fail: Telling an agent "never touch WeChat / iMessage / 1Password" in
AGENTS.mddoes not stop an unscopedsnapshot, a stale@ref, or anx,yclick from landing on a private chat window or Notification Center banner.
agent-desktop-router packages a battle-tested Three-Tier Routing Workflow together with a zero-dependency technical safety gate that works identically across Claude Code, Codex, and Antigravity.
Quick Start
Option A — Let Your Agent Install It (Recommended)
Paste this prompt into Claude Code, Codex, or Google Antigravity:
Clone https://github.com/mcncarl/agent-desktop-router (or update if already cloned),
read docs/INSTALLATION.md, and configure agent-desktop-router for all agents installed
on my Mac. Run scripts/doctor.py afterward and let me know if any macOS Accessibility
permission toggle is needed.
Option B — 2-Line CLI Install
git clone https://github.com/mcncarl/agent-desktop-router.git && cd agent-desktop-router
python3 scripts/install.py --agents auto && python3 scripts/doctor.py
(Use --lang zh to inject Simplified Chinese routing rules into AGENTS.md / CLAUDE.md.)
Architecture: Safety Gate + Three-Tier Escalation
flowchart TD
Task["Incoming Desktop or Browser Task"] --> Gate["Layer 0: Hard Safety Gate<br/>PreToolUse Hook + CLI Wrapper + Swift CoreGraphics Probe<br/>Blocks private IMs, password managers & Notification Center"]
Gate --> T1["Tier 1: Native CLI / API / File Edit<br/>ExtendScript · Draft JSON · Local Markdown · Official CLIs<br/>Fastest · Deterministic · Zero UI Touch"]
T1 -- "Needs live UI or browser" --> WebCheck{"Browser or Desktop App?"}
WebCheck -- "Codex / Claude (cookie-synced)<br/>or Antigravity (public web)" --> T2A["Tier 2A: Agent Built-in Browser<br/>Zero focus theft, native speed"]
WebCheck -- "Antigravity (logged-in web)<br/>or Accessible Desktop App" --> T2B["Tier 2B: agent-desktop (Headless Default)<br/>Chrome locked via dedicated --window-id<br/>Obsidian / Electron / Native menu bars<br/>Does NOT move mouse or steal focus"]
T2A -- "Custom canvas / Visual QA" --> T3["Tier 3: Computer Use Fallback (LCU / Native CUA)<br/>Custom-drawn video timelines · AE dialogs · iPhone Mirroring<br/>Shared local ChatGPT.app CUA engine across all agents"]
T2B -- "Empty AX tree or headless click ignored" --> T3
Routing Matrix at a Glance
| Scenario | Selected Tier | Why |
|---|---|---|
| Project files, notes, cloud docs, timelines with scriptable APIs | Tier 1: Native CLI / API / File | Millisecond speed, zero UI flakiness |
| Web pages in Codex / Claude Code (cookie-synced), or public pages in Antigravity | Tier 2A: Built-in Agent Browser | Fastest web path when the host browser already holds (or doesn't need) cookies |
| Logged-in web pages in Antigravity (isolated webview) or pure CLI sessions | Tier 2B: Chrome Default --new-window + agent-desktop --window-id | Opens a clean 1-tab window in your primary Chrome profile (--profile-directory="Default") and locks --window-id so personal multi-tab windows never time out or lose @snapshot:eN refs |
| Electron & native macOS apps (Obsidian, Finder, menu bars) | Tier 2B: agent-desktop (headless) | Reads Accessibility tree & clicks in background without moving your cursor |
| Custom-drawn canvases (CapCut/Jianying, AE modals, FocuSee, iPhone Mirroring) | Tier 3: Computer Use (LCU / CUA) | Screenshot + vision coordinates handle any pixel-rendered surface |
| Private IMs, password vaults, macOS Notification Center | Blocked at Layer 0 | Hard-blocked before tool execution across every agent |
Defense-in-Depth Safety Guard (src/guard.py + src/probe.swift)
Unlike prompt-only instructions, agent-desktop-router intercepts calls before execution across all three agent architectures:
- Claude Code:
PreToolUsehook in~/.claude/settings.json(Bash,mcp__agent-desktop__*,mcp__lcu__*) - Google Antigravity: Native Antigravity plugin (
~/.gemini/config/plugins/agent-desktop-router/hooks.json) - Codex & Terminal: Transparent
~/.local/bin/agent-desktopwrapper invokingguard.py --cli-check
Four Technical Enforcement Checks
- Config-Driven App & Compound-Term Filtering: Blocks apps in
~/.config/agent-desktop-router/blocked-apps.jsonwhile cleanly honoringallowed_bundles/allowed_termsexemptions (e.g., allowing enterprise work tools like WeCom / 企业微信 and Official Accounts / 微信公众号 while strictly blocking personal WeChat / 微信). - No Blind Frontmost Fallback: Rejects unscoped
agent-desktop snapshot,screenshot,find,press, orfocus-windowcalls that would accidentally inspect whichever private window happens to be frontmost. - Live PID, Window & Coordinate Verification (
probe.swift):@snapshot:eN→ resolves element PID fromrefmap.jsonand verifies bundle/owner viaNSRunningApplication.--window-id w-1234→ queriesCGWindowListCopyWindowInfoto verify the window exists and is not owned by a blocked app.--xy x,y→ inspects the full on-screen window stack at(x, y)so coordinate clicks cannot hit a blocked window.
- Anti-Bypass & Fail-Closed Design: Blocks
agent-desktop batch,xargs,$VARtarget interpolation, and wrapper scripts; fails closed ifblocked-apps.jsonis malformed.
Default Protected Surfaces (config/blocked-apps.default.json)
| Category | Protected by Default | Default Exemptions (allowed_*) |
|---|---|---|
| Private Messengers | WeChat (微信, WeChatAppEx, Web WeChat), Apple Messages (iMessage), WhatsApp, Telegram, Signal | WeCom (企业微信 / com.tencent.WeWorkMac), WeChat Official Accounts (微信公众号), WeRead (微信读书) |
| Credentials & Vaults | 1Password, Bitwarden, macOS Keychain Access (钥匙串访问) | — |
| System Surfaces | macOS Notification Center (block_notification_center: true) | dock, menu-bar-extras |
Customize ~/.config/agent-desktop-router/blocked-apps.json anytime — changes apply immediately with zero agent restart.
CLI Reference
# Install or update across Claude Code, Codex, and Antigravity (idempotent)
python3 scripts/install.py --agents auto [--lang en|zh] [--no-rules] [--dry-run]
# Check config, native Swift probe, CLI wrapper, Accessibility state & ChatGPT.app signature
python3 scripts/doctor.py [--json]
# Cleanly remove managed hooks, rule blocks & plugin (moves files to macOS ~/.Trash)
python3 scripts/uninstall.py [--purge-config]
# Run the automated test suite
python3 -m unittest discover -s tests -v
See docs/INSTALLATION.md for full setup details, agent-desktop / amontlabs/lcu integration notes, and permission troubleshooting.
Repository Layout
agent-desktop-router/
├── config/blocked-apps.default.json # Default protected apps & safe work exemptions
├── docs/INSTALLATION.md # Human + Agent step-by-step installation runbook
├── scripts/
│ ├── install.py # Idempotent multi-agent installer
│ ├── doctor.py # Health, Accessibility & bundle diagnostics
│ └── uninstall.py # Non-destructive uninstaller (uses ~/.Trash)
├── skills/desktop-browser-routing/ # On-demand operational skill for all 3 agents
├── src/
│ ├── guard.py # Zero-dependency Claude / Antigravity / CLI guard
│ └── probe.swift # Native CoreGraphics & AppKit window/PID inspector
├── templates/ # English & Chinese AGENTS.md snippets + plugin assets
└── tests/test_router.py # Automated guard, probe & lifecycle tests
Credits & License
- Integrates with
vercel-labs/agent-desktop(Tier 2) andamontlabs/lcu(Tier 3); see THIRD_PARTY_NOTICES.md. - Licensed under the GNU Affero General Public License v3.0 (AGPL-3.0).
// faq
What is agent-desktop-router?
Three-tier macOS desktop & browser routing with PreToolUse and CoreGraphics safety guards for Claude Code, Codex, and Antigravity. It is open-source on GitHub.
Is agent-desktop-router free to use?
agent-desktop-router is open-source under the AGPL-3.0 license, so it is free to use.
What category does agent-desktop-router belong to?
agent-desktop-router is listed under mcp-servers in the Claudeers registry of Claude-compatible tools.
// embed badge
[](https://claudeers.com/agent-desktop-router)
// retro hit counter
[](https://claudeers.com/agent-desktop-router)
// reviews
// guestbook
// related in MCP Servers
f.k.a. Awesome ChatGPT Prompts. Share, discover, and collect prompts from the community. Free and open source — self-host for your organization with complete…
A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Gemini CLI & Hermes Agent. Only official website: ccswitch.io
🪨 why use many token when few token do trick — Claude Code skill that cuts 65% of tokens by talking like caveman
An open-source AI agent that brings the power of Gemini directly into your terminal.