### Complete tauri-mcp Server Startup Example Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/configuration.md A comprehensive example demonstrating how to start the tauri-mcp server with custom configuration file, debug logging, app path, host binding, and port. ```bash tauri-mcp \ --config ~/.tauri-mcp.toml \ --log-level debug \ --app-path /path/to/test-app \ serve \ --host 127.0.0.1 \ --port 5000 ``` -------------------------------- ### Start tauri-mcp Server Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/configuration.md Starts the tauri-mcp server using the default configuration. ```bash tauri-mcp serve # Uses: ./tauri-mcp.toml (if exists), localhost:3000, info log level ``` -------------------------------- ### Start tauri-mcp with Auto-Launch App Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/configuration.md Starts the tauri-mcp server and automatically launches a specified application when the server starts. ```bash tauri-mcp --app-path /path/to/my-app serve # App will be launched when server starts ``` -------------------------------- ### Build and Install tauri-mcp from Source Source: https://github.com/dirvine/tauri-mcp/blob/main/README.md Clones the tauri-mcp repository and installs it locally using Cargo. This method is useful for development and testing. ```bash # Clone the repository git clone https://github.com/dirvine/tauri-mcp.git cd tauri-mcp # Build and install cargo install --path . ``` -------------------------------- ### JSON Success Response Example Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/README.md All tool responses are JSON objects. This example shows a successful launch response. ```json { "status": "launched", "process_id": "uuid..." } ``` -------------------------------- ### Create a new InputSimulator instance Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/api-reference/input-simulator.md Instantiates a new InputSimulator. No setup or imports are required beyond having the `InputSimulator` struct available. ```rust let simulator = InputSimulator::new(); ``` -------------------------------- ### Configuration Precedence Example Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/configuration.md Illustrates the order of configuration priority: Defaults < TOML file < Environment variables < Command-line flags. This example shows how environment variables can override TOML file settings. ```bash # Config file has event_streaming = false # But this overrides it: TAURI_MCP_CONFIG=/etc/tauri-mcp.toml tauri-mcp serve # Edit config to have event_streaming = true # Then CLI would override it (if there were a CLI flag) ``` -------------------------------- ### Config File Not Found Warning Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/configuration.md Example output when the specified configuration file does not exist. The server will proceed using default settings. ```text Warning: Config file not found at /path/to/config.toml Using default configuration ``` -------------------------------- ### Start tauri-mcp Server Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/README.md Execute this command to start the tauri-mcp server, which listens for JSON-RPC requests. ```bash tauri-mcp serve ``` -------------------------------- ### ServerConfig Usage Examples Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/types.md Demonstrates how to create and load ServerConfig instances, including using the default configuration, creating a custom configuration, and parsing configuration from a TOML string. ```rust // Default config let config = ServerConfig::default(); ``` ```rust // Custom config let config = ServerConfig { auto_discover: true, session_management: true, event_streaming: true, performance_profiling: false, network_interception: false, }; ``` ```rust // From TOML let config_str = tokio::fs::read_to_string("tauri-mcp.toml").await?; let config: ServerConfig = toml::from_str(&config_str)?; ``` -------------------------------- ### ProcessManager App Lifecycle Example Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/INDEX.md Demonstrates launching an application, retrieving its logs, and stopping it using the ProcessManager. Ensure the ProcessManager is initialized before use. ```rust let mut manager = ProcessManager::new(); let process_id = manager.launch_app("/path/to/app", vec![]).await?; let logs = manager.get_app_logs(&process_id, Some(10)).await?; manager.stop_app(&process_id).await?; ``` -------------------------------- ### Start tauri-mcp with Network Binding Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/configuration.md Starts the tauri-mcp server and binds it to a specific host and port, making it accessible from other machines on the network. ```bash tauri-mcp serve --host 0.0.0.0 --port 8080 # Accessible from any machine on the network ``` -------------------------------- ### Start ChromeDriver Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/api-reference/debug-tools.md Command to start the ChromeDriver server on a specified port. ```bash chromedriver --port=9515 & ``` -------------------------------- ### InputSimulator Keyboard and Mouse Input Example Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/INDEX.md Shows how to send keyboard and mouse inputs to a specific application process using the InputSimulator. Requires a valid process ID. ```rust simulator.send_keyboard_input(&process_id, "cmd+a").await?; simulator.send_mouse_click(&process_id, 400, 300, "left").await?; ``` -------------------------------- ### Install ChromeDriver Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/api-reference/debug-tools.md Instructions for installing ChromeDriver on macOS, Linux, and Windows. ```bash # macOS brew install chromedriver ``` ```bash # Linux apt-get install chromium-chromedriver ``` ```bash # Windows # Download from https://chromedriver.chromium.org/ ``` -------------------------------- ### Example Process ID (UUID) Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/README.md Each launched application is assigned a unique identifier (UUID) used in all subsequent tool calls. ```text 550e8400-e29b-41d4-a716-446655440000 ``` -------------------------------- ### Example JSON for WindowInfo Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/types.md Illustrates the expected JSON format for a WindowInfo object, useful for understanding serialization and deserialization. ```json { "title": "My Tauri App", "x": 100, "y": 200, "width": 1024, "height": 768, "is_visible": true, "is_focused": true } ``` -------------------------------- ### Complete Input Workflow Example Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/api-reference/input-simulator.md Demonstrates a full sequence of input operations including typing text, selecting all, copying, clicking, scrolling, and dragging. Ensure the target application is focused and has the necessary permissions. ```rust use tauri_mcp::tools::input::InputSimulator; let sim = InputSimulator::new(); let pid = "550e8400-e29b-41d4-a716-446655440000"; // Type text into a focused field sim.send_keyboard_input(pid, "Hello, world!").await?; // Select all and copy sim.send_keyboard_input(pid, "cmd+a").await?; sim.send_keyboard_input(pid, "cmd+c").await?; // Click a button sim.send_mouse_click(pid, 640, 480, "left").await?; // Scroll down sim.send_mouse_scroll(pid, 640, 480, -5).await?; // Drag to select sim.send_mouse_drag(pid, 100, 100, 200, 200).await?; ``` -------------------------------- ### Launch Tauri Application Request Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/endpoints.md Use the `launch_app` tool to start a Tauri application. Provide the full path to the executable and optionally include command-line arguments. ```json { "jsonrpc": "2.0", "id": 1, "method": "launch_app", "params": { "app_path": "/path/to/my-tauri-app", "args": ["--debug", "--user-data-dir=/tmp/test"] } } ``` -------------------------------- ### Start tauri-mcp Server with Custom Host and Port Source: https://github.com/dirvine/tauri-mcp/blob/main/README.md Starts the tauri-mcp server, allowing you to specify a custom host and port for network access. ```bash # With custom host and port tauri-mcp serve --host 127.0.0.1 --port 3000 ``` -------------------------------- ### Install tauri-mcp via Cargo Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/configuration.md Installs the tauri-mcp binary to your system's Cargo bin directory. ```bash cargo install tauri-mcp # Installs to ~/.cargo/bin/tauri-mcp ``` -------------------------------- ### TOML Configuration - Development Example Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/configuration.md A TOML configuration suitable for development, enabling all features including event streaming and performance profiling. ```toml auto_discover = true session_management = true event_streaming = true performance_profiling = true network_interception = true ``` -------------------------------- ### Start tauri-mcp Server with Specific Tauri App Source: https://github.com/dirvine/tauri-mcp/blob/main/README.md Launches the tauri-mcp server and associates it with a specific Tauri application path. ```bash # With a specific Tauri app tauri-mcp --app-path ./my-tauri-app ``` -------------------------------- ### Serve MCP Server Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/configuration.md Starts the MCP server. Use flags to specify the host and port. The default host is localhost for security. ```bash tauri-mcp serve ``` ```bash tauri-mcp serve --host 127.0.0.1 --port 3000 ``` -------------------------------- ### Start tauri-mcp with Debug Logging Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/configuration.md Starts the tauri-mcp server with debug logging enabled, either via an environment variable or a command-line flag. ```bash TAURI_MCP_LOG_LEVEL=debug tauri-mcp serve # or tauri-mcp --log-level debug serve ``` -------------------------------- ### tauri-mcp TOML Configuration Example Source: https://github.com/dirvine/tauri-mcp/blob/main/README.md Example configuration file for tauri-mcp using TOML format. Settings control features like auto-discovery, session management, and network interception. ```toml auto_discover = true session_management = true event_streaming = false performance_profiling = false network_interception = false ``` -------------------------------- ### Example Response for get_user_data Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/endpoints.md This is a typical success response when invoking the `get_user_data` command. ```json { "status": "success", "command": "get_user_data", "result": "Command invoked successfully" } ``` -------------------------------- ### TOML Configuration - Production Example Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/configuration.md A TOML configuration optimized for production, disabling features like auto-discovery and performance profiling to minimize overhead. ```toml auto_discover = false session_management = true event_streaming = false performance_profiling = false network_interception = false ``` -------------------------------- ### Launch App JSON-RPC Response Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/README.md This is an example of a successful response from the tauri-mcp server after a 'launch_app' request, including the process ID. ```json { "jsonrpc": "2.0", "id": 1, "result": { "process_id": "550e8400-e29b-41d4-a716-446655440000", "status": "launched" } } ``` -------------------------------- ### Launch Tauri App using MCP Tool Source: https://github.com/dirvine/tauri-mcp/blob/main/README.md Use the `launch_app` MCP tool to start a Tauri application. Specify the application path and any command-line arguments. ```javascript await use_mcp_tool("tauri-mcp", "launch_app", { app_path: "/path/to/tauri-app", args: ["--debug"] }); ``` -------------------------------- ### Endpoints JSON-RPC Launch App Request Example Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/INDEX.md Illustrates a JSON-RPC request to the 'launch_app' method, specifying the application path. This is typically used for inter-process communication. ```json { "jsonrpc": "2.0", "id": 1, "method": "launch_app", "params": { "app_path": "/path/to/app" } } ``` -------------------------------- ### Concurrency Example for Input Simulation Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/api-reference/input-simulator.md Demonstrates how multiple concurrent keyboard input operations are safe. Although the methods are async, they delegate to blocking tasks, and the OS serializes the actual input. ```rust let sim = InputSimulator::new(); let pid = "123"; // These run concurrently but OS processes them sequentially tokio::join!( sim.send_keyboard_input(pid, "a"), sim.send_keyboard_input(pid, "b"), sim.send_keyboard_input(pid, "c") ); // Result: "abc" is typed ``` -------------------------------- ### Start tauri-mcp Standalone Server Source: https://github.com/dirvine/tauri-mcp/blob/main/README.md Launches the tauri-mcp server as a standalone application. Default host and port are used unless specified. ```bash # Start the MCP server tauri-mcp serve ``` -------------------------------- ### Create New ProcessManager Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/api-reference/process-manager.md Initializes a new ProcessManager instance. This is the starting point for managing application processes. ```rust let manager = ProcessManager::new(); ``` -------------------------------- ### Build DXT Node.js Package on macOS/Linux Source: https://github.com/dirvine/tauri-mcp/blob/main/README.md Execute this script to build the Node.js wrapper version of the DXT package. Ensure you have Rust and Node.js 18+ installed, and the 'zip' command is in your PATH. ```bash # Build the Node.js wrapper version (recommended) ./build-dxt-node.sh # The DXT package will be created as tauri-mcp-node-*.dxt ``` -------------------------------- ### Handle ConfigError in Rust Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/errors.md This example demonstrates handling ConfigError during server initialization. If a configuration error occurs, it prints an error message and falls back to default configuration. ```rust match TauriMcpServer::new(config_path).await { Err(TauriMcpError::ConfigError(msg)) => { eprintln!("Config error: {}", msg); eprintln!("Using default configuration"); } Ok(server) => { /* ... */ } // Placeholder for successful server creation Err(e) => eprintln!("Other error: {}", e), } ``` -------------------------------- ### Build DXT Package on Windows Source: https://github.com/dirvine/tauri-mcp/blob/main/README.md Steps to build a DXT package on Windows using PowerShell. This involves building the release binary, organizing files into a package structure, installing Node.js dependencies, and creating the final archive. ```powershell # Create a Windows build script or use WSL # Ensure you have zip.exe available or use PowerShell's Compress-Archive # Build release binary cargo build --release # Create package directory structure mkdir dxt-package-node mkdir dxt-package-node\server # Copy files copy target\release\tauri-mcp.exe dxt-package-node\ copy server\*.* dxt-package-node\server\ copy manifest-node.json dxt-package-node\manifest.json # Install Node dependencies cd dxt-package-node\server npm install --production cd ..\.. # Create DXT archive (using PowerShell) Compress-Archive -Path dxt-package-node\* -DestinationPath tauri-mcp-node.zip Rename-Item tauri-mcp-node.zip tauri-mcp-node-0.1.8.dxt ``` -------------------------------- ### Get Window Information Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/endpoints.md Retrieves detailed information about the application window, including its dimensions, position, visibility, and focus state. Requires the process ID. ```json { "method": "get_window_info", "params": { "process_id": "550e8400-e29b-41d4-a716-446655440000" } } ``` -------------------------------- ### Monitor Application Resources Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/endpoints.md Use this endpoint to get CPU, memory, and disk usage for a specific process. Ensure the process ID is valid. ```json { "method": "monitor_resources", "params": { "process_id": "550e8400-e29b-41d4-a716-446655440000" } } ``` -------------------------------- ### Testing a Tauri App with tauri-mcp Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/README.md Sequence of tauri-mcp commands for testing a Tauri application. This workflow involves starting the server, launching the app, taking screenshots, sending input, and checking logs. ```bash # 1. Start the server tauri-mcp serve # 2. Launch the app # Request: launch_app with app_path # 3. Wait for startup # Sleep 1-2 seconds # 4. Verify with screenshot # Request: take_screenshot # 5. Send input # Request: send_keyboard_input # 6. Check results # Request: get_app_logs # 7. Cleanup # Request: stop_app ``` -------------------------------- ### Get Tauri App Logs Response Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/endpoints.md Example response structure for retrieving application logs. Each log entry is prefixed with `[stdout]` or `[stderr]` to indicate the stream. ```json { "logs": [ "[stdout] App started", "[stdout] Listening on port 3000", "[stderr] Warning: deprecated config option" ] } ``` -------------------------------- ### Build Tauri MCP Project Source: https://github.com/dirvine/tauri-mcp/blob/main/SETUP.md Build the Tauri MCP project. Use `cargo build` for debug builds and `cargo build --release` for release builds. Includes commands for running tests and installing the project locally. ```bash cargo build ``` ```bash cargo build --release ``` ```bash cargo test ``` ```bash cargo install --path . ``` -------------------------------- ### Manual Claude Desktop MCP Configuration Source: https://github.com/dirvine/tauri-mcp/blob/main/README.md Add this JSON configuration to your Claude Desktop settings for manual MCP server setup. Ensure the command points to the Node.js wrapper for tauri-mcp. ```json { "mcpServers": { "tauri-mcp": { "command": "node", "args": ["/path/to/tauri-mcp/server/index.js"], "env": { "TAURI_MCP_LOG_LEVEL": "info" } } } } ``` -------------------------------- ### InputSimulator::new Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/api-reference/input-simulator.md Creates a new InputSimulator instance, ready to simulate input. ```APIDOC ## InputSimulator::new() ### Description Creates a new `InputSimulator` instance. ### Signature ```rust pub fn new() -> Self ``` ### Returns A new `InputSimulator` ready to simulate input. ### Example ```rust let simulator = InputSimulator::new(); ``` ``` -------------------------------- ### Basic Command Invocation with IpcManager Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/api-reference/ipc-manager.md Demonstrates how to initialize the IpcManager, list available IPC handlers for a given process ID, and invoke a specific command with arguments. Ensure you have the necessary imports and a valid process ID. ```rust use tauri_mcp::tools::ipc::IpcManager; use serde_json::json; let ipc_manager = IpcManager::new(); let process_id = "550e8400-e29b-41d4-a716-446655440000"; // List available commands let handlers = ipc_manager.list_ipc_handlers(&process_id).await?; println!("Available commands: {:?}", handlers); // Invoke a command let result = ipc_manager.call_ipc_command( &process_id, "invoke", json!({ "cmd": "fetch_user_profile", "user_id": 42 }) ).await?; println!("Result: {}", result); ``` -------------------------------- ### JSON Error Response Example (JSON-RPC) Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/README.md All tool responses are JSON objects. This example shows a JSON-RPC error response. ```json { "error": { "code": -32602, "message": "Invalid params", "data": "Missing required parameter: app_path" } } ``` -------------------------------- ### Basic Process Management Workflow Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/api-reference/process-manager.md Demonstrates the fundamental workflow of launching an application, checking its logs, monitoring its resources, and then stopping it. Ensure the application path is correct and that the necessary async runtime is available. ```rust use tauri_mcp::tools::process::ProcessManager; let mut manager = ProcessManager::new(); // Launch an app let process_id = manager.launch_app( "/path/to/app", vec![] ).await?; // Let it run... tokio::time::sleep(tokio::time::Duration::from_secs(2)).await; // Check logs let logs = manager.get_app_logs(&process_id, Some(10)).await?; println!("Recent logs: {:?}", logs); // Monitor resources let stats = manager.monitor_resources(&process_id).await?; println!("Stats: {}", serde_json::to_string_pretty(&stats)?); // Stop the app manager.stop_app(&process_id).await?; ``` -------------------------------- ### Testing Input Handling with Keyboard Shortcuts Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/api-reference/input-simulator.md Shows how to simulate keyboard shortcuts for testing application responses, such as opening a find dialog. It includes a delay for the UI to update and suggests verifying the result with a screenshot. Requires a window manager to take screenshots. ```rust // Test that the app responds to keyboard shortcuts sim.send_keyboard_input(pid, "ctrl+f").await?; // Open Find dialog tokio::time::sleep(Duration::from_millis(500)).await; let screenshot = window_manager.take_screenshot(pid, None).await?; // Verify Find dialog appears in screenshot ``` -------------------------------- ### Execute Tool: Launch App Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/configuration.md Executes the 'launch_app' tool. Arguments must be valid JSON, specifying the application path and any arguments for the app. ```bash tauri-mcp tool launch_app '{"app_path": "/path/to/app", "args": []}' ``` -------------------------------- ### Install tauri-mcp using Cargo Source: https://github.com/dirvine/tauri-mcp/blob/main/README.md Installs the tauri-mcp package globally using the Cargo package manager. Suitable for CLI usage, integration with other tools, and development. ```bash cargo install tauri-mcp ``` -------------------------------- ### Managing Multiple Processes Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/api-reference/process-manager.md Illustrates how to launch and manage multiple application processes concurrently. It shows launching two apps, monitoring the resources of all running processes, and then cleaning them up. This is useful for scenarios requiring multiple independent applications to run simultaneously. ```rust let mut manager = ProcessManager::new(); // Launch multiple apps let pid1 = manager.launch_app("/app/app1", vec![]).await?; let pid2 = manager.launch_app("/app/app2", vec![]).await?; // Monitor all let running = manager.get_running_processes(); for pid in running { let stats = manager.monitor_resources(&pid).await?; println!("{}: CPU={}", pid, stats["cpu_usage"]); } // Clean up for pid in manager.get_running_processes() { manager.stop_app(&pid).await?; } ``` -------------------------------- ### Basic Window Manager Operations Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/api-reference/window-manager.md Demonstrates common window management tasks such as retrieving window information, taking screenshots, and manipulating window properties like position, size, and focus. ```rust use tauri_mcp::tools::window::WindowManager; let manager = WindowManager::new(); let process_id = "550e8400-e29b-41d4-a716-446655440000"; // Get window info let info = manager.get_window_info(process_id).await?; println!("Window size: {}x{}", info["width"], info["height"]); // Take a screenshot let screenshot = manager.take_screenshot(process_id, None).await?; println!("Screenshot: {}", screenshot[0..50].to_string() + "..."); // Manipulate window manager.move_window(process_id, 100, 100).await?; manager.resize_window(process_id, 1280, 720).await?; manager.focus_window(process_id).await?; ``` -------------------------------- ### Handle Other Error Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/errors.md Provides a basic example of handling the generic 'Other' error type. This is useful for logging unexpected issues. ```rust match result { Err(TauriMcpError::Other(msg)) => { eprintln!("Unexpected error: {}", msg); } _ => {} } ``` -------------------------------- ### Usage of WindowInfo in Rust Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/types.md Demonstrates how to create a WindowInfo instance and serialize it into a JSON string. Requires the `serde_json` crate. ```rust use tauri_mcp::tools::window::WindowInfo; let window = WindowInfo { title: "Main Window".to_string(), x: 100, y: 100, width: 800, height: 600, is_visible: true, is_focused: true, }; let json = serde_json::to_string(&window)?; println!("Window: {}", json); ``` -------------------------------- ### Invalid Log Level Warning Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/configuration.md Example warning when an invalid log level is specified. The server will default to 'info' and continue running. ```text Warning: Invalid log level 'verbose' - using 'info' ``` -------------------------------- ### Create WindowManager Instance Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/api-reference/window-manager.md Instantiates a new WindowManager. On Linux, this opens a connection to the X11 display server. ```rust let window_manager = WindowManager::new(); ``` -------------------------------- ### Get Running Processes Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/api-reference/process-manager.md Retrieves a list of UUIDs for all currently active processes managed by the system. This is a synchronous method and does not require `await`. ```rust let active_pids = manager.get_running_processes(); for pid in active_pids { println!("Running process: {}", pid); } ``` -------------------------------- ### send_mouse_drag Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/api-reference/input-simulator.md Simulates a mouse drag operation from a starting point to an ending point. This is useful for actions like selecting text or moving files. ```APIDOC ## send_mouse_drag ### Description Simulate a mouse drag operation from one point to another. ### Signature ```rust pub async fn send_mouse_drag( &self, process_id: &str, start_x: i32, start_y: i32, end_x: i32, end_y: i32 ) -> Result<()> ``` ### Parameters #### Path Parameters - **process_id** (`&str`) - Required - UUID of the target process (informational) - **start_x** (`i32`) - Required - Starting X coordinate (pixels) - **start_y** (`i32`) - Required - Starting Y coordinate (pixels) - **end_x** (`i32`) - Required - Ending X coordinate (pixels) - **end_y** (`i32`) - Required - Ending Y coordinate (pixels) ### Returns `Result<()>` ### Error Conditions - Failed to create Enigo instance - Failed to move mouse or press/release button - Task spawn failed ### Behavior 1. Moves mouse to the starting position 2. Waits 50ms 3. Presses the left mouse button 4. Waits 50ms 5. Moves the mouse in 10 steps to the ending position with 20ms delays between steps 6. Releases the left mouse button 7. All operations are performed in a spawned blocking task ### Notes - The drag operation uses 10 intermediate steps for smooth animation - Total time for a drag is approximately 200-300ms plus OS processing - Only the left mouse button is supported for dragging ### Example ```rust // Drag from (100, 100) to (500, 400) simulator.send_mouse_drag(&process_id, 100, 100, 500, 400).await?; ``` ``` -------------------------------- ### Create tauri-mcp Configuration File Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/configuration.md Creates a TOML configuration file for tauri-mcp with specific settings. ```bash cat > tauri-mcp.toml << 'EOF' auto_discover = true session_management = true event_streaming = false performance_profiling = false network_interception = false EOF ``` -------------------------------- ### InputSimulator Methods Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/README.md Simulates keyboard and mouse input using the enigo library for interacting with the application. ```APIDOC ## InputSimulator ### Description Simulates keyboard and mouse input via the enigo library. ### Key Methods - `send_keyboard_input()`: Simulates keyboard input. - `send_mouse_click()`: Simulates mouse clicks. - `send_mouse_move()`: Simulates mouse movement. - `send_mouse_drag()`: Simulates mouse dragging. - `send_mouse_scroll()`: Simulates mouse scrolling. ``` -------------------------------- ### Get Page Source Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/api-reference/debug-tools.md Retrieves the HTML source of the webview for a given process ID. Requires an active WebDriver session to be established first. ```rust debug_tools.connect_webdriver(&process_id, 9222).await?; let html = debug_tools.get_page_source(&process_id).await?; println!("Page length: {} bytes", html.len()); ``` -------------------------------- ### Invoke Command with Multiple Parameters Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/endpoints.md Demonstrates invoking a backend function with multiple parameters using the `invoke` command. The `args` object should contain the `cmd` and any other required parameters. ```json { "method": "call_ipc_command", "params": { "process_id": "550e8400-e29b-41d4-a716-446655440000", "command_name": "invoke", "args": { "cmd": "my_backend_function", "param1": "value1", "param2": 42 } } } ``` -------------------------------- ### Invalid TOML Syntax Error Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/configuration.md Example error message when the configuration file contains invalid TOML syntax. The server will exit with an error code. ```text Error: Configuration error: expected type `boolean` for key `auto_discover` at line 2 ``` -------------------------------- ### Rust ProcessError Handling Example Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/errors.md Demonstrates how to match and handle `ProcessError` within a `TauriMcpError` result. This is useful for implementing retry logic or user feedback. ```rust match result { Err(TauriMcpError::ProcessError(msg)) => { eprintln!("Failed to manage process: {}", msg); // Retry with different app path or check system state } _ => {} } ``` -------------------------------- ### IpcManager::new Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/api-reference/ipc-manager.md Creates a new IpcManager instance with an empty command handler registry. ```APIDOC ## IpcManager::new() ### Description Creates a new `IpcManager` instance with an empty command handler registry. ### Signature ```rust pub fn new() -> Self ``` ### Returns A new `IpcManager` ready to interact with Tauri applications. ### Example ```rust let ipc_manager = IpcManager::new(); ``` ``` -------------------------------- ### Launch Tauri App Server Source: https://github.com/dirvine/tauri-mcp/blob/main/README.md Use this command to launch the tauri-mcp server for testing. This is the initial step before running automated tests. ```bash # Launch the server tauri-mcp serve ``` -------------------------------- ### focus_window Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/api-reference/window-manager.md Bring the application window to the foreground and give it keyboard focus. ```APIDOC ## focus_window ### Description Bring the application window to the foreground and give it keyboard focus. ### Method Not applicable (SDK method) ### Parameters #### Path Parameters - **process_id** (string) - Required - UUID of the process ### Example ```rust window_manager.focus_window(&process_id).await?; ``` ``` -------------------------------- ### Rust ScreenshotError Handling Example Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/errors.md Shows how to handle `ScreenshotError` by printing an error message and checking for specific conditions like 'No screens' or 'permission' issues. ```rust match result { Err(TauriMcpError::ScreenshotError(msg)) => { eprintln!("Screenshot failed: {}", msg); if msg.contains("No screens") { // No display available } else if msg.contains("permission") { // Grant permissions on macOS } } _ => {} } ``` -------------------------------- ### Initialize Protocol Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/endpoints.md Use this JSON-RPC request to initialize the connection before making tool calls. Supported protocol versions include '1.0' and date-based versions. ```json { "jsonrpc": "2.0", "id": 1, "method": "initialize", "params": { "protocolVersion": "1.0", "capabilities": {} } } ``` -------------------------------- ### Get Window Information (Rust) Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/api-reference/window-manager.md Retrieves window dimensions, position, and state for a given process ID. Note that current implementations return placeholder values. ```rust pub async fn get_window_info(&self, process_id: &str) -> Result ``` ```json { "title": "Tauri App", "x": 100, "y": 100, "width": 800, "height": 600, "is_visible": true, "is_focused": false, "platform": "macos|windows|linux" } ``` ```rust #[cfg(target_os = "macos")] async fn get_window_info_macos(&self, process_id: &str) -> Result { Ok(json!({ "title": "Tauri App", "x": 100, "y": 100, "width": 800, "height": 600, "is_visible": true, "is_focused": false, "platform": "macos" })) } ``` ```rust let info = window_manager.get_window_info(&process_id).await?; println!("Window: {} ({}x{})", info["title"], info["width"], info["height"] ); ``` -------------------------------- ### Get Debugging Information Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/api-reference/debug-tools.md Retrieves DevTools information, including the debugging URL, and fetches console logs. Requires connecting to WebDriver first to access console logs. ```rust // Get DevTools info let info = debug_tools.get_devtools_info(&process_id).await?; println!("DevTools available at: {}", info["devtools_url"]); // Get console output debug_tools.connect_webdriver(&process_id, 9222).await?; let logs = debug_tools.get_console_logs(&process_id).await?; for log in logs { println!("[{}] {}", log["level"], log["message"]); } ``` -------------------------------- ### Create New DebugTools Instance Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/api-reference/debug-tools.md Instantiates a new DebugTools object. This is the starting point for all other DebugTools operations. It configures an HTTP client with a default 30-second timeout for DevTools communication. ```rust let debug_tools = DebugTools::new(); ``` -------------------------------- ### TOML Configuration - Feature Flags Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/configuration.md Configure tauri-mcp features using TOML format. This example shows common feature flags like auto-discovery, session management, and event streaming. ```toml # Feature flags auto_discover = true session_management = true event_streaming = false performance_profiling = false network_interception = false ``` -------------------------------- ### TOML Configuration - Minimal Defaults Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/configuration.md An empty TOML file or omitting the `tauri-mcp.toml` file entirely will result in using all default configuration values. ```toml # Empty file or omit tauri-mcp.toml entirely ``` -------------------------------- ### Launch App Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/README.md Launches a specified application and returns its process ID. ```APIDOC ## Launch App ### Description Launches an application using the provided path and returns the process ID and status. ### Method `launch_app` ### Parameters #### Request Body - **app_path** (string) - Required - The absolute path to the application executable. ### Request Example ```json { "jsonrpc": "2.0", "id": 1, "method": "launch_app", "params": { "app_path": "/path/to/my-app" } } ``` ### Response #### Success Response (200) - **process_id** (string) - The unique identifier for the launched process. - **status** (string) - The status of the launch operation (e.g., "launched"). #### Response Example ```json { "jsonrpc": "2.0", "id": 1, "result": { "process_id": "550e8400-e29b-41d4-a716-446655440000", "status": "launched" } } ``` ``` -------------------------------- ### Tauri MCP Project Structure Source: https://github.com/dirvine/tauri-mcp/blob/main/README.md Overview of the directory layout for the Tauri MCP project. Key directories include 'src' for source code, 'examples' for sample applications, and 'tests' for integration tests. ```plaintext tauri-mcp/ ├── src/ │ ├── main.rs # Entry point │ ├── server.rs # MCP server implementation │ ├── tools/ # Tool implementations │ │ ├── process.rs # Process management │ │ ├── window.rs # Window manipulation │ │ ├── input.rs # Input simulation │ │ ├── debug.rs # Debugging tools │ │ └── ipc.rs # IPC interaction │ └── utils/ # Utility modules ├── examples/ # Example Tauri apps └── tests/ # Integration tests ``` -------------------------------- ### WindowManager::new Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/api-reference/window-manager.md Creates a new WindowManager instance. This is used to initialize the window management capabilities. ```APIDOC ## WindowManager::new ### Description Creates a new `WindowManager` instance. ### Signature ```rust pub fn new() -> Self ``` ### Platform-Specific Behavior - **Linux**: Opens a connection to the X11 display server via `xlib::XOpenDisplay`. Panics if the display cannot be opened. - **macOS & Windows**: Initializes an empty struct; no external connections needed. ### Example ```rust let window_manager = WindowManager::new(); ``` ``` -------------------------------- ### InputSimulator API Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/INDEX.md Simulate keyboard and mouse inputs for automating user interactions. ```APIDOC ## InputSimulator API ### Description Provides methods for simulating keyboard and mouse inputs. ### Methods - `send_keyboard_input()`: Type text and send key combinations. - `send_mouse_click()`: Click at screen coordinates. - `send_mouse_move()`: Move the mouse cursor. - `send_mouse_drag()`: Drag the mouse. - `send_mouse_scroll()`: Scroll the mouse wheel. ``` -------------------------------- ### Get Tauri App Logs Request Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/endpoints.md Retrieve stdout and stderr logs from a running Tauri application. Specify the `process_id` and optionally the number of recent `lines` to fetch. Logs are captured in real-time. ```json { "method": "get_app_logs", "params": { "process_id": "550e8400-e29b-41d4-a716-446655440000", "lines": 50 } } ``` -------------------------------- ### Get Console Logs Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/api-reference/debug-tools.md Retrieves console logs from the browser for a specified process ID. Requires an active WebDriver session. The response is an array of log entries, each with level, message, source, and timestamp. ```rust let logs = debug_tools.get_console_logs(&process_id).await?; for log in logs { println!("[{}] {}", log["level"], log["message"]); } ``` ```json [ { "level": "INFO", "message": "App initialized", "source": "console-api", "timestamp": 1640000000000 }, { "level": "WARNING", "message": "Deprecation warning", "source": "console-api", "timestamp": 1640000001000 } ] ``` -------------------------------- ### Platform-Specific Details Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/api-reference/window-manager.md Details on how window management is implemented across different operating systems. ```APIDOC ## Platform-Specific Details ### macOS - Uses `cocoa` crate for native APIs - `focus_window` uses Objective-C message passing to activate the app - X11 display code is not compiled on macOS - Screenshot functionality via the universal `screenshots` crate ### Windows - Uses `windows` crate for Win32 APIs - Window manipulation functions are placeholders (not yet fully implemented) - `GetWindowRect`, `GetWindowText` APIs are available for future implementation - Screenshot functionality via the universal `screenshots` crate ### Linux (X11) - Uses `x11` and `xcb` crates for X11 protocol - Maintains an X11 display connection in `WindowManager.display` - Window manipulation functions are placeholders - Screenshot functionality via the universal `screenshots` crate - Panics if X11 display cannot be opened at initialization ``` -------------------------------- ### ProcessManager::launch_app Source: https://github.com/dirvine/tauri-mcp/blob/main/_autodocs/api-reference/process-manager.md Spawns and launches a Tauri application, returning a unique identifier for the process session. ```APIDOC ## launch_app ### Description Spawn and launch a Tauri application. This method configures piped stdout and stderr, spawns the process, and starts a background task to read log output. ### Signature ```rust pub async fn launch_app(&mut self, app_path: &str, args: Vec) -> Result ``` ### Parameters #### Path Parameters - **app_path** (`&str`) - Required - Absolute or relative path to the Tauri application executable - **args** (`Vec`) - Required - Command-line arguments to pass to the application ### Returns `Result` - On success: A UUID string identifying this process session - On error: `TauriMcpError::ProcessError` if the app path doesn't exist or spawn fails ### Error Conditions - App path does not exist on the filesystem - Application binary is not executable - Process spawn failed (insufficient permissions, system resources exhausted, etc.) - Failed to obtain the process ID from the child process handle - Failed to set up stdout/stderr capture ### Behavior 1. Validates that `app_path` points to an existing file 2. Creates a `tokio::process::Command` with the app path and arguments 3. Configures piped stdout and stderr 4. Spawns the process 5. Starts a background task to read and buffer log output from both streams 6. Stores the process info in the internal HashMap with a UUID key 7. Logs the launch event with tracing at INFO level ### Example ```rust let mut manager = ProcessManager::new(); let process_id = manager.launch_app( "/path/to/my-app", vec!["--debug".to_string(), "--profile=test".to_string()] ).await?; println!("Process ID: {}", process_id); ``` ```