list_windows
Retrieve a list of all open windows, including their labels, titles, and focus state, to monitor and manage application windows during testing or automation.
Instructions
List all open windows with their labels, titles, and focus state
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The tool handler for 'list_windows'. Calls socketManager.listWindows() and returns the result as JSON text content.
list_windows: async () => { const result = await socketManager.listWindows(); return { content: [ { type: 'text' as const, text: JSON.stringify(result, null, 2), }, ], }; }, - SocketManager.listWindows() method that sends the 'list_windows' command via JSON-RPC over a Unix socket and returns the typed result (windows array with label, title, focused, visible, size, bridge_initialized).
async listWindows(): Promise<{ windows: Array<{ label: string; title: string; focused: boolean; visible: boolean; size: { width: number; height: number } | null; bridge_initialized: boolean }> }> { const result = await this.sendCommand('list_windows') as { windows: Array<{ label: string; title: string; focused: boolean; visible: boolean; size: { width: number; height: number } | null; bridge_initialized: boolean }> }; return result; } - Schema definition for the 'list_windows' tool: name, description ('List all open windows with their labels, titles, and focus state'), and an empty inputSchema (no arguments required).
list_windows: { name: 'list_windows', description: 'List all open windows with their labels, titles, and focus state', inputSchema: z.object({}), }, - packages/tauri-mcp/src/server.ts:111-134 (registration)The CallToolRequestSchema handler in McpServer that dynamically dispatches tool calls (including 'list_windows') to the handler created by createToolHandlers via toolHandlers[name].
// Call tool handler this.server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; if (!(name in this.toolHandlers)) { throw new Error(`Unknown tool: ${name}`); } const handler = this.toolHandlers[name as ToolName]; try { return await handler(args as never); } catch (error) { return { content: [ { type: 'text' as const, text: `Error: ${(error as Error).message}`, }, ], isError: true, }; } }); - packages/tauri-mcp/src/server.ts:63-109 (registration)The ListToolsRequestSchema handler that registers all toolSchemas (including 'list_windows') as available tools via the MCP ListToolsRequest.
private setupHandlers() { // Get essential tools filter (null = show all) const essentialTools = getEssentialTools(); // List tools handler this.server.setRequestHandler(ListToolsRequestSchema, async () => { const allSchemas = Object.values(toolSchemas); // Filter tools if ESSENTIAL_TOOLS is set const filteredSchemas = essentialTools ? allSchemas.filter((schema) => essentialTools.has(schema.name)) : allSchemas; const tools: Tool[] = filteredSchemas.map((schema) => { const properties: Record<string, object> = {}; const required: string[] = []; const shape = schema.inputSchema.shape as Record<string, unknown>; for (const [key, zodValue] of Object.entries(shape)) { const zodSchema = zodValue as { _def?: { typeName?: string; description?: string }; description?: string; isOptional?: () => boolean }; properties[key] = { type: this.getZodType(zodSchema), description: zodSchema._def?.description || zodSchema.description || '', }; // Check if required (not optional) if (!zodSchema.isOptional?.()) { const typeName = zodSchema._def?.typeName; if (typeName !== 'ZodOptional') { required.push(key); } } } return { name: schema.name, description: schema.description, inputSchema: { type: 'object' as const, properties, required: required.length > 0 ? required : undefined, }, }; }); return { tools }; });