Skip to content

fix(mcp): reject Playwright isolated contexts on extension-only backends - #30

Open
AKzar1el wants to merge 3 commits into
devnoname120:mainfrom
AKzar1el:fix/playwright-isolated-context-capabilities-20261117
Open

AKzar1el wants to merge 3 commits into
devnoname120:mainfrom
AKzar1el:fix/playwright-isolated-context-capabilities-20261117

Conversation

@AKzar1el

@AKzar1el AKzar1el commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Classify Playwright MCP upstreams by configured connection mode: browser-level, CDP (permission-dependent), or extension/existing-tabs-only.
  • Reject browser_tabs({action:"new",isolatedContext:"lane06_grants_funding"}) on an extension-only upstream before dispatch, without silently falling back to a shared browser profile.
  • Translate the exact CDP Target.createBrowserContext -32000 Not allowed error into an actionable failure. Do not retry potentially ambiguous operations.
  • Expose the configured capability in catalog runtime status and in the direct extension tool description; retain existing/default-context behavior and public tool contracts.

Incident evidence / root cause

Codexify's local November 17 startup logs show the regular playwright upstream repeatedly timed out after the default 20 seconds, while the separately configured playwright-extension upstream had 60 seconds and could remain available. Codexify materializes upstream MCP tools only when their server successfully initializes; consequently the regular tool vanished while an incompatible extension-backed tool could still appear. Why regular Playwright initialization exceeded its deadline remains unverified.

Chromium restricts Target.createBrowserContext to browser-level DevTools sessions. Playwright's extension attaches to existing tabs; it cannot be treated as a capability-equivalent fallback.

References: https://chromium.googlesource.com/chromium/src/+/6f2fb1192aff6ccb325971ac93516aa92574be3e/content/browser/devtools/protocol/target_handler.cc and https://playwright.dev/mcp/configuration/browser-extension

Verification (commit 42e253e)

  • Upstream GitHub CI check: PASS (Format, Clippy, Rust tests, Rust/TypeScript browser companion contract, and related checks).
  • Eight new regression tests: PASS, confirmed individually in CI logs: seven backend capability and recovery-state unit tests, plus a mock MCP forwarding integration test covering extension no-dispatch, browser-level forwarding, exact CDP refusal, and ordinary extension tabs.
  • Windows service integration: PASS; macOS service integration: PASS.
  • Local cargo fmt --check and git diff --check: PASS; isolated worktree clean.
  • A local standalone headless Chromium baseline with data: fixtures confirms that independent browser contexts can be created, and also reproduces the upstream shared-tab selection and index-reuse race.
  • The local cargo test --bin codexify browser_context_tests build compiled but matched zero tests; it is not counted as a test pass. The corrected --lib compilation was stopped after the exact committed tests passed in CI, to avoid unnecessary memory pressure on the live service.
  • No grant sites, user accounts, production browser profiles, or application submissions were used.

One unrelated CI job still fails

The Diff widget layout (Chromium and WebKit) job failed in scripts/test-statistics-extras.mjs with locator.scrollIntoViewIfNeeded: Element is not attached to the DOM on the Chromium statistics/Extras test. The affected dashboard files are not changed by this PR; base main passed that job previously. This is not proven a pre-existing failure, and merge must remain blocked until it is resolved or an authorized rerun passes. A targeted rerun attempt was rejected because the fork contributor lacks admin permissions on the upstream repository.

Strict limitations / follow-up

This PR is capability enforcement, not complete multi-agent tab isolation. It does not transparently migrate sessions between MCP backends, restart a missing regular upstream, or fix the shared current-tab pointer and index-based selection inside Playwright's upstream implementation. The controlled Chromium fixture still reproduces two agents selecting each other's tabs when they share one backend. Until per-agent stable target identity is integrated end-to-end, do not assume concurrent agents sharing one Playwright MCP backend have safe tab ownership.

The remaining reliability work requires trusted conversation identity propagated through the bridge, stable owned-target selection across all tab actions (not only new), and verified completion-only cleanup. It should be reviewed as a separate integrated change rather than introducing a misleading per-call fallback here.

Reviewer checklist

  1. Verify extension requests are rejected before forwarding in direct/catalog/gateway exposure.
  2. Check capability classification for explicit --extension, env and CDP cases.
  3. Confirm -32000 translation does not retry or infer success after ambiguous failure.
  4. Confirm unchanged/default-context operations remain compatible.
  5. Require a real owned-tab integration regression before claiming multi-agent isolation.
  6. Resolve/rerun the failed unrelated dashboard CI check before merge.

Deployment: None. Do not merge/restart the live Codexify service until independent review and required checks permit it. A bounded startupTimeoutSec for the regular browser can be considered separately after diagnosing its slow startup.

@AKzar1el
AKzar1el marked this pull request as ready for review November 17, 2026 23:22

Copy link
Copy Markdown
Contributor Author

@devnoname120 This focused Playwright capability PR is ready for independent review. The main Rust/Clippy/Format check and Windows/macOS service integration jobs passed, including all eight new regression tests. One unrelated dashboard layout job failed on a detached Chromium DOM element in scripts/test-statistics-extras.mjs; my attempt to rerun only that job was denied by upstream repository permissions. Could a maintainer please review the capability boundary and rerun or triage that failed job before merge? The PR is intentionally not a fix for upstream shared-tab ownership, and nothing has been deployed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant