Skip to content

Declare the Playwright MCP server, and resolve it against the consuming project - #2

Merged
pysnooLab merged 1 commit into
mainfrom
fix/plugin-mcp-wiring
Aug 5, 2026
Merged

Declare the Playwright MCP server, and resolve it against the consuming project#2
pysnooLab merged 1 commit into
mainfrom
fix/plugin-mcp-wiring

Conversation

@pysnooLab

Copy link
Copy Markdown
Collaborator

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-mcp reporting "present" while the browser was unusable.

  • scripts/playwright-mcp.sh derived 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 no node_modules, so neither the MCP cli nor the pinned Chromium could be found.
  • Nothing declared the server. A consuming project had to keep its own .mcp.json pointing at .claude/scripts/playwright-mcp.sh, a path the plugin now owns and the project no longer has.

Solution

  • playwright-mcp.sh reads CLAUDE_PROJECT_DIR first, falling back to its own location so the copied-into-.claude 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 ships .mcp.json declaring the server, so a consuming project drops its own.
  • check-hooks-wiring gained the matching assertion: every ${CLAUDE_PLUGIN_ROOT} path in .mcp.json must exist on disk, for the same reason it already checks hooks.json.

How to test

npm test
npm run check

387 tests green, and check-hooks-wiring now reports the .mcp.json path 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.json args the way it is in hooks.json. It follows the shape of the official example-plugin, but it is an assumption until a real install proves it.

This should land before atomic-crm#343, which removes the .mcp.json that currently keeps the browser working there.

…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.
@pysnooLab
pysnooLab merged commit 033e910 into main Aug 5, 2026
2 checks passed
@pysnooLab
pysnooLab deleted the fix/plugin-mcp-wiring branch August 5, 2026 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant