Skip to content

Commit 39a5531

Browse files
feat(mcp): remove remoteHeaders in favor of remoteEndpoint headers
Drops the remoteHeaders config field, the --remote-header CLI flag, and the PLAYWRIGHT_MCP_REMOTE_HEADERS env var. Headers for a remote connect are now supplied through the ConnectOptions object form of remoteEndpoint.
1 parent 17b02fc commit 39a5531

6 files changed

Lines changed: 7 additions & 36 deletions

File tree

packages/playwright-core/src/tools/mcp/browserFactory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ async function createRemoteBrowser(config: FullConfig): Promise<BrowserWithInfo>
121121
// shape.
122122
const remote = config.browser.remoteEndpoint!;
123123
const remoteOptions = typeof remote === 'string'
124-
? { endpoint: remote, headers: config.browser.remoteHeaders }
124+
? { endpoint: remote }
125125
: remote;
126126

127127
const descriptor = await serverRegistry.find(remoteOptions.endpoint);

packages/playwright-core/src/tools/mcp/config.d.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,6 @@ export type Config = {
9090
*/
9191
remoteEndpoint?: string | playwright.ConnectOptions & { endpoint: string };
9292

93-
/**
94-
* Headers to send with the remote endpoint connect request. Ignored when
95-
* `remoteEndpoint` is provided as a [ConnectOptions] object; supply
96-
* `headers` on that object instead.
97-
*/
98-
remoteHeaders?: Record<string, string>;
99-
10093
/**
10194
* Paths to TypeScript files to add as initialization scripts for Playwright page.
10295
*/

packages/playwright-core/src/tools/mcp/config.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ export type CLIOptions = {
6363
port?: number;
6464
proxyBypass?: string;
6565
proxyServer?: string;
66-
remoteHeader?: Record<string, string>;
6766
saveSession?: boolean;
6867
secrets?: Record<string, string>;
6968
sharedBrowserContext?: boolean;
@@ -333,7 +332,6 @@ function configFromCLIOptions(cliOptions: CLIOptions): Config & { configFile?: s
333332
initPage: cliOptions.initPage,
334333
initScript: cliOptions.initScript,
335334
remoteEndpoint: cliOptions.endpoint,
336-
remoteHeaders: cliOptions.remoteHeader,
337335
},
338336
extension: cliOptions.extension,
339337
server: {
@@ -404,7 +402,6 @@ export function configFromEnv(env?: NodeJS.ProcessEnv): Config & { configFile?:
404402
options.port = numberParser(e.PLAYWRIGHT_MCP_PORT);
405403
options.proxyBypass = envToString(e.PLAYWRIGHT_MCP_PROXY_BYPASS);
406404
options.proxyServer = envToString(e.PLAYWRIGHT_MCP_PROXY_SERVER);
407-
options.remoteHeader = headerParser(envToString(e.PLAYWRIGHT_MCP_REMOTE_HEADERS));
408405
options.secrets = dotenvFileLoader(e.PLAYWRIGHT_MCP_SECRETS_FILE);
409406
options.storageState = envToString(e.PLAYWRIGHT_MCP_STORAGE_STATE);
410407
options.testIdAttribute = envToString(e.PLAYWRIGHT_MCP_TEST_ID_ATTRIBUTE);

packages/playwright-core/src/tools/mcp/program.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ export function decorateMCPCommand(command: Command) {
6363
.option('--port <port>', 'port to listen on for SSE transport.')
6464
.option('--proxy-bypass <bypass>', 'comma-separated domains to bypass proxy, for example ".com,chromium.org,.domain.com"')
6565
.option('--proxy-server <proxy>', 'specify proxy server, for example "http://myproxy:3128" or "socks5://myproxy:8080"')
66-
.option('--remote-header <headers...>', 'headers to send with the remote endpoint connect request, multiple can be specified.', headerParser)
6766
.option('--sandbox', 'enable the sandbox for all process types that are normally not sandboxed.')
6867
.option('--save-session', 'Whether to save the Playwright MCP session into the output directory.')
6968
.option('--secrets <path>', 'path to a file containing secrets in the dotenv format', dotenvFileLoader)

tests/mcp/cli-remote.spec.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ import { test, expect } from './cli-fixtures';
1919

2020
test.skip(({ mcpBrowser }) => mcpBrowser !== 'chromium', 'Run only on the chromium project; the remote server connection is browser-agnostic.');
2121

22-
test('attach to run-server endpoint with remoteHeaders from config', async ({ cli, runServerEndpoint, server }, testInfo) => {
22+
test('attach to run-server endpoint with headers from config', async ({ cli, runServerEndpoint, server }, testInfo) => {
2323
const configPath = testInfo.outputPath('config.json');
2424
await fs.promises.writeFile(configPath, JSON.stringify({
2525
browser: {
26-
remoteEndpoint: runServerEndpoint,
27-
remoteHeaders: { 'x-playwright-browser': 'chromium' },
26+
remoteEndpoint: {
27+
endpoint: runServerEndpoint,
28+
headers: { 'x-playwright-browser': 'chromium' },
29+
},
2830
isolated: true,
2931
},
3032
}, null, 2));

tests/mcp/remote-endpoint.spec.ts

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,7 @@ import { test, expect } from './fixtures';
1818

1919
test.skip(({ mcpBrowser }) => mcpBrowser !== 'chromium', 'Run only on the chromium project; the remote server connection is browser-agnostic.');
2020

21-
test('remoteHeaders selects the browser on run-server endpoint', async ({ startClient, server, runServerEndpoint }) => {
22-
const { client } = await startClient({
23-
config: {
24-
browser: {
25-
remoteEndpoint: runServerEndpoint,
26-
remoteHeaders: { 'x-playwright-browser': 'chromium' },
27-
isolated: true,
28-
},
29-
},
30-
});
31-
32-
const response = await client.callTool({
33-
name: 'browser_navigate',
34-
arguments: { url: server.HELLO_WORLD },
35-
});
36-
expect(response).toHaveResponse({
37-
page: expect.stringContaining('Page Title: Title'),
38-
});
39-
});
40-
41-
test('connect without remoteHeaders fails on run-server endpoint', async ({ startClient, server, runServerEndpoint }) => {
21+
test('connect without headers fails on run-server endpoint', async ({ startClient, server, runServerEndpoint }) => {
4222
const { client } = await startClient({
4323
config: {
4424
browser: {

0 commit comments

Comments
 (0)