Files
shopdb-flask/.claude/setup/test-mcp-servers.ps1
Proudlock bd48814021 Reorganize repository structure and clean up documentation
Clean up and organize the flask-shopdb repository for better
maintainability and discoverability:

## Changes

- Update .gitignore for build artifacts (publish/, data/, 122M total)
- Reorganize .claude/ into 6 subdirectories with README navigation
- Consolidate overlapping MCP setup guides into MCP-QUICK-START.md
- Move deployment docs from root to docs/deployment/
- Archive dated status reports to .claude/archived/
- Delete temporary files (logs, backups, empty reports, ~50K)

## New Structure

.claude/ organized into:
- setup/ - MCP, VM, Hyper-V, GitHub setup guides + scripts (17 files)
- plans/ - Feature plans and protocols (5 files)
- maintenance/ - Deployment checklists and reports (4 files)
- archived/ - Historical documentation (9 files)
- skills/ - Claude Code automation (5 files)
- workflows/ - Security audit workflow (1 file)

docs/deployment/ created with 6 deployment guides:
- LOCAL-DEV-SETUP.md, DOCKER-SETUP.md, DOCKER-PREBUILT-APPROACH.md
- PRODUCTION-READINESS.md, DEPLOY-TO-VM.md, README.md

Root directory cleaned to essential docs only:
- CLAUDE.md, README.md, CONTRIBUTING.md, CHANGELOG.md

Benefits:
- Clear navigation via README.md in each subdirectory
- No duplicate/overlapping documentation
- Large artifacts properly gitignored (won't bloat repository)
- Historical context preserved in archived/

See .claude/CLEANUP-SUMMARY.md for complete details.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-09-11 15:45:05 -04:00

264 lines
11 KiB
PowerShell

# Test All MCP Servers for ShopDB Development
# Run from flask-shopdb directory to verify all MCP servers are configured and working
#
# Usage:
# .\\.claude\test-mcp-servers.ps1
# .\\.claude\test-mcp-servers.ps1 -Verbose
# .\\.claude\test-mcp-servers.ps1 -SkipVM
param(
[switch]$SkipVM,
[switch]$Verbose
)
$ErrorActionPreference = "Continue"
Write-Host ""
Write-Host "==========================================" -ForegroundColor Cyan
Write-Host "ShopDB MCP Server Test Suite" -ForegroundColor Cyan
Write-Host "==========================================" -ForegroundColor Cyan
Write-Host ""
$results = @{}
$configPath = Join-Path $PSScriptRoot "mcp-servers.json"
# Test 1: Configuration File Exists
Write-Host "[1/7] Checking MCP configuration..." -ForegroundColor Yellow
if (Test-Path $configPath) {
$config = Get-Content $configPath | ConvertFrom-Json
Write-Host " OK: Config file exists at $configPath" -ForegroundColor Green
$results["config"] = $true
} else {
Write-Host " FAIL: Config file not found at $configPath" -ForegroundColor Red
$results["config"] = $false
exit 1
}
# Test 2: Gortex MCP Server
Write-Host "[2/7] Testing Gortex MCP server..." -ForegroundColor Yellow
$gortexPath = "C:\Users\270015376\Documents\gortex.exe"
if (Test-Path $gortexPath) {
try {
$gortexVersion = & $gortexPath --version 2>&1
Write-Host " OK: Gortex found at $gortexPath" -ForegroundColor Green
if ($Verbose) { Write-Host " Version: $gortexVersion" -ForegroundColor Gray }
$results["gortex"] = $true
} catch {
Write-Host " WARN: Gortex found but cannot execute: $($_.Exception.Message)" -ForegroundColor Yellow
$results["gortex"] = $false
}
} else {
Write-Host " FAIL: Gortex not found at $gortexPath" -ForegroundColor Red
Write-Host " Download from: https://github.com/zzet/gortex/releases" -ForegroundColor Yellow
$results["gortex"] = $false
}
# Test 3: MySQL MCP Server (via npx)
Write-Host "[3/7] Testing MySQL MCP server..." -ForegroundColor Yellow
try {
$npxCheck = Get-Command npx -ErrorAction Stop
Write-Host " OK: npx found at $($npxCheck.Source)" -ForegroundColor Green
# Test MySQL connection
$mysqlHost = "127.0.0.1"
$mysqlPort = 3306
$tcp = Test-NetConnection -ComputerName $mysqlHost -Port $mysqlPort -WarningAction SilentlyContinue -InformationLevel Quiet
if ($tcp) {
Write-Host " OK: MySQL server is reachable at ${mysqlHost}:${mysqlPort}" -ForegroundColor Green
$results["mysql"] = $true
} else {
Write-Host " WARN: MySQL server not reachable at ${mysqlHost}:${mysqlPort}" -ForegroundColor Yellow
Write-Host " Start with: docker compose up -d db" -ForegroundColor Yellow
$results["mysql"] = $false
}
} catch {
Write-Host " FAIL: npx not found (Node.js/npm not installed)" -ForegroundColor Red
Write-Host " Install from: https://nodejs.org/" -ForegroundColor Yellow
$results["mysql"] = $false
}
# Test 4: Browser MCP Server (via npx)
Write-Host "[4/7] Testing Browser MCP server..." -ForegroundColor Yellow
if ($npxCheck) {
try {
# Check if package exists
$browserPkg = npm view @agent-infra/mcp-server-browser version 2>&1
if ($LASTEXITCODE -eq 0) {
Write-Host " OK: Browser MCP package exists (version $browserPkg)" -ForegroundColor Green
$results["browser"] = $true
} else {
Write-Host " WARN: Browser MCP package not found in npm registry" -ForegroundColor Yellow
$results["browser"] = $false
}
} catch {
Write-Host " WARN: Cannot verify browser MCP package" -ForegroundColor Yellow
$results["browser"] = $false
}
} else {
Write-Host " SKIP: npx not available" -ForegroundColor Gray
$results["browser"] = $false
}
# Test 5: VM SSH MCP Server
if (-not $SkipVM) {
Write-Host "[5/7] Testing VM SSH MCP server..." -ForegroundColor Yellow
# Check VM connectivity
$vmIP = "192.168.100.10"
$vmUser = "SupportUser"
# Test network connectivity
$ping = Test-Connection -ComputerName $vmIP -Count 1 -Quiet -ErrorAction SilentlyContinue
if ($ping) {
Write-Host " OK: VM is reachable at $vmIP" -ForegroundColor Green
# Check SSH port
$sshPort = Test-NetConnection -ComputerName $vmIP -Port 22 -WarningAction SilentlyContinue -InformationLevel Quiet
if ($sshPort) {
Write-Host " OK: SSH port 22 is open on VM" -ForegroundColor Green
$results["vm"] = $true
} else {
Write-Host " WARN: SSH port 22 is not open on VM" -ForegroundColor Yellow
Write-Host " Run enable-vm-ssh.ps1 on the VM (as Administrator)" -ForegroundColor Yellow
$results["vm"] = $false
}
} else {
Write-Host " FAIL: VM not reachable at $vmIP" -ForegroundColor Red
Write-Host " Check: Hyper-V VM is running" -ForegroundColor Yellow
Write-Host " Check: VM network adapter connected to internal switch" -ForegroundColor Yellow
$results["vm"] = $false
}
# Check ssh-mcp package
if ($npxCheck) {
try {
$sshMcpPkg = npm view ssh-mcp version 2>&1
if ($LASTEXITCODE -eq 0) {
Write-Host " OK: ssh-mcp package available (version $sshMcpPkg)" -ForegroundColor Green
} else {
Write-Host " WARN: ssh-mcp package not found" -ForegroundColor Yellow
}
} catch {
Write-Host " WARN: Cannot verify ssh-mcp package" -ForegroundColor Yellow
}
}
# Note about dual user setup
if ($sshPort) {
Write-Host " INFO: Two VM users configured:" -ForegroundColor Cyan
Write-Host " - SupportUser (admin) for installation/config" -ForegroundColor Gray
Write-Host " - shopfloor (standard user, auto-login) for testing" -ForegroundColor Gray
}
} else {
Write-Host "[5/7] Skipping VM test (use -SkipVM switch)" -ForegroundColor Gray
$results["vm"] = "skipped"
}
# Test 6: Hyper-V Status
Write-Host "[6/7] Checking Hyper-V VMs..." -ForegroundColor Yellow
try {
$vms = Get-VM -ErrorAction Stop
if ($vms.Count -gt 0) {
Write-Host " OK: Found $($vms.Count) VM(s)" -ForegroundColor Green
foreach ($vm in $vms) {
$stateColor = if ($vm.State -eq "Running") { "Green" } else { "Yellow" }
Write-Host " - $($vm.Name): $($vm.State)" -ForegroundColor $stateColor
}
$results["hyperv"] = $true
} else {
Write-Host " INFO: No VMs found" -ForegroundColor Gray
$results["hyperv"] = $true
}
} catch {
Write-Host " INFO: Cannot use PowerShell Hyper-V cmdlets (need Hyper-V Administrators group)" -ForegroundColor Gray
Write-Host " NOTE: VM MCP works via SSH - no admin needed for that!" -ForegroundColor Cyan
Write-Host " TIP: Use Hyper-V Manager GUI to view/manage VMs" -ForegroundColor Gray
if ($Verbose) { Write-Host " Error: $($_.Exception.Message)" -ForegroundColor Gray }
$results["hyperv"] = "no-permission"
}
# Test 7: VM Snapshots
Write-Host "[7/7] Checking VM snapshots..." -ForegroundColor Yellow
try {
$snapshots = Get-VMSnapshot -VMName * -ErrorAction Stop
if ($snapshots.Count -gt 0) {
Write-Host " OK: Found $($snapshots.Count) snapshot(s)" -ForegroundColor Green
foreach ($snap in $snapshots) {
Write-Host " - $($snap.VMName): $($snap.Name) ($(Get-Date $snap.CreationTime -Format 'yyyy-MM-dd HH:mm'))" -ForegroundColor Gray
}
$results["snapshots"] = $true
} else {
Write-Host " INFO: No snapshots found" -ForegroundColor Gray
Write-Host " Create snapshots via Hyper-V Manager GUI (right-click VM -> Checkpoint)" -ForegroundColor Gray
$results["snapshots"] = "none"
}
} catch {
Write-Host " INFO: Cannot use PowerShell snapshot cmdlets (need Hyper-V Administrators group)" -ForegroundColor Gray
Write-Host " TIP: Use Hyper-V Manager GUI to create/restore snapshots" -ForegroundColor Cyan
if ($Verbose) { Write-Host " Error: $($_.Exception.Message)" -ForegroundColor Gray }
$results["snapshots"] = "no-permission"
}
# Summary
Write-Host ""
Write-Host "==========================================" -ForegroundColor Cyan
Write-Host "Summary" -ForegroundColor Cyan
Write-Host "==========================================" -ForegroundColor Cyan
Write-Host ""
$passCount = ($results.Values | Where-Object { $_ -eq $true }).Count
$totalCount = $results.Count
$percentage = [math]::Round(($passCount / $totalCount) * 100)
foreach ($test in $results.Keys) {
$status = $results[$test]
$icon = switch ($status) {
$true { "OK"; "Green" }
$false { "FAIL"; "Red" }
"skipped" { "SKIP"; "Gray" }
"none" { "INFO"; "Yellow" }
"no-permission" { "WARN"; "Yellow" }
default { "UNKNOWN"; "Gray" }
}
Write-Host " $($test.PadRight(15)): $($icon[0])" -ForegroundColor $icon[1]
}
Write-Host ""
Write-Host "Overall: $passCount/$totalCount tests passed ($percentage%)" -ForegroundColor $(if ($percentage -ge 80) { "Green" } elseif ($percentage -ge 50) { "Yellow" } else { "Red" })
Write-Host ""
# Next Steps
if ($passCount -lt $totalCount) {
Write-Host "Next Steps:" -ForegroundColor Yellow
Write-Host ""
if (-not $results["gortex"]) {
Write-Host " 1. Install Gortex:" -ForegroundColor White
Write-Host " curl -L -o gortex_windows_amd64.zip https://github.com/zzet/gortex/releases/latest/download/gortex_windows_amd64.zip" -ForegroundColor Gray
Write-Host " unzip -o gortex_windows_amd64.zip -d C:\Users\270015376\Documents\" -ForegroundColor Gray
Write-Host ""
}
if (-not $results["mysql"]) {
Write-Host " 2. Start MySQL database:" -ForegroundColor White
Write-Host " docker compose up -d db" -ForegroundColor Gray
Write-Host ""
}
if ($results["vm"] -eq $false) {
Write-Host " 3. Configure VM SSH:" -ForegroundColor White
Write-Host " a. Start VM in Hyper-V Manager" -ForegroundColor Gray
Write-Host " b. Run .claude\enable-vm-ssh.ps1 on VM (as Administrator)" -ForegroundColor Gray
Write-Host " c. Test: ssh SupportUser@192.168.100.10" -ForegroundColor Gray
Write-Host ""
}
}
Write-Host "To use MCP servers with Claude Code:" -ForegroundColor Cyan
Write-Host " 1. Run Claude Code from this directory (flask-shopdb)" -ForegroundColor White
Write-Host " 2. MCP servers will auto-load from .claude/mcp-servers.json" -ForegroundColor White
Write-Host " 3. Test by asking Claude to use each server" -ForegroundColor White
Write-Host ""
exit $(if ($passCount -eq $totalCount) { 0 } else { 1 })