Skip to main content

victauri_plugin/mcp/
webview_params.rs

1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3use std::fmt;
4
5/// Parameters for the `eval_js` tool.
6#[derive(Debug, Deserialize, JsonSchema)]
7pub struct EvalJsParams {
8    /// JavaScript code to evaluate in the webview. Async expressions supported.
9    pub code: String,
10    /// Target webview label. If omitted, targets the first available webview.
11    pub webview_label: Option<String>,
12}
13
14/// Output format for DOM snapshots.
15#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
16#[serde(rename_all = "snake_case")]
17pub enum SnapshotFormat {
18    /// Compact accessible text — 70-80% fewer tokens than JSON.
19    Compact,
20    /// Full JSON tree with all element attributes.
21    Json,
22}
23
24impl fmt::Display for SnapshotFormat {
25    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
26        match self {
27            Self::Compact => f.write_str("compact"),
28            Self::Json => f.write_str("json"),
29        }
30    }
31}
32
33/// Parameters for the `snapshot` tool.
34#[derive(Debug, Deserialize, JsonSchema)]
35pub struct SnapshotParams {
36    /// Target webview label. If omitted, targets the first available webview.
37    pub webview_label: Option<String>,
38    /// Snapshot format: "compact" (default, accessible text) or "json" (full tree). Compact uses 70-80% fewer tokens.
39    pub format: Option<SnapshotFormat>,
40}