feat(agent): add Playwright browser MCP integration#1255
Open
srtab wants to merge 9 commits into
Open
Conversation
Replace MCPToolkit.get_tools() with an aopen() async context manager so callers own session lifetime, and persist the server-issued Mcp-Session-Id across turns. Stateful servers (Playwright above all) tie browser context to the session id, so without resume each chat turn opened a fresh browser and snapshot/navigate landed in different contexts. - aopen() captures the session id per server via streamablehttp_client's get_session_id callback (discarded by MultiServerMCPClient) and reuses it on subsequent opens with initialize=False to satisfy Playwright's "already initialized" check. - MCPSessionStateMiddleware writes the ids dict into graph state so the checkpointer carries it forward; chat streaming reads it back on the next turn and passes it to aopen() to resume. - Stale-id recovery falls back to a fresh session and overwrites the dead id so persistence doesn't preserve it. - Job/webhook callers pass session_ids=None (one-shot semantics unchanged); only chat persists. - mcp_playwright --allowed-hosts updated to include the docker service name so the daiv app can reach it past the DNS-rebinding guard.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the Microsoft Playwright MCP server as a first-class built-in MCP integration. When the
mcpcompose profile is enabled, the DAIV agent gains a full headless-Chromium browser surface (~23playwright_browser_*tools — navigate, screenshot, console messages, network requests, click, type, evaluate, etc.) via streamable HTTP. Each agent session gets a fresh isolated browser context.feat(agent): newPlaywrightMCPServer(MCPServer)registered via the existing@mcp_serverdecorator, plus aPLAYWRIGHT_URLsetting (defaulthttp://mcp_playwright:8931/mcp).feat(compose): newmcp_playwrightservice runningmcr.microsoft.com/playwright/mcp:latestunder themcp/fullprofiles, headless Chromium with--isolated, healthchecked vianode -eHTTP probe (the image ships neitherwgetnorcurl).docs: documented the new env var and added a Playwright section to the MCP tools customization guide.Deliberate choice: no
tool_filter, so the full Playwright surface is exposed (includingbrowser_run_code_unsafe). The trust boundary is documented in the class docstring and asserted by a dedicated test so any future narrowing shows up in the diff.Design doc and implementation plan live at
docs/superpowers/specs/2026-05-25-browser-mcp-design.mdanddocs/superpowers/plans/2026-05-25-browser-mcp.mdrespectively (gitignored).Test plan
PlaywrightMCPServer(name, enabled/disabled, no tool_filter, connection URL) — all pass.