Skip to main content
Glama
Radek44

MCP Tauri Automation

by Radek44

launch_app

Launch Tauri desktop applications for automated testing and interaction by specifying the application binary path and optional arguments or environment variables.

Instructions

Launch a Tauri application via tauri-driver. The tauri-driver must be running on the configured port (default: 4444).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
appPathYesPath to the Tauri application binary
argsNoOptional command-line arguments to pass to the application
envNoOptional environment variables to set for the application

Implementation Reference

  • The primary handler function for the 'launch_app' MCP tool. It calls the underlying TauriDriver.launchApp, retrieves the app state, and formats the response as a ToolResponse.
    export async function launchApp(
      driver: TauriDriver,
      params: LaunchAppParams
    ): Promise<ToolResponse<{ message: string; sessionId?: string }>> {
      try {
        await driver.launchApp(params);
        const state = driver.getAppState();
    
        return {
          success: true,
          data: {
            message: `Application launched successfully: ${params.appPath}`,
            sessionId: state.sessionId,
          },
        };
      } catch (error) {
        return {
          success: false,
          error: error instanceof Error ? error.message : String(error),
        };
      }
    }
  • Type definition for the input parameters of the launch_app tool.
    export interface LaunchAppParams {
      /** Path to the Tauri application binary */
      appPath: string;
      /** Optional additional arguments to pass to the app */
      args?: string[];
      /** Optional environment variables */
      env?: Record<string, string>;
    }
  • src/index.ts:53-75 (registration)
    Registration of the 'launch_app' tool in the MCP server's listTools response, including name, description, and input schema.
      name: 'launch_app',
      description: 'Launch a Tauri application via tauri-driver. The tauri-driver must be running on the configured port (default: 4444).',
      inputSchema: {
        type: 'object',
        properties: {
          appPath: {
            type: 'string',
            description: 'Path to the Tauri application binary',
          },
          args: {
            type: 'array',
            items: { type: 'string' },
            description: 'Optional command-line arguments to pass to the application',
          },
          env: {
            type: 'object',
            additionalProperties: { type: 'string' },
            description: 'Optional environment variables to set for the application',
          },
        },
        required: ['appPath'],
      },
    },
  • src/index.ts:208-218 (registration)
    The switch case in the CallToolRequestHandler that invokes the launchApp handler function for 'launch_app' calls.
    case 'launch_app': {
      const result = await launchApp(driver, args as any);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2),
          },
        ],
      };
    }
  • Core implementation in TauriDriver class that performs the actual application launch using WebDriver remote connection to tauri-driver.
    async launchApp(params: LaunchAppParams): Promise<void> {
      if (this.appState.isRunning) {
        throw new Error('Application is already running. Close it first.');
      }
    
      const appPath = params.appPath || this.config.appPath;
      if (!appPath) {
        throw new Error('Application path is required');
      }
    
      try {
        // Ensure screenshot directory exists
        await fs.mkdir(this.config.screenshotDir, { recursive: true });
    
        // Connect to tauri-driver via WebDriver
        const browser = await remote({
          capabilities: {
            'tauri:options': {
              application: appPath,
              args: params.args || [],
              env: params.env || {},
            },
          } as any,
          logLevel: 'error',
          port: this.config.webdriverPort,
        });
    
        this.appState.browser = browser;
        this.appState.isRunning = true;
        this.appState.appPath = appPath;
        this.appState.sessionId = browser.sessionId;
    
        // Set default timeout
        await browser.setTimeout({
          implicit: this.config.defaultTimeout,
        });
      } catch (error) {
        this.appState.isRunning = false;
        this.appState.browser = null;
        throw new Error(`Failed to launch application: ${error instanceof Error ? error.message : String(error)}`);
      }
    }

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