vtcode_core/cli/args/webmcp.rs
1use clap::{Args, Subcommand, ValueHint};
2use std::path::PathBuf;
3
4/// WebMCP bridge command family.
5#[derive(Debug, Clone, Subcommand)]
6pub enum WebmcpCommand {
7 /// Start the standalone WebMCP server.
8 Serve(WebmcpServeArgs),
9 /// Serve MCP over local stdin/stdout without opening a network listener.
10 Stdio {
11 /// Enable coding tasks using existing workspace trust and execution policies.
12 #[arg(long)]
13 companion: bool,
14 },
15 /// Start the server and print a one-time browser pairing code.
16 Pair(WebmcpPairArgs),
17 /// Show configured WebMCP listener status.
18 Status,
19 /// List the safe bridge operations.
20 Tools,
21 /// List configured headless workspace roots.
22 Roots,
23 /// Revoke in-process pairings when used by an embedding runtime.
24 Unpair,
25}
26
27/// Options for the standalone WebMCP server.
28#[derive(Debug, Clone, Args)]
29pub struct WebmcpServeArgs {
30 /// Literal loopback bind host. Remote clients require `--allow-remote` and a TLS-terminating reverse proxy.
31 #[arg(long, value_name = "HOST")]
32 pub host: Option<String>,
33 /// Bind port, or zero for a random available port.
34 #[arg(long, value_name = "PORT")]
35 pub port: Option<u16>,
36 /// Explicit browser origin allowlist. Repeat for multiple origins.
37 #[arg(long = "origin", value_name = "ORIGIN", action = clap::ArgAction::Append)]
38 pub origins: Vec<String>,
39 /// Explicit root exposed by headless mode. One root is supported per bridge.
40 #[arg(long = "allowed-root", value_name = "PATH", value_hint = ValueHint::DirPath, action = clap::ArgAction::Append)]
41 pub allowed_roots: Vec<PathBuf>,
42 /// Enable remote reverse-proxy mode (requires a `wss://` public URL; the listener remains loopback).
43 #[arg(long)]
44 pub allow_remote: bool,
45 /// Public WSS URL advertised for remote pairing.
46 #[arg(long, value_name = "URL")]
47 pub public_url: Option<String>,
48 /// Enable the read-only OpenAI-compatible remote MCP surface.
49 #[arg(long)]
50 pub mcp: bool,
51 /// Enable companion coding tasks on the remote MCP service (one workspace, one active task).
52 #[arg(long, requires = "mcp")]
53 pub companion: bool,
54 /// Canonical external HTTPS URL for the remote MCP `/sse/` endpoint.
55 #[arg(long = "mcp-public-url", value_name = "URL")]
56 pub mcp_public_url: Option<String>,
57 /// External HTTPS OAuth authorization-server URL advertised to MCP clients.
58 #[arg(long = "mcp-authorization-server", value_name = "URL")]
59 pub mcp_authorization_server: Option<String>,
60 /// Environment variable containing the internal bearer token from the proxy.
61 #[arg(long = "mcp-proxy-token-env", value_name = "NAME")]
62 pub mcp_proxy_token_env: Option<String>,
63 /// Optional HTTP(S) URL prefix used for escaped file citation URLs.
64 #[arg(long = "mcp-citation-url-prefix", value_name = "URL")]
65 pub mcp_citation_url_prefix: Option<String>,
66}
67
68/// Options for starting a paired standalone server.
69#[derive(Debug, Clone, Args)]
70pub struct WebmcpPairArgs {
71 /// Browser origin to bind to the one-time pairing code.
72 #[arg(long, value_name = "ORIGIN")]
73 pub origin: String,
74 /// Literal bind host.
75 #[arg(long, value_name = "HOST")]
76 pub host: Option<String>,
77 /// Bind port, or zero for a random available port.
78 #[arg(long, value_name = "PORT")]
79 pub port: Option<u16>,
80 /// Enable remote reverse-proxy mode (requires a `wss://` public URL; the listener remains loopback).
81 #[arg(long)]
82 pub allow_remote: bool,
83 /// Public WSS URL advertised for remote pairing.
84 #[arg(long, value_name = "URL")]
85 pub public_url: Option<String>,
86}