open_new_tab
Open a new browser tab and optionally navigate to a specified URL to manage multiple pages or separate tasks during automation.
Instructions
Open a new browser tab and optionally navigate it to a URL.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/selenium_mcp_server/server.py:89-93 (handler)MCP tool handler for 'open_new_tab' - decorated with @mcp.tool(), delegates to browser.open_new_tab via _run helper.
@mcp.tool() def open_new_tab(url: str | None = None) -> dict[str, Any]: """Open a new browser tab and optionally navigate it to a URL.""" return _run("open_new_tab", browser.open_new_tab, url) - _run helper function that invokes the browser method with error handling and dict conversion.
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 - Core implementation of open_new_tab on BrowserManager - validates URL, switches to a new tab window, optionally navigates to URL, returns BrowserState.
def open_new_tab(self, url: str | None = None) -> BrowserState: if url is not None: self._validate_url(url) with self._lock: driver = self._require_driver() driver.switch_to.new_window("tab") if url is not None: driver.get(url) return self.state() - BrowserState Pydantic model - the return type schema for open_new_tab.
class BrowserState(BaseModel): session_id: str | None current_url: str | None title: str | None window_handles: list[str] active_window_handle: str | None