Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions mcp/mcp.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
{
Copy link
Copy Markdown
Contributor

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.

"mcpServers": {
"playwright": {
"command": "npx",
"args": [
"@playwright/mcp@latest"
],
"command": "patchright-playwright-mcp",
"args": [],
"env": {
"FASTMCP_LOG_LEVEL": "ERROR"
}
}
}
}
}
4 changes: 4 additions & 0 deletions mcp/patchright-shim/node_modules/playwright/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions mcp/servers/patchright-playwright-mcp
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 "$@"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 [Security Concern]: The script is using exec with "$@" which could potentially allow command injection if not properly sanitized1. Consider adding input validation for the arguments before passing them to exec.

Footnotes

  1. CWE-78: OS Command Injection - https://cwe.mitre.org/data/definitions/78.html

19 changes: 19 additions & 0 deletions mcp/setup-patchright-shim.sh
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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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"