browsing 0.1.6

Browser automation: navigate, click, extract, screenshot. Standalone browser control via CDP.
Documentation
//! MCP tool parameter types

use schemars::JsonSchema;
use serde::Deserialize;

#[derive(Debug, Deserialize, JsonSchema)]
pub struct NavigateParams {
    #[schemars(description = "URL to navigate to")]
    pub url: String,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub struct FollowLinkParams {
    #[schemars(description = "Index of link from get_links (0-based)")]
    pub index: Option<u32>,
    #[schemars(description = "Or specify URL directly")]
    pub url: Option<String>,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub struct GetContentParams {
    #[schemars(description = "Max characters to return")]
    pub max_chars: Option<u32>,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub struct SaveContentParams {
    #[schemars(description = "Path to save file")]
    pub path: String,
    #[schemars(description = "Content type: text, or image index from list_content")]
    pub content_type: String,
    #[schemars(description = "For image: index from list_content.images")]
    pub image_index: Option<u32>,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub struct GetImageParams {
    #[schemars(description = "Index from list_content.images (0-based)")]
    pub index: Option<u32>,
}

#[derive(Clone, Debug, Deserialize, JsonSchema)]
pub struct GenerateSitemapParams {
    #[schemars(description = "Starting URL to crawl")]
    pub url: String,
    #[schemars(description = "Maximum pages to crawl")]
    pub max_pages: Option<u32>,
    #[schemars(description = "Maximum link depth from start")]
    pub max_depth: Option<u32>,
    #[schemars(description = "Only follow links within same domain")]
    pub same_domain_only: Option<bool>,
    #[schemars(description = "Chars of content preview per page")]
    pub content_preview_chars: Option<u32>,
    #[schemars(description = "Path to save sitemap JSON file")]
    pub save_path: Option<String>,
    #[schemars(description = "Delay in ms between page navigations")]
    pub delay_ms: Option<u64>,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub struct ScreenshotParams {
    #[schemars(description = "Capture full scrollable page")]
    pub full_page: Option<bool>,
    #[schemars(description = "CSS selector for element (e.g. '.sidebar', '#content', 'a')")]
    pub selector: Option<String>,
    #[schemars(description = "If selector matches multiple elements, use this index")]
    pub element_index: Option<u32>,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub struct ClickParams {
    #[schemars(description = "CSS selector for element to click (e.g. '#submit', 'button.primary')")]
    pub selector: String,
    #[schemars(description = "If selector matches multiple elements, use this index (0-based)")]
    pub element_index: Option<u32>,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub struct InputParams {
    #[schemars(description = "CSS selector for input field")]
    pub selector: String,
    #[schemars(description = "Text to type into the field")]
    pub text: String,
    #[schemars(description = "If selector matches multiple elements, use this index (0-based)")]
    pub element_index: Option<u32>,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub struct SendKeysParams {
    #[schemars(description = "Keys to send: Enter, Escape, Tab, ArrowDown, ArrowUp, etc.")]
    pub keys: String,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub struct ScrollParams {
    #[schemars(description = "Direction: up, down, left, right")]
    pub direction: String,
    #[schemars(description = "Amount to scroll in pixels (default: 3 page heights for up/down)")]
    pub amount: Option<u32>,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub struct WaitParams {
    #[schemars(description = "Fixed seconds to wait (default: 3, max: 30). Only used if no condition specified.")]
    pub seconds: Option<u64>,
    #[schemars(description = "Wait until element matching this CSS selector appears")]
    pub wait_for_element: Option<String>,
    #[schemars(description = "Wait until this text appears on the page")]
    pub wait_for_text: Option<String>,
    #[schemars(description = "Wait until current URL contains this substring")]
    pub wait_for_url: Option<String>,
    #[schemars(description = "Wait until page is stable (no DOM mutations for this many ms)")]
    pub wait_for_stable_ms: Option<u64>,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub struct EvaluateParams {
    #[schemars(description = "JavaScript expression to evaluate on the page")]
    pub expression: String,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub struct DropdownOptionsParams {
    #[schemars(description = "CSS selector for dropdown/select element")]
    pub selector: String,
}

#[derive(Debug, Deserialize, JsonSchema)]
pub struct SelectDropdownParams {
    #[schemars(description = "CSS selector for dropdown/select element")]
    pub selector: String,
    #[schemars(description = "Values to select (for multi-select)")]
    pub values: Vec<String>,
}