tauri_manage_window
Manage Tauri application windows by listing available windows, retrieving detailed window information, or resizing windows to specific dimensions using logical or physical pixels.
Instructions
[Tauri Apps Only] Manage Tauri windows. Actions: "list" - List all windows with labels, titles, URLs, and state. "info" - Get detailed info for a window (size, position, title, focus, visibility). "resize" - Resize a window (requires width/height, uses logical pixels by default). Requires active tauri_driver_session. For browser windows, use Chrome DevTools MCP instead.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | Action: "list" all windows, get "info" for one window, or "resize" a window | |
| windowId | No | Window label to target (defaults to "main"). Required for "info", optional for "resize" | |
| width | No | Width in pixels (required for "resize" action) | |
| height | No | Height in pixels (required for "resize" action) | |
| logical | No | Use logical pixels (true, default) or physical pixels (false). Only for "resize" | |
| appIdentifier | No | App port or bundle ID to target. Defaults to the only connected app or the default app if multiple are connected. |
Implementation Reference
- Main handler function for the tauri_manage_window tool. Dispatches to list, info, or resize actions by sending WebSocket commands to the MCP Bridge plugin in the Tauri app.export async function manageWindow(options: { action: 'list' | 'info' | 'resize'; windowId?: string; width?: number; height?: number; logical?: boolean; appIdentifier?: string | number; }): Promise<string> { const { action, windowId, width, height, logical, appIdentifier } = options; switch (action) { case 'list': { return listWindows(appIdentifier); } case 'info': { try { const client = await ensureSessionAndConnect(appIdentifier); const response = await client.sendCommand({ command: 'get_window_info', args: { windowId }, }); if (!response.success) { throw new Error(response.error || 'Unknown error'); } return JSON.stringify(response.data); } catch(error: unknown) { const message = error instanceof Error ? error.message : String(error); throw new Error(`Failed to get window info: ${message}`); } } case 'resize': { if (width === undefined || height === undefined) { throw new Error('width and height are required for resize action'); } return resizeWindow({ width, height, windowId, logical, appIdentifier }); } default: { throw new Error(`Unknown action: ${action}`); } } }
- Zod schema for validating inputs to the tauri_manage_window tool, defining actions list/info/resize and parameters.export const ManageWindowSchema = z.object({ action: z.enum([ 'list', 'info', 'resize' ]) .describe('Action: "list" all windows, get "info" for one window, or "resize" a window'), windowId: z.string().optional() .describe('Window label to target (defaults to "main"). Required for "info", optional for "resize"'), width: z.number().int().positive().optional() .describe('Width in pixels (required for "resize" action)'), height: z.number().int().positive().optional() .describe('Height in pixels (required for "resize" action)'), logical: z.boolean().optional().default(true) .describe('Use logical pixels (true, default) or physical pixels (false). Only for "resize"'), appIdentifier: z.union([ z.string(), z.number() ]).optional().describe( 'App port or bundle ID to target. Defaults to the only connected app or the default app if multiple are connected.' ), });
- packages/mcp-server/src/tools-registry.ts:588-611 (registration)Tool registration in the central TOOLS array, defining metadata, schema, annotations, and handler that parses args and calls manageWindow.{ name: 'tauri_manage_window', description: '[Tauri Apps Only] Manage Tauri windows. Actions: ' + '"list" - List all windows with labels, titles, URLs, and state. ' + '"info" - Get detailed info for a window (size, position, title, focus, visibility). ' + '"resize" - Resize a window (requires width/height, uses logical pixels by default). ' + 'Requires active tauri_driver_session. ' + 'For browser windows, use Chrome DevTools MCP instead.', category: TOOL_CATEGORIES.UI_AUTOMATION, schema: ManageWindowSchema, annotations: { title: 'Manage Tauri Window', readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false, }, handler: async (args) => { const parsed = ManageWindowSchema.parse(args); return await manageWindow(parsed); }, },
- Helper function called by manageWindow for 'list' action, sends 'list_windows' command to plugin.export async function listWindows(appIdentifier?: string | number): Promise<string> { try { const client = await ensureSessionAndConnect(appIdentifier); const response = await client.sendCommand({ command: 'list_windows', }); if (!response.success) { throw new Error(response.error || 'Unknown error'); } const windows = response.data as unknown[]; return JSON.stringify({ windows, defaultWindow: 'main', totalCount: windows.length, }); } catch(error: unknown) { const message = error instanceof Error ? error.message : String(error); throw new Error(`Failed to list windows: ${message}`); } }
- Helper function called by manageWindow for 'resize' action, sends 'resize_window' command to plugin.export async function resizeWindow(options: { width: number; height: number; windowId?: string; logical?: boolean; appIdentifier?: string | number; }): Promise<string> { try { const client = await ensureSessionAndConnect(options.appIdentifier); const response = await client.sendCommand({ command: 'resize_window', args: { width: options.width, height: options.height, windowId: options.windowId, logical: options.logical ?? true, }, }); if (!response.success) { throw new Error(response.error || 'Unknown error'); } return JSON.stringify(response.data); } catch(error: unknown) { const message = error instanceof Error ? error.message : String(error); throw new Error(`Failed to resize window: ${message}`); } }