Skip to main content

VictauriBuilder

Struct VictauriBuilder 

Source
pub struct VictauriBuilder { /* private fields */ }
Expand description

Builder for configuring the Victauri plugin before adding it to a Tauri app.

Supports port selection, authentication, privacy controls, output redaction, and capacity tuning. All settings have sensible defaults and can be overridden via environment variables.

Authentication is enabled by default. If no explicit token is set and no VICTAURI_AUTH_TOKEN env var exists, a random UUID token is auto-generated and printed to the log. Call auth_disabled() to explicitly opt out of authentication.

Implementations§

Source§

impl VictauriBuilder

Source

pub fn new() -> Self

Create a new builder with default settings.

Source

pub fn port(self, port: u16) -> Self

Set the TCP port for the MCP server (default: 7373, env: VICTAURI_PORT).

Source

pub fn event_capacity(self, capacity: usize) -> Self

Set the maximum number of events in the ring-buffer log (default: 10,000).

Source

pub fn recorder_capacity(self, capacity: usize) -> Self

Set the maximum events kept during session recording (default: 50,000).

Source

pub fn eval_timeout(self, timeout: Duration) -> Self

Set the timeout for JavaScript eval operations (default: 30s, env: VICTAURI_EVAL_TIMEOUT).

Source

pub fn auth_token(self, token: impl Into<String>) -> Self

Set an explicit auth token for the MCP server (env: VICTAURI_AUTH_TOKEN).

Source

pub fn generate_auth_token(self) -> Self

Generate a random UUID v4 auth token.

Source

pub fn auth_disabled(self) -> Self

Explicitly disable authentication. By default, Victauri auto-generates a token if none is provided. Call this method to opt out of auth entirely.

Warning: Without authentication, any process on localhost can access the MCP server. Only use this in trusted environments.

Source

pub fn disable_tools(self, tools: &[&str]) -> Self

Disable specific MCP tools by name (e.g., ["eval_js", "screenshot"]).

Source

pub fn command_allowlist(self, commands: &[&str]) -> Self

Only allow these Tauri commands to be invoked via MCP (positive allowlist).

Source

pub fn command_blocklist(self, commands: &[&str]) -> Self

Block specific Tauri commands from being invoked via MCP.

Source

pub fn add_redaction_pattern(self, pattern: impl Into<String>) -> Self

Add a regex pattern for output redaction (e.g., r"SECRET_\w+").

Source

pub fn enable_redaction(self) -> Self

Enable output redaction with built-in patterns (API keys, emails, tokens).

Source

pub fn strict_privacy_mode(self) -> Self

Enable strict privacy mode (equivalent to PrivacyProfile::Observe).

Disables all mutation tools (eval_js, screenshot, interactions, input, storage writes, navigation, CSS injection) and enables output redaction.

Prefer privacy_profile() for finer control.

Source

pub fn privacy_profile(self, profile: PrivacyProfile) -> Self

Set the privacy profile tier.

  • Observe — read-only (snapshots, logs, registry)
  • Test — observe + interactions + input + storage writes + recording
  • FullControl — everything (default)

Profiles automatically enable redaction for Observe and Test. Use disable_tools() to apply overrides on top of a profile.

Source

pub fn console_log_capacity(self, capacity: usize) -> Self

Set the maximum console log entries kept in the JS bridge (default: 1000).

Source

pub fn network_log_capacity(self, capacity: usize) -> Self

Set the maximum network log entries kept in the JS bridge (default: 1000).

Source

pub fn navigation_log_capacity(self, capacity: usize) -> Self

Set the maximum navigation log entries kept in the JS bridge (default: 200).

Source

pub fn commands(self, schemas: &[CommandInfo]) -> Self

Pre-register command schemas so get_registry, resolve_command, and detect_ghost_commands return real results from the moment the server starts.

Pass the __schema() functions generated by #[inspectable].

VictauriBuilder::new()
    .commands(&[
        greet__schema(),
        increment__schema(),
        add_todo__schema(),
    ])
    .build()
Source

pub fn auto_discover(self) -> Self

Auto-discover all #[inspectable] commands in the binary.

Uses inventory to collect every command marked with #[inspectable] at link time — no manual listing required. This replaces both .commands(&[...]) and register_commands!().

tauri::Builder::default()
    .plugin(
        VictauriBuilder::new()
            .auto_discover()
            .build()
            .unwrap(),
    )
Source

pub fn allow_file_navigation(self) -> Self

Allow file: URLs in the navigate tool’s go_to action.

By default, only http and https schemes are permitted. Calling this method opts in to file: navigation, which grants the MCP client access to local filesystem paths via the webview.

Warning: Enabling this in untrusted environments exposes local files to any process that can reach the MCP server.

Source

pub fn on_ready(self, f: impl FnOnce(u16) + Send + 'static) -> Self

Register a callback invoked once the MCP server is listening. The callback receives the port number.

Source

pub fn build<R: Runtime>(self) -> Result<TauriPlugin<R>, BuilderError>

Consume the builder and produce a Tauri plugin.

In release builds this always succeeds. In debug builds the builder configuration is validated first.

§Errors

Returns BuilderError if the port, event capacity, recorder capacity, or eval timeout are outside their valid ranges (debug builds only).

Trait Implementations§

Source§

impl Default for VictauriBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,