set_window_size
Resize application windows to precise dimensions on macOS by specifying width and height values for programmatic layout control.
Instructions
Resize a window to specific dimensions
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| appName | Yes | Name of the application | |
| width | Yes | Window width | |
| height | Yes | Window height |
Implementation Reference
- src/index.js:663-692 (handler)The main handler function for the set_window_size tool. It activates the specified application, brings its front window to the foreground, and uses AppleScript via System Events to resize the window to the given width and height.async setWindowSize(appName, width, height) { 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 size of front window to {${width}, ${height}} end tell end tell `; try { await this.runAppleScript(script); return { content: [{ type: 'text', text: `Successfully resized ${appName} window to ${width}x${height}` }] }; } catch (error) { return { content: [{ type: 'text', text: `Error resizing ${appName}: ${error.message}` }] }; } }
- src/index.js:180-201 (schema)The input schema definition for the set_window_size tool, specifying appName, width, and height as required parameters.{ name: 'set_window_size', description: 'Resize a window to specific dimensions', inputSchema: { type: 'object', properties: { appName: { type: 'string', description: 'Name of the application', }, width: { type: 'number', description: 'Window width', }, height: { type: 'number', description: 'Window height', }, }, required: ['appName', 'width', 'height'], }, },
- src/index.js:231-232 (registration)The dispatch case in the CallToolRequestSchema handler that routes calls to the setWindowSize method.case 'set_window_size': return await this.setWindowSize(args.appName, args.width, args.height);
- src/index.js:697-709 (helper)Helper function used by setWindowSize to map application names to their process names for AppleScript.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; }