#!/bin/bash
# Electron Native MCP Server Setup Script
set -e
echo "π Electron Native MCP Server Setup"
echo "===================================="
echo ""
# Check if Node.js is installed
if ! command -v node &> /dev/null; then
echo "β Node.js is not installed"
echo "Please install Node.js 18 or later from https://nodejs.org/"
exit 1
fi
NODE_VERSION=$(node -v | cut -d'v' -f2 | cut -d'.' -f1)
if [ "$NODE_VERSION" -lt 18 ]; then
echo "β Node.js version 18 or later is required"
echo "Current version: $(node -v)"
exit 1
fi
echo "β
Node.js $(node -v) detected"
echo ""
# Check if we're on macOS
if [[ "$OSTYPE" != "darwin"* ]]; then
echo "β This server only supports macOS"
exit 1
fi
echo "β
macOS detected"
echo ""
# Check for Xcode Command Line Tools
if ! xcode-select -p &> /dev/null; then
echo "β οΈ Xcode Command Line Tools not found"
echo "Installing Xcode Command Line Tools..."
xcode-select --install
echo "Please complete the installation and run this script again"
exit 1
fi
echo "β
Xcode Command Line Tools installed"
echo ""
# Install dependencies
echo "π¦ Installing dependencies..."
npm install
if [ $? -ne 0 ]; then
echo "β Failed to install dependencies"
exit 1
fi
echo "β
Dependencies installed"
echo ""
# Build the project
echo "π¨ Building the project..."
npm run build
if [ $? -ne 0 ]; then
echo "β Build failed"
exit 1
fi
echo "β
Build successful"
echo ""
# Get the absolute path
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
echo "π Configuration"
echo "================"
echo ""
echo "Add this to your Claude Desktop config:"
echo "File: ~/Library/Application Support/Claude/claude_desktop_config.json"
echo ""
echo "{"
echo " \"mcpServers\": {"
echo " \"electron-native\": {"
echo " \"command\": \"node\","
echo " \"args\": [\"$PROJECT_DIR/dist/index.js\"]"
echo " }"
echo " }"
echo "}"
echo ""
# Check permissions
echo "π Checking macOS Permissions"
echo "=============================="
echo ""
echo "This server requires the following permissions:"
echo ""
echo "1. Accessibility"
echo " β System Settings β Privacy & Security β Accessibility"
echo " β Add your terminal app (Terminal, iTerm2, VS Code, etc.)"
echo ""
echo "2. Screen Recording"
echo " β System Settings β Privacy & Security β Screen Recording"
echo " β Add your terminal app"
echo ""
echo "3. Input Monitoring"
echo " β System Settings β Privacy & Security β Input Monitoring"
echo " β Add your terminal app"
echo ""
echo "You can check permission status using the 'check_all_permissions' tool"
echo ""
# Offer to install example app
echo "π± Example Electron App"
echo "======================="
echo ""
read -p "Would you like to install the example Electron app? (y/n) " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "Installing example app..."
cd "$PROJECT_DIR/examples/test-electron-app"
npm install
if [ $? -eq 0 ]; then
echo "β
Example app installed"
echo ""
echo "To run the example app:"
echo " cd examples/test-electron-app"
echo " npm start"
else
echo "β Failed to install example app"
fi
cd "$PROJECT_DIR"
fi
echo ""
echo "β¨ Setup Complete!"
echo "=================="
echo ""
echo "Next steps:"
echo "1. Add the configuration to Claude Desktop (see above)"
echo "2. Grant the required macOS permissions"
echo "3. Restart Claude Desktop"
echo "4. Test with the example Electron app"
echo ""
echo "For more information, see:"
echo " - README.md - Overview and features"
echo " - USAGE.md - Detailed usage guide"
echo " - IMPLEMENTATION.md - Technical details"
echo ""
echo "Happy automating! π"