focus_window
Focus a specific window by label in Tauri desktop applications to enable AI-assisted automation and testing through the Model Context Protocol.
Instructions
Focus a specific window by label
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| window | Yes | Window label to focus |
Implementation Reference
- The focus_window tool handler that receives the window label from args and calls socketManager.focusWindow to execute the focus operation, returning the result as formatted text content.focus_window: async (args: { window: string }) => { const result = await socketManager.focusWindow(args.window); return { content: [ { type: 'text' as const, text: result, }, ], }; },
- Tool schema definition for focus_window, specifying it takes a single required parameter 'window' (string) which is the window label to focus.focus_window: { name: 'focus_window', description: 'Focus a specific window by label', inputSchema: z.object({ window: z.string().describe('Window label to focus'), }), },
- packages/tauri-mcp/src/server.ts:58-58 (registration)Tool handlers creation - creates all tool handlers including focus_window by calling createToolHandlers with the managers.this.toolHandlers = createToolHandlers(this.tauriManager, this.socketManager);
- packages/tauri-mcp/src/server.ts:112-134 (registration)MCP server request handler that routes tool calls to the appropriate handler function, dispatching focus_window calls to the registered 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, }; } });
- SocketManager.focusWindow implementation that sends a JSON-RPC 'focus_window' command with the window label parameter and returns a formatted success message.async focusWindow(windowLabel: string): Promise<string> { const result = await this.sendCommand('focus_window', { window: windowLabel }) as { focused: string }; return `Focused window: ${result.focused}`; }