From 5e49f7a53ed81572cdf7a4999e0300d08eab2e37 Mon Sep 17 00:00:00 2001 From: Morgan Joyce Date: Tue, 22 Jul 2025 14:42:52 -0500 Subject: [PATCH] fix(mcp): add auto-install to Playwright MCP wrapper - Update wrapper script to automatically run setup script if needed - Follow Spilled Coffee Principle by making installation automatic - Improve error handling and logging during installation Principle: spilled-coffee-principle --- mcp/playwright-mcp-wrapper.sh | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) 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