Adding Playwright MCP + CloakBrowser to an Agent
Many Agents ship with built-in browser_* tools. They are fine for reading a page, but not great once you need to log in, fill out forms, or submit something. Playwright MCP is an official MCP server maintained by Microsoft, and it exposes a much wider set of browser automation tools.
The catch: plain Playwright breaks pretty quickly on modern anti-bot checks. navigator.webdriver = true, an empty plugin list, and a mismatched TLS fingerprint are all signals aimed straight at automated browsers. That is why I switched it to CloakBrowser.
What CloakBrowser is
CloakBrowser applies anti-detection patches to Chromium at the C++ layer. It is not a JS-level stealth patch, which would leave the TLS fingerprint unchanged. It ships with 49+ source-level patches. The project claims a 30/30 pass rate on bot detection tests and a reCAPTCHA v3 score of 0.9, roughly human level.
Installing CloakBrowser
uv tool install cloakbrowser
# If you need to set environment variables
# uv tool update-shell
# The browser binary is installed under /home/<username>/.cloakbrowser
cloakbrowser install
# Check the installed browser info
cloakbrowser infoConfiguring the MCP server
There are two config files. The first one belongs to Playwright MCP itself. It tells Playwright MCP to use CloakBrowser instead of the bundled Chromium:
/home/<username>/.agents/mcp/playwright-mcp/config.json:
The second one is the Agent’s MCP config. This example uses hermes agent. For other Agent tools, follow their own configuration docs.
The mcp_servers section in /home/<username>/.hermes/config.yaml:
mcp_servers:
playwright-cloak:
enabled: true
command: npx
args:
- "@playwright/mcp@latest"
- "--config"
- "/home/<username>/.agents/mcp/playwright-mcp/config.json"
- "--headless"Add --caps=storage to args to enable cookie persistence tools.
Cookie persistence
Playwright MCP has two persistence mechanisms:
-
Persistent Profile Mode (default) — browser state is saved automatically to
/home/<username>/.cache/ms-playwright/mcp-chrome-profile/. However, when using CloakBrowser viaexecutablePath, this directory is never created, so this path does not work. -
--storage-stateexplicit load/save — use--isolatedto disable profile mode, and--storage-state=<path>to load a previously saved state file on startup.
Working config:
mcp_servers:
playwright-cloak:
enabled: true
command: npx
args:
- "@playwright/mcp@latest"
- "--caps=storage"
- "--config"
- "/home/<username>/.hermes/playwright-mcp/config.json"
- "--headless"
- "--isolated"
- "--storage-state=/home/<username>/.hermes/playwright-mcp/storage-state.json"Workflow:
- First use: log in to the target site manually
- Call
browser_storage_stateto save tostorage-state.json - Next startup: the MCP server automatically restores cookies and localStorage from
storage-state.json
Extra tools provided by --caps=storage:
| Tool | Purpose |
|---|---|
browser_storage_state |
Save cookies + localStorage to a file |
browser_set_storage_state |
Restore from a file |
browser_cookie_list/get/set/delete/clear |
Manage individual cookies precisely |