Document Playwright MCP usage to prevent module loading errors#15848
Document Playwright MCP usage to prevent module loading errors#15848
Conversation
- Update daily-multi-device-docs-tester workflow with clear Playwright MCP usage instructions - Add "Cannot Find Module 'playwright'" troubleshooting section to docs - Clarify that Playwright is available via MCP tools only, not as npm package - Provide examples of correct MCP tool usage vs incorrect require() patterns Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR updates gh-aw workflow guidance and troubleshooting docs to prevent agents from trying to load Playwright as an npm module, clarifying that Playwright is accessed via MCP tools in these workflows.
Changes:
- Adds a new troubleshooting section for “Cannot find module 'playwright'” with MCP-based alternatives.
- Updates the
daily-multi-device-docs-testerworkflow prompt with explicit “MCP tools only” instructions and an example. - Aligns the local docs preview URL to include the
/gh-aw/base path.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| docs/src/content/docs/troubleshooting/common-issues.md | Adds a new troubleshooting entry explaining the Playwright MCP usage pattern vs require('playwright'). |
| .github/workflows/daily-multi-device-docs-tester.md | Updates the workflow prompt with explicit Playwright MCP instructions and an example snippet. |
Comments suppressed due to low confidence (2)
docs/src/content/docs/troubleshooting/common-issues.md:190
mcp__playwright__browser_snapshot()is described here as taking a screenshot, but elsewhere in the repobrowser_snapshotis used for an accessibility tree/text snapshot (and there is a separatebrowser_take_screenshottool for images). This could mislead users into using the wrong tool; either update the wording to “accessibility snapshot” or switch the example to the screenshot tool.
// ✅ CORRECT - Use MCP Playwright tools
// Example: Navigate and take screenshot
await mcp__playwright__browser_navigate({
url: "https://example.com"
});
await mcp__playwright__browser_snapshot();
docs/src/content/docs/troubleshooting/common-issues.md:208
- The heading “Available MCP Playwright Tools” implies this is the full tool list, but the Playwright MCP integration exposes many more tools (e.g.,
browser_take_screenshot,browser_wait_for, etc.). Consider renaming this to indicate it’s a partial/common subset, or provide a link/instruction to usegh aw mcp inspect <workflow> --server playwrightto see the complete set.
**Available MCP Playwright Tools:**
- `mcp__playwright__browser_navigate` - Navigate to URL
- `mcp__playwright__browser_snapshot` - Take screenshot
- `mcp__playwright__browser_run_code` - Execute custom Playwright code
- `mcp__playwright__browser_click` - Click elements
- `mcp__playwright__browser_type` - Type text
- `mcp__playwright__browser_close` - Close browser
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - `mcp__playwright__browser_type` - Type text | ||
| - `mcp__playwright__browser_close` - Close browser | ||
|
|
||
| See the [Playwright Tool documentation](/gh-aw/reference/tools/#playwright-tool-playwright) for complete details. |
There was a problem hiding this comment.
The link text says “complete details”, but the referenced Tools page documents Playwright configuration (tools: playwright:) and doesn’t describe the MCP tool operations (mcp__playwright__browser_*). Suggest rewording to “configuration details” and/or adding a pointer to gh aw mcp inspect for the runtime tool list and signatures.
This issue also appears in the following locations of the same file:
- line 184
- line 202
| See the [Playwright Tool documentation](/gh-aw/reference/tools/#playwright-tool-playwright) for complete details. | |
| See the [Playwright tool configuration documentation](/gh-aw/reference/tools/#playwright-tool-playwright) for configuration details. For the runtime MCP tool list and signatures, run `gh aw mcp inspect`. |
| mcp__playwright__browser_run_code({ | ||
| code: `async (page) => { | ||
| await page.setViewportSize({ width: 390, height: 844 }); | ||
| await page.goto('http://localhost:4321/gh-aw/'); | ||
| return { url: page.url(), title: await page.title() }; | ||
| }` | ||
| }) |
There was a problem hiding this comment.
The Playwright MCP call in this example isn’t awaited. Since these MCP tool calls are async, leaving off await can cause agents to proceed before navigation/testing completes. Update the snippet to explicitly await the mcp__playwright__browser_run_code(...) call (and close it consistently).
| mcp__playwright__browser_run_code({ | |
| code: `async (page) => { | |
| await page.setViewportSize({ width: 390, height: 844 }); | |
| await page.goto('http://localhost:4321/gh-aw/'); | |
| return { url: page.url(), title: await page.title() }; | |
| }` | |
| }) | |
| await mcp__playwright__browser_run_code({ | |
| code: `async (page) => { | |
| await page.setViewportSize({ width: 390, height: 844 }); | |
| await page.goto('http://localhost:4321/gh-aw/'); | |
| return { url: page.url(), title: await page.title() }; | |
| }`, | |
| }); |
AI agents in the
daily-multi-device-docs-testerworkflow attemptedrequire('playwright'), which fails because Playwright is provided via MCP server (Docker container), not as an npm package.Changes:
Workflow prompt (
.github/workflows/daily-multi-device-docs-tester.md):localhost:4321→localhost:4321/gh-aw/Troubleshooting docs (
docs/src/content/docs/troubleshooting/common-issues.md):Incorrect (fails):
Correct (MCP tools):
Available MCP tools:
browser_navigate,browser_run_code,browser_snapshot,browser_click,browser_type,browser_close.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
https://api.github.com/user/usr/bin/gh gh api user --jq .login(http block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
✨ PR Review Safe Output Test - Run 22028525088