diff --git a/mcp/playwright-mcp-wrapper.sh b/mcp/playwright-mcp-wrapper.sh index cc7c81aa..a6ce6518 100755 --- a/mcp/playwright-mcp-wrapper.sh +++ b/mcp/playwright-mcp-wrapper.sh @@ -7,10 +7,32 @@ set -e # Log file for debugging LOG_FILE="$HOME/.playwright-mcp.log" +# Get the directory of this script +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + # Check if playwright-mcp is installed if ! command -v playwright-mcp &> /dev/null; then - echo "Error: playwright-mcp not found. Please run mcp/setup-playwright-mcp.sh first." | tee -a "$LOG_FILE" - exit 1 + echo "playwright-mcp not found. Attempting to install automatically..." | tee -a "$LOG_FILE" + + # Check if setup script exists + if [[ -f "$SCRIPT_DIR/setup-playwright-mcp.sh" ]]; then + echo "Running setup script..." | tee -a "$LOG_FILE" + # Make sure it's executable + chmod +x "$SCRIPT_DIR/setup-playwright-mcp.sh" + # Run the setup script + "$SCRIPT_DIR/setup-playwright-mcp.sh" + + # Check again if installation was successful + if ! command -v playwright-mcp &> /dev/null; then + echo "Error: Installation failed. Please run mcp/setup-playwright-mcp.sh manually." | tee -a "$LOG_FILE" + exit 1 + fi + + echo "Installation successful!" | tee -a "$LOG_FILE" + else + echo "Error: Setup script not found at $SCRIPT_DIR/setup-playwright-mcp.sh" | tee -a "$LOG_FILE" + exit 1 + fi fi # Set default log level if not provided