Skip to content

The headless browser for AI agents and web scraping

fix(mcp): use existing cookie persistence on shutdown

SGavrl604d30b6714e
diff --git a/crates/obscura-mcp/src/lib.rs b/crates/obscura-mcp/src/lib.rs
index 87916c3c..0e0a16ee 100644
--- a/crates/obscura-mcp/src/lib.rs
+++ b/crates/obscura-mcp/src/lib.rs
@@ -258,8 +258,7 @@ pub async fn run(proxy: Option<String>, user_agent: Option<String>, stealth: boo
let mut state = BrowserState::new(proxy, user_agent, stealth);
state.operator_network_hints = true;
- // Cookies and Web Storage are written on every navigation; this covers the
- // writes an agent makes after a page has settled, on the way out.
+ // Save cookies changed after navigation when the transport closes.
let mut runtime_pump_armed = false;
loop {
@@ -287,7 +286,7 @@ pub async fn run(proxy: Option<String>, user_agent: Option<String>, stealth: boo
continue;
};
if n == 0 {
- state.context.save_storage();
+ state.context.save_cookies();
return Ok(());
}