Playwright MCP gives AI coding agents such as Claude Code, Cursor and VS Code Copilot a real browser they can drive: open pages, click, fill forms and read what is on screen. Out of the box, that browser uses your own connection, so the agent sees what you see from your desk. Put a residential proxy behind it and the agent can check a page as a visitor in Germany, Japan or Brazil would, from a real home connection. This guide covers the setup, keeping credentials safe, sticky sessions, matching locale to location, and checking that it works. For the wider picture of agents and proxies, see our AI agents overview.
Why give an agent a geo-targeted browser
Most of what a coding agent checks in a browser varies by visitor location:
- Localisation. Does the German page show German copy, euro prices and the right legal notices?
- Geo rules. Do redirects, cookie banners and blocked regions behave as intended?
- Search and ads. What does a results page or an ad slot show in another market?
- Bugs that only happen elsewhere. A slow CDN edge, a broken currency format, a missing translation.
An agent on your office connection cannot see any of this. Our post on why MCP servers need a proxy layer covers the general case; this guide is the hands-on version for Playwright MCP.
Option 1: the quick flag
Playwright MCP accepts a proxy on the command line, for example --proxy-server "http://user:password@myproxy:3128", and the same value in the PLAYWRIGHT_MCP_PROXY_SERVER environment variable. It works, but anything on a command line can be read by other processes on the same machine, and MCP client configs tend to end up in dotfiles and repositories. Use it for a quick test, not for real credentials.
Option 2: a configuration file
The safer route is a JSON configuration file kept outside your project, readable only by you. Playwright MCP passes browser.launchOptions straight to Playwright, which takes the proxy server, username and password separately:
{
"browser": {
"browserName": "chromium",
"launchOptions": {
"headless": true,
"proxy": {
"server": "http://p.shifter.io:443",
"username": "customer-USERNAME-country-de-sid-mcpde01-ttl-600",
"password": "PASSWORD"
}
},
"contextOptions": {
"locale": "de-DE",
"timezoneId": "Europe/Berlin"
}
}
}
Save it as, say, ~/.config/playwright-mcp/de.json, restrict it with chmod 600, and keep it out of version control. Then register the server with your client. In Claude Code:
claude mcp add playwright-de -- npx @playwright/mcp@latest --config ~/.config/playwright-mcp/de.json
For clients that use an mcpServers block, such as Cursor or VS Code:
{
"mcpServers": {
"playwright-de": {
"command": "npx",
"args": ["@playwright/mcp@latest", "--config", "/home/you/.config/playwright-mcp/de.json"]
}
}
}
The agent now has the same browser tools as before, and every page it opens leaves from a home connection in Germany.
Sticky sessions, not rotation
An agent rarely loads one page. It navigates, clicks, fills a form and checks the result, and the site expects the same visitor throughout. If the IP changes between those steps, logins drop, carts empty and fraud checks fire.
With the Shifter gateway, targeting and sessions live in the proxy username:
| Username ending | Behaviour |
|---|---|
-country-de | A new German IP for each connection |
-country-de-sid-mcpde01-ttl-600 | The same German IP for up to 10 minutes |
-country-us-city-new_york-sid-nyc01-ttl-600 | The same New York IP for up to 10 minutes |
For agent work, use a session id with a time-to-live that covers a task. Change the session id when you want a fresh identity.
Match the browser to the location
A German IP with an American browser locale and a Pacific time zone looks inconsistent, and some sites react to that. The contextOptions above set locale and timezoneId so the browser matches its exit. If a site asks for the precise location, Playwright MCP can grant the permission with --grant-permissions geolocation, and you can set coordinates through Playwright’s geolocation option in the same contextOptions.
Two more settings matter:
- One country per server. Register
playwright-de,playwright-usand so on, each with its own config file. The agent picks the right tool for the job, and you can see in the transcript which market it checked. - Separate profiles. By default, Playwright MCP keeps a persistent profile per workspace, and the docs warn that “A persistent profile can only be used by one browser instance at a time”. Start extra servers with
--isolated, which keeps the profile in memory, or give each its own--user-data-dir.
Prompts that work
Agents do better with a clear market, a starting page and a definition of done. A few examples:
- “Using playwright-de, open our pricing page and list every price shown, with currency and any tax note.”
- “Using playwright-us, search for our brand on the store’s own search and tell me which product appears first, with a screenshot.”
- “Using playwright-jp, go through the sign-up form up to the payment step, without submitting, and report any untranslated text.”
Naming the server in the prompt matters when several are registered: the agent then uses the right country, and the transcript shows which market each answer came from. Ask for screenshots when you need evidence, since they record what the visitor actually saw at that moment.
Check that it works
Before trusting the results, ask the agent to check the connection:
- The IP. “Open an IP lookup page and tell me the country and connection type.” With the config above, it should report Germany and a residential connection. Our free IP Info tool shows both.
- The session. Ask it to check twice a minute apart. With a session id, both checks should show the same address.
- Leaks. Ask it to run a WebRTC leak test. Playwright routes the browser’s web traffic through the proxy, but it is worth confirming no other address appears. Our guide to WebRTC leaks explains what to look for.
Common problems
| Symptom | Likely cause | Fix |
|---|---|---|
| Every page fails with a proxy error | Wrong username or password, or the config file is not loaded | Check the path passed to --config and the credentials in it |
| The agent reports your real country | The server was started without the config, or another server answered | Ask the agent which MCP server it used, and remove the unproxied one if needed |
| Pages time out | A slow page or a busy exit | Raise --timeout-navigation, or start a new session id |
| Logins keep dropping | Rotation between steps | Add a session id and a time-to-live to the username |
| The agent meets a CAPTCHA | The site wants a human check | Have the agent stop and report it, not try to solve it |
Keep costs and risks down
- Bypass what does not need the proxy.
--proxy-bypasstakes a comma-separated list of domains that go direct, such as your own staging site. Do not bypass anything whose view should be local. - Keep the agent on task.
--allowed-originsand--blocked-originslimit where the browser goes, although the docs note the allowlist “does not serve as a security boundary”. - Treat page content as untrusted. A page can contain text written to steer an agent. Keep the agent’s permissions narrow and review what it does with your accounts.
For deeper Playwright proxy techniques, including per-context proxies and cutting bandwidth, see our guide to residential proxies in Playwright. To run many browser agents at once outside an editor, see Browser Use agents behind residential proxies.
The bottom line
Playwright MCP turns a coding agent into a browser user, and a residential proxy decides where that user is. Keep the credentials in a private config file, use one sticky session per task and one server per country, match locale and time zone to the exit, and have the agent confirm its IP before it reports what it saw.
Sources and references
- Microsoft, Playwright MCP, README and configuration reference: github.com
- Playwright, BrowserType.launchPersistentContext options, including proxy, locale and timezoneId: playwright.dev
- Model Context Protocol, introduction: modelcontextprotocol.io