# Digital Ocean MCP Server Setup Script for Claude Code
# Run this script to add the Digital Ocean MCP server

Write-Host "===========================================================" -ForegroundColor Cyan
Write-Host "  Digital Ocean MCP Server Setup for Claude Code" -ForegroundColor Cyan
Write-Host "===========================================================" -ForegroundColor Cyan
Write-Host ""

# Set the API token as environment variable
$env:DIGITALOCEAN_API_TOKEN = "dop_v1_8bb780b3b00b9f0a4858e0e37130ca48e4220f7c9de256e06128c55080edd248"

Write-Host "[OK] Digital Ocean API token set" -ForegroundColor Green
Write-Host ""

# Add the MCP server using the claude CLI
Write-Host "Adding Digital Ocean MCP server..." -ForegroundColor Yellow
Write-Host ""

# Try to find the claude command
$claudeCommand = Get-Command claude -ErrorAction SilentlyContinue

if ($claudeCommand) {
    Write-Host "Found Claude CLI at: $($claudeCommand.Source)" -ForegroundColor Green

    # Add the Digital Ocean MCP server
    $addCommand = "claude mcp add digitalocean --env DIGITALOCEAN_API_TOKEN=$env:DIGITALOCEAN_API_TOKEN -- npx -y @digitalocean/mcp --services apps,databases,droplets,networking"
    Write-Host "Running: $addCommand" -ForegroundColor Gray

    Invoke-Expression $addCommand

    if ($LASTEXITCODE -eq 0) {
        Write-Host ""
        Write-Host "[OK] Digital Ocean MCP server added successfully!" -ForegroundColor Green
    }
    else {
        Write-Host ""
        Write-Host "[FAIL] Failed to add MCP server. Exit code: $LASTEXITCODE" -ForegroundColor Red
    }
}
else {
    Write-Host "[INFO] Claude CLI command not found in PATH" -ForegroundColor Yellow
    Write-Host ""
    Write-Host "MANUAL SETUP REQUIRED:" -ForegroundColor Yellow
    Write-Host "------------------------------------------------------" -ForegroundColor Gray
    Write-Host ""
    Write-Host "Run this command in your terminal:" -ForegroundColor White
    Write-Host ""
    Write-Host 'claude mcp add digitalocean --env DIGITALOCEAN_API_TOKEN=dop_v1_8bb780b3b00b9f0a4858e0e37130ca48e4220f7c9de256e06128c55080edd248 -- npx -y @digitalocean/mcp --services apps,databases,droplets,networking' -ForegroundColor Cyan
    Write-Host ""
    Write-Host "Or use VS Code Command Palette (Ctrl+Shift+P):" -ForegroundColor White
    Write-Host "  1. Type: Claude Code: Add MCP Server" -ForegroundColor Gray
    Write-Host "  2. Name: digitalocean" -ForegroundColor Gray
    Write-Host "  3. Command: npx @digitalocean/mcp --services apps,databases,droplets,networking" -ForegroundColor Gray
    Write-Host "  4. Env var: DIGITALOCEAN_API_TOKEN=dop_v1_8bb780b3b00b9f0a4858e0e37130ca48e4220f7c9de256e06128c55080edd248" -ForegroundColor Gray
    Write-Host ""
    Write-Host "For more help: https://www.digitalocean.com/community/tutorials/claude-code-mcp-server" -ForegroundColor Blue
}

Write-Host ""
Write-Host "===========================================================" -ForegroundColor Cyan
