Skip to main content

Crate tauri_plugin_mcp_bridge

Crate tauri_plugin_mcp_bridge 

Source
Expand description

§Tauri MCP Bridge Plugin

A Tauri plugin that bridges the Model Context Protocol (MCP) with Tauri applications, enabling deep inspection and interaction with Tauri’s IPC layer, backend state, and window management.

§Overview

The MCP Bridge plugin extends MCP servers with direct access to Tauri internals. It provides real-time IPC monitoring, window state inspection, backend state access, and event emission capabilities.

§Features

  • IPC Monitoring: Capture and analyze all Tauri IPC calls with timing information
  • Window Information: Query detailed window state (size, position, focus, visibility)
  • Backend State: Access application backend state and metadata
  • Event Emission: Trigger custom events for testing and automation
  • WebSocket Server: Real-time event streaming on dynamically allocated port

§Usage

Add the plugin to your Tauri application:

use tauri_plugin_mcp_bridge;

fn main() {
    tauri::Builder::default()
        .plugin(tauri_plugin_mcp_bridge::init())
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}

§Architecture

The plugin consists of three main components:

  • Commands Module: Tauri commands for IPC interaction
  • Monitor Module: IPC event capture and storage
  • WebSocket Module: Real-time event streaming server

§Examples

§Start IPC Monitoring

import { invoke } from '@tauri-apps/api/core';

await invoke('plugin:mcp-bridge|start_ipc_monitor');

§Get Window Information

const info = await invoke('plugin:mcp-bridge|get_window_info');
console.log(info); // { width, height, x, y, title, focused, visible }

§Permissions

The plugin’s default permission set enables all commands. Individual permissions can be configured in your capabilities using the autogenerated permission identifiers:

  • allow-capture-native-screenshot / deny-capture-native-screenshot
  • allow-emit-event / deny-emit-event
  • allow-execute-command / deny-execute-command
  • allow-execute-js / deny-execute-js
  • allow-get-backend-state / deny-get-backend-state
  • allow-get-ipc-events / deny-get-ipc-events
  • allow-get-window-info / deny-get-window-info
  • allow-list-windows / deny-list-windows
  • allow-report-ipc-event / deny-report-ipc-event
  • allow-request-script-injection / deny-request-script-injection
  • allow-script-result / deny-script-result
  • allow-start-ipc-monitor / deny-start-ipc-monitor
  • allow-stop-ipc-monitor / deny-stop-ipc-monitor

Re-exports§

pub use config::Builder;
pub use config::Config;

Modules§

commands
Command handlers for the MCP Bridge plugin.
config
Configuration for the MCP Bridge plugin.
discovery
Simple port discovery for multiple Tauri instances.
monitor
IPC monitoring and event capture.
screenshot
script_registry
Script Registry for managing persistent scripts across page navigations.
websocket
WebSocket server for real-time event streaming.

Functions§

init
Initializes the MCP Bridge plugin.
init_with_config
Initializes the MCP Bridge plugin with custom configuration.