-
Notifications
You must be signed in to change notification settings - Fork 2
feat(mcp): default Patchright backend for Playwright MCP #1265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,11 @@ | ||
| { | ||
| "mcpServers": { | ||
| "playwright": { | ||
| "command": "npx", | ||
| "args": [ | ||
| "@playwright/mcp@latest" | ||
| ], | ||
| "command": "patchright-playwright-mcp", | ||
| "args": [], | ||
| "env": { | ||
| "FASTMCP_LOG_LEVEL": "ERROR" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| # Wrapper to run @playwright/mcp with Patchright as the default backend. | ||
| # Opt out by setting USE_PATCHRIGHT=0 or USE_PATCHRIGHT=false | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| # mcp/servers -> repo root is ../.. | ||
| DOT_DEN="$(cd "$SCRIPT_DIR/../.." && pwd)" | ||
|
|
||
| USE_PATCHRIGHT_VAL="${USE_PATCHRIGHT:-1}" | ||
| if [[ "$USE_PATCHRIGHT_VAL" != "0" && "$USE_PATCHRIGHT_VAL" != "false" ]]; then | ||
| # Prepend shim node_modules so require('playwright') resolves to Patchright | ||
| export NODE_PATH="${DOT_DEN}/mcp/patchright-shim/node_modules${NODE_PATH:+:$NODE_PATH}" | ||
| fi | ||
|
|
||
| # Execute the community Playwright MCP server | ||
| exec npx @playwright/mcp@latest "$@" | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛑 [Security Concern]: The script is using Footnotes
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| # Install Patchright into the local shim so Playwright resolves to Patchright | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| SHIM_DIR="$SCRIPT_DIR/patchright-shim" | ||
|
|
||
| mkdir -p "$SHIM_DIR" | ||
|
|
||
| if [[ ! -f "$SHIM_DIR/package.json" ]]; then | ||
| (cd "$SHIM_DIR" && npm init -y >/dev/null 2>&1) | ||
| fi | ||
|
|
||
| echo "Installing patchright into $SHIM_DIR ..." | ||
| (cd "$SHIM_DIR" && npm install patchright --silent) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider adding error handling for the npm install command to provide more informative error messages if the installation fails. |
||
|
|
||
| echo "Patchright shim ready. Optional: download Chromium once with:\n npx patchright install chromium" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a version field to the configuration to help with future compatibility checks and migrations.