tauri_ipc_get_backend_state
Retrieve backend state information from Tauri applications, including app metadata, Tauri version, and environment details to verify connectivity and gather application information.
Instructions
[Tauri Apps Only] Get Tauri backend state: app metadata, Tauri version, environment. Requires active tauri_driver_session. Use to verify you're connected to a Tauri app and get app info.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| 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 the tool logic by sending an IPC command 'plugin:mcp-bridge|get_backend_state' to the Tauri app via the MCP bridge plugin client.export async function getBackendState(options: { useExistingClient?: boolean; appIdentifier?: string | number; } = {}): Promise<string> { try { const { useExistingClient = false, appIdentifier } = options; if (useExistingClient) { // During session setup, use the already-connected client directly const client = getExistingPluginClient(); if (!client || !client.isConnected()) { throw new Error('No connected client available'); } const response = await client.sendCommand({ command: 'invoke_tauri', args: { command: 'plugin:mcp-bridge|get_backend_state', args: {} }, }); if (!response.success) { throw new Error(response.error || 'Unknown error'); } return JSON.stringify(response.data); } // Normal mode: use executeIPCCommand which validates session const result = await executeIPCCommand({ command: 'plugin:mcp-bridge|get_backend_state', appIdentifier }); const parsed = JSON.parse(result); if (!parsed.success) { throw new Error(parsed.error || 'Unknown error'); } return JSON.stringify(parsed.result); } catch(error: unknown) { const message = error instanceof Error ? error.message : String(error); throw new Error(`Failed to get backend state: ${message}`); } }
- Zod schema for validating the tool's input parameters, specifically the optional appIdentifier.export const GetBackendStateSchema = z.object({ 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:567-585 (registration)Tool registration in the central TOOLS array, defining name, description, category, schema reference, annotations, and thin wrapper handler that parses args and delegates to getBackendState.{ name: 'tauri_ipc_get_backend_state', description: '[Tauri Apps Only] Get Tauri backend state: app metadata, Tauri version, environment. ' + 'Requires active tauri_driver_session. ' + 'Use to verify you\'re connected to a Tauri app and get app info.', category: TOOL_CATEGORIES.IPC_PLUGIN, schema: GetBackendStateSchema, annotations: { title: 'Get Tauri Backend State', readOnlyHint: true, openWorldHint: false, }, handler: async (args) => { const parsed = GetBackendStateSchema.parse(args); return await getBackendState({ appIdentifier: parsed.appIdentifier }); }, },