Skip to main content
Glama

Resize Window

resize_window
Idempotent

Set 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

TableJSON Schema
NameRequiredDescriptionDefault
appNameYesApplication name (e.g. 'Safari')
widthYesWindow width in pixels
heightYesWindow height in pixels
windowTitleNoSpecific window title. If omitted, targets the first window.

Implementation Reference

  • 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);
        }
      },
    );
  • 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."),
    },
  • 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);
        }
      },
    );
  • 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()});
      `;
    }
  • 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];`;
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already indicate idempotency and non-destructive behavior. The description adds no further behavioral details such as error handling or limitations beyond schema.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is very concise with a single sentence, no fluff. However, it could be slightly expanded to include edge cases without losing conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no output schema and a simple operation, the description is minimal but missing some context like what happens if window not found or whether dimensions are clamped.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so baseline is 3. The description does not add any additional meaning beyond the schema's parameter descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action (resize) and the resource (a window) with specific dimensions, distinguishing it from siblings like move_window or minimize_window.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives like move_window or when it's appropriate to resize vs minimize. No context about prerequisites or conditions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/heznpc/AirMCP'

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