Skip to main content
Glama
by Radek44

execute_tauri_command

Execute Tauri IPC commands to automate desktop application testing and functionality without manual interaction or complex scripting.

Instructions

Execute a Tauri IPC command. The command must be exposed in the Tauri app's src-tauri/src/main.rs file.

Input Schema

NameRequiredDescriptionDefault
commandYesName of the Tauri command to execute
argsNoArguments to pass to the command

Input Schema (JSON Schema)

{ "properties": { "args": { "additionalProperties": true, "description": "Arguments to pass to the command", "type": "object" }, "command": { "description": "Name of the Tauri command to execute", "type": "string" } }, "required": [ "command" ], "type": "object" }

Implementation Reference

  • MCP tool handler function that calls the TauriDriver's executeTauriCommand and formats the ToolResponse.
    export async function executeTauriCommand( driver: TauriDriver, params: ExecuteTauriCommandParams ): Promise<ToolResponse<{ result: unknown }>> { try { const result = await driver.executeTauriCommand(params.command, params.args); return { success: true, data: { result, }, }; } catch (error) { return { success: false, error: error instanceof Error ? error.message : String(error), }; } }
  • Core implementation in TauriDriver class that executes Tauri IPC commands via injected JavaScript invoking window.__TAURI__.invoke.
    async executeTauriCommand(command: string, args: Record<string, unknown> = {}): Promise<unknown> { this.ensureAppRunning(); try { // Execute JavaScript in the Tauri window to call the command const result = await this.appState.browser!.execute( (cmd: string, cmdArgs: Record<string, unknown>) => { // @ts-ignore - Tauri's invoke function is injected globally return window.__TAURI__?.invoke(cmd, cmdArgs); }, command, args ); return result; } catch (error) { throw new Error(`Failed to execute Tauri command '${command}': ${error instanceof Error ? error.message : String(error)}`); } }
  • src/index.ts:172-190 (registration)
    Tool registration in the ListToolsRequestSchema handler, defining the tool's name, description, and input schema for MCP.
    { name: 'execute_tauri_command', description: 'Execute a Tauri IPC command. The command must be exposed in the Tauri app\'s src-tauri/src/main.rs file.', inputSchema: { type: 'object', properties: { command: { type: 'string', description: 'Name of the Tauri command to execute', }, args: { type: 'object', description: 'Arguments to pass to the command', additionalProperties: true, }, }, required: ['command'], }, },
  • Dispatch handler in the central CallToolRequestSchema switch statement that invokes the tool handler and formats the MCP response.
    case 'execute_tauri_command': { const result = await executeTauriCommand(driver, args as any); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }
  • TypeScript type definition for the tool's input parameters.
    export interface ExecuteTauriCommandParams { /** Command name to execute */ command: string; /** Arguments to pass to the command */ args?: Record<string, unknown>; }

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/Radek44/mcp-tauri-automation'

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