launch_app
Launch an application on Linux via shell command, running as a detached process from the server. Execute commands like 'firefox' or 'gnome-terminal'.
Instructions
Launch an application via a shell command (e.g. "firefox", "gnome-terminal", "code /path/to/project"). The process is detached from this server.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| command | Yes |
Implementation Reference
- server.js:333-347 (handler)The launchApp function that executes the tool logic. It validates the 'command' argument as a string, spawns the command via 'sh -c' as a detached child process (stdio ignored), unrefs the child so it can outlive the server, and returns the PID.
function launchApp(args) { if (typeof args.command !== 'string' || !args.command.trim()) { return errorResult('command is required (string)'); } try { const child = spawn('sh', ['-c', args.command], { stdio: 'ignore', detached: true, }); child.unref(); return textResult({ command: args.command, pid: child.pid }); } catch (e) { return errorResult(`launch_app failed: ${e.message}`); } } - server.js:528-537 (schema)Tool registration metadata and input schema for launch_app. Defines name 'launch_app', description, annotations (destructiveHint, openWorldHint), and inputSchema requiring a 'command' string property.
{ name: 'launch_app', description: 'Launch an application via a shell command (e.g. "firefox", "gnome-terminal", "code /path/to/project"). The process is detached from this server.', annotations: { title: 'Launch application', destructiveHint: true, openWorldHint: true }, inputSchema: { type: 'object', properties: { command: { type: 'string' } }, required: ['command'], }, }, - server.js:567-569 (registration)Tool dispatch mapping in HANDLERS object: 'launch_app: launchApp' maps the tool name to the handler function.
launch_app: launchApp, screenshot_text: screenshotText, }; - server.js:585-598 (registration)tools/list endpoint returns the TOOLS array; tools/call dispatches to HANDLERS[name] to invoke the handler function.
if (method === 'tools/list') { respond(id, { tools: TOOLS }); return; } if (method === 'tools/call') { const { name, arguments: args = {} } = params || {}; const handler = HANDLERS[name]; if (!handler) { error(id, -32601, `unknown tool: ${name}`); return; } try { const result = await Promise.resolve(handler(args)); respond(id, result); } catch (e) { log('tool error:', name, e.message, e.stack); respond(id, errorResult(`tool ${name} threw: ${e.message}`)); } return; - server.js:56-62 (helper)Helper utilities used by the handler: requireBin for checking binary availability, textResult and errorResult for building JSON-RPC response objects.
// ─── Helpers ────────────────────────────────────────────────────────────── function requireBin(name) { if (!BIN[name]) { return `Required system tool "${name}" is not installed. Install with: sudo apt install ${name === 'gnomeShot' ? 'gnome-screenshot' : name === 'xclip' ? 'xclip' : name === 'xdotool' ? 'xdotool' : 'wmctrl'}`; } return null; }