stop_app
Stop a running Tauri desktop application to manage app lifecycle or end testing sessions. This tool enables automated app control without CDP dependencies.
Instructions
Stop app
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- Tool schema definition for stop_app with name, description, and empty input schemastop_app: { name: 'stop_app', description: 'Stop app', inputSchema: z.object({}), },
- Tool handler that calls tauriManager.stop() and returns the result as JSONstop_app: async () => { const result = await tauriManager.stop(); return { content: [ { type: 'text' as const, text: JSON.stringify(result, null, 2), }, ], }; },
- Core implementation of stop() method that terminates the Tauri app process, cleans up sockets, and handles platform-specific process terminationasync stop(): Promise<{ message: string }> { // Clean up socket file (Unix only) if (process.platform !== 'win32') { const socketPath = this.getSocketPath(); if (fs.existsSync(socketPath)) { try { fs.unlinkSync(socketPath); } catch (e) { // Ignore } } } if (!this.process) { return { message: 'App was not running' }; } return new Promise((resolve) => { const proc = this.process!; proc.on('exit', () => { this.process = null; this.status = 'not_running'; this.detectedPipePath = null; this.detectedUnixSocketPath = null; resolve({ message: 'App stopped' }); }); // Send SIGTERM if (process.platform !== 'win32') { // Kill process group on Unix try { process.kill(-proc.pid!, 'SIGTERM'); } catch (e) { proc.kill('SIGTERM'); } } else { // On Windows, kill the app binary first, then the process tree // This ensures the actual Tauri app is terminated even if process tree fails this.cleanupOrphanProcesses(); if (proc.pid) { spawn('taskkill', ['/PID', proc.pid.toString(), '/T', '/F'], { stdio: 'ignore', shell: true, }); } proc.kill('SIGTERM'); } // Force kill after 5 seconds setTimeout(() => { if (this.process === proc) { proc.kill('SIGKILL'); this.cleanupOrphanProcesses(); this.process = null; this.status = 'not_running'; this.detectedPipePath = null; this.detectedUnixSocketPath = null; resolve({ message: 'App force stopped' }); } }, 5000); }); }
- packages/tauri-mcp/src/server.ts:14-23 (registration)Tool registration - stop_app is included in the DEFAULT_ESSENTIAL_TOOLS arrayconst DEFAULT_ESSENTIAL_TOOLS = [ 'app_status', 'launch_app', 'stop_app', 'snapshot', 'click', 'fill', 'screenshot', 'navigate', ];
- Helper method cleanupOrphanProcesses() that handles killing orphaned Tauri app processes by binary name on both Unix and Windowsprivate cleanupOrphanProcesses(): void { if (!this.appConfig) return; if (process.platform === 'win32') { // On Windows, try to kill by binary name try { spawn('taskkill', ['/IM', `${this.appConfig.binaryName}.exe`, '/F'], { stdio: 'ignore', shell: true, }); } catch (e) { // Ignore errors } } else { try { // Kill by binary name spawn('pkill', ['-9', this.appConfig.binaryName], { stdio: 'ignore' }); // Kill tauri dev processes for this directory const pattern = `tauri dev.*${this.appConfig.appDir.replace(/\//g, '\\/')}`; spawn('pkill', ['-9', '-f', pattern], { stdio: 'ignore' }); } catch (e) { // Ignore errors } } }