loupe

module
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2026 License: Apache-2.0

README

macOS Go 1.26 MCP, CLI and HTTP for agents CI status Latest release Apache 2.0 license

The device on your desk, in your hand.
Stream Android devices, emulators and iOS simulators from your Mac to any browser at 60 fps, with live touch.
Agents drive it through a CLI, MCP or HTTP. In the browser you see each tap coming, and your touch takes over.


Quick start

brew install bmcreations/tap/loupe
brew services start loupe
open "http://localhost:18456/?token=$(cat ~/Library/Caches/loupe/token)"

The picker lists every Android device on adb and every AVD you have installed, booted or not. Open one to stream it. iOS simulators need simcap, built with your own Xcode:

brew install --HEAD bmcreations/tap/simcap && brew services restart loupe

Without a certificate the service answers on loopback only. To reach it from your phone, give it TLS: docs/getting-started.md walks through it with Tailscale, then pairing a phone and connecting an agent.

Work on the same device as your agent

Open a device in the browser while an agent drives it, and the web client shows who has control and where the agent is about to tap.

  1. The agent claims the device. A second agent gets claimedBy and picks another one.
  2. In the browser, you see its cursor before it taps. The banner reads "claude is driving", and Take over gives you control. Between an agent's calls the cursor stays where it last acted for 20 seconds, dimmed.
  3. Touch the screen and you're driving. The agent's input is refused with humanHeld and a retry time, and the banner reads "claude is waiting for you". Mark a device hands off to refuse agents entirely.
  4. Box what's wrong and send it. Flag for agent sends your note, the screenshot and the UI tree. An interrupt stops the agent mid-task.

The cursor, the banner and Take over are only in the browser. An agent working alone sees none of them: the CLI, MCP or HTTP just answers claimedBy or humanHeld. Claims and the human hold are in docs/agent-api.md, flags and interrupts in docs/flags.md.

Drive it from a shell or an agent

Every command is also an MCP tool. Point Claude Code or any MCP client at loupe mcp and it gets the same commands, with the same claims:

claude mcp add loupe -- loupe mcp

tap takes a node instead of a point: loupe tap <target> --text "Sign in" finds it in the accessibility tree and taps its center, and --id and --desc match the other fields. Two matches are refused with the candidates rather than guessed at. Coordinates still work, in device pixels, the ones ui reports in each node's center. sequence runs several steps in one call, and stops at the first that fails. Drive from the accessibility tree rather than from the video. boot starts a shut-down AVD or simulator, with --wait for how long to wait (0 returns at once), and boot-status reports on an AVD boot still running. docs/cli.md covers the commands, docs/mcp.md the tools, and docs/agent-api.md every HTTP route.

What it does

Streams devices

  • Android phones over adb. One plugged in later appears in the picker; one unplugged stays listed as missing, with the reason.
  • Every installed AVD, booted or not. Opening one boots it from a warm snapshot. An idle emulator is paused after 5 minutes and shut down after 30. Save & Shut Down keeps what you installed for every later boot, Reset returns one to a clean state, and New device creates an AVD from the system images you have.
  • iOS simulators through simcap. Physical iPhones and iPads are a preview: they stream over a cable, and input is still being worked on. See docs/ios.md.
  • Devices on your other machines. Add another loupe server as a peer and its targets join your picker. See docs/remote-targets.md.

Feels like the device is in your hand

  • Video goes over WebTransport (HTTP/3), with WebSocket as a fallback. Adaptive bitrate lowers the encoder's rate when the link can't carry it and raises it again when the link recovers.
  • Multi-touch, swipes, hardware buttons, and your phone's own keyboard.
  • The clipboard works both ways, and can be shared across every open target and the Mac's pasteboard.
  • Add it to the Home Screen and it runs full screen as an app.

Lets agents work beside you

  • The accessibility tree with a precomputed center per node, tap by text, resource id or description, swipe, text, keys, waiting for a node, app launch, deep links, screenshots, APK install, logs, crash reports, boot and shutdown. On a debuggable Compose app, each node names the composable that drew it, with its source line.
  • camera points an AVD's, simulator's or iPhone's back camera at an image, so a scanner can be tested without holding a phone up to a screen.
  • Claims, the human hold and flags let you share a device with an agent. See Work on the same device as your agent.
  • Recording writes the encoder's output to an MP4, with no re-encode.

Fits into your workflow

  • A GitHub Action installs a pull request's APK on a target and comments on the PR with a link that opens it. See action/README.md.
  • Extensions are separate programs that loupe proxies under /api/ext, and they can draw overlays on a device. See docs/extensions.md.
  • loupe pair gives a device its own session, which you can revoke without re-keying every other device.

Security

Anyone who can reach the port can drive every device on it, so every request needs the shared token or a paired session, and plain HTTP is refused on anything but loopback. The token and every session have full access; there are no scopes yet. docs/security.md says what is protected and what isn't.

Build from source

git clone https://github.com/bmcreations/loupe && cd loupe
make build
./loupe -addr 127.0.0.1:8080 -synthetic -no-devices

Go is all it takes. The scrcpy-server jar is embedded and the web client has no build step, so there is no scrcpy to install and no npm. The test pattern needs ffmpeg; it should hold about 60 fps in the stats overlay before you plug in a device. docs/running.md lists every flag.

Docs

Doc For
getting-started.md From an install to a phone, a service and an agent
cli.md loupe <command>, claims between commands
mcp.md loupe mcp and pushing flags into Claude Code
agent-api.md Every /api/* route, claims and the human hold
targets.md AVDs, Android devices, the phone keyboard, the clipboard, device frames
ios.md iOS simulators, and physical iPhones in preview
running.md Every flag, the settings file, the stats overlay, tests
security.md The token, TLS, pairing and sessions

docs/README.md indexes the rest: architecture, the wire protocol, flags, recording, extensions and notes for working on the code.

Licensing

loupe is Apache 2.0. It embeds and redistributes the scrcpy-server jar, which is also Apache 2.0; third_party/scrcpy/LICENSE and THIRD_PARTY_NOTICES.md carry that text and the upstream attribution. Section 6 grants no trademark rights: nothing here may imply this is scrcpy or that Genymobile endorses it.

simcap, the iOS helper, is also Apache 2.0 and lives in its own repo, bmcreations/simcap. It calls private frameworks from your own Xcode install; docs/ios.md says which, and what that means for an Xcode update.

iPhone, iPad, Mac, macOS and Xcode are trademarks of Apple Inc. loupe is not affiliated with Apple.

Directories

Path Synopsis
cmd
apischema command
Command apischema regenerates docs/api.schema.json from the server's own response types.
Command apischema regenerates docs/api.schema.json from the server's own response types.
kbprobe command
Command kbprobe attaches loupe's UHID keyboard to a device through a live scrcpy session, types, and removes it, saving a screenshot at each step so whether the on-screen keyboard stayed down can be looked at.
Command kbprobe attaches loupe's UHID keyboard to a device through a live scrcpy session, types, and removes it, saving a screenshot at each step so whether the on-screen keyboard stayed down can be looked at.
linkshaper command
Command linkshaper is a UDP relay that impairs the link between a loupe client and a loupe server, so the adaptive bitrate controller can be driven through congestion and recovery on demand.
Command linkshaper is a UDP relay that impairs the link between a loupe client and a loupe server, so the adaptive bitrate controller can be driven through congestion and recovery on demand.
loupe command
Command loupe streams an Android device or emulator to a browser at 60fps.
Command loupe streams an Android device or emulator to a browser at 60fps.
overlaptest command
Command overlaptest reproduces a relaunch's stream overlap against a real device: open a second scrcpy server while the first is still streaming, then close the first.
Command overlaptest reproduces a relaunch's stream overlap against a real device: open a second scrcpy server while the first is still streaming, then close the first.
rotprobe command
Command rotprobe answers one question about scrcpy-server 3.3.4: what does the video stream actually do when the device rotates?
Command rotprobe answers one question about scrcpy-server 3.3.4: what does the video stream actually do when the device rotates?
runnerprobe command
Command runnerprobe sends lines to the XCUITest runner on an iPhone over usbmux and prints each reply with its round trip, which checks the runner without a server:
Command runnerprobe sends lines to the XCUITest runner on an iPhone over usbmux and prints each reply with its round trip, which checks the runner without a server:
simprobe command
Command simprobe answers whether simcap can stream an iOS simulator well enough to be a loupe target, before anything in the session is built on it.
Command simprobe answers whether simcap can stream an iOS simulator well enough to be a loupe target, before anything in the session is built on it.
touchrotprobe command
Command touchrotprobe answers the question the rotation fix turns on: after a rotation, does scrcpy-server accept a touch whose screen size came from the new SPS, and does it reject one carrying the size from the stream header?
Command touchrotprobe answers the question the rotation fix turns on: after a rotation, does scrcpy-server accept a touch whose screen size came from the new SPS, and does it reject one carrying the size from the stream header?
uiprobe command
Command uiprobe drives one live WebTransport session end to end -- touch, events, health -- against a running loupe server, the way cmd/wtprobe verifies the video path.
Command uiprobe drives one live WebTransport session end to end -- touch, events, health -- against a running loupe server, the way cmd/wtprobe verifies the video path.
wtprobe command
Command wtprobe drives a real WebTransport session against a running loupe server and reports what it received.
Command wtprobe drives a real WebTransport session against a running loupe server and reports what it received.
internal
a11ydump
Package a11ydump carries the device half of loupe's Android tree dump: a dex (tools/a11ydump) that app_process runs to print the screen's accessibility tree as uiautomator dump's XML, in about 250ms where uiautomator takes 2s, with each scrollable node's scroll-backward and scroll-forward actions added.
Package a11ydump carries the device half of loupe's Android tree dump: a dex (tools/a11ydump) that app_process runs to print the screen's accessibility tree as uiautomator dump's XML, in about 250ms where uiautomator takes 2s, with each scrollable node's scroll-backward and scroll-forward actions added.
apischema
Package apischema reflects over the server's HTTP response types and emits one JSON Schema document (draft 2020-12) describing them, keyed by endpoint.
Package apischema reflects over the server's HTTP response types and emits one JSON Schema document (draft 2020-12) describing them, keyed by endpoint.
awake
Package awake keeps the Mac from idle-sleeping while someone is using it through loupe.
Package awake keeps the Mac from idle-sleeping while someone is using it through loupe.
camfeed
Package camfeed passes camera frames to Handset Camera, the Mac camera that Handset's camera extension adds.
Package camfeed passes camera frames to Handset Camera, the Mac camera that Handset's camera extension adds.
clipshare
Package clipshare holds the one clipboard a server's targets and its Mac share, and hands each change to whatever writes it onward.
Package clipshare holds the one clipboard a server's targets and its Mac share, and hands each change to whatever writes it onward.
composetree
Package composetree reads the composable tree out of a debuggable Compose app and maps it onto the uiautomator tree loupe already serves.
Package composetree reads the composable tree out of a debuggable Compose app and maps it onto the uiautomator tree loupe already serves.
config
Package config is the persisted server configuration and the rules for changing it.
Package config is the persisted server configuration and the rules for changing it.
dest
Package dest reads the places a flag can be sent beyond loupe mcp sessions and T3 threads: a program on this Mac, such as `claude -p` or `codex exec`, or a webhook.
Package dest reads the places a flag can be sent beyond loupe mcp sessions and T3 threads: a program on this Mac, such as `claude -p` or `codex exec`, or a webhook.
h264
Package h264 provides the minimum bitstream inspection the server needs: locating parameter sets in an Annex B stream and deriving the codec string a browser's VideoDecoder expects.
Package h264 provides the minimum bitstream inspection the server needs: locating parameter sets in an Annex B stream and deriving the codec string a browser's VideoDecoder expects.
hevc
Package hevc reads what loupe needs from an HEVC (H.265) parameter set: the RFC 6381 codec string a viewer's decoder is configured with.
Package hevc reads what loupe needs from an HEVC (H.265) parameter set: the RFC 6381 codec string a viewer's decoder is configured with.
httpapi
Package httpapi exposes the target registry and streaming endpoint over HTTP.
Package httpapi exposes the target registry and streaming endpoint over HTTP.
mcpserver
Package mcpserver is `loupe mcp`: a Model Context Protocol server over stdio that turns a running loupe server's HTTP API into tools.
Package mcpserver is `loupe mcp`: a Model Context Protocol server over stdio that turns a running loupe server's HTTP API into tools.
mp4
Package mp4 writes one H.264 video track to an MP4 file, streaming samples to disk and holding only the sample table in memory.
Package mp4 writes one H.264 video track to an MP4 file, streaming samples to disk and holding only the sample table in memory.
pairing
Package pairing keeps device sessions and the one-time codes that create them.
Package pairing keeps device sessions and the one-time codes that create them.
peer
Package peer holds the servers this one has been told about: their URLs, tokens and pinned certificates, the polling that keeps their target rows fresh, and the HTTP and TLS plumbing for reaching them.
Package peer holds the servers this one has been told about: their URLs, tokens and pinned certificates, the polling that keeps their target rows fresh, and the HTTP and TLS plumbing for reaching them.
record
Package record writes a live session's frames to MP4 files and keeps a capped store of them.
Package record writes a live session's frames to MP4 files and keeps a capped store of them.
scrcpy
Package scrcpy implements the wire protocol spoken by scrcpy-server: the video stream framing it emits, and the control messages it accepts.
Package scrcpy implements the wire protocol spoken by scrcpy-server: the video stream framing it emits, and the control messages it accepts.
scrcpy/server
Package server embeds the scrcpy-server jar that loupe pushes to the device.
Package server embeds the scrcpy-server jar that loupe pushes to the device.
session
Package session owns the live streaming sessions and the binary protocol spoken between this server and a browser client.
Package session owns the live streaming sessions and the binary protocol spoken between this server and a browser client.
t3
Package t3 drives T3 Code's CLI: list a project's threads, send one a message, start a new one.
Package t3 drives T3 Code's CLI: list a project's threads, send one a message, start a new one.
target
Package target defines the contract every streamable Android source satisfies, plus the concrete implementations: a physical device over adb, a managed emulator, and a synthetic test pattern used to validate the client without any Android hardware attached.
Package target defines the contract every streamable Android source satisfies, plus the concrete implementations: a physical device over adb, a managed emulator, and a synthetic test pattern used to validate the client without any Android hardware attached.
trace
Package trace writes a newline-delimited JSON record per sample so a session can be analyzed after the fact instead of read off a phone screen.
Package trace writes a newline-delimited JSON record per sample so a session can be analyzed after the fact instead of read off a phone screen.
tspath
Package tspath reads how Tailscale is carrying traffic to a peer: directly, through a peer relay, or through a DERP server.
Package tspath reads how Tailscale is carrying traffic to a peer: directly, through a peer relay, or through a DERP server.
usbmux
Package usbmux opens a TCP connection to a port on an iPhone over its USB cable, through macOS's own usbmuxd at /var/run/usbmuxd.
Package usbmux opens a TCP connection to a port on an iPhone over its USB cable, through macOS's own usbmuxd at /var/run/usbmuxd.
wsx
Package wsx is a minimal RFC 6455 WebSocket server implementation.
Package wsx is a minimal RFC 6455 WebSocket server implementation.
Package web embeds the browser client so the server ships as a single file.
Package web embeds the browser client so the server ships as a single file.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL