Safari Screenshot MCP Server
by rogerheykoop
Safari Screenshot
A Node.js MCP Server for capturing screenshots using Safari on macOS.
Features
- Capture window screenshots at specific sizes
- Support for different zoom levels
- Configurable wait times for page load
- Clean up after capture
- Native macOS screenshot quality
Usage
Copy
Requirements
- macOS
- Safari
- Node.js >= 14.0.0
- Terminal needs Accessibility permissions (System Preferences → Security & Privacy → Privacy → Accessibility)
Installation
Copy
Options
Option | Type | Default | Description |
---|---|---|---|
url | string | required | The URL to capture |
outputPath | string | auto | Where to save the screenshot (default: ./screenshots/[hostname]-[timestamp].png) |
width | number | 1024 | Window width in pixels |
height | number | 768 | Window height in pixels |
waitTime | number | 3 | Seconds to wait for page load |
zoomLevel | number | 1 | Page zoom level (1 = 100%) |
Common Viewport Sizes
The module is tested with these common viewport sizes:
- Desktop: 1920×1080 (Full HD)
- Laptop: 1366×768
- Tablet Landscape: 1024×768
- Tablet Portrait: 768×1024
- Mobile Large: 428×926 (iPhone 12 Pro Max)
- Mobile Medium: 390×844 (iPhone 12 Pro)
- Mobile Small: 375×667 (iPhone SE)
How It Works
- Opens Safari with specified window size
- Loads the URL and waits for page load
- Applies zoom level if specified
- Uses native macOS screencapture for pixel-perfect results
- Verifies screenshot was captured successfully
- Cleans up Safari windows
Permissions
This package requires System Events permissions to work:
- Open System Preferences > Security & Privacy > Privacy > Accessibility
- Add Terminal (or your IDE) to the list of allowed apps
Using with Cursor
Setup in Cursor
- Open Cursor
- Go to settings, "Add MCP Server"
- In the configuration dialog:
- Name:
safari-screenshot
- Type:
command
- Command:
npx -y @rogerheykoop/mcp-safari-screenshot
Or for local development:
- Command:
npx -y /path/to/mcp-safari-screenshot/server.js
- Name:
Example Commands
After connecting to the server in Cursor, you can use these commands:
Copy
Response: Will capture at 1920×1080
Copy
Response: Will capture at 390×844
Copy
Response: Will capture with zoomLevel: 0.5
Supported Parameters
The MCP server understands these concepts:
- Device names (e.g., "iPhone", "iPad", "desktop")
- Dimensions (e.g., "1024x768")
- Zoom levels (e.g., "50% zoom", "2x zoom")
- Wait times (e.g., "wait 5 seconds")
Example Workflows
- Responsive TestingCopy
- Zoom TestingCopy
- Custom SizeCopy
Tips
- Screenshots are saved to the
screenshots
directory by default - Device names automatically set appropriate dimensions
- The server handles cleanup of Safari windows
- Use "wait X seconds" for slow-loading pages
Troubleshooting
If you encounter issues:
- Check Terminal has Accessibility permissions
- Verify Safari is not in private browsing mode
- Ensure the working directory is writable
- Check Cursor's console for error messages
License
MIT
Testing Locally
You can test the MCP implementation directly:
Copy
Expected responses:
- Discover will return capabilities
- Execute will:
- Log progress to stderr
- Return result JSON to stdout
- Save screenshot to ./screenshots/
You must be authenticated.
Enables capturing high-quality native macOS screenshots using Safari through a Node.js server, supporting various sizes, zoom levels, and load wait times.