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
4 changes: 2 additions & 2 deletions .codex/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ log_file = "~/.codex/logs/codex.log"
# Note: Codex uses 'mcp_servers' (underscore) not 'mcpServers' (camelCase)

[mcp_servers.playwright]
command = "npx"
args = ["@playwright/mcp@latest"]
command = "patchright-playwright-mcp"
args = []
env = { FASTMCP_LOG_LEVEL = "ERROR" }

# Additional MCP servers can be added here
Expand Down
8 changes: 3 additions & 5 deletions mcp/mcp.json
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"
}
}
}
}
}
28 changes: 28 additions & 0 deletions mcp/patchright-playwright-mcp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash
set -euo pipefail

# Wrapper to launch Playwright MCP through Patchright by default.
#
# Behavior:
# - Default enables Patchright shim by setting NODE_PATH to the shim dir
# - Opt-out by setting USE_PATCHRIGHT=0 or USE_PATCHRIGHT=false
# - Optional debug: USE_PATCHRIGHT_DEBUG=1 prints shim activation to stderr
# - Override underlying command with PLAYWRIGHT_MCP_CMD if needed

# Resolve repository-local paths dynamically (no hardcoded absolute paths)
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd -P)"
SHIM_NODE_MODULES="$SCRIPT_DIR/patchright-shim/node_modules"

USE_PATCHRIGHT="${USE_PATCHRIGHT:-1}"
if [[ "${USE_PATCHRIGHT}" != "0" && "${USE_PATCHRIGHT,,}" != "false" ]]; then
export NODE_PATH="${SHIM_NODE_MODULES}${NODE_PATH+:$NODE_PATH}"
export USE_PATCHRIGHT_DEBUG="${USE_PATCHRIGHT_DEBUG:-0}"
fi

CMD="${PLAYWRIGHT_MCP_CMD:-npx}"

if [[ "$CMD" == "npx" ]]; then
exec npx "@playwright/mcp@latest" "$@"
else
exec "$CMD" "$@"
fi
17 changes: 17 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.

11 changes: 10 additions & 1 deletion mcp/setup-all-mcp-servers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ done
# Create servers directory if it doesn't exist
mkdir -p "$MCP_DIR/servers"

# Ensure patchright-playwright-mcp is available on PATH for portability
WRAPPER_SRC="$MCP_DIR/patchright-playwright-mcp.sh"
DEST_DIR="${HOME}/.local/bin"
DEST_LINK="${DEST_DIR}/patchright-playwright-mcp"
mkdir -p "${DEST_DIR}"
if [ ! -e "${DEST_LINK}" ]; then
ln -s "${WRAPPER_SRC}" "${DEST_LINK}" || true
fi

# Summary
echo -e "\n${GREEN}MCP Server Setup Summary:${NC}"
echo "- Working directory: $REPO_ROOT"
Expand Down Expand Up @@ -88,4 +97,4 @@ for binary in "${binaries[@]}"; do
else
echo -e " ${RED}✗ $binary${NC}"
fi
done
done