Architecture
Victauri embeds a full MCP server inside your running Tauri application. This page explains the design decisions and how the pieces fit together.
The Three Layers
Victauri provides access to three distinct layers of a Tauri application:
┌─────────────────────────────────────────────────┐
│ MCP Client │
│ (Claude Code, VS Code, etc.) │
└─────────────────┬───────────────────────────────┘
│ HTTP/SSE (localhost:7373)
┌─────────────────▼───────────────────────────────┐
│ Victauri Plugin │
│ (axum server + tool handlers) │
├─────────────────┬────────────┬──────────────────┤
│ WebView │ IPC │ Backend │
│ (JS Bridge) │ (Intercept)│ (AppHandle) │
└────────┬────────┴─────┬──────┴────────┬─────────┘
│ │ │
DOM/Events Command Flow Rust State
WebView Layer
The JS bridge is injected into every webview via js_init_script() (persistent across navigations). It provides:
- DOM snapshots — Full accessible tree with ARIA roles, names, and ref handles
- Element interaction — Click, hover, fill, type, press keys with Playwright-grade actionability checks
- JS evaluation — Run arbitrary JavaScript with async/await support
- CSS inspection — Computed styles, bounding boxes with box model
- Console/mutation logs — Captured in-bridge with configurable capacity
- Network interception — Fetch and XMLHttpRequest monitoring
- Navigation tracking — pushState, replaceState, popstate, hashchange
IPC Layer
Tauri 2 has two webview-to-Rust IPC transports (Tauri’s scripts/ipc-protocol.js):
- Custom-protocol
fetch()— the desktop default:http://ipc.localhost/<command>on Windows (WebView2;https://ipc.localhost/<command>for apps withuseHttpsScheme, also on Android),ipc://localhost/<command>on macOS (WKWebView) and Linux (WebKitGTK). The response comes back as the fetch response. window.ipc.postMessage(provided by wry) — used always on Android, and on desktop for the rest of the page’s life after one custom-protocol fetch fails (a blocked scheme, a CSP error, a service worker). Tauri logsIPC custom protocol failed, Tauri will now use the postMessage interface insteadand never goes back to fetch until the page reloads. The response comes back as an eval ofwindow.__TAURI_INTERNALS__.runCallback(id, value).
Victauri captures both into one IPC log. On the fetch transport a route rule can also mock or delay real IPC (see route); such calls are tagged mocked / route_delay_ms and kept out of the evidence-based analyses. postMessage IPC is observe-only:
- fetch path — the fetch interceptor records command, args, status (from the
Tauri-Responseheader), duration and response body. - postMessage path —
window.ipcand every__TAURI_INTERNALS__method are frozen, so this path cannot be wrapped. The bridge observes it at the two points it can reach: the request when Tauri serializes the IPC message (JSON.stringify(message, replacer)right beforewindow.ipc.postMessage), and the response when Tauri delivers it through the callback stored for that call in__TAURI_INTERNALS__.callbacks. Entries carry the same fields plustransport: "post_message". The invoke key in the message is never kept. A fetch attempt that Tauri retried over postMessage counts once (the postMessage entry); the failed fetch stays visible in the network log. Because page script can stage a serialization and a callback without a real call,recording replayskips postMessage-captured calls.
get_diagnostics reports which transport is in use and how complete capture is, as info.ipc_capture (transport: fetch / post_message_fallback / post_message / unknown; capture: full / requests_only / none / unknown), and adds an ipc-postmessage-fallback warning when Tauri has switched. detect_ghost_commands, check_ipc_integrity, and introspect coverage / command_catalog / command_timings carry the same ipc_capture object, so a report built from a partial IPC picture says so. requests_only means the callback table was not reachable, so responses (and outcomes) are unknown; none means the switch was detected but no postMessage traffic could be observed.
What the IPC log does not capture:
- Rust → JS events (
emit/Emitter) — these arrive as evals, not IPC calls. Window lifecycle events and the events you name inVictauriBuilder::listen_eventsare captured separately (introspect event_bus); other app events are not. - Channel messages (
tauri::ipc::Channel) — streamed to a JS callback by eval, or fetched in chunks; only theplugin:__TAURI_CHANNEL__|fetchrequests for large chunks appear, as IPC calls, not the messages themselves. - Isolation-pattern payloads — with
"pattern": { "use": "isolation" }the args are encrypted by the isolation iframe before they are sent, so the command name, status and timing are logged but the args are not readable. - Alternative transports that bypass Tauri’s IPC entirely (tauri-invoke-http, sidecars) — see Compatibility.
Built on that log:
- Command registry — Discover all available commands with metadata
- IPC log — Full history of command invocations with timing
- Ghost command detection — Find frontend-invoked commands not in the registry
- Integrity checking — Detect stale, pending, or errored IPC calls
Backend Layer
Since the plugin runs in the same process, it has direct access to:
- AppHandle — Manage windows, invoke commands, read state
- Memory stats — Real OS process memory (working set, page faults)
- Diagnostics — Plugin uptime, tool invocation counts, configuration
Same-Process Embedded Design
Unlike external automation tools that communicate over DevTools Protocol or WebSocket bridges, Victauri runs inside the application process:
External approach: Victauri approach:
Agent ──HTTP──► Proxy Agent ──HTTP──► Tauri App
│ (contains MCP server)
CDP Direct AppHandle access
│ No extra process hop
Browser No state drift
Benefits:
- No state drift — The MCP server reads the same memory as the application
- No external hop — No IPC hop to an external process. Rust-side tools (registry, memory,
app_state,query_db, window state) answer in well under a millisecond; webview tools (eval_js,dom_snapshot,interact, …) are a JS round trip through the webview, typically ~10-30 ms - Full access — Can read Rust state, invoke commands, access the database directly
- Single dependency — No separate process to manage or keep alive
The JS Bridge
The bridge (window.__VICTAURI__) is injected as an init script so it survives page navigations:
// Available methods on window.__VICTAURI__:
__VICTAURI__.version // Bridge version string
__VICTAURI__.snapshot() // Full DOM tree with refs
__VICTAURI__.getRef(id) // Get element by ref handle
__VICTAURI__.click(ref) // Click with actionability checks
__VICTAURI__.fill(ref, val) // Set input value
__VICTAURI__.type(ref, text) // Type character-by-character
__VICTAURI__.pressKey(key) // Dispatch keyboard event
__VICTAURI__.getConsoleLogs() // Captured console entries
__VICTAURI__.getStyles(ref) // Computed CSS properties
// ... 20+ methods total
Ref Handles
Following Playwright MCP’s pattern, elements are identified by short-lived ref handles rather than CSS selectors:
- Refs are derived from the accessible tree (ARIA roles and names)
- They are short opaque strings like
"k3f9e3": treat them as whole values, never parse them - The first four characters tag the page load, so a ref from before a reload or from another window fails at once and says why
- An element keeps its ref while it stays in the page, through later snapshots and DOM restructuring
This avoids brittle CSS selectors and gives agents a semantic view of the UI.
Actionability Checks
Before interactions (click, fill, type, hover), the bridge performs Playwright-grade checks:
- Element exists in DOM
- Element is visible (not
display:noneorvisibility:hidden) - Element is enabled (not
disabledattribute) - Element has non-zero size
- Element is not covered by another element (hit-test)
- Element does not have
pointer-events:none - Element is in viewport (with auto-scroll)
- Element is attached to DOM
- Element is actionable for the specific operation
Stability is not checked: a click on an element that is mid-animation lands wherever it is at that moment.
Dual Protocol: MCP + REST
Victauri serves both protocols on the same port:
| Endpoint | Protocol | Use Case |
|---|---|---|
/mcp | MCP Streamable HTTP + SSE | AI agents (Claude Code, etc.) |
/api/tools | REST (plain JSON) | Scripts, CI, curl, custom integrations |
/health | GET (no auth) | Health checks, watchdog |
/info | GET | Server metadata |
The REST API uses the same tool dispatch, auth, rate limiting, and privacy enforcement as MCP. It simply removes the MCP handshake overhead (the /mcp transport itself is already sessionless by default). tools/list and resources/list responses to MCP 2026-07-28 peers carry SEP-2549 cache hints (ttlMs, cacheScope: private) so clients can cache the static catalogs.
MCP Resources
Three read-on-demand resources expose live state (the subscribe capability is deliberately not advertised — resources/subscribe is legacy-protocol-only under MCP 2026-07-28, and Victauri has no server-initiated update push; read resources when you need them):
victauri://state— Plugin state (commands registered, events captured, memory, port)victauri://windows— All window states (position, size, visibility, URL)victauri://ipc-log— Recent IPC call history
Port Fallback
If port 7373 is already in use (e.g., another Tauri app running Victauri), the server tries ports 7374 through 7383. If none of them can be bound (on Windows a whole block can be reserved for Hyper-V/WinNAT with nothing listening on it: netsh int ipv4 show excludedportrange protocol=tcp), it listens on a port the OS assigns on 127.0.0.1 and logs a warning. The actual bound port is written to the per-process discovery directory (<root>/<pid>/port, alongside the auth token and metadata.json; <root> is per-user — see Security) for client discovery and cleaned up on shutdown.
Release Safety
The entire plugin is gated:
#![allow(unused)]
fn main() {
pub fn init<R: Runtime>() -> TauriPlugin<R> {
#[cfg(debug_assertions)]
{ /* full MCP server setup */ }
#[cfg(not(debug_assertions))]
{ /* no-op plugin — zero runtime cost */ }
}
}
In release builds:
- No axum server is started
- No JS bridge is injected
- No memory is allocated for event logs
init()is a no-op — zero runtime cost
Note: the crate still compiles into your build. The #[cfg(debug_assertions)]
gate removes the runtime behaviour, not the dependency. To also keep its compiled
code out of release binaries, make victauri-plugin an optional dependency behind a
Cargo feature and gate the .plugin(...) call on that feature. (Not [dev-dependencies]:
those are invisible to the app binary, which would then fail to compile.)