#!/bin/sh
# Claude Desktop runs this to start Legato's MCP server. The server is the app's own
# `legato mcp`, so the extension always matches the Legato that's installed.
for app in "/Applications/Legato.app" "$HOME/Applications/Legato.app" \
  "$(mdfind "kMDItemCFBundleIdentifier == 'com.legatobar.mac'" 2>/dev/null | grep -v '/\.Trash/' | head -n 1)"; do
  if [ -n "$app" ] && [ -x "$app/Contents/Helpers/legato" ]; then
    exec "$app/Contents/Helpers/legato" mcp
  fi
done
echo "Legato isn't on this Mac. Download it from https://legatobar.com, then restart Claude." >&2
exit 1
