Skip to main content
Glama

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
NameRequiredDescriptionDefault
appNameYesName of the application
widthYesWindow width
heightYesWindow height

Implementation Reference

  • 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}` }] }; } }
  • 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);
  • 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; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/itrimble/moom-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server