From 09f5f834b9d00177cf38eb9ec629a7a41cad942a Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Mon, 13 Apr 2026 16:59:09 -0700 Subject: [PATCH] chore(mcp): default to extension protocol v1 Split protocol.VERSION into LATEST_VERSION (the newest protocol the relay knows how to speak) and DEFAULT_VERSION (the one it uses when PLAYWRIGHT_EXTENSION_PROTOCOL is unset). Default is v1 while v2 rolls out; opt into v2 via the env variable. --- packages/playwright-core/src/tools/mcp/cdpRelay.ts | 6 +++--- packages/playwright-core/src/tools/mcp/protocol.ts | 11 ++++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/packages/playwright-core/src/tools/mcp/cdpRelay.ts b/packages/playwright-core/src/tools/mcp/cdpRelay.ts index 623d1f5c4a59b..3b2f54597e7fd 100644 --- a/packages/playwright-core/src/tools/mcp/cdpRelay.ts +++ b/packages/playwright-core/src/tools/mcp/cdpRelay.ts @@ -22,8 +22,8 @@ * - /extension/guid - Extension connection * * Protocol version is controlled by PLAYWRIGHT_EXTENSION_PROTOCOL env variable: - * - v1: single-tab, extension manages debugger attachment - * - v2 (default): multi-tab, relay manages debugger via chrome.* APIs + * - v1 (default): single-tab, extension manages debugger attachment + * - v2: multi-tab, relay manages debugger via chrome.* APIs */ import { spawn } from 'child_process'; @@ -77,7 +77,7 @@ export class CDPRelayServer { this._browserChannel = browserChannel; this._userDataDir = userDataDir; this._executablePath = executablePath; - this._protocolVersion = parseInt(process.env.PLAYWRIGHT_EXTENSION_PROTOCOL ?? protocol.VERSION.toString(), 10); + this._protocolVersion = parseInt(process.env.PLAYWRIGHT_EXTENSION_PROTOCOL ?? protocol.DEFAULT_VERSION.toString(), 10); const sendCommand = (method: string, params: any): Promise => { if (!this._extensionConnection) diff --git a/packages/playwright-core/src/tools/mcp/protocol.ts b/packages/playwright-core/src/tools/mcp/protocol.ts index c62f5a78c7699..b8f639a4914d3 100644 --- a/packages/playwright-core/src/tools/mcp/protocol.ts +++ b/packages/playwright-core/src/tools/mcp/protocol.ts @@ -14,9 +14,14 @@ * limitations under the License. */ -// Whenever the commands/events change, the version must be updated. The latest -// extension version should be compatible with the old MCP clients. -export const VERSION = 2; +// The latest protocol version defined in this file. Bumped whenever the +// commands/events change. The latest extension version should remain +// compatible with older MCP clients. +export const LATEST_VERSION = 2; + +// The protocol version used by default when PLAYWRIGHT_EXTENSION_PROTOCOL is +// not set. May lag behind LATEST_VERSION while a new version is rolling out. +export const DEFAULT_VERSION = 1; // Structural mirrors of @types/chrome shapes used over the wire. The extension // imports the real chrome.* types and they are structurally compatible.