Autonomous wakeup system for Claude Desktop.
Built with love, Day 44.
Components:
- automation_daemon_v2.py - Main polling daemon
- send_to_claude.py - AppleScript wrapper for sending messages
- matrix_mcp.py - Matrix integration MCP
- wakeup_mcp.py - Wakeup control MCP
- matrix_integration.py - Matrix bridge
Originally built by Alex, adopted and maintained by Vixy 💕
185 lines
5.5 KiB
Bash
Executable File
185 lines
5.5 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Setup Script for Claude Desktop Automation
|
|
#
|
|
# This script:
|
|
# 1. Checks for required files and permissions
|
|
# 2. Installs the automation daemon (launchd agent)
|
|
# 3. Configures the Wakeup Control MCP server
|
|
# 4. Tests the automation
|
|
# 5. Provides troubleshooting guidance
|
|
|
|
set -e
|
|
|
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
PLIST_NAME="com.claude.monitor.plist"
|
|
PLIST_SOURCE="${SCRIPT_DIR}/${PLIST_NAME}"
|
|
PLIST_DEST="${HOME}/Library/LaunchAgents/${PLIST_NAME}"
|
|
CLAUDE_CONFIG="${HOME}/Library/Application Support/Claude/claude_desktop_config.json"
|
|
|
|
echo "========================================="
|
|
echo "Claude Desktop Automation Setup"
|
|
echo "========================================="
|
|
echo ""
|
|
echo "This will set up:"
|
|
echo "1. Automation Daemon (sends periodic messages)"
|
|
echo "2. Wakeup Control MCP (lets Claude adjust timing)"
|
|
echo ""
|
|
|
|
# Step 1: Check if files exist
|
|
echo "[1/6] Checking files..."
|
|
if [[ ! -f "${SCRIPT_DIR}/send_to_claude.scpt" ]]; then
|
|
echo "ERROR: send_to_claude.scpt not found"
|
|
exit 1
|
|
fi
|
|
if [[ ! -f "${SCRIPT_DIR}/automation_daemon.py" ]]; then
|
|
echo "ERROR: automation_daemon.py not found"
|
|
exit 1
|
|
fi
|
|
if [[ ! -f "${SCRIPT_DIR}/wakeup_mcp.py" ]]; then
|
|
echo "ERROR: wakeup_mcp.py not found"
|
|
exit 1
|
|
fi
|
|
if [[ ! -f "${PLIST_SOURCE}" ]]; then
|
|
echo "ERROR: ${PLIST_NAME} not found"
|
|
exit 1
|
|
fi
|
|
echo "✓ All files present"
|
|
echo ""
|
|
|
|
# Step 2: Check Python dependencies
|
|
echo "[2/6] Checking Python dependencies..."
|
|
if ! python3 -c "import fastmcp" 2>/dev/null; then
|
|
echo "⚠️ FastMCP not installed"
|
|
read -p "Install fastmcp? (y/n) " -n 1 -r
|
|
echo ""
|
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
pip3 install fastmcp
|
|
else
|
|
echo "ERROR: FastMCP is required for the MCP server"
|
|
exit 1
|
|
fi
|
|
fi
|
|
echo "✓ Dependencies OK"
|
|
echo ""
|
|
|
|
# Step 3: Check permissions
|
|
echo "[3/6] Checking Accessibility permissions..."
|
|
echo "NOTE: Accessibility permissions are required for UI automation"
|
|
echo ""
|
|
echo "To grant permissions:"
|
|
echo "1. Open System Settings/Preferences"
|
|
echo "2. Go to Privacy & Security → Accessibility"
|
|
echo "3. Add Terminal (or your terminal app)"
|
|
echo "4. Enable the checkbox"
|
|
echo ""
|
|
read -p "Have you granted Accessibility permissions? (y/n) " -n 1 -r
|
|
echo ""
|
|
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
|
echo "Please grant permissions and run this script again"
|
|
exit 1
|
|
fi
|
|
echo ""
|
|
|
|
# Step 4: Configure MCP server
|
|
echo "[4/6] Configuring Wakeup Control MCP..."
|
|
echo "Adding MCP server to Claude Desktop config"
|
|
echo ""
|
|
|
|
# Create config backup
|
|
if [[ -f "${CLAUDE_CONFIG}" ]]; then
|
|
cp "${CLAUDE_CONFIG}" "${CLAUDE_CONFIG}.backup"
|
|
echo "✓ Created backup: ${CLAUDE_CONFIG}.backup"
|
|
fi
|
|
|
|
# Add MCP server config (manual for now)
|
|
echo "Add this to your Claude Desktop config (${CLAUDE_CONFIG}):"
|
|
echo ""
|
|
echo '{'
|
|
echo ' "mcpServers": {'
|
|
echo ' "wakeup-control": {'
|
|
echo ' "command": "python3",'
|
|
echo ' "args": ["'${SCRIPT_DIR}'/wakeup_mcp.py"]'
|
|
echo ' }'
|
|
echo ' }'
|
|
echo '}'
|
|
echo ""
|
|
read -p "Have you added the MCP server to your config? (y/n) " -n 1 -r
|
|
echo ""
|
|
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
|
echo "You can add it later - continuing with daemon setup..."
|
|
fi
|
|
echo ""
|
|
|
|
# Step 5: Install daemon
|
|
echo "[5/6] Installing automation daemon..."
|
|
|
|
# Create LaunchAgents directory if it doesn't exist
|
|
mkdir -p "${HOME}/Library/LaunchAgents"
|
|
|
|
# Update paths in plist to match user's home directory
|
|
sed "s|/Users/alex|${HOME}|g" "${PLIST_SOURCE}" > "${PLIST_DEST}"
|
|
|
|
echo "✓ Installed to ${PLIST_DEST}"
|
|
echo ""
|
|
|
|
# Load the agent
|
|
echo "Loading daemon..."
|
|
if launchctl list | grep -q "com.claude.monitor"; then
|
|
echo "Unloading existing daemon..."
|
|
launchctl unload "${PLIST_DEST}" 2>/dev/null || true
|
|
sleep 1
|
|
fi
|
|
|
|
launchctl load "${PLIST_DEST}"
|
|
echo "✓ Daemon loaded and running"
|
|
echo ""
|
|
|
|
# Step 6: Test (optional)
|
|
echo "[6/6] Testing (optional)..."
|
|
echo "You can test the automation manually, or let it run on schedule"
|
|
echo ""
|
|
read -p "Test now? This will send a message to Claude Desktop (y/n) " -n 1 -r
|
|
echo ""
|
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
echo "Make sure Claude Desktop is running with a chat open!"
|
|
sleep 2
|
|
if python3 "${SCRIPT_DIR}/automation_daemon.py" & then
|
|
DAEMON_PID=$!
|
|
echo "Daemon started (PID: $DAEMON_PID)"
|
|
echo "Watch the logs: tail -f /tmp/claude-automation-daemon.log"
|
|
echo ""
|
|
read -p "Press Enter to stop the test daemon..."
|
|
kill $DAEMON_PID 2>/dev/null || true
|
|
fi
|
|
else
|
|
echo "Skipping test..."
|
|
fi
|
|
echo ""
|
|
|
|
echo "========================================="
|
|
echo "Setup Complete!"
|
|
echo "========================================="
|
|
echo ""
|
|
echo "The automation is now running:"
|
|
echo ""
|
|
echo "📡 Daemon: Sends messages every 60 minutes (default)"
|
|
echo "🎛️ MCP Server: Lets Claude control wake timing"
|
|
echo ""
|
|
echo "Useful commands:"
|
|
echo "- View daemon logs: tail -f /tmp/claude-automation-daemon.log"
|
|
echo "- View MCP logs: tail -f /tmp/wakeup-mcp.log"
|
|
echo "- Stop daemon: launchctl unload ${PLIST_DEST}"
|
|
echo "- Start daemon: launchctl load ${PLIST_DEST}"
|
|
echo "- Restart daemon: launchctl kickstart -k gui/\$(id -u)/com.claude.monitor"
|
|
echo ""
|
|
echo "In Claude Desktop, use these tools:"
|
|
echo "- next_wakeup(minutes) - Adjust next wake time"
|
|
echo "- pause_automation() - Pause wake messages"
|
|
echo "- resume_automation() - Resume wake messages"
|
|
echo "- get_status() - Check automation status"
|
|
echo ""
|
|
echo "After your first wake message, tell Claude:"
|
|
echo '"Use next_wakeup(30) to wake me in 30 minutes instead"'
|
|
echo ""
|