Skip to main content
Glama
WhiteNightShadow

camoufox-reverse-mcp

reset_browser_state

Reset browser state on the MCP server without restarting the browser. Clear hooks, network captures, routes, cookies, and storage as needed.

Instructions

Reset MCP-side browser residual state without closing the browser.

Args: clear_persistent_hooks: Remove all persistent init scripts. clear_network_capture: Clear network request buffer and stop captures. clear_active_routes: Clear instrumentation routes. clear_cookies: ALSO clear browser cookies (destructive; default False). clear_storage: ALSO clear localStorage/sessionStorage (default False).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
clear_persistent_hooksNo
clear_network_captureNo
clear_active_routesNo
clear_cookiesNo
clear_storageNo

Implementation Reference

  • The handler function for the 'reset_browser_state' tool. Clears residual MCP-side browser state including persistent hooks, network captures, instrumentation routes, cookies, and storage, without closing the browser.
    @mcp.tool()
    async def reset_browser_state(
        clear_persistent_hooks: bool = True,
        clear_network_capture: bool = True,
        clear_active_routes: bool = True,
        clear_cookies: bool = False,
        clear_storage: bool = False,
    ) -> dict:
        """Reset MCP-side browser residual state without closing the browser.
    
        Args:
            clear_persistent_hooks: Remove all persistent init scripts.
            clear_network_capture: Clear network request buffer and stop captures.
            clear_active_routes: Clear instrumentation routes.
            clear_cookies: ALSO clear browser cookies (destructive; default False).
            clear_storage: ALSO clear localStorage/sessionStorage (default False).
        """
        from typing import Any
        result: dict[str, Any] = {"status": "reset"}
        try:
            if clear_persistent_hooks:
                try:
                    from .hooking import remove_hooks
                    r = await remove_hooks(keep_persistent=False)
                    result["hooks_removed"] = r
                except Exception as e:
                    result["hooks_remove_error"] = str(e)
            if clear_network_capture:
                count = len(browser_manager._network_requests)
                browser_manager._network_requests.clear()
                browser_manager._request_id_counter = 0
                browser_manager._capturing = False
                browser_manager._capture_body = False
                result["network_requests_cleared"] = count
            if clear_active_routes:
                try:
                    from .instrumentation import _active_routes, _stop
                    count = len(_active_routes)
                    await _stop(None)
                    result["instrumentation_routes_cleared"] = count
                except Exception as e:
                    result["instrumentation_clear_error"] = str(e)
            if clear_cookies:
                try:
                    ctx = browser_manager.contexts.get("default")
                    if ctx:
                        await ctx.clear_cookies()
                        result["cookies_cleared"] = True
                except Exception as e:
                    result["cookies_clear_error"] = str(e)
            if clear_storage:
                try:
                    page = await browser_manager.get_active_page()
                    await page.evaluate(
                        "() => { try { localStorage.clear(); } catch(e) {} "
                        "try { sessionStorage.clear(); } catch(e) {} }"
                    )
                    result["storage_cleared"] = True
                except Exception as e:
                    result["storage_clear_error"] = str(e)
            return result
        except Exception as e:
            return {"error": str(e)}
  • The @mcp.tool() decorator registers 'reset_browser_state' as an MCP tool on the FastMCP server instance.
    @mcp.tool()
  • Input schema / type definitions for the tool: five boolean parameters with defaults controlling which state to clear.
    @mcp.tool()
    async def reset_browser_state(
        clear_persistent_hooks: bool = True,
        clear_network_capture: bool = True,
        clear_active_routes: bool = True,
        clear_cookies: bool = False,
        clear_storage: bool = False,
    ) -> dict:
  • launch_browser() warns users about residual state and suggests calling reset_browser_state().
    has_residuals = (
        len(browser_manager._persistent_scripts) > 0
        or len(browser_manager._network_requests) > 0
        or len(_active_routes) > 0
    )
    if has_residuals:
        result.setdefault("warnings", []).append(
            "browser already running with residual state. "
            "Call reset_browser_state() or close_browser() + launch_browser()."
        )
  • check_environment() recommends reset_browser_state() if browser has residual state.
    if has_residuals:
        recommendations.append("Browser has residual state. Consider reset_browser_state().")
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must disclose behavioral traits. It does mention which parameters are destructive (clear_cookies, clear_storage) and that others remove state like hooks and network capture. However, it does not describe side effects like losing ongoing captures, reversibility, or potential impact on the browser session. Partial transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with a clear, concise opening sentence explaining the tool's core function. The parameter details are presented as a bulleted list, which is easy to parse. It is not overly verbose, though the bullet list could be slightly more compact.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description covers the tool's purpose and all parameters. However, it lacks information about return values or success/failure output (no output schema exists). It also does not mention error conditions, prerequisites, or whether the tool can be safely called multiple times. For a reset tool, these details would improve completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description fully compensates by explaining each parameter's purpose: removing persistent hooks, clearing network capture, clearing routes, and also clarifying that clear_cookies and clear_storage are destructive and default to False. This adds significant meaning beyond the bare boolean names in the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Reset' and the resource 'MCP-side browser residual state', and distinguishes from 'without closing the browser', which differentiates it from siblings like close_browser. It also lists specific state components (hooks, network capture, routes, cookies, storage) for clarity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage when you want to clear state but keep the browser open, contrasting with close_browser. However, it does not provide explicit guidance on when to use this tool versus alternatives like remove_hooks or network_capture for granular operations. No when-not-to-use or prerequisite information is given.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/WhiteNightShadow/camoufox-reverse-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server