list_windows
Retrieve details of all open windows including labels, titles, and focus status to monitor application state during automated testing of Tauri desktop apps.
Instructions
List all open windows with their labels, titles, and focus state
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The list_windows handler function that calls socketManager.listWindows() and formats the result as JSON text content for the MCP response.list_windows: async () => { const result = await socketManager.listWindows(); return { content: [ { type: 'text' as const, text: JSON.stringify(result, null, 2), }, ], }; },
- Schema definition for list_windows tool including name, description, and empty input schema (no parameters required).list_windows: { name: 'list_windows', description: 'List all open windows with their labels, titles, and focus state', inputSchema: z.object({}), },
- The listWindows() method implementation that sends a 'list_windows' command via JSON-RPC to the Tauri app and returns the window list with labels, titles, focus state, visibility, and size information.async listWindows(): Promise<{ windows: Array<{ label: string; title: string; focused: boolean; visible: boolean; size: { width: number; height: number } | null }> }> { const result = await this.sendCommand('list_windows') as { windows: Array<{ label: string; title: string; focused: boolean; visible: boolean; size: { width: number; height: number } | null }> }; return result; }
- packages/tauri-mcp/src/server.ts:68-109 (registration)ListToolsRequestSchema handler that registers all tools including list_windows, converting Zod schemas to MCP tool format and filtering based on ESSENTIAL_TOOLS environment variable.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 }; });
- packages/tauri-mcp/src/server.ts:112-134 (registration)CallToolRequestSchema handler that routes tool execution requests to the appropriate handler function, including list_windows, with error handling.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, }; } });