#!/usr/bin/env bash

echo "=== Installing @cyanheads/filesystem-mcp-server ==="

# Check for Node.js
if ! command -v node >/dev/null 2>&1; then
    echo "Error: Node.js not found! Please install Node.js first." >&2
    exit 1
fi

echo "Node.js version: $(node --version)"

# Install globally via npm
echo "Installing @cyanheads/filesystem-mcp-server globally..."
npm install -g @cyanheads/filesystem-mcp-server

if [ $? -eq 0 ]; then
    echo "Installation successful!"
    echo "The package is now available at: $(npm list -g @cyanheads/filesystem-mcp-server --depth=0)"
    echo ""
    echo "You can now run the launcher: ./launch_filesystem_mcp.sh"
    echo "Or use it directly with npx or in your MCP client config."
else
    echo "Installation failed!" >&2
    exit 1
fi
