Purpose
swift-mcp-gui is a Model Context Protocol (MCP) server used to execute control commands such as keyboard input and mouse movement on macOS. It enables automation control of macOS through SwiftAutoGUI, for use by MCP clients.
Requirements
- macOS 15.0 or later
- Swift 6.0 or later
- Xcode 16.0 or later
- Homebrew (recommended)
Installation
Install via Homebrew (recommended)
Install via NakaokaRei/tap:
brew install NakaokaRei/tap/swift-mcp-gui
Then point the MCP client to the installed binary. On Intel Mac, the path is /usr/local/bin/swift-mcp-gui. Subsequent upgrades can be run with:
brew upgrade swift-mcp-gui
Install by cloning the repository
After cloning this repository, add the command to the MCP client.
Main capabilities (available tools)
The server provides the following tools for controlling macOS:
-
Mouse movement: tool name moveMouse. Input x (x coordinate, accepts integer, floating-point, or string representation) and y (y coordinate, accepts integer, floating-point, or string representation), moves the mouse cursor to the specified coordinates.
-
Mouse click: tool name mouseClick. Input button (string, "left" or "right"), performs a mouse click at the current cursor position.
-
Keyboard input: tool name sendKeys. Input keys (string array, key names), sends keyboard shortcuts or key combinations. Example keys: "command", "control", "option", "shift", "return", "space", "a", "1", etc.
-
Scroll: tool name scroll. Input direction (string, "up", "down", "left", "right") and clicks (number, number of scroll clicks), scrolls in the specified direction.
-
Get screen size: tool name getScreenSize. Returns the main screen size (width and height).
-
Get pixel color: tool name getPixelColor. Returns the RGBA color value (0-255) of the pixel at the specified coordinates.
-
Capture screen: tool name captureScreen. Input quality (number, optional, 0.0-1.0, default 0.5, JPEG compression quality), scale (number, optional, 0.1-1.0, default 0.25, image size scaling factor), output (string, optional, "path" or "image", default "path", output format). When output is "path", saves to a temporary file and returns the file path and dimensions, which can reduce token consumption; when output is "image", returns inline image content, for use by AI vision (such as Claude).
-
Capture region: tool name captureRegion. Input x (region x coordinate), y (region y coordinate), width (region width), height(region height), quality (optional, 0.0-1.0, default 0.5), scale (optional, 0.1-1.0, default 0.25), output (optional, "path" or "image", default "path").
-
Save Screenshot: tool name saveScreenshot. Input filename (path to save the screenshot), x (optional, region x coordinate), y (optional, region y coordinate), width (optional, region width), height (optional, region height), quality (optional, 0.0-1.0, default 0.1), scale (optional, 0.1-1.0, default 0.25). Capture the screen or a region and save it to a file; the file format is determined by the filename extension (.jpg, .jpeg, .png); the quality parameter only affects JPEG files.
-
Execute AppleScript: tool name executeAppleScript. Input script (the AppleScript code to execute), execute it directly and return the result. If the script returns a value, return "AppleScript Result: "; if the script completes but returns no value, return "AppleScript executed successfully (no result returned)".
-
Execute AppleScript File: tool name executeAppleScriptFile. Input path (the AppleScript file path), execute the AppleScript in the file and return the result. If the script completes but returns no value, return "AppleScript file executed successfully (no result returned): ".
Usage
- Ensure the environment requirements are met.
- Install via Homebrew or by cloning the repository.
- Point the MCP client to the swift-mcp-gui binary or add the corresponding command.
- The MCP client can then call the above tools to control macOS.
Security Notes
This server requires full accessibility permissions in System Preferences to control the mouse and keyboard. Please be careful when running it, and only connect trusted MCP clients.
ApplicableScenarios
Suitable for scenarios that require programmatically controlling the macOS mouse and keyboard through an MCP client, or performing automated operations such as executing AppleScript and taking screenshots.
Limitations
- Only supports macOS 15.0 or later.
- Requires Swift 6.0 or later, Xcode 16.0 or later.
- Requires full accessibility permissions.
- Other details regarding fees, pricing, and platform support are not yet provided.