feat(mcp): add --host flag for MCP HTTP transport bind address (#254)

Add a --host CLI flag to 'obscura mcp --http' so the server can bind to
addresses other than 127.0.0.1 (e.g. 0.0.0.0 for Docker Compose sidecar
deployments). The default remains 127.0.0.1 for security.

Closes #253
This commit is contained in:
Ben Younes authored and GitHub committed 2026-06-06 18:17:46 +02:00
1 parent 94bd2cce42
commit 6edf111753
3 files changed
+9 -6

No files matched your search

+3 -3
View File
@@ -10,10 +10,10 @@ use crate::{dispatch, BrowserState};
/// Connections are handled sequentially on the current thread — the browser
/// session (including the V8 runtime) is single-threaded and `!Send`, so we
/// never need to move state across threads.
pub async fn run(port: u16, proxy: Option<String>, user_agent: Option<String>, stealth: bool) -> Result<()> {
let addr = std::net::SocketAddr::from(([127, 0, 0, 1], port));
pub async fn run(host: String, port: u16, proxy: Option<String>, user_agent: Option<String>, stealth: bool) -> Result<()> {
let addr: std::net::SocketAddr = format!("{}:{}", host, port).parse()?;
let listener = TcpListener::bind(&addr).await?;
tracing::info!("MCP HTTP server on http://127.0.0.1:{}/mcp", port);
tracing::info!("MCP HTTP server on http://{}:{}/mcp", host, port);
let mut state = BrowserState::new(proxy, user_agent, stealth);