Enables comprehensive screen capture capabilities on macOS, including capturing entire screens, specific application windows, or all windows of an app with various formatting options.
Enables local AI image analysis of screenshots through Ollama, supporting models like LLaVA and Qwen2-VL for vision tasks without sending data to the cloud.
Provides integration with OpenAI's vision models (like GPT-4o) for analyzing captured screenshots through the OpenAI API.
Peekaboo MCP: Lightning-fast macOS Screenshots for AI Agents
Peekaboo is a macOS-only MCP server that enables AI agents to capture screenshots of applications, windows, or the entire system, with optional visual question answering through local or remote AI models.
What is Peekaboo?
Peekaboo bridges the gap between AI assistants and visual content on your screen. Without visual capabilities, AI agents are fundamentally limited when debugging UI issues or understanding what's happening on screen. Peekaboo solves this by giving AI agents the ability to:
- Capture screenshots of your entire screen, specific applications, or individual windows
- Analyze visual content using AI vision models (both local and cloud-based)
- List running applications and their windows for targeted captures
- Work non-intrusively without changing window focus or interrupting your workflow
Key Features
- 🚀 Fast & Non-intrusive: Uses Apple's ScreenCaptureKit for instant captures without focus changes
- 🎯 Smart Window Targeting: Fuzzy matching finds the right window even with partial names
- 🤖 AI-Powered Analysis: Ask questions about screenshots using GPT-4o, Claude, or local models
- 🔒 Privacy-First: Run entirely locally with Ollama, or use cloud providers when needed
- 📦 Easy Installation: One-click install via Cursor or simple npm/npx commands
- 🛠️ Developer-Friendly: Clean JSON API, TypeScript support, comprehensive logging
Read more about the design philosophy and implementation details in the blog post.
Installation
Requirements
- macOS 14.0+ (Sonoma or later)
- Node.js 20.0+
- Screen Recording Permission (you'll be prompted on first use)
Quick Start
For Cursor IDE
Or manually add to your Cursor settings:
For Claude Desktop
Edit your Claude Desktop configuration file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
- Windows:
%APPDATA%\Claude\claude_desktop_config.json
Add the Peekaboo configuration:
Then restart Claude Desktop.
Configuration
Peekaboo can be configured using environment variables:
Available Environment Variables
Variable | Description | Default |
---|---|---|
PEEKABOO_AI_PROVIDERS | JSON string defining AI providers for image analysis (see AI Analysis). | "" (disabled) |
PEEKABOO_LOG_LEVEL | Logging level (trace, debug, info, warn, error, fatal). | info |
PEEKABOO_LOG_FILE | Path to the server's log file. If the specified directory is not writable, falls back to the system temp directory. | ~/Library/Logs/peekaboo-mcp.log |
PEEKABOO_DEFAULT_SAVE_PATH | Default directory for saving captured images when no path is specified. | System temp directory |
PEEKABOO_OLLAMA_BASE_URL | Base URL for the Ollama API server. Only needed if Ollama is running on a non-default address. | http://localhost:11434 |
PEEKABOO_CONSOLE_LOGGING | Boolean ("true" /"false" ) for development console logs. | "false" |
PEEKABOO_CLI_TIMEOUT | Timeout in milliseconds for Swift CLI operations. Prevents hanging processes. | 30000 (30 seconds) |
PEEKABOO_CLI_PATH | Optional override for the Swift peekaboo CLI executable path. | (uses bundled CLI) |
AI Provider Configuration
The PEEKABOO_AI_PROVIDERS
environment variable is your gateway to unlocking Peekaboo's analytical abilities for both the dedicated analyze
tool and the image
tool (when a question
is supplied with an image capture). It should be a string defining the AI providers and their default models. For example:
PEEKABOO_AI_PROVIDERS="openai/gpt-4o,ollama/llava:latest,anthropic/claude-3-haiku-20240307"
Or using semicolon separators:
PEEKABOO_AI_PROVIDERS="openai/gpt-4o;ollama/llava:latest;anthropic/claude-3-haiku-20240307"
Each entry follows the format provider_name/model_identifier
. You can use either commas (,
) or semicolons (;
) as separators.
provider_name
: Currently supported values areollama
(for local Ollama instances) andopenai
. Support foranthropic
is planned.model_identifier
: The specific model to use for that provider (e.g.,llava:latest
,gpt-4o
).
The analyze
tool and the image
tool (when a question
is provided) will use these configurations. If the provider_config
argument in these tools is set to \"auto\"
(the default for analyze
, and an option for image
), Peekaboo will try providers from PEEKABOO_AI_PROVIDERS
in the order they are listed, checking for necessary API keys (like OPENAI_API_KEY
) or service availability (like Ollama running at http://localhost:11434
or the URL specified in PEEKABOO_OLLAMA_BASE_URL
).
You can override the model or pick a specific provider listed in PEEKABOO_AI_PROVIDERS
using the provider_config
argument in the analyze
or image
tools. (The system will still verify its operational readiness, e.g., API key presence or service availability.)
Setting Up Local AI with Ollama
Ollama provides powerful local AI models that can analyze your screenshots without sending data to the cloud.
Installing Ollama
Downloading Vision Models
For powerful machines, LLaVA (Large Language and Vision Assistant) is the recommended model:
For less beefy machines, Qwen2-VL provides excellent performance with lower resource requirements:
Model Size Guide:
qwen2-vl:7b
- ~4GB download, ~6GB RAM required (excellent for lighter machines)llava:7b
- ~4.5GB download, ~8GB RAM requiredllava:13b
- ~8GB download, ~16GB RAM requiredllava:34b
- ~20GB download, ~40GB RAM required
Configuring Peekaboo with Ollama
Add Ollama to your Claude Desktop configuration:
For less powerful machines (using Qwen2-VL):
Multiple AI Providers (Ollama + OpenAI):
macOS Permissions
Peekaboo requires specific macOS permissions to function:
1. Screen Recording Permission (Required)
For macOS Sequoia (15.0+):
- Open System Settings → Privacy & Security
- Scroll down to Screen & System Audio Recording
- Toggle on your terminal application or MCP client
- You may need to restart the application after granting permission
For macOS Sonoma (14.0) and earlier:
- Open System Preferences → Security & Privacy → Privacy
- Select Screen Recording from the left sidebar
- Click the lock icon and enter your password
- Click + and add your terminal application or MCP client
- Restart the application
Applications that need permission:
- Terminal.app:
/Applications/Utilities/Terminal.app
- Claude Desktop:
/Applications/Claude.app
- VS Code:
/Applications/Visual Studio Code.app
- Cursor:
/Applications/Cursor.app
2. Accessibility Permission (Optional)
For macOS Sequoia (15.0+):
- Open System Settings → Privacy & Security
- Select Accessibility
- Toggle on your terminal/MCP client application
For macOS Sonoma (14.0) and earlier:
- Open System Preferences → Security & Privacy → Privacy
- Select Accessibility from the left sidebar
- Add your terminal/MCP client application
Testing & Debugging
Using MCP Inspector
The easiest way to test Peekaboo is with the MCP Inspector:
This launches an interactive web interface where you can test all of Peekaboo's tools and see their responses in real-time.
Direct CLI Testing
Expected output:
Available Tools
Peekaboo provides three main tools for AI agents:
1. image
- Capture Screenshots
Captures macOS screen content with automatic shadow/frame removal.
Important: Screen captures cannot use format: "data"
due to the large size of screen images causing JavaScript stack overflow errors. Screen captures always save to files, either to a specified path or a temporary directory. When format: "data"
is requested for screen captures, the tool automatically falls back to PNG format and saves to a file with a warning message explaining the fallback.
Examples:
Browser Helper Filtering
Peekaboo automatically filters out browser helper processes when searching for common browsers (Chrome, Safari, Firefox, Edge, Brave, Arc, Opera). This prevents confusing errors when helper processes like "Google Chrome Helper (Renderer)" are matched instead of the main browser application.
Examples:
Browser-Specific Error Messages:
- Instead of generic "Application not found"
- Shows clear messages like "Chrome browser is not running or not found"
- Only applies to browser identifiers - other apps work normally
File Naming and Path Behavior
Peekaboo intelligently manages output paths to prevent file overwrites while respecting your intentions:
Key Principle: Single vs Multiple Captures
When you provide a specific file path (e.g., ~/Desktop/screenshot.png
), Peekaboo determines whether to use it exactly or add metadata based on the capture context:
- Single Capture → Exact Path
- Capturing one specific window
- Capturing one specific screen (when only one display exists)
- Capturing with
app_target: "frontmost"
- Your path is used exactly as specified
- Multiple Captures → Metadata Added
- Capturing all windows of an app (
mode: "multi"
or multiple windows exist) - Capturing all screens (when multiple displays exist)
- Capturing with no specific target (defaults to all screens)
- Metadata is appended to prevent overwrites
- Capturing all windows of an app (
Examples:
Long Filename Protection:
Peekaboo automatically handles filesystem limitations:
- Truncates filenames exceeding macOS's 255-byte limit
- Preserves UTF-8 multibyte characters (emoji, non-Latin scripts)
- Ensures metadata is always included when needed
- Never creates invalid filenames
Example:
Format Validation:
- Invalid formats ("bmp", "gif", "tiff", etc.) automatically convert to PNG
- You'll receive a clear warning message when format correction occurs
- Only "png" and "jpg"/"jpeg" are valid formats
2. list
- System Information
Lists running applications, windows, or server status.
Examples:
3. analyze
- AI Vision Analysis
Analyzes existing images using configured AI models.
Examples:
Testing
Peekaboo includes comprehensive test suites for both TypeScript and Swift components:
TypeScript Tests
- Unit Tests: Test individual functions and modules in isolation
- Integration Tests: Test tool handlers with mocked Swift CLI
- Platform-Specific Tests: Some integration tests require macOS and Swift binary
Swift Tests
Platform Support
- macOS: All tests run (unit, integration, Swift)
- Linux/CI: Only TypeScript tests run (Swift-dependent tests are automatically skipped)
- Environment Variables:
SKIP_SWIFT_TESTS=true
: Force skip Swift-dependent testsCI=true
: Automatically skips Swift-dependent tests
Troubleshooting
Common Issues
Haunting | Exorcism |
---|---|
Permission denied errors during image capture | Grant Screen Recording permission in System Settings → Privacy & Security. Ensure the correct application (Terminal, Claude, VS Code, etc.) is added and checked. Restart the app after changing permissions. |
Window capture issues (wrong window, focus problems) | Grant Accessibility permission if using capture_focus: "foreground" or for more reliable window targeting. |
Swift CLI unavailable or PEEKABOO_CLI_PATH issues | Ensure the peekaboo binary is at the root of the NPM package, or if PEEKABOO_CLI_PATH is set, verify it points to a valid executable. You can test the Swift CLI directly: path/to/peekaboo --version . If missing or broken, rebuild: cd peekaboo-cli && swift build -c release (then place binary appropriately or update PEEKABOO_CLI_PATH ). |
AI analysis failed | Check your PEEKABOO_AI_PROVIDERS environment variable for correct format and valid provider/model pairs. Ensure API keys (e.g., OPENAI_API_KEY ) are set if using cloud providers. Verify local services like Ollama are running (PEEKABOO_OLLAMA_BASE_URL ). Check the server logs (PEEKABOO_LOG_FILE or console if PEEKABOO_CONSOLE_LOGGING="true" ) for detailed error messages from the AI provider. |
Command not found: peekaboo-mcp | If installed globally, ensure your system's PATH includes the global npm binaries directory. If running from a local clone, use node dist/index.js or a configured npm script. For npx , ensure the package name @steipete/peekaboo-mcp is correct. |
General weirdness or unexpected behavior | Check the Peekaboo MCP server logs! The default location is ~/Library/Logs/peekaboo-mcp.log (or what you set in PEEKABOO_LOG_FILE ). Set PEEKABOO_LOG_LEVEL=debug for maximum detail. |
Debug Mode
Getting Help
Building from Source
Development Setup
Local Development Configuration
For development, you can run Peekaboo locally:
Alternatively, running directly with node
:
Remember to use absolute paths and unique server names to avoid conflicts with the npm version.
Using the AppleScript Version
For simple screenshot capture without MCP integration:
Note: This legacy version doesn't include AI analysis or MCP features.
Manual Configuration for Other MCP Clients
For MCP clients other than Claude Desktop:
Tool Documentation
image
- Screenshot Capture
Captures macOS screen content and optionally analyzes it. Window shadows/frames are automatically excluded.
Parameters:
app_target
(string, optional): Specifies the capture target. If omitted or empty, captures all screens.- Examples:
"screen:INDEX"
: Captures the screen at the specified zero-based index (e.g.,"screen:0"
). (Note: Index selection from multiple screens is planned for full support in the Swift CLI)."frontmost"
: Captures the frontmost window of the currently active application."AppName"
: Captures all windows of the application namedAppName
(e.g.,"Safari"
,"com.apple.Safari"
). Fuzzy matching is used."PID:ProcessID"
: Captures all windows of the application with the specified process ID (e.g.,"PID:663"
). Useful when multiple instances of the same app are running."AppName:WINDOW_TITLE:Title"
: Captures the window ofAppName
that has the specifiedTitle
(e.g.,"Notes:WINDOW_TITLE:My Important Note"
)."AppName:WINDOW_INDEX:Index"
: Captures the window ofAppName
at the specified zero-basedIndex
(e.g.,"Preview:WINDOW_INDEX:0"
for the frontmost window of Preview).
- Examples:
path
(string, optional): Base absolute path for saving the captured image(s). Ifformat
is"data"
andpath
is also provided, the image is saved to this path (as a PNG) AND Base64 data is returned. If aquestion
is provided andpath
is omitted, a temporary path is used for capture, and the file is deleted after analysis.question
(string, optional): If provided, the captured image will be analyzed. The server automatically selects an AI provider from those configured in thePEEKABOO_AI_PROVIDERS
environment variable.format
(string, optional, default:"png"
): Specifies the output image format or data return type."png"
or"jpg"
: Saves the image to the specifiedpath
in the chosen format. For application captures: ifpath
is not provided, behaves like"data"
. For screen captures: always saves to file."data"
: Returns Base64 encoded PNG data of the image directly in the MCP response. Ifpath
is also specified, a PNG file is also saved to thatpath
. Note: Screen captures cannot use this format and will automatically fall back to PNG file format.- Invalid values (empty strings, null, or unrecognized formats) automatically fall back to
"png"
.
capture_focus
(string, optional, default:"background"
): Controls window focus behavior during capture."background"
: Captures without altering the current window focus (default)."foreground"
: Attempts to bring the target application/window to the foreground before capture. This might be necessary for certain applications or to ensure a specific window is captured if multiple are open.
Behavior with question
(AI Analysis):
- If a
question
is provided, the tool will capture the image (saving it topath
if specified, or a temporary path otherwise). - This image is then sent to an AI model for analysis. The AI provider and model are chosen automatically by the server based on your
PEEKABOO_AI_PROVIDERS
environment variable (trying them in order until one succeeds). - The analysis result is returned as
analysis_text
in the response. Image data (Base64) is NOT returned in thecontent
array when a question is asked. - If a temporary path was used for the image, it's deleted after the analysis attempt.
Output Structure (Simplified):
content
: Can containImageContentItem
(ifformat: "data"
orpath
was omitted, and noquestion
) and/orTextContentItem
(for summaries, analysis text, warnings).saved_files
: Array of objects, each detailing a file saved topath
(ifpath
was provided).analysis_text
: Text from AI (ifquestion
was asked).model_used
: AI model identifier (ifquestion
was asked).
For detailed parameter documentation, see docs/spec.md.
Technical Features
Screenshot Capabilities
- Multi-display support: Captures each display separately
- Smart app targeting: Fuzzy matching for application names
- Multiple formats: PNG, JPEG, WebP, HEIF support
- Automatic naming: Timestamp-based file naming
- Permission checking: Automatic verification of required permissions
Window Management
- Application listing: Complete list of running applications with PIDs
- Window enumeration: List all windows for specific apps
- Flexible matching: Find apps by partial name, bundle ID, or Process ID
- PID targeting: Target specific processes using
PID:XXX
syntax - Status monitoring: Active/inactive status, window counts
AI Integration
- Provider agnostic: Supports Ollama and OpenAI (Anthropic coming soon)
- Natural language: Ask questions about captured images
- Configurable: Environment-based provider selection
- Fallback support: Automatic failover between providers
Architecture
Technical Details
JSON Output Format
The Swift CLI outputs structured JSON when called with --json-output
:
MCP Integration
The Node.js server provides:
- Schema validation via Zod
- Proper MCP error codes
- Structured logging via Pino
- Full TypeScript type safety
Security
Peekaboo respects macOS security:
- Checks permissions before operations
- Graceful handling of missing permissions
- Clear guidance for permission setup
Development
Testing Commands
Building
Known Issues
- FileHandle warning: Non-critical Swift warning about TextOutputStream conformance
- AI Provider Config: Requires
PEEKABOO_AI_PROVIDERS
environment variable for analysis features
License
MIT License - see LICENSE file for details.
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
Author
Created by Peter Steinberger - @steipete
Read more about Peekaboo's design and implementation in the blog post.
local-only server
The server can only run on the client's local machine because it depends on local resources.
A macOS utility that captures screenshots and analyzes them with AI vision, enabling AI assistants to see and interpret what's on your screen.
Related MCP Servers
- AsecurityAlicenseAqualityProvides screenshot and OCR capabilities for macOS.Last updated -13510JavaScriptMIT License
- AsecurityAlicenseAqualityEnables capturing high-quality native macOS screenshots using Safari through a Node.js server, supporting various sizes, zoom levels, and load wait times.Last updated -17TypeScriptMIT License
- AsecurityAlicenseAqualityA Model Context Protocol server that provides AI vision capabilities for analyzing UI screenshots, offering tools for screen analysis, file operations, and UI/UX report generation.Last updated -261JavaScriptISC License
- -securityFlicense-qualityEnables AI tools to capture and process screenshots of a user's screen, allowing AI assistants to see and analyze what the user is looking at through a simple MCP interface.Last updated -1Python