Skip to main content
Glama

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
NameRequiredDescriptionDefault
windowYesWindow 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'), }), },
  • Tool handlers creation - creates all tool handlers including focus_window by calling createToolHandlers with the managers.
    this.toolHandlers = createToolHandlers(this.tauriManager, this.socketManager);
  • 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}`; }

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/DaveDev42/tauri-plugin-mcp'

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