Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
fix: handle BrokenPipeError gracefully when MCP client disconnects
Laith Weinbergerdf4e2f9f1518
diff --git a/browser_use/mcp/server.py b/browser_use/mcp/server.pyindex bb4e9be7b..d27d1f40c 100644--- a/browser_use/mcp/server.py+++ b/browser_use/mcp/server.py@@ -1227,18 +1227,21 @@ class BrowserUseServer:raise RuntimeError('MCP stdio transport requires stdin, but this process was launched without one.')async with mcp.server.stdio.stdio_server() as (read_stream, write_stream):- await self.server.run(- read_stream,- write_stream,- InitializationOptions(- server_name='browser-use',- server_version='0.1.0',- capabilities=self.server.get_capabilities(- notification_options=NotificationOptions(),- experimental_capabilities={},+ try:+ await self.server.run(+ read_stream,+ write_stream,+ InitializationOptions(+ server_name='browser-use',+ server_version='0.1.0',+ capabilities=self.server.get_capabilities(+ notification_options=NotificationOptions(),+ experimental_capabilities={},+ ),),- ),- )+ )+ except BrokenPipeError:+ logger.warning('MCP client disconnected while writing to stdio; shutting down server cleanly.')async def main(session_timeout_minutes: int = 10):