feat(mcp)!: e2e mcp is headless by default, and open_session takes headed
e2e run and e2e explore are headless by default and take --headed. e2e mcp did the opposite: it was headed outside CI and took --headless. So e2e mcp --headed was an unknown option, and on a machine with no display (a Linux box, a container) every open_session failed until you passed the other flag. Showing or hiding the browser also meant editing the MCP client config, when it's really the agent's call: the user says "let me watch" in the chat, not in .mcp.json.
open_sessiontakes an optionalheadedboolean (packages/e2e/src/mcp/session.ts).headed: trueshows this session's browser or simulator,falsehides it. Each session keeps its own value, so two sessions on one server can differ. The opening line (..., headed;) and the session telemetry report the session's value, not the server's.e2e mcp --headedsets the default for sessions that don't passheaded. Without it, sessions are headless, the same asrunandexplore(packages/e2e/src/cli/mcp.ts). The CI check is gone becauserundoesn't do one either.--headlessis still accepted but hidden from--helpand the docs (packages/e2e/src/cli/index.ts). It now asks for the default. Rejecting it would break any client config that passes it, and MCP hosts mostly hide stderr, so the user would only see a failed connection.- The agent wins: neither the default nor a leftover
--headlessstopsopen_session {headed: true}. On a machine with no display that open fails withENGINE_FAILURE(Missing X server or $DISPLAY), and the agent can retry headless. - The schema description and the server instructions tell the agent to pass
headed: truewhen the user wants to watch.docs/reference/mcp.mdxandskills/e2e/references/mcp.mddocument the argument and the new default.
open_session({}) // headless, or headed under e2e mcp --headed
open_session({ headed: true }) // the user wants to watch
open_session({ headed: false }) // headless even under --headed
Tests that fail on main: mcp-session-host.test.ts overrides the server default both ways on the fake engine and checks what reached the engine and the telemetry. mcp-server.test.ts runs with CI unset, asserts the default session opens headless, starts the CLI with --headed and with --headless on the fake engine, and checks that headed is in the schema the client receives.
Verified
Ran it locally: yes
e2e mcpsurface: the built CLI served the testbed to an MCP client over stdio withCIunset. For each case it calledopen_sessionand read the opening line.- Every headless case opens a session. Every headed case gets as far as launching a headed Chromium, which fails here (Linux, no
$DISPLAY), the same waye2e run tests/smoke.e2e.ts --headeddoes on this machine.
$ e2e mcp -> open_session {}
Session 01a10b49-... open on target "web" (platform web, engine web 0.12.0), headless; config .../apps/testbed/e2e.config.ts.
$ e2e mcp -> open_session {"headed":true}
ENGINE_FAILURE: browser launch failed: browserType.launch: Target page, context or browser has been closed
$ e2e mcp --headed -> open_session {"headed":false}
Session 01a10b49-... open on target "web" (platform web, engine web 0.12.0), headless; config .../apps/testbed/e2e.config.ts.
$ e2e mcp --headed -> open_session {}
ENGINE_FAILURE: browser launch failed: browserType.launch: Target page, context or browser has been closed
$ e2e mcp --headless -> open_session {}
Session 01a10b1a-... open on target "web" (platform web, engine web 0.12.0), headless; config .../apps/testbed/e2e.config.ts.
The headed property the client sees on open_session:
{"type":"boolean","description":"Show the browser or simulator, when the engine supports it; pass true when the user wants to watch. Default: headless, unless the server was started with --headed"}
Changes made by Claude Opus 5.5 (claude-opus-5-5) in Claude Code.