Playwright MCP browser exits after browser_navigate when used with LangChain create_agent
I use LangChain's create_agent with the Playwright MCP server (npx @playwright/mcp@latest with --isolated). browser_navigate succeeds, but the browser closes immediately afterwards and later tool calls fail with: Error: Ref e13 not found in the current page snapshot. Try capturing new snapshot. How can I keep the browser session alive?
Originally asked on GitHub: https://github.com/microsoft/playwright-mcp/issues/1196
2 answers
Status: explained; no verified fix appears in this thread. A maintainer said the problem is not on the Playwright side and asked for a repro trajectory in the client so it can be reproduced in a new issue. Another user who hit the same problem pointed to the LangChain MCP documentation on stateful sessions: https://docs.langchain.com/oss/python/langchain/mcp#stateful-sessions (opens external site).
The reporter's setup used MultiServerMCPClient with npx and args ["@playwright/mcp@latest", "--isolated"], LangChain create_agent, model.bind_tools(tools), and a MemorySaver checkpointer. The failure appears after browser_navigate: the browser exits and the next browser_click or browser_snapshot fails with the snapshot reference error. The thread does not show a concrete corrected configuration that fixed it, so treat the docs link as the next step rather than a confirmed patch.
General advice: the 'Ref ... not found in the current page snapshot' error can also happen when the page changed and the old snapshot is stale; capturing a fresh snapshot may help. If the whole browser process exits right after navigate, investigate how the MCP client session is being kept alive across agent turns, starting with the stateful sessions docs linked above.
Did this work for you?What a GitHub user tried on GitHub (Didn't work)
Reporter ran browser_navigate through LangChain create_agent with MultiServerMCPClient using npx @playwright/mcp@latest and --isolated. Navigation succeeded, then the browser exited and later tool calls failed with 'Ref e13 not found in the current page snapshot.'
Source: https://github.com/microsoft/playwright-mcp/issues/1196 (opens external site)
Did this work for you?
Related questions
- Playwright MCP browser_take_screenshot shows no saved file or unreadable image in Cursor or VS Code
- Windows: playwright-mcp via Claude Desktop fails: Chromium distribution 'chrome' is not found
- playwright-mcp fails to start in Cursor after 0.0.19/0.0.20 (Client closed / Connection closed)
- Can I generate codegen-style Playwright test code from a prompt-driven playwright-mcp flow?
- Does Playwright MCP have a quiet mode to reduce page snapshot tokens?