Safari截图
STDIOmacOS系统Safari浏览器截图工具
macOS系统Safari浏览器截图工具
A Node.js MCP Server for capturing screenshots using Safari on macOS.
import { takeScreenshot } from './screenshot.js'; // Basic window screenshot await takeScreenshot({ url: 'https://www.apple.com', outputPath: './screenshot.png', width: 1024, // Optional: window width (default: 1024) height: 768, // Optional: window height (default: 768) waitTime: 3, // Optional: seconds to wait for load (default: 3) zoomLevel: 1, // Optional: page zoom level (default: 1) }); // Responsive design testing await takeScreenshot({ url: 'https://www.apple.com', outputPath: './mobile.png', width: 375, // iPhone SE width height: 667, // iPhone SE height zoomLevel: 1, }); // High-resolution capture await takeScreenshot({ url: 'https://www.apple.com', outputPath: './desktop-hd.png', width: 1920, // Full HD width height: 1080, // Full HD height waitTime: 5, // Wait longer for HD content zoomLevel: 0.8, // Zoom out slightly });
npm install safari-screenshot
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%) |
The module is tested with these common viewport sizes:
This package requires System Events permissions to work:
Open Cursor
Go to settings, "Add MCP Server"
In the configuration dialog:
safari-screenshot
command
npx -y @rogerheykoop/mcp-safari-screenshot
Or for local development:
npx -y /path/to/mcp-safari-screenshot/server.js
After connecting to the server in Cursor, you can use these commands:
Take a screenshot of https://apple.com at desktop size
Response: Will capture at 1920×1080
Capture https://apple.com on iPhone 12 Pro
Response: Will capture at 390×844
Screenshot github.com at 50% zoom
Response: Will capture with zoomLevel: 0.5
The MCP server understands these concepts:
Responsive Testing
Take screenshots of apple.com on iPhone, iPad, and desktop
Zoom Testing
Capture github.com at 75% zoom and 125% zoom
Custom Size
Screenshot example.com at 1440x900
screenshots
directory by defaultIf you encounter issues:
MIT
You can test the MCP implementation directly:
# Test discovery echo '{"type":"discover"}' | npx -y ./server.js # Test screenshot echo '{"type":"execute","tool":"take_screenshot","input":"Take a screenshot of https://apple.com","requestId":"123"}' | npx -y ./server.js
Expected responses: