#!/bin/bash
#
# Installation script for fullstack-mcp
# Cross-platform support for macOS and Linux
#
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Detect OS
detect_os() {
case "$(uname -s)" in
Darwin*) echo "macos" ;;
Linux*) echo "linux" ;;
CYGWIN*|MINGW*|MSYS*) echo "windows" ;;
*) echo "unknown" ;;
esac
}
OS=$(detect_os)
# Function to print colored output
print_info() {
echo -e "${BLUE}[INFO]${NC} $1"
}
print_success() {
echo -e "${GREEN}[OK]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Get the directory where this script is located
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
echo ""
echo "============================================"
echo " Full-Stack MCP Server Installation"
echo "============================================"
echo ""
print_info "Detected OS: $OS"
print_info "Script directory: $SCRIPT_DIR"
echo ""
# Check prerequisites
print_info "Checking prerequisites..."
# Check Node.js
if command -v node >/dev/null 2>&1; then
NODE_VERSION=$(node -v | cut -d'v' -f2)
print_success "Node.js found: v$NODE_VERSION"
# Check version >= 18
MAJOR_VERSION=$(echo "$NODE_VERSION" | cut -d'.' -f1)
if [ "$MAJOR_VERSION" -lt 18 ]; then
print_error "Node.js version 18+ required. Please upgrade."
exit 1
fi
else
print_error "Node.js not found. Please install Node.js 18+ first."
echo " Visit: https://nodejs.org/"
exit 1
fi
# Check npm
if command -v npm >/dev/null 2>&1; then
print_success "npm found: $(npm -v)"
else
print_error "npm not found. Please install npm."
exit 1
fi
# Check for OpenCode CLI
if command -v opencode >/dev/null 2>&1; then
print_success "OpenCode CLI found"
else
print_warning "OpenCode CLI not found. Install it with: npm install -g opencode"
print_info "The MCP server will still install, but tools won't work without OpenCode."
fi
echo ""
print_info "Installing dependencies..."
cd "$SCRIPT_DIR"
npm install
echo ""
print_info "Building TypeScript..."
npm run build
if [ -f "$SCRIPT_DIR/dist/index.js" ]; then
print_success "Build successful: dist/index.js created"
else
print_error "Build failed: dist/index.js not found"
exit 1
fi
echo ""
echo "============================================"
echo " Installation Complete!"
echo "============================================"
echo ""
print_info "To add this MCP server to Claude Code, run:"
echo ""
echo " claude mcp add fullstack-mcp \\"
echo " --command node \\"
echo " --args \"$SCRIPT_DIR/dist/index.js\" \\"
echo " --args \"-m\" \\"
echo " --args \"cerebras/zai-glm-4.6\" \\"
echo " --env CEREBRAS_API_KEY=your-api-key"
echo ""
print_info "Or add to your .mcp.json:"
echo ""
cat << EOF
{
"mcpServers": {
"fullstack-mcp": {
"command": "node",
"args": ["$SCRIPT_DIR/dist/index.js", "-m", "cerebras/zai-glm-4.6"],
"env": {
"CEREBRAS_API_KEY": "your-api-key"
}
}
}
}
EOF
echo ""
print_info "Then initialize your project with:"
echo " $SCRIPT_DIR/init-project.sh /path/to/your/project"
echo ""