File size: 4,820 Bytes
d086025
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# Getting Started

Get Victauri running in your Tauri app in under 5 minutes.

## Prerequisites

- A Tauri 2.0+ application
- Rust toolchain (stable)
- An MCP client (Claude Code, VS Code, or any MCP-compatible tool)

## Step 1: Add the Dependency

Add `victauri-plugin` to your app's `src-tauri/Cargo.toml`:

```toml
[dependencies]
victauri-plugin = "0.5"
```

The plugin runs inside your app process. In release builds, `init()` returns a no-op plugin (zero runtime cost) thanks to the `#[cfg(debug_assertions)]` gate — no feature flags needed. The crate still compiles into your binary, so for a zero compiled-footprint release, add it under `[dev-dependencies]` instead and gate your `init()` call with `#[cfg(debug_assertions)]`.

## Step 2: Initialize the Plugin

Add `victauri::init()` to your Tauri builder in `src-tauri/src/main.rs`:

```rust
fn main() {
    tauri::Builder::default()
        .plugin(victauri_plugin::init())
        // ... your other plugins and setup
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}
```

That's it. In debug builds, this starts an MCP server on `127.0.0.1:7373`. In release builds, it's a no-op.

## Step 3: Add Capabilities

Add the `victauri:default` capability to your app's capabilities file. Create or edit `src-tauri/capabilities/default.json`:

```json
{
  "identifier": "default",
  "windows": ["*"],
  "permissions": [
    "core:default",
    "victauri:default"
  ]
}
```

Without this capability, the Tauri permission system silently blocks IPC callbacks and the plugin cannot interact with your webviews.

## Step 4: Connect via MCP

Create a `.mcp.json` file in your project root (`victauri init` writes this for you):

```json
{
  "mcpServers": {
    "victauri": {
      "command": "victauri",
      "args": ["bridge"]
    }
  }
}
```

This connects through the **`victauri bridge`** — a stdio proxy that discovers the running
app's port at connect time, re-discovers it across restarts, and reads the auth token
automatically from the discovery directory. Because the port is resolved dynamically, the
agent always reaches the right app — even after a rebuild, or when several Victauri apps are
running. (Requires the CLI on your `PATH`: `cargo install victauri-cli`.)

### Multiple apps running at once

Pin the bridge to a specific app by its Tauri bundle identifier — `victauri init` bakes this
in automatically when it can read your `tauri.conf.json`:

```json
{
  "mcpServers": {
    "victauri": {
      "command": "victauri",
      "args": ["bridge", "--app", "com.your.app"]
    }
  }
}
```

### Authentication

Auth is **enabled by default** (the token is auto-generated and auto-discovered — the bridge
reads it for you, so no manual header is needed). To pin a fixed token for CI, set it on the
builder with `.auth_token("…")` (or the `VICTAURI_AUTH_TOKEN` env var).

> Connecting with a raw `"url": "http://127.0.0.1:7373/mcp"` also works, but it hardcodes a
> port — if that port is taken (another app, a leftover instance) your agent can silently bind
> the *wrong* app. Prefer the bridge.

## Step 5: Verify It Works

With your app running, check the health endpoint:

```bash
curl http://127.0.0.1:7373/health
# Returns: ok

curl http://127.0.0.1:7373/info
# Returns: {"name":"victauri","port":7373,"protocol":"mcp","version":"0.8.8",...}
```

Or use the Victauri CLI:

```bash
cargo install victauri-cli
victauri check
```

## Optional: Register Commands

To enable command discovery and ghost command detection, annotate your Tauri commands with `#[inspectable]` and register them:

```rust
use victauri_plugin::inspectable;

#[inspectable(description = "Greet a user", intent = "greeting")]
#[tauri::command]
fn greet(name: &str) -> String {
    format!("Hello, {}!", name)
}

fn main() {
    tauri::Builder::default()
        .plugin(victauri_plugin::init())
        .invoke_handler(tauri::generate_handler![greet])
        .setup(|app| {
            victauri_plugin::register_commands!(app, greet__schema());
            Ok(())
        })
        .run(tauri::generate_context!())
        .unwrap();
}
```

## Optional: REST API

All 35 tools are also available via a REST API with no MCP handshake at all:

```bash
# List available tools
curl http://127.0.0.1:7373/api/tools

# Execute a tool directly
curl -X POST http://127.0.0.1:7373/api/tools/eval_js \
  -H "Content-Type: application/json" \
  -d '{"code": "document.title"}'
```

## Next Steps

- [Architecture](./architecture.md) — Understand how Victauri works under the hood
- [Tools Reference](./tools-reference.md) — Complete list of all 35 tools
- [Configuration](./configuration.md) — Customize port, auth, privacy, and more
- [Testing](./testing.md) — Write automated tests with the victauri-test crate