Resize Window
resize_windowSet an application window to precise width and height in pixels. Specify the app name and optionally a window title to target.
Instructions
Resize a window to specific dimensions.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| appName | Yes | Application name (e.g. 'Safari') | |
| width | Yes | Window width in pixels | |
| height | Yes | Window height in pixels | |
| windowTitle | No | Specific window title. If omitted, targets the first window. |
Implementation Reference
- src/system/tools.ts:704-711 (handler)The handler function for the resize_window tool. It accepts appName, width, height, and optional windowTitle, then executes a JXA script to resize the window.
async ({ appName, width, height, windowTitle }) => { try { return ok(await runJxa(resizeWindowScript(appName, width, height, windowTitle))); } catch (e) { return errJxaFor("resize window", e); } }, ); - src/system/tools.ts:693-701 (schema)Input schema definition for the resize_window tool using Zod validation.
appName: z.string().min(1).max(500).describe("Application name (e.g. 'Safari')"), width: z.number().int().min(1).describe("Window width in pixels"), height: z.number().int().min(1).describe("Window height in pixels"), windowTitle: z .string() .max(500) .optional() .describe("Specific window title. If omitted, targets the first window."), }, - src/system/tools.ts:687-711 (registration)Registration of the 'resize_window' tool on the MCP server.
server.registerTool( "resize_window", { title: "Resize Window", description: "Resize a window to specific dimensions.", inputSchema: { appName: z.string().min(1).max(500).describe("Application name (e.g. 'Safari')"), width: z.number().int().min(1).describe("Window width in pixels"), height: z.number().int().min(1).describe("Window height in pixels"), windowTitle: z .string() .max(500) .optional() .describe("Specific window title. If omitted, targets the first window."), }, annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false }, }, async ({ appName, width, height, windowTitle }) => { try { return ok(await runJxa(resizeWindowScript(appName, width, height, windowTitle))); } catch (e) { return errJxaFor("resize window", e); } }, ); - src/system/scripts.ts:387-394 (helper)Helper function that generates a JXA (JavaScript for Automation) script string to resize a window using System Events.
export function resizeWindowScript(appName: string, width: number, height: number, windowTitle?: string): string { return ` const se = Application('System Events'); ${windowSelector(appName, windowTitle)} win.size = [${width}, ${height}]; JSON.stringify({resized: true, app: '${esc(appName)}', size: win.size()}); `; } - src/system/scripts.ts:365-375 (helper)Helper function that generates JXA code to select a window by app name and optional title.
function windowSelector(appName: string, windowTitle?: string): string { if (windowTitle) { return `const proc = se.processes.byName('${esc(appName)}'); const wins = proc.windows.whose({name: '${esc(windowTitle)}'})(); if (wins.length === 0) throw new Error('No window found: ${esc(windowTitle)}'); const win = wins[0];`; } return `const proc = se.processes.byName('${esc(appName)}'); const wins = proc.windows(); if (wins.length === 0) throw new Error('No windows found for ${esc(appName)}'); const win = wins[0];`;