Skip to content

feat(devcontainer): connect agent sessions to the cluster browser #5348

Open

Description

@dan-petty

Update 2026-11-26 (infra move): The shared Renovate preset moved to dan-petty/infra.

.github/renovate/base.json is gone. The preset is renovate/base.json of dan-petty/infra, and .github/renovate.json extends it. Validate only .github/renovate.json here. A preset change goes to infra.


Problem or Motivation

Agents in Claude Code and Kilo cannot take browser screenshots. On 2026-11-13, the agents of the retric-ai website redesign could not check their pages visually. The Playwright tools were not loaded, and a local install was refused. The owner asked: "how do I get a browser set up?"

Facts (2026-11-13):

  • .claude/settings.json turns off playwright@claude-plugins-official (chore(agent): turn off unused Claude Code plugins #4468).
  • The plugin and the Kilo extension start npx @playwright/mcp@latest. That has no version pin, so it breaks the project pin rules.
  • The devcontainer image has no Chromium and no Playwright browser.

The owner chose one shared browser in the cluster (#5356). This item is the client side of that design. The devcontainer gets no browser.

Proposed Solution & Architectural Design

Connect agent sessions and workstation scripts to the cluster browser of #5356. Do not change the devcontainer Dockerfile, and do not put Chromium in the image.

Client pin

Committed MCP config .agents/playwright-mcp.json

It holds no path and no real domain:

  • browser.remoteEndpoint: exposeNetwork <loopback>:8821,<loopback>:8822,<loopback>:8823, timeout 30000. The timeout keeps a fifth session from waiting forever for a --max-clients slot.
  • browser.isolated: true, outputDir .data/agent/browser (gitignored).
  • timeouts.idle: 300000. This closes the remote browser and frees a slot. Without it, the remote browser never closes.
  • allowed-origins: the 3 loopback preview ports, fonts.googleapis.com and fonts.gstatic.com only. This is a guard, not a boundary.

Values at run time (never committed)

  • The endpoint with the path: ws://127.0.0.1:13000/<path>?browser=chromium. The path is the keyring value browser_ws_path of feat(k8s): run a pinned Playwright browser server in namespace devops #5356. The query is necessary: the bundled MCP sends no browser name, and run-server then fails with "launch mode for null".
  • The tunnel-host origins come from the configured domain at run time, for example from an environment variable that the session sets from config. The agent may open the tunnel hosts (owner decision 2 of feat(k8s): run a pinned Playwright browser server in namespace devops #5356).
  • The bundled MCP takes remoteEndpoint only from its config file. It has no flag and no environment variable for it (playwright mcp --help of 1.65). allowed-origins has the variable PLAYWRIGHT_MCP_ALLOWED_ORIGINS.
  • Thus the session needs a per-user config under .data/agent/browser/ (gitignored). It adds the endpoint and the tunnel-host origins to the committed values. The plan picks how that file is written (a person step or a small devops step) and records the cost (rule 3).

MCP entry

  • Add the stdio entry browser to .mcp.json and kilo.jsonc only: uv run playwright mcp --config <the per-user config>.
  • Do not add it to claude_mcp.json.j2, mcp.json.j2 or kilo_mcp.json.j2. devops devcontainer renders them for any repository.
  • The owner's gitignored .claude/settings.local.json sets enableAllProjectMcpServers, so the entry starts with no extra setting. Other users approve it at the project prompt.
  • Set kilo-code.new.browserAutomation.enabled to false in .vscode/settings.json. The Kilo extension hard-codes npx @playwright/mcp@latest.
  • Keep playwright@claude-plugins-official off.

Transport

  • The user starts kubectl port-forward -n devops deploy/browser 13000:3000 first. Off the home network, run devops k8s tunnel start before it.
  • When the forward is down, the tool fails with a connect error, and the agent docs name the command.
  • When the pod restarts, the forward stops. Then the user runs the command again. There is no fallback URL.

Local previews

  • Serve a preview on 127.0.0.1 at port 8821, 8822 or 8823, for example python -m http.server --bind 127.0.0.1 8821. Only these ports are in the exposeNetwork rule.
  • The server starts a SOCKS5 proxy for each connection. For the matched ports, the client opens the TCP connection in the devcontainer. Other hosts load directly from the pod.
  • A page cannot reach other devcontainer forwards: Argo CD 8080, Grafana 8030, Prometheus 9090, Ollama 11434, Qdrant 6333, Valkey 6379, OTel 4318 and the browser forward 13000.
  • Workstation scripts use the Python connect() API from the same pin. A script for a local preview names only its port in exposeNetwork. A script for public pages or tunnel hosts sets no exposeNetwork.

Docs

Update CONTRIBUTING.md:61, the agent tool docs and the knowledge base:

  • the port-forward command, and the rule to run it again after a pod restart
  • where the path comes from
  • the preview port rule (8821 to 8823)
  • the 428 fix: git pull, then restart the browser MCP server
  • a Python connect() script example

After the merge, add a comment on #4720, #4745, #4754, #4755 and #5186 that names these paths.

Target Subsystem

FastMCP & IDE Integrations

Existing Tool Considered

Rejected options:

  • @playwright/mcp 0.0.85: it pulls playwright-core 1.66.0-alpha, so the 1.65 server answers HTTP 428.
  • The plugin and the Kilo built-in (npx @playwright/mcp@latest): no version pin.
  • A Node client lock in the devcontainer image: it moves only when a person rebuilds the image, and it waits for build(devcontainer): add ping, traceroute, mtr, nc and tcpdump #5343.
  • Chromium in the devcontainer image (the first plan of this issue): several hundred MB in each image, sandbox work under rootless Podman, a copy on each workstation, and no path for in-cluster integrations.

Build estimate: about 0.7M to 1.2M agent tokens and half a day, plus the per-user config writer if the plan picks a devops step.

Keep cost:

  • A 51 MB wheel in each project venv (uv cache hardlinks).
  • The MCP entry adds about 25 deferred tool names to each session.
  • At each Playwright minor, a short window of HTTP 428 for sessions on a stale checkout.

Acceptance Criteria

  • In the devcontainer with no browser binary, an agent takes full-page shots of a 127.0.0.1:8821 preview at 1280 and 400 px, in light and dark.
  • A request from that page to 127.0.0.1:13000 or 127.0.0.1:8080 fails.
  • A 1.64 client gets a clear HTTP 428 error.
  • Test: the committed exposeNetwork holds no bare <loopback> and no *.
  • Test: the committed config and the MCP entries hold no path and no host other than loopback and the 2 font hosts.
  • Test: the client pin major.minor equals the image major.minor.
  • Kilo starts the pinned entry, and its built-in browser automation does not start.
  • The token cost of the tool listing is measured for 7 days, against the 150M tokens a week that the eager plugin listing cost in chore(agent): turn off unused Claude Code plugins #4468. If the cost is material, change to playwright-cli with a skill.

Dependencies

Depends on #5356. The acceptance needs the running server, the path value and the Renovate group.

It does not wait for #5343, because the devcontainer Dockerfile does not change.

Not verified yet

  • The PyPI wheel 1.65.1 runs playwright mcp as a stdio MCP server under uv run, and its process tree exits when Claude Code or Kilo closes stdin.
  • remoteEndpoint.timeout bounds the wait for a free --max-clients slot, so a fifth session fails in about 30 s.
  • PLAYWRIGHT_MCP_ALLOWED_ORIGINS replaces or extends the list of the config file.
  • kilo-code.new.browserAutomation.enabled=false stops the built-in @playwright/mcp@latest process of Kilo 7.8.27, and Kilo accepts the pinned entry in kilo.jsonc.

Alternatives check of 2026-11-28: in-use.
The item already names this tool.
Tool: playwright (https://pypi.org/project/playwright), Apache-2.0, last activity 2026-11-14, maintained.
Reason: Searches found the Playwright PyPI wheel, which the issue already names and which ships both the stdio MCP server and the Python connect() API for the remote cluster browser; the Node @playwright/mcp package is the rejected alternative.

Covers:

  • Bundled stdio MCP server for Claude Code and Kilo sessions
  • Python connect() API for workstation screenshot scripts
  • Remote endpoint with isolated contexts and allowed-origin guard
  • Full-page screenshots at chosen widths and color schemes

Lacks:

  • No flag or env var for remoteEndpoint, so a per-user config file is needed
  • No fallback when the port-forward stops or the pod restarts
  • A major.minor mismatch with the server answers HTTP 428
  • About 51 MB wheel in each project venv

Proposed design

Problem statement

Agents in Claude Code and Kilo cannot take browser screenshots: .claude/settings.json:4 turns the Playwright plugin off, and the devcontainer image holds no browser. The owner chose one shared browser in the cluster (#5356), so this item is the client side of that design. It pins the playwright client, commits the MCP config, adds the browser entry to .mcp.json and kilo.jsonc, turns the Kilo built-in browser off, and documents the port-forward, the preview ports and the 428 recovery. The devcontainer Dockerfile and the image do not change.

Acceptance criteria

Requirement: Pinned Playwright client

The dev dependency group SHALL pin playwright==1.65.1, and uv.lock SHALL hold its wheel hash.

Scenario: Lock and tree show the pin

  • WHEN uv lock --check and uv tree --group dev run in the repository
  • THEN both exit 0 and the tree prints playwright v1.65.1.

Requirement: Renovate pin group

The Renovate configuration MUST put the pep621 manager for playwright into the playwright group.

Scenario: Renovate config validator passes

  • WHEN npx --yes --package [email protected] renovate-config-validator --strict --no-global .github/renovate.json runs
  • THEN the command exits 0 and prints Config validated successfully.

Requirement: Client and image lockstep

A test MUST fail when the pinned client major.minor differs from the browser image major.minor.

Scenario: Lockstep test passes

  • WHEN uv run pytest tests/test_playwright_pin.py::test_client_matches_image runs
  • THEN the test passes and reports the two equal major.minor values.

Requirement: Committed MCP config

The committed .agents/playwright-mcp.json MUST hold only the three loopback preview ports in exposeNetwork and only loopback and the two font hosts in its allowed origins.

Scenario: Config validator passes

  • WHEN jq -e '.browser.isolated == true and .browser.remoteEndpoint.exposeNetwork == ["127.0.0.1:8821","127.0.0.1:8822","127.0.0.1:8823"] and .browser.remoteEndpoint.timeout == 30000 and .browser.outputDir == ".data/agent/browser" and .timeouts.idle == 300000' .agents/playwright-mcp.json runs
  • THEN the command exits 0 and prints the parsed config.

Requirement: MCP entry scope

The browser stdio entry MUST be in .mcp.json and kilo.jsonc only, and no devcontainer template MUST hold it.

Scenario: Entry scope validator passes

  • WHEN jq -e '.mcpServers.browser' .mcp.json and rg -n 'playwright mcp' src/devops_cli/templates run
  • THEN the first command exits 0 and names the uv run playwright mcp --config command, and the search prints no match.

Requirement: Per-user config stays out of git

The per-user MCP config MUST live under .data/agent/browser/ and MUST NOT be tracked by git.

Scenario: Git ignores the per-user config

  • WHEN git check-ignore -v .data/agent/browser/playwright-mcp.json runs
  • THEN the command exits 0 and names the .data/* rule of .gitignore.

Requirement: Kilo built-in browser off

.vscode/settings.json MUST set kilo-code.new.browserAutomation.enabled to false.

Scenario: Kilo uses the pinned entry

  • WHEN a live check starts Kilo and lists its MCP servers
  • THEN the list shows browser with uv run playwright mcp --config, and no @playwright/mcp@latest process runs.

Requirement: Remote screenshots

An agent session MUST take full-page screenshots of a local preview through the cluster browser at 1280 and 400 px in light and dark.

Scenario: Four screenshots

  • WHEN a live check starts kubectl port-forward -n devops deploy/browser 13000:3000 and runs the browser MCP tool on http://127.0.0.1:8821
  • THEN the tool writes four PNG files under .data/agent/browser and exits 0.

Requirement: Preview isolation

A page served on a preview port MUST NOT reach any other devcontainer forward.

Scenario: Blocked forwards

  • WHEN a live check loads a page from 127.0.0.1:8821 and fetches http://127.0.0.1:13000 and http://127.0.0.1:8080
  • THEN both fetches fail.

Requirement: Stale client error

A client whose major.minor differs from the server MUST receive HTTP 428.

Scenario: 1.64 client

  • WHEN a live check runs a 1.64 client against the 1.65 server
  • THEN the client prints HTTP 428 and exits non-zero.

Requirement: Agent docs

The agent docs MUST name the port-forward command, the path source, the preview port rule, the 428 recovery and a connect() example.

Scenario: Docs check

  • WHEN rg -n searches CONTRIBUTING.md and docs for kubectl port-forward -n devops deploy/browser, browser_ws_path, 8821, HTTP 428 and connect(
  • THEN each search prints at least one match.

Requirement: Workstation script

A workstation script MUST connect to the cluster browser with the pinned Python connect() API.

Scenario: Connect script

  • WHEN a live check runs a Python script with connect() from the pinned wheel
  • THEN the script opens http://127.0.0.1:8821 and writes a screenshot.

Existing Tool Considered

Use playwright (https://pypi.org/project/playwright), Apache-2.0, maintained; the alternatives check of 2026-11-17 gives in-use, and its block names what the tool lacks. The bundled MCP server and the Python connect() API come from the same playwright==1.65.1 wheel, so the change adds no second client. The change builds no code: it pins the wheel, commits the MCP config and edits the MCP entries and the docs. The per-user config is a documented copy step of about five minutes per user, with no build tokens.

Key questions

  • Which existing tool covers the browser client need?: Use playwright 1.65.1 from PyPI (Apache-2.0, maintained). The alternatives check of 2026-11-17 gives in-use, and its block names what the tool lacks. The bundled MCP server and the Python connect() API come from the same wheel, so the change pins no second client. (best practice) [sources: https://pypi.org/project/playwright, pyproject.toml:102]
    • Chosen: playwright 1.65.1. The alternatives check gives in-use, and the wheel bundles the MCP server and the connect API.
    • Rejected: @playwright/mcp 0.0.85. It pulls playwright-core 1.66.0-alpha and gets HTTP 428 from the 1.65 server.
    • Rejected: the plugin and the Kilo built-in. Both run npx @playwright/mcp@latest, so neither has a version pin.
  • How does the client reach the cluster browser?: Use kubectl port-forward -n devops deploy/browser 13000:3000, the project's documented way to reach an in-cluster service from a workstation. Off the home network, run devops k8s tunnel start first. The client has no fallback URL, and the user runs the command again after a pod restart. (best practice) [sources: docs/MCP_TOOLS.md:18, docs/CLI_REFERENCE.md:29, k8s/README.md:18]
    • Chosen: kubectl port-forward. It is the project's documented pattern for an in-cluster service from a workstation, and the devcontainer is not in the cluster.
    • Rejected: in-cluster DNS. The devcontainer cannot resolve the cluster service.
    • Rejected: fallback URL. A pod restart stops the forward, and no second URL exists.
  • How is the per-user MCP config written?: Use a documented person step: the user copies .agents/playwright-mcp.json to .data/agent/browser/playwright-mcp.json, adds the ws://127.0.0.1:13000/<path>?browser=chromium endpoint from the keyring value browser_ws_path, and adds the tunnel-host origins from the configured domain. The file stays out of git under .data/agent/. A new devops command is not worth its build and test cost. (best practice) [sources: AGENTS.md:18, SECURITY.md:17, AGENTS.md:9]
    • Chosen: documented person step. A copy and edit keeps the path out of git and adds no code, so rule 3 of AGENTS.md needs no build cost.
    • Rejected: new devops command. It adds code and tests for a per-user secret, and the issue allows a person step.
  • Which preview ports may a page reach?: Only 127.0.0.1:8821, 127.0.0.1:8822 and 127.0.0.1:8823 are in exposeNetwork. The devcontainer forwards Argo CD 8080, Grafana 8030, Prometheus 8090, Tempo 3200, Qdrant 6333 and Ollama 11434, and the workstation forwards other services; a page on a preview port must not reach them. The issue body's 9090 for Prometheus is the in-cluster service port; the devcontainer forward is 8090. (best practice) [sources: src/devops_cli/templates/devcontainer.json.j2:75, k8s/README.md:18, SECURITY.md:18]
    • Chosen: three loopback ports. Only 8821 to 8823 are in exposeNetwork, so the other forwards stay unreachable.
    • Rejected: all loopback. It opens Argo CD, Grafana, Prometheus and the other forwards to the page.
    • Rejected: wildcard. It is a boundary hole and the issue forbids it.
  • Should the token cost measurement block this item?: No. Defer it to a new issue: the measurement needs seven days of real Claude Code and Kilo sessions after the merge, so it cannot be an acceptance criterion of this pull request. The archive of chore(agent): turn off unused Claude Code plugins #4461 records the 150M tokens a week that the eager plugin listing cost, and that is the comparison the follow-up makes. (best practice) [sources: openspec/changes/archive/2026-11-11-4461-turn-off-unused-claude-code-plugins/proposal.md:5]
    • Chosen: defer. The measurement needs seven days of real sessions after the merge.
    • Rejected: block. It would hold a workable client change for a week of usage.
  • Should the MCP entry go into the devcontainer templates?: No. Add it to .mcp.json and kilo.jsonc only. devops devcontainer renders mcp.json.j2, claude_mcp.json.j2 and kilo_mcp.json.j2 for any repository, so a browser entry there would reach repositories that run no cluster browser. (best practice) [sources: src/devops_cli/commands/devcontainer.py:188, src/devops_cli/commands/devcontainer.py:201, src/devops_cli/commands/devcontainer.py:219]
    • Chosen: agent files only. The templates render for any repository, which may have no cluster browser.
    • Rejected: templates too. It would add a broken browser entry to other repositories.
  • The issue lists four MCP facts as not verified. How does the plan settle them?: Verify each before the entry is written: uv run playwright mcp --help for the stdio command, the --config option and the absence of a remoteEndpoint flag or variable; a run of the bundled server with the committed config for the browser.remoteEndpoint, browser.isolated, outputDir and timeouts.idle keys and the PLAYWRIGHT_MCP_ALLOWED_ORIGINS variable; a 1.64 client against the 1.65 server for the 428 reply; and Kilo 7.8.27 for kilo-code.new.browserAutomation.enabled. If a fact does not hold, return the item with the evidence and write no compensating entry. (best practice) [sources: AGENTS.md:8]
    • Chosen: verify first. Rule 2 of AGENTS.md requires the premise to be confirmed against the real system before code is written.
    • Rejected: assume the facts hold. An unverified config key or flag would break the entry and cost a later fix.
  • Which Renovate manager updates the client pin?: Add the pep621 manager for playwright to the playwright group of feat(k8s): run a pinned Playwright browser server in namespace devops #5356. The shared preset extends config:recommended and no rule turns pep621 off, so the manager reads the dev dependency group of pyproject.toml and moves the client with the image. (best practice) [sources: pyproject.toml:102, .github/renovate/base.json:4]
    • Chosen: pep621. It reads the dev dependency group of pyproject.toml, and the preset leaves pep621 on.
    • Rejected: pip_requirements. The pin is not in a requirements file.
    • Rejected: no manager. The pin would not update, and the client would drift from the image.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#5356

Activity

  1. added
    source/agent
    type/infra
    scope/devcontainer
    status/new
    value/medium
    effort/medium
    on Nov 13, 2026
  2. dan-petty commented on Nov 13, 2026

    @dan-petty
    OwnerAuthor
  3. added
    priority/p2-medium
    on Nov 13, 2026
  4. dan-petty commented on Nov 13, 2026

    @dan-petty
    OwnerAuthor

    On hold (2026-11-13): the owner prefers a shared browser in the k8s cluster: "It would be better if I could run playwright in the k8s cluster and use it for other service integrations". A design study runs now (in-cluster Playwright service, how agent sessions and Service jobs connect, security). This issue changes to the devcontainer client side of that design or closes as superseded when the study ends.

  5. changed the title [-]build(devcontainer): a pinned headless browser for agent screenshots[/-] [+]feat(devcontainer): connect agent sessions to the cluster browser[/+] on Nov 13, 2026
  6. dan-petty commented on Nov 13, 2026

    @dan-petty
    OwnerAuthor

    Re-scoped (2026-11-13): this issue is now the client side of the cluster browser design. The in-image Chromium plan is removed, and the devcontainer Dockerfile does not change.

    The browser server, its in-cluster path and the path value are in #5356. The hold on this issue is over when #5356 merges. The issue edit history keeps the old body.

  7. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Alternatives check: in-use

    Reason: The searches surfaced the Playwright MCP server, shipped in the maintained playwright wheel (Apache-2.0), which the issue itself already names as its client ("the MCP server that Playwright bundles"). It gives agent browser automation and screenshots over a remote browser endpoint plus the Python connect() API, so it covers the whole client-side need; the only thing outside it is the in-cluster browser service of #5356.

    The item already names this tool.

    Tool: playwright (https://pypi.org/project/playwright)

    • License: Apache-2.0
    • Last activity: 2026-11-14
    • Maintained: yes

    Covers:

    • Stdio MCP server for agent browser control (navigate, screenshot, full-page shots) run as uv run playwright mcp.
    • Connection to a remote browser server through browser.remoteEndpoint, with isolated contexts, an output dir, an idle timeout and an allowed-origins guard.
    • Python connect() API from the same pinned wheel for workstation scripts, so client and scripts share one pin.

    Lacks:

    • The cluster browser server itself, its path value and its --max-clients slot behaviour are feat(k8s): run a pinned Playwright browser server in namespace devops #5356, a separate service this client only talks to.
    • No built-in transport: the user must run kubectl port-forward (and write a per-user config) to reach the remote endpoint, with no fallback URL.
    • The @playwright/mcp npm package (0.0.85) is rejected by the issue because it pulls playwright-core 1.66.0-alpha and answers HTTP 428 against the 1.65 server.

    Tools considered:

    Searches run:

    • Playwright MCP server remote browser endpoint, results: 5
    • playwright python package bundles MCP server command, results: 5
    • playwright mcp browser automation MCP server npm, results: 5
    • microsoft playwright-mcp GitHub, results: 5
    • playwright mcp remote browser, results: 5
    • Playwright MCP server browser screenshots agents, results: 5
    • "playwright" MCP remoteEndpoint config allowed-origins, results: 5
    • playwright mcp python package uv run playwright mcp, results: 5

    Sources:

    Checked on 2026-11-17. A person decides what this means for the item. The check changes no label and closes no issue.

  8. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 666a03f while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/devcontainersource/agentstatus/newtype/infravalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions