set_window_position
Move application windows to exact screen coordinates for precise positioning control in macOS window management.
Instructions
Move a window to a specific position for precise control
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| appName | Yes | Name of the application | |
| x | Yes | X coordinate | |
| y | Yes | Y coordinate |
Implementation Reference
- src/index.js:629-657 (handler)The handler function that executes the set_window_position tool. It constructs and runs an AppleScript to activate the specified application and set the position of its front window to the given (x, y) coordinates.async setWindowPosition(appName, x, y) { const processName = this.getProcessName(appName); const script = ` tell application "${appName}" to activate delay 0.5 tell application "System Events" tell process "${processName}" set frontmost to true set position of front window to {${x}, ${y}} end tell end tell `; try { await this.runAppleScript(script); return { content: [{ type: 'text', text: `Successfully positioned ${appName} window at (${x}, ${y})` }] }; } catch (error) { return { content: [{ type: 'text', text: `Error positioning ${appName}: ${error.message}` }] }; }
- src/index.js:161-178 (schema)Defines the input schema for the set_window_position tool, specifying required parameters appName (string), x (number), and y (number).inputSchema: { type: 'object', properties: { appName: { type: 'string', description: 'Name of the application', }, x: { type: 'number', description: 'X coordinate', }, y: { type: 'number', description: 'Y coordinate', }, }, required: ['appName', 'x', 'y'], },
- src/index.js:229-230 (registration)Registers the tool handler in the CallToolRequestSchema switch statement, dispatching to the setWindowPosition method.case 'set_window_position': return await this.setWindowPosition(args.appName, args.x, args.y);
- src/index.js:158-179 (registration)Registers the tool in the ListToolsRequestSchema response, providing name, description, and input schema.{ name: 'set_window_position', description: 'Move a window to a specific position for precise control', inputSchema: { type: 'object', properties: { appName: { type: 'string', description: 'Name of the application', }, x: { type: 'number', description: 'X coordinate', }, y: { type: 'number', description: 'Y coordinate', }, }, required: ['appName', 'x', 'y'], }, },
- src/index.js:697-709 (helper)Helper function to map application names to their process names, used in setWindowPosition to target the correct System Events process.getProcessName(appName) { const processMap = { "Visual Studio Code": "Code", "iTerm": "iTerm2", "Safari": "Safari", "Claude": "Claude", "Terminal": "Terminal", "Finder": "Finder", "Chrome": "Google Chrome", "Firefox": "Firefox" }; return processMap[appName] || appName; }