#!/usr/bin/env bash
# MCP Server Setup — Timmy's perception and action layer
# Run once on Hermes (Mac M3 Max) to install both MCP servers.
# No custom code. pip install and verify.

set -euo pipefail

echo "=== Installing MCP Servers ==="

# 1. steam-info-mcp — game-layer perception (#545)
pip install steam-info-mcp
echo "✓ steam-info-mcp installed: $(which steam-info-mcp)"

# 2. mcp-pyautogui — desktop control / execute_action (#546)
pip install mcp-pyautogui
echo "✓ mcp-pyautogui installed: $(which mcp-pyautogui)"

echo ""
echo "=== Verify Steam API Key ==="
if [ -z "${STEAM_API_KEY:-}" ]; then
  echo "⚠  STEAM_API_KEY not set."
  echo "   Get one at: https://steamcommunity.com/dev/apikey"
  echo "   Then: export STEAM_API_KEY=your-key-here"
  echo "   Add to ~/.zshrc or ~/.bashrc for persistence."
else
  echo "✓ STEAM_API_KEY is set"
fi

echo ""
echo "=== Verify macOS Accessibility Permissions ==="
echo "mcp-pyautogui needs Accessibility permissions to control mouse/keyboard."
echo "System Settings → Privacy & Security → Accessibility"
echo "Add Terminal (or whatever runs the heartbeat loop)."

echo ""
echo "=== Quick Smoke Test ==="
echo "Test steam-info-mcp:"
echo "  echo '{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/list\"}' | steam-info-mcp"
echo ""
echo "Test mcp-pyautogui:"
echo "  echo '{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/list\"}' | mcp-pyautogui"
echo ""
echo "Both should return JSON with available tools."
echo "=== Done ==="
