Declare the Playwright MCP server, and resolve it against the consuming project - #2
Merged
Merged
Conversation
…ng project
Migrating a real project onto the plugin surfaced two layout assumptions the extraction
had missed, both silent: a missing MCP server shows up as a tool that simply is not
there, with no error anywhere.
playwright-mcp.sh derived the repo from its own location ($0/../..). That held when the
harness lived in a project's .claude/, where the two coincide, but installed as a plugin
the script sits outside the project and resolved to the plugin's parent, which has no
node_modules. It reads CLAUDE_PROJECT_DIR first now, keeping the old fallback so the
copied-in layout still works. It needs the CONSUMING project's node_modules: both the MCP
cli and the Chromium the e2e suite already provisions live there.
The plugin also declares the server itself, in .mcp.json, so a consuming project no longer
carries a .mcp.json pointing at a script the plugin now owns.
check-hooks-wiring gained the matching assertion: every ${CLAUDE_PLUGIN_ROOT} path in
.mcp.json must exist, same reason it already checks hooks.json.
One thing this cannot verify from here: whether ${CLAUDE_PLUGIN_ROOT} is expanded in a
plugin's .mcp.json args the way it is in hooks.json. It follows the documented example
plugin's shape, but confirm the browser tools actually appear on the first real install.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Migrating a real project onto the plugin (atomic-crm#343) surfaced two layout assumptions the extraction missed. Both are silent: a missing MCP server shows up as a tool that simply is not there, with no error anywhere. It is the same failure mode as
ensure-playwright-mcpreporting "present" while the browser was unusable.scripts/playwright-mcp.shderived the repo from its own location ($0/../..). That held when the harness lived inside a project's.claude/, where the two coincide. Installed as a plugin, the script sits outside the project and resolved to the plugin's parent, which has nonode_modules, so neither the MCP cli nor the pinned Chromium could be found..mcp.jsonpointing at.claude/scripts/playwright-mcp.sh, a path the plugin now owns and the project no longer has.Solution
playwright-mcp.shreadsCLAUDE_PROJECT_DIRfirst, falling back to its own location so the copied-into-.claudelayout still works. It needs the consuming project'snode_modules: both the MCP cli and the Chromium the e2e suite already provisions live there..mcp.jsondeclaring the server, so a consuming project drops its own.check-hooks-wiringgained the matching assertion: every${CLAUDE_PLUGIN_ROOT}path in.mcp.jsonmust exist on disk, for the same reason it already checkshooks.json.How to test
npm test npm run check387 tests green, and
check-hooks-wiringnow reports the.mcp.jsonpath alongside the 31 hook registrations.The part that cannot be verified from a checkout: install the plugin in a project and confirm the
mcp__playwright__browser_*tools appear. That is what tells you${CLAUDE_PLUGIN_ROOT}is expanded in a plugin's.mcp.jsonargs the way it is inhooks.json. It follows the shape of the officialexample-plugin, but it is an assumption until a real install proves it.This should land before atomic-crm#343, which removes the
.mcp.jsonthat currently keeps the browser working there.