Skip to main content
Glama

tinysnap

Screenshots for coding agents. A 6 MB menu-bar app that holds the macOS Screen Recording permission once, and hands it to any agent that asks — over a local HTTP API or MCP.

agent ──MCP stdio──▶ tinysnap-mcp.mjs ──HTTP──▶ tinysnap.app ──▶ PNG
 (pi, Claude,                                                        │
  Codex, anything)                                     ~/.tinysnap/shots/*.png

Why not screencapture in a terminal? The permission is per app, so the terminal has to be granted first — and agents run in whatever terminal they were launched from. tinysnap is granted once and every agent borrows it.

Built with tinyjs: txiki.js backend + system webview, no Electron, no node_modules at runtime.


Quickstart

git clone https://github.com/math4mad/tinysnap && cd tinysnap
./scripts/install.sh --with-pi        # build → ~/Applications/tinysnap.app → login item → pi MCP

Then grant the permission once:

  1. System Settings → Privacy & Security → Screen & System Audio Recording

  2. Turn on tinysnap (or +, then pick dist/tinysnap.app)

  3. Restart it: launchctl kickstart -k gui/$(id -u)/com.local.tinysnap

If tinysnap is not in the list at all (this happens — macOS only adds an app once it actually asks to capture, and a silent denial never asks): reset the decision, restart the app, and trigger one capture so the prompt can appear:

tccutil reset ScreenCapture local.tinysnap
launchctl kickstart -k gui/$(id -u)/com.local.tinysnap
curl -s -XPOST localhost:8799/capture >/dev/null    # macOS shows the prompt

Check it:

node scripts/selftest.mjs             # 16 checks: HTTP, crops, MCP, PNG headers

Expected:

HTTP   GET / · /health · /display · capture(rect) · cropped size 400x60 ✓ · capture(full)
       3456x2234 ✓ · bad request 400 ✓ · /recent ✓ · 404 ✓
MCP    initialize ✓ · tools/list (3) ✓ · list_screens ✓ · capture_screen → image 400x60 ✓
       · recent_shots ✓ · unknown tool → tool error ✓

16 passed, 0 failed

Manual (no install script):

npm install
tinyjs build
open dist/tinysnap.app

Requirements: macOS 14+, tinyjs (curl -fsSL https://tinyjs.app/install | sh), node 18+ for the MCP bridge. Optional: gh for nothing, this is it.


Related MCP server: CaptureScreenMCP

Use it from an agent (MCP)

Add to your client's MCP config — pi: ~/.pi/agent/mcp.json, Claude Code: .mcp.json, Claude Desktop: claude_desktop_config.json:

{
  "mcpServers": {
    "tinysnap": {
      "command": "node",
      "args": ["/abs/path/to/tinysnap/mcp/tinysnap-mcp.mjs"]
    }
  }
}

(scripts/install.sh prints the exact snippet with your path.)

Tools

tool

what you get

capture_screen

the PNG as an image block (the agent can actually see it), plus path, byte size and capture time. x/y/w/h in points; omit them for the whole display. Crops capped at 4096 px/side.

list_screens

main display size in points + pixel scale — call it before converting pixels to points

recent_shots

paths of the last N captures, newest first

// what an agent does, roughly
await call('list_screens');                      // 1728x1117 pt, scale=2
await call('capture_screen', { x: 100, y: 80, w: 800, h: 600 });
// → sees the image, then fixes the CSS, then captures again

Points vs pixels: window APIs, 截图 coordinates and CSS pixels are points; the PNG is pixels (2× on a Retina display). Multiply points by scale to compare against an image.

Writing the prompt (the part that decides if it works)

The tools are three; the prompt decides whether the agent looks or guesses.

先看 list_screens 拿到屏幕 point 尺寸和 scale,
再用 capture_screen 截变化的那块(point),
看图 → 改 → 再截同一块对比。
最后说明"截图里具体哪里对了、哪里还差"。

Copy-paste templates for web dev, desktop/notch windows, before/after diffs, and a "固定说明" block for CLAUDE.md / AGENTS.md: docs/prompts.md.

Use it from a shell

curl -s localhost:8799/health | jq
curl -s -XPOST localhost:8799/capture -d '{"x":739,"y":0,"w":250,"h":33}' | jq -r .path
curl -s -XPOST localhost:8799/capture | jq -r .path        # whole screen
curl -s 'localhost:8799/recent?limit=5' | jq

Every capture is also written to ~/.tinysnap/shots/snap-<ISO>.png, so a human can open it.

API

endpoint

GET /

plain-text endpoint list

GET /health

{ ok, version, upSeconds, captures, shots, display, lastError }

GET /display

{ display: { width, height, scale, pixelWidth, pixelHeight } }

POST /capture

body { x?, y?, w?, h? } → { path, width, height, bytes, ms, scale, source }

GET /recent?limit=5

newest shots, newest first

Loopback only (127.0.0.1:8799), TINYSNAP_PORT overrides the port. w/h without x/y is a 400 — otherwise you would silently get the top-left corner.


Recipes

Web dev — "did my CSS change actually work?"

./examples/verify-webapp.sh http://127.0.0.1:5173/    # captures 900x700 pt and opens it

or from the agent: capture_screen the browser area, look, fix, repeat. See examples/verify-webapp.sh for the shape of it.

Desktop dev — check a window you just moved/resized:

  1. list_screens → get points + scale

  2. capture_screen the window rect (points, from your window API)

  3. look at the PNG, compare with the intent

Notch / menu-bar apps — a 250×33 pt pill is a two-line capture:

curl -s -XPOST localhost:8799/capture -d '{"x":739,"y":0,"w":250,"h":33}' | jq -r .path

CI / no display — not supported: the capture is ScreenCaptureKit, it needs a window server. On a headless mac, run the app in a user session (or use xvfb-style tooling elsewhere).


How it works

tinyjs.json      mainWindow:false + activation:accessory → tray app, no window, no Dock icon
backend/capture.ts   captureScreen() → sips crop → ~/.tinysnap/shots → Shot
backend/main.ts      HTTP API + tray menu
mcp/…mjs             MCP stdio ⇄ HTTP (zero deps, node)
scripts/selftest.mjs 16 end-to-end checks (parses PNG IHDR, not just trusting the daemon)
  • Cropping without dependencies: sips -c <pxH> <pxW> --cropOffset <pxY> <pxX> in --out out (system tool, no image library, no sharp).

  • Point size without a display API: tinyjs's backend has none (only the page does), so the main display's point size comes from Finder's desktop bounds via osascript — no extra permission.

  • One capture at a time: a queue serialises captures, so two agents shooting at once can't interleave temp files.

  • Launch it via LaunchServices, not exec: TCC auto-denies an app that is exec'd as a background process (raw binary, or a launchd agent whose program is that binary) — no prompt, no list entry. open -a puts it in the user session where macOS will ask. This is what scripts/install.sh does.

  • Stable install path: scripts/install.sh copies the bundle to ~/Applications/tinysnap.app and points the login item there. macOS keys the Screen Recording grant to the app's identity and path, so rebuilding in the repo's dist/ (ad-hoc signature, new hash every time) drops the grant, while the installed copy keeps it until you re-run the installer.

Troubleshooting

symptom

fix

capture_screen → "用户拒绝了…TCC" / denied

Grant Screen & System Audio Recording to tinysnap, restart the app (the TCC verdict is cached per process). tccutil reset ScreenCapture local.tinysnap to start over.

tinysnap daemon is not reachable

The app is not running: launchctl kickstart -k gui/$(id -u)/com.local.tinysnap, or open dist/tinysnap.app

Crop is one pixel / wrong area

x/y and w/h go together, in points. list_screens gives the scale.

Permission prompt never appears

macOS won't re-prompt after a denial. Reset it: tccutil reset ScreenCapture local.tinysnap, restart the app, capture again.

tinysnap is not in the Screen Recording list

macOS only lists an app after it asks to capture. Force the ask: reset (tccutil reset ScreenCapture local.tinysnap), restart the app, then trigger one capture (tray → 截一次全屏试试).

Works, then a rebuild breaks it

Install to the stable path: ./scripts/install.sh puts the app at ~/Applications/tinysnap.app and points the login item there. Rebuilding in the repo (dist/) changes the signature, and macOS drops the grant.

Never prompts, never shows up in the list, tccutil reset doesn't help

How the app is launched matters. Launching the binary directly — ./dist/tinysnap.app/Contents/MacOS/tinysnap, or a launchd agent whose program is that binary — gets silently auto-denied by TCC and the app never appears in the list. Launch it through LaunchServices instead: open -a ~/Applications/tinysnap.app, and in the LaunchAgent use ProgramArguments: [/usr/bin/open, -a, <app>] (no KeepAlive — open exits immediately, so KeepAlive would respawn in a loop).

Port 8799 taken

TINYSNAP_PORT=8899 for both the app and the MCP bridge (same env var).

Security

  • Listens on 127.0.0.1 only; nothing is exposed to the network.

  • Any local process can ask for a screenshot — that is the point, but it means anything running as you can too. Same trust boundary as your clipboard.

  • No telemetry, no network calls. The MCP bridge only ever talks to the daemon.

License

MIT — see LICENSE. tinyjs itself is by the tinyjs authors; the backend/*.d.ts files are tinyjs's type definitions, kept so npm run typecheck works out of the box.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      A
      quality
      D
      maintenance
      Enables LLMs to capture screenshots and screen recordings through MCP with chunked session-based transfers for reliable image consumption. Supports multi-monitor selection, timeline capture, and compatibility with both vision and non-vision language models.
      11
      1
      -
    • A
      license
      Not graded
      quality
      D
      maintenance
      A Windows-local MCP server for capturing screenshots (full screen, displays, regions, active window) and managing capture images via deletion tools, using a .NET tool interface.
      3
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables capturing full-screen or selected region screenshots on Windows, saving them as PNG files locally and returning image data via MCP.
      2,530 npm
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      MCP server that captures short screen recordings as numbered, timestamped still frames and composes them into a single contact sheet returned as image content, letting AI agents reason about motion, animations, and UI transitions instead of inspecting video frame by frame. Also supports single screenshots and listing targetable windows.
      6
      53 npm
      1
      MIT