#[cfg(feature = "mcp")]
use stygian_browser::mcp::{McpBrowserServer, is_mcp_enabled};
#[cfg(feature = "mcp")]
use stygian_browser::{BrowserConfig, BrowserPool};
#[cfg(not(feature = "mcp"))]
fn main() {
eprintln!("This example requires the `mcp` feature.");
eprintln!("Run with: cargo run --example mcp_server -p stygian-browser --features mcp");
std::process::exit(1);
}
#[cfg(feature = "mcp")]
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
tracing_subscriber::fmt()
.with_writer(std::io::stderr)
.with_env_filter(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info")),
)
.init();
if !is_mcp_enabled() {
eprintln!("MCP server is disabled. Set STYGIAN_MCP_ENABLED=true to enable.");
std::process::exit(1);
}
tracing::info!("Starting stygian-browser MCP server");
let pool = BrowserPool::new(BrowserConfig::default()).await?;
let server = McpBrowserServer::new(pool);
server.run().await?;
Ok(())
}