tauri_ipc_execute_command
Execute Tauri IPC commands to invoke Rust backend functions from Tauri applications, enabling communication between frontend and backend components.
Instructions
[Tauri Apps Only] Execute Tauri IPC commands (invoke Rust backend functions). Requires active tauri_driver_session. This is Tauri-specific IPC, not browser APIs. For Electron IPC or browser APIs, use appropriate tools for those frameworks.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| command | Yes | ||
| args | No | ||
| appIdentifier | No | App port or bundle ID to target. Defaults to the only connected app or the default app if multiple are connected. |
Implementation Reference
- Core handler function that executes Tauri IPC commands by connecting to the plugin client via WebSocket and invoking the specified command with arguments.export async function executeIPCCommand(options: { command: string; args?: unknown; appIdentifier?: string | number; }): Promise<string> { try { const { command, args = {}, appIdentifier } = options; // Ensure we have an active session and are connected const client = await ensureSessionAndConnect(appIdentifier); // Send IPC command via WebSocket to the mcp-bridge plugin const response = await client.sendCommand({ command: 'invoke_tauri', args: { command, args }, }); if (!response.success) { return JSON.stringify({ success: false, error: response.error || 'Unknown error' }); } return JSON.stringify({ success: true, result: response.data }); } catch(error: unknown) { const message = error instanceof Error ? error.message : String(error); return JSON.stringify({ success: false, error: message }); } }
- Zod schema defining the input parameters for the tool: command (string), optional args (unknown), and optional appIdentifier (string or number).export const ExecuteIPCCommandSchema = z.object({ command: z.string(), args: z.unknown().optional(), appIdentifier: z.union([ z.string(), z.number() ]).optional().describe( 'App port or bundle ID to target. Defaults to the only connected app or the default app if multiple are connected.' ), });
- packages/mcp-server/src/tools-registry.ts:479-502 (registration)Tool definition and registration in the central TOOLS registry array, with inline handler that validates inputs and delegates to executeIPCCommand.{ name: 'tauri_ipc_execute_command', description: '[Tauri Apps Only] Execute Tauri IPC commands (invoke Rust backend functions). ' + 'Requires active tauri_driver_session. This is Tauri-specific IPC, not browser APIs. ' + 'For Electron IPC or browser APIs, use appropriate tools for those frameworks.', category: TOOL_CATEGORIES.IPC_PLUGIN, schema: ExecuteIPCCommandSchema, annotations: { title: 'Execute Tauri IPC Command', readOnlyHint: false, destructiveHint: false, openWorldHint: false, }, handler: async (args) => { const parsed = ExecuteIPCCommandSchema.parse(args); return await executeIPCCommand({ command: parsed.command, args: parsed.args, appIdentifier: parsed.appIdentifier, }); }, },