add_cookie
Add a cookie dictionary to the current domain's cookie store, enabling session management and state persistence in automated browser tests.
Instructions
Add a Selenium cookie dict to the current domain.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cookie | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- Core implementation of the add_cookie handler. Calls Selenium's WebDriver.add_cookie(cookie) under a thread lock and returns {'added': True}.
def add_cookie(self, cookie: dict[str, Any]) -> dict[str, bool]: with self._lock: self._require_driver().add_cookie(cookie) return {"added": True} - src/selenium_mcp_server/server.py:207-210 (registration)MCP tool registration for add_cookie. Decorated with @mcp.tool(), it delegates to browser.add_cookie via _run helper.
@mcp.tool() def add_cookie(cookie: dict[str, Any]) -> dict[str, bool]: """Add a Selenium cookie dict to the current domain.""" return _run("add_cookie", browser.add_cookie, cookie)