Repository navigation
Description
Summary
#85 introduced patch-playwright-mcp.sh and made Playwright MCP usable in this image. As implemented, the script lives in claude-code/.devcontainer/, and consumer projects copy it verbatim into their own .devcontainer/. They then wire it into postCreateCommand (via init-plugins.sh) and postStartCommand.
That works, but it leaves a per-project copy of a script that has zero project-specific configuration. Every time the upstream script changes — different chromium flags, a new MCP CLI convention, a bug fix in the patch loop — every consumer project has to manually mirror the change. The daily image rebuild + pull_policy: always already exists as the upstream-update channel for everything else; this script should ride it too.
This image already does exactly that for rtk and ralphex: both are built (or downloaded) in parallel build stages and COPY-ed to /usr/local/bin/. The pattern is established. We just extend it to the patch script.
Why this matters
For a consumer project today, the per-project surface area for #85 is:
.devcontainer/patch-playwright-mcp.sh— verbatim copy of the upstream file..devcontainer/init-plugins.sh— calls the script viabash "$(dirname "$0")/patch-playwright-mcp.sh"..devcontainer/devcontainer.jsonpostStartCommand— calls the script viabash /workspace/.devcontainer/patch-playwright-mcp.sh.- (The sandbox variant under
.devcontainer/claude-sandbox/devcontainer.jsonrepeats Create GitHub Action for multiplatform builds #3.)
Items 2–4 each have to invoke the script (and that doesn't go away). Item 1 is the part that doesn't need to be per-project. Removing it cuts one file from every consumer's .devcontainer/ and removes the only thing in that surface area that has to be kept in sync with upstream by hand.
Proposed change
Three small diffs.
1. claude-code/.devcontainer/Dockerfile
In the FROM ... AS base stage (so both default and sandbox targets inherit), add right after the existing system-package install — alongside the existing COPY --from=rtk-download / COPY --from=ralphex-download lines or just before them, doesn't matter:
COPY .devcontainer/patch-playwright-mcp.sh /usr/local/bin/patch-playwright-mcp
RUN chmod 0755 /usr/local/bin/patch-playwright-mcpPlacing it in base rather than per-target is the right call: both targets already install chromium per #85, so both need the patch script. The script's own early-exit (if [ ! -x /usr/bin/chromium ]; then exit 0; fi) means it stays safe in any future image variant that omits chromium — calling it is always free.
2. claude-code/.devcontainer/init-plugins.sh
Replace the current invocation:
bash "$(dirname "$0")/patch-playwright-mcp.sh"with the image path:
/usr/local/bin/patch-playwright-mcpThe script-relative path resolution ($(dirname "$0")) stops being needed: the script's location is now image-stable, not relative to init-plugins.sh.
3. claude-code/.devcontainer/patch-playwright-mcp.sh
Keep the file in the source tree unchanged. The Dockerfile COPY reads from there, so this remains the build-time source of truth. Nothing else needs to change.
4. claude-code/README.md — consumer setup guidance
The "Essential Setup for Consumer Projects" section currently lists patch-playwright-mcp.sh as one of the files projects copy from this template. Drop that line. Update the lifecycle commands snippet:
"postCreateCommand": "bash .devcontainer/init-plugins.sh",
"postStartCommand": "/usr/local/bin/patch-playwright-mcp",
"updateContentCommand": "mise install && bun install && sudo find /workspace -type d -name node_modules -exec chown -R node:node {} \\;"Add a short note explaining why init-plugins.sh stays per-project but patch-playwright-mcp doesn't: init-plugins.sh carries project-specific marketplace and plugin lists; the patch script carries no project-specific config. That's the boundary — project-specific config stays per-project; universal logic moves into the image.
Trade-offs / alternatives I considered
- Belt-and-suspenders (keep the per-project copy AND ship in the image): rejected. Two sources of truth invite drift, and the per-project copy would slowly diverge as consumer projects forget to sync.
- Move all of
init-plugins.shinto the image so it doesn't even need to be per-project: rejected.init-plugins.shcarries project-specific configuration (marketplace list, plugin list). It's meant to be per-project. The patch script isn't. - Use a non-
COPYmechanism (e.g. download in a parallel build stage likertkandralphex): rejected. Those download from external GitHub releases because the binaries don't live in this repo.patch-playwright-mcp.shdoes live in this repo, so a plainCOPYfrom the build context is simpler and faster. - Drop the script entirely and bypass the plugin (Option B from Playwright MCP plugin can't launch a browser in
claude-code-sandbox, and the existing ARM64 patch is broken inclaude-codetoo #85: definemcpServers.playwrightdirectly in~/.claude/settings.json): out of scope for this issue. That's a different architectural choice about whether to preserve the plugin layer at all. This issue assumes Playwright MCP plugin can't launch a browser inclaude-code-sandbox, and the existing ARM64 patch is broken inclaude-codetoo #85's choice to keep it.
Verification plan
- Build both targets:
docker build --target default -t claude-code:default . docker build --target sandbox -t claude-code:sandbox .
- In each, confirm the script lands at the expected path and is executable:
docker run --rm claude-code:default ls -la /usr/local/bin/patch-playwright-mcp docker run --rm claude-code:sandbox ls -la /usr/local/bin/patch-playwright-mcp
- In each, confirm the script runs and exits cleanly when there's no
~/.claude/plugins/cacheto patch (the no-op path):Expected: exit code 0, no output (thedocker run --rm claude-code:default /usr/local/bin/patch-playwright-mcp
findfinds nothing). - In a consumer project with
.devcontainer/patch-playwright-mcp.shdeleted,init-plugins.shupdated to call/usr/local/bin/patch-playwright-mcp, and bothdevcontainer.jsonfiles updated to invoke the same path frompostStartCommand: rebuild the devcontainer, then confirm the cached.mcp.jsonfiles under~/.claude/plugins/cache/claude-plugins-official/playwright/*/are patched with the upstream args ("command": "npx", args including--browser chromium --executable-path /usr/bin/chromium --no-sandbox --headless). - Restart Claude Code and confirm
mcp__plugin_playwright_playwright__browser_navigatetoabout:blanksucceeds.
Migration impact for consumer projects
Once this lands, consumer projects pulling the new image need the following one-time changes:
- Delete
.devcontainer/patch-playwright-mcp.sh. - In
.devcontainer/init-plugins.sh, change the playwright block frombash "$(dirname "$0")/patch-playwright-mcp.sh"to/usr/local/bin/patch-playwright-mcp. - In every
devcontainer.jsonpostStartCommandthat calls the script, changebash /workspace/.devcontainer/patch-playwright-mcp.shto/usr/local/bin/patch-playwright-mcp. (A project with bothdefaultandsandboxvariants needs the change in both.)
After that one-time migration, future upstream changes to the patch logic (chromium flag tweaks, MCP arg adjustments, bug fixes in the loop) flow automatically on the next docker compose pull. No manual mirror, no per-project sync.
Why now
This closes the loop #85 opened. #85 was scoped to "make Playwright MCP work at all"; this issue is the small refinement that takes per-project surface area from "one file + invocations" down to just "invocations". Same shape as rtk and ralphex already have. A four-line Dockerfile diff and a one-line init-plugins.sh diff.
Activity
refactor(claude-code): bake patch-playwright-mcp into the image (#87) (…