polarize
polarize is a Rust MCP (Model
Context Protocol) server that automates real, native macOS AppKit
applications: screenshot capture, accessibility-tree inspection, and
synthetic mouse/keyboard input.
Status
The workspace builds, lints, and tests cleanly. Native-API behavior
cannot be exercised in CI — see docs/INVARIANTS.md
for exactly what's live-verified versus compile-checked only, per
tool.
Tools
polarize exposes 25 MCP tools, in six families:
screenshot — capture a window or the whole screen to PNG,
optionally scoped by a bundle id or app name.
describe — walk the AXUIElement accessibility tree for the
frontmost (or a named) app, returning each element's role, label or
title, normalized [0, 1] frame, and focusable/interactive flags,
plus a ready-to-read indented text rendering of the whole tree.
tap — post a synthetic mouse click via CGEvent at a screen
position. Coordinates are normalized [0, 1] fractions of the
target screen or window's width/height, not raw pixels.
keyboard — post synthetic key events via CGEvent: type a
string, or press a named key. Naming a target app posts the keys
to that app by pid, without stealing focus. When no pid resolves, it
activates the target first.
perform_action — press one element through its own
AXUIElementPerformAction action, naming the element by identifier,
role, subrole, or label instead of by coordinate. This reaches an
occluded element and an element below click-target size, neither of
which tap can hit. It refuses an action the element does not
publish, and refuses a disabled control, before it calls the
platform.
await_ui_element — block until an element appears, instead of
polling describe in a loop. It wakes on an AXObserver
notification and re-reads the tree every poll interval regardless,
because some accessibility trees never post one.
await_screen_idle — block until an app's accessibility tree
stops changing for a given window. Use it after an action that
starts an animation or a load, when there is no single element to
wait for.
run_applescript — run AppleScript source through osascript,
optionally wrapped in a tell application block. This reaches
scriptable apps such as Finder, Mail, Safari, Music, and Notes with
semantic operations no accessibility or CGEvent call can express.
script_dictionary — list a scriptable app's own verbs and
classes, read from its sdef dictionary. Call it before
run_applescript to find out what an app accepts.
set_value — write one accessibility attribute directly: text, a
number, or a selected-text range. This avoids the focus race and the
keyboard-layout dependence of simulated typing. Read PINV-27 first:
web content often takes the write without firing input or
keydown, so a controlled component can update and then snap back.
hit_test_at_point — report the element that really sits under a
point. It asks the system-wide accessibility element, so another
app's window counts as occlusion. It resolves the same fraction
tap resolves, so it preflights a click.
set_window_frame — move and resize one window. The response
reports the frame the window really got, re-read after the write.
Apps clamp their own minimum and maximum size.
window_action — minimize, restore, focus, close, or full-screen
one window.
list_windows — list an app's windows, merging the accessibility
list with the window server's for durable window ids and an
on-screen flag.
app_launch — start an app, or report it was already running.
app_quit — ask an app to exit. It asks politely unless the
caller asks to force, because a forced quit discards unsaved work.
list_displays — report every active display, in the same pixel
space screenshot and tap use.
find_text — find on-screen text with Vision OCR, for apps whose
accessibility tree is sparse, missing, or wrong. Each match carries a
frame a caller can hand straight to tap. The first call after an OS
update takes about 27 seconds, while macOS compiles the model.
clipboard_read — read the pasteboard. A refused read reports a
permission error, never empty text.
clipboard_write — replace the pasteboard contents.
describe_notifications — read every notification banner on
screen: its app, title, body, and frame.
dismiss_notification — close one banner, then re-read to report
whether it really went away.
frontmost_app — report the app that holds focus now.
await_workspace_event — wait for an app switch, a wake, or a
session change.
record_flow — record real mouse and keyboard input for a