Forum Discussion

shobhit-vishwakarma's avatar
shobhit-vishwakarma
Copper Contributor
Jul 31, 2026

Playwright MCP browser context is lost after 8-12 minutes of idle time.

Hi Everyone,

I'm building an AI agent that uses Playwright MCP to control a browser, and I'm running into an issue where the browser context is lost after the agent remains idle for a while.

 

Architecture

My current setup looks like this:

  • AI Agent (Client) hosted on Azure Container Apps
  • Playwright MCP Server hosted on Azure Container Apps
  • Chrome Extension running in the user's browser
  • The extension maintains a webhook connection to the Playwright MCP relay/server.
  • The MCP server generates Chrome DevTools Protocol (CDP) commands, which are executed by the Chrome Extension in the user's browser.

This allows the browser to continue running on the user's machine while the agent and MCP server are hosted remotely.

Issue

Everything works as expected while the agent is actively interacting with the browser.

However, if the agent stays idle for around 8–12 minutes, the next request fails with an agent response that the browser context is lost (or the context/browser is no longer available).

If I ask the agent to retry, it invokes the browser_close tool and creates a new browser session. While this allows execution to continue, it completely loses the previous browser state, including:

  1. Current page
  2. Navigation history
  3. Login/session state tied to that browser context
  4. Any work already completed in the existing session

Ideally, I want the existing browser session and context to remain usable even after periods of inactivity.

Questions

  1. Is there any idle timeout in Playwright MCP or its browser context management that could explain this behavior?
  2. Could this be related to the CDP connection between the Chrome Extension and the MCP server being dropped after inactivity?
  3. Are there recommended keep-alive or heartbeat mechanisms for long-lived browser sessions?
  4. Has anyone successfully maintained browser contexts for extended idle periods (30+ minutes or longer)?
  5. Is there a recommended pattern for reconnecting to an existing browser context instead of creating a new one when the connection is interrupted?

Environment

  1. Playwright MCP Server hosted on Azure Container Apps
  2. AI Agent hosted on Azure Container Apps
  3. Chrome Extension executing CDP commands in the user's local Chrome browser
  4. Communication between the agent, MCP server, and extension over the network

 

I'd appreciate any guidance on where to investigate this issue or best practices for maintaining persistent browser contexts in this kind of architecture. If anyone has encountered a similar problem, I'd be interested in hearing how you resolved it.

 

Thanks in advance!

No RepliesBe the first to reply