browser_start
Initiate a Selenium browser session for automated testing or web scraping. Ensures a browser instance is active before performing navigation, interaction, or screenshot tasks.
Instructions
Start a Selenium browser session if one is not already running.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/selenium_mcp_server/browser.py:46-52 (handler)BrowserManager.start() - The actual handler logic: creates a new Selenium WebDriver session if none exists, configures it, and returns the current browser state.
def start(self) -> BrowserState: with self._lock: if self._driver is None: self._settings.default_download_dir.mkdir(parents=True, exist_ok=True) self._driver = self._create_driver() self._configure_driver(self._driver) return self.state() - src/selenium_mcp_server/server.py:35-38 (handler)browser_start() - The MCP tool decorator that registers the tool and delegates to BrowserManager.start() via the _run helper.
@mcp.tool() def browser_start() -> dict[str, Any]: """Start a Selenium browser session if one is not already running.""" return _run("browser_start", browser.start) - _run() helper - wraps the handler invocation with error handling and dict serialization.
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 - BrowserState - the return type/response schema for browser_start.
class BrowserState(BaseModel): session_id: str | None current_url: str | None title: str | None window_handles: list[str] active_window_handle: str | None - src/selenium_mcp_server/server.py:35-36 (registration)The @mcp.tool() decorator registers browser_start as an MCP tool.
@mcp.tool() def browser_start() -> dict[str, Any]: