browser_stop
Stop the active Selenium browser session to release system resources and terminate automation tasks.
Instructions
Stop the current Selenium browser session.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/selenium_mcp_server/browser.py:54-60 (handler)Core handler: BrowserManager.stop() – quits the Selenium WebDriver session under a thread lock, suppresses WebDriverExceptions, sets driver to None, and returns {'stopped': True}.
def stop(self) -> dict[str, bool]: with self._lock: if self._driver is not None: with suppress(WebDriverException): self._driver.quit() self._driver = None return {"stopped": True} - src/selenium_mcp_server/server.py:41-44 (registration)Registration: The browser_stop tool is registered via @mcp.tool() decorator on a FastMCP instance. The function delegates to browser.stop() through the _run helper.
@mcp.tool() def browser_stop() -> dict[str, bool]: """Stop the current Selenium browser session.""" return _run("browser_stop", browser.stop) - Helper: _run() wraps the call to browser.stop(), catches BrowserError and other exceptions, logging them before re-raising.
def _run(action: str, func: Any, *args: Any, **kwargs: Any) -> Any: try: return _as_dict(func(*args, **kwargs)) except BrowserError: logger.exception("Browser action failed: %s", action) raise except Exception as exc: logger.exception("Unexpected Selenium MCP error during %s", action) raise BrowserError(f"{action} failed: {exc}") from exc - Helper (alternate entry): The ASGI route /browser/stop also calls browser.stop() directly via the stop_browser Starlette route handler.
async def stop_browser(request) -> JSONResponse: # noqa: ANN001 return JSONResponse(browser.stop())