Tauri MCP + OpenCode
Quick workflow
- •Ensure the Tauri app runs with the MCP plugin and socket server enabled.
- •Start the MCP server (stdio transport for OpenCode).
- •Register the MCP server with OpenCode (command + args + env).
- •Use the tools to inspect and control the app.
1) Enable the Tauri plugin and socket server
Add the plugin to your Tauri app and start the socket server. The example below mirrors the upstream docs and is typically gated to dev builds:
rust
#[cfg(debug_assertions)]
{
tauri::Builder::default()
.plugin(tauri_mcp::init_with_config(
tauri_mcp::PluginConfig::new("YOUR_APP_NAME".to_string())
.start_socket_server(true)
// IPC (default) or TCP
.socket_path("/tmp/tauri-mcp.sock")
// .tcp("127.0.0.1", 9999)
))
// ... rest of your builder config
}
Notes:
- •On Windows, the default IPC path resolves to a named pipe like
\\.\pipe\tmp\tauri-mcp.sock. - •If you use TCP, match the host/port in the MCP server env (see below).
2) Build or install the MCP server
Choose one path:
- •
Build from source:
- •
pip install -r requirements.txt - •
python build.py mcp - •MCP server entrypoint:
mcp-server-ts/build/index.js
- •
- •
Use npm without building:
- •
npx -y @delorenj/tauri-mcp-server@latest
- •
3) Register with OpenCode (stdio transport)
OpenCode uses stdio transport for MCP servers. Configure it with either opencode mcp add or your OpenCode config file. Provide env vars if you are not using default IPC.
Example (IPC, default path):
bash
opencode mcp add tauri-mcp -- npx -y @delorenj/tauri-mcp-server@latest
Example (TCP):
bash
opencode mcp add tauri-mcp \ --env TAURI_MCP_CONNECTION_TYPE=tcp \ --env TAURI_MCP_TCP_HOST=127.0.0.1 \ --env TAURI_MCP_TCP_PORT=9999 \ -- npx -y @delorenj/tauri-mcp-server@latest
Example (IPC with custom path):
bash
opencode mcp add tauri-mcp \ --env TAURI_MCP_CONNECTION_TYPE=ipc \ --env TAURI_MCP_IPC_PATH=/tmp/tauri-mcp.sock \ -- npx -y @delorenj/tauri-mcp-server@latest
4) Available tools
Use these tools in OpenCode once the MCP server is connected:
- •
take_screenshot(window_label) - •
get_dom(window_label) - •
execute_js(code, window_label, timeout_ms) - •
manage_window(operation, window_label, x, y, width, height) - •
manage_local_storage(action, key, value, window_label) - •
simulate_text_input(text, delay_ms, initial_delay_ms) - •
simulate_mouse_movement(x, y, relative, click, button) - •
get_element_position(selector_type, selector_value, window_label, should_click) - •
send_text_to_element(selector_type, selector_value, text, window_label, delay_ms)
Notes and guardrails
- •Use
get_domandexecute_jsto inspect and query state before driving UI actions. - •Prefer
get_element_position+simulate_mouse_movementfor precise clicks. - •
send_text_to_elementmay not update React state; fall back toexecute_jsorsimulate_text_inputif needed. - •If screenshots fail, confirm the app name and window label match the Tauri window you want.