install.ps1โข12 kB
# MCP Fullstack Installation Script for Windows
# This script installs MCP Fullstack and optionally sets it up as a Windows service
param(
[switch]$Service,
[string]$InstallDir = "$env:USERPROFILE\.mcp-fullstack",
[string]$Port = "3000",
[switch]$Help
)
# Colors for output
$ColorRed = "Red"
$ColorGreen = "Green"
$ColorYellow = "Yellow"
$ColorBlue = "Blue"
$ColorMagenta = "Magenta"
function Write-ColorOutput {
param(
[Parameter(Mandatory=$true)][string]$Message,
[string]$Color = "White"
)
Write-Host $Message -ForegroundColor $Color
}
function Show-Help {
Write-ColorOutput "MCP Fullstack Installation Script" $ColorBlue
Write-ColorOutput "=================================" $ColorBlue
Write-Host ""
Write-Host "Usage: .\install.ps1 [options]"
Write-Host ""
Write-Host "Options:"
Write-Host " -Service Install as Windows service"
Write-Host " -InstallDir Installation directory (default: ~/.mcp-fullstack)"
Write-Host " -Port Server port (default: 3000)"
Write-Host " -Help Show this help message"
Write-Host ""
Write-Host "Examples:"
Write-Host " .\install.ps1 # Basic installation"
Write-Host " .\install.ps1 -Service # Install as Windows service"
Write-Host " .\install.ps1 -Port 8080 # Install on port 8080"
exit 0
}
if ($Help) {
Show-Help
}
# Check execution policy
$ExecutionPolicy = Get-ExecutionPolicy
if ($ExecutionPolicy -eq "Restricted") {
Write-ColorOutput "โ PowerShell execution policy is Restricted" $ColorRed
Write-ColorOutput "Please run: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser" $ColorYellow
exit 1
}
Write-ColorOutput "๐ MCP Fullstack Installation Script" $ColorBlue
Write-ColorOutput "====================================" $ColorBlue
Write-Host ""
Write-ColorOutput "Platform: Windows" $ColorGreen
Write-ColorOutput "Architecture: $env:PROCESSOR_ARCHITECTURE" $ColorGreen
Write-Host ""
# Check if Node.js is installed
try {
$NodeVersion = & node --version 2>$null
if ($LASTEXITCODE -ne 0) {
throw "Node.js not found"
}
Write-ColorOutput "Node.js: $NodeVersion" $ColorGreen
# Check Node.js version
$VersionNumber = [int]($NodeVersion.Substring(1).Split('.')[0])
if ($VersionNumber -lt 18) {
Write-ColorOutput "โ Node.js 18+ is required (current: $NodeVersion)" $ColorRed
exit 1
}
} catch {
Write-ColorOutput "โ Node.js is not installed" $ColorRed
Write-ColorOutput "Please install Node.js 18+ from https://nodejs.org/" $ColorYellow
exit 1
}
# Check if npm is installed
try {
$NpmVersion = & npm --version 2>$null
if ($LASTEXITCODE -ne 0) {
throw "npm not found"
}
Write-ColorOutput "npm: $NpmVersion" $ColorGreen
} catch {
Write-ColorOutput "โ npm is not installed" $ColorRed
exit 1
}
Write-Host ""
# Check for administrative privileges if installing as service
if ($Service) {
$CurrentUser = [Security.Principal.WindowsIdentity]::GetCurrent()
$Principal = New-Object Security.Principal.WindowsPrincipal($CurrentUser)
$AdminRole = [Security.Principal.WindowsBuiltInRole]::Administrator
if (-not $Principal.IsInRole($AdminRole)) {
Write-ColorOutput "โ Installing as a Windows service requires administrative privileges" $ColorRed
Write-ColorOutput "Please run PowerShell as Administrator and try again" $ColorYellow
exit 1
}
}
Write-ColorOutput "๐ Installation Configuration" $ColorMagenta
Write-ColorOutput "Install Directory: $InstallDir" $ColorGreen
Write-ColorOutput "Server Port: $Port" $ColorGreen
Write-ColorOutput "Install as Service: $(if ($Service) { 'Yes' } else { 'No' })" $ColorGreen
Write-Host ""
# Confirm installation
$Response = Read-Host "Continue with installation? (y/N)"
if ($Response -notmatch "^[Yy]$") {
Write-Host "Installation cancelled."
exit 0
}
Write-ColorOutput "๐ Starting installation..." $ColorYellow
Write-Host ""
try {
# Create installation directory
Write-ColorOutput "๐ Creating installation directory..." $ColorBlue
New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null
New-Item -ItemType Directory -Path "$InstallDir\logs" -Force | Out-Null
# Check if we're in the project directory
if (Test-Path "package.json") {
$PackageJson = Get-Content "package.json" | ConvertFrom-Json
if ($PackageJson.name -eq "mcp-fullstack") {
Write-ColorOutput "๐ฆ Using current directory as source..." $ColorBlue
$SourceDir = Get-Location
} else {
throw "Not in MCP Fullstack project directory"
}
} else {
Write-ColorOutput "๐ฆ Cloning from repository..." $ColorBlue
Write-ColorOutput "โ ๏ธ Note: This script should be updated with the actual repository URL" $ColorYellow
$SourceDir = Get-Location
}
# Copy project files
Write-ColorOutput "๐ Copying project files..." $ColorBlue
# Get all files except excluded ones
$ExcludePatterns = @(
"node_modules",
".git",
"dist",
"dashboard\node_modules",
"dashboard\dist"
)
Get-ChildItem -Path $SourceDir -Recurse | Where-Object {
$relativePath = $_.FullName.Substring($SourceDir.Path.Length + 1)
$exclude = $false
foreach ($pattern in $ExcludePatterns) {
if ($relativePath -like "*$pattern*") {
$exclude = $true
break
}
}
-not $exclude
} | ForEach-Object {
$destPath = Join-Path $InstallDir ($_.FullName.Substring($SourceDir.Path.Length + 1))
$destDir = Split-Path $destPath -Parent
if (-not (Test-Path $destDir)) {
New-Item -ItemType Directory -Path $destDir -Force | Out-Null
}
if (-not $_.PSIsContainer) {
Copy-Item $_.FullName $destPath -Force
}
}
# Navigate to installation directory
Set-Location $InstallDir
# Install dependencies
Write-ColorOutput "๐ฆ Installing dependencies..." $ColorBlue
& npm install --production
if ($LASTEXITCODE -ne 0) { throw "npm install failed" }
# Build the dashboard
Write-ColorOutput "๐๏ธ Building dashboard..." $ColorBlue
Set-Location "dashboard"
& npm install
if ($LASTEXITCODE -ne 0) { throw "Dashboard npm install failed" }
& npm run build
if ($LASTEXITCODE -ne 0) { throw "Dashboard build failed" }
Set-Location ".."
# Build the server
Write-ColorOutput "๐๏ธ Building server..." $ColorBlue
& npm run build
if ($LASTEXITCODE -ne 0) { throw "Server build failed" }
# Create environment file
Write-ColorOutput "โ๏ธ Creating environment configuration..." $ColorBlue
$EnvContent = @"
# MCP Fullstack Configuration
PORT=$Port
HOST=0.0.0.0
LOG_LEVEL=info
# WebDriver (optional - for remote WebDriver)
# WEB_DRIVER_REMOTE_URL=http://selenium-hub:4444/wd/hub
# Supabase (optional)
# SUPABASE_URL=https://your-project.supabase.co
# SUPABASE_SERVICE_ROLE=your-service-role-key
# SUPABASE_ANON=your-anon-key
# External Services (optional)
# RENDER_API_TOKEN=your-render-token
# VERCEL_TOKEN=your-vercel-token
# POSTHOG_API_HOST=https://app.posthog.com
# POSTHOG_PROJECT_KEY=your-project-key
# POSTHOG_PERSONAL_API_KEY=your-personal-api-key
# GEMINI_API_KEY=your-gemini-api-key
"@
$EnvContent | Out-File -FilePath ".env" -Encoding utf8
# Create CLI batch file
Write-ColorOutput "๐ Creating CLI wrapper..." $ColorBlue
$BatchContent = @"
@echo off
node "$InstallDir\dist\cli.js" %*
"@
$BatchContent | Out-File -FilePath "$env:USERPROFILE\mcp-fullstack.bat" -Encoding ascii
# Add to PATH if not already there
$UserPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($UserPath -notlike "*$env:USERPROFILE*") {
[Environment]::SetEnvironmentVariable("Path", "$UserPath;$env:USERPROFILE", "User")
Write-ColorOutput "Added to PATH. Please restart your terminal." $ColorYellow
}
# Install as service if requested
if ($Service) {
Write-ColorOutput "๐ง Installing as Windows service..." $ColorBlue
& node "dist\cli.js" service install --port $Port
if ($LASTEXITCODE -ne 0) { throw "Service installation failed" }
Write-ColorOutput "โถ๏ธ Starting service..." $ColorBlue
& node "dist\cli.js" service start
if ($LASTEXITCODE -ne 0) { throw "Service start failed" }
}
# Check for Chrome
Write-ColorOutput "๐ Checking for Chrome..." $ColorBlue
$ChromePaths = @(
"${env:ProgramFiles}\Google\Chrome\Application\chrome.exe",
"${env:ProgramFiles(x86)}\Google\Chrome\Application\chrome.exe",
"${env:LOCALAPPDATA}\Google\Chrome\Application\chrome.exe"
)
$ChromeFound = $false
foreach ($path in $ChromePaths) {
if (Test-Path $path) {
Write-ColorOutput "โ
Chrome found at: $path" $ColorGreen
$ChromeFound = $true
break
}
}
if (-not $ChromeFound) {
Write-ColorOutput "โ ๏ธ Chrome not found" $ColorYellow
Write-ColorOutput "For browser automation features, please install Google Chrome" $ColorYellow
}
# Installation complete
Write-Host ""
Write-ColorOutput "๐ Installation completed successfully!" $ColorGreen
Write-ColorOutput "=================================" $ColorGreen
Write-Host ""
# Show next steps
Write-ColorOutput "๐ Next Steps:" $ColorMagenta
Write-Host ""
if ($Service) {
Write-ColorOutput "1. Service Management:" $ColorBlue
Write-ColorOutput " โข Check status: mcp-fullstack service status" $ColorGreen
Write-ColorOutput " โข View logs: mcp-fullstack service logs" $ColorGreen
Write-ColorOutput " โข Restart: mcp-fullstack service restart" $ColorGreen
Write-Host ""
Write-ColorOutput "2. Access Dashboard:" $ColorBlue
Write-ColorOutput " โข Open: http://localhost:$Port" $ColorGreen
Write-ColorOutput " โข Install as PWA for standalone window experience" $ColorGreen
Write-Host ""
} else {
Write-ColorOutput "1. Start the server:" $ColorBlue
Write-ColorOutput " โข Run: mcp-fullstack start" $ColorGreen
Write-ColorOutput " โข Or navigate to: $InstallDir and run: npm start" $ColorGreen
Write-Host ""
Write-ColorOutput "2. Install as service (optional):" $ColorBlue
Write-ColorOutput " โข Run as Administrator: mcp-fullstack service install" $ColorGreen
Write-Host ""
Write-ColorOutput "3. Access Dashboard:" $ColorBlue
Write-ColorOutput " โข Open: http://localhost:$Port" $ColorGreen
Write-Host ""
}
Write-ColorOutput "3. Configuration:" $ColorBlue
Write-ColorOutput " โข Edit: $InstallDir\.env" $ColorGreen
Write-ColorOutput " โข Add your API keys for external services" $ColorGreen
Write-Host ""
Write-ColorOutput "4. CLI Commands:" $ColorBlue
Write-ColorOutput " โข Help: mcp-fullstack --help" $ColorGreen
Write-ColorOutput " โข Info: mcp-fullstack info" $ColorGreen
Write-ColorOutput " โข Test: mcp-fullstack test" $ColorGreen
Write-Host ""
Write-ColorOutput "๐ Documentation:" $ColorBlue
Write-ColorOutput " โข README: $InstallDir\README.md" $ColorGreen
Write-ColorOutput " โข Repository: https://github.com/your-repo/mcp-fullstack" $ColorGreen
Write-Host ""
Write-ColorOutput "Happy coding with MCP Fullstack! ๐" $ColorGreen
} catch {
Write-ColorOutput "โ Installation failed: $_" $ColorRed
Write-ColorOutput "Please check the error message above and try again." $ColorYellow
exit 1
}