# Test MCP initialization with proper headers
Write-Host "Testing SQLx MCP Server with proper MCP protocol" -ForegroundColor Green
# Calculate content length
$jsonContent = @'
{
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {
"protocolVersion": "2024-11-05",
"capabilities": {},
"clientInfo": {
"name": "test-client",
"version": "1.0.0"
}
}
}
'@
$contentLength = [System.Text.Encoding]::UTF8.GetByteCount($jsonContent)
$mcpMessage = "Content-Length: $contentLength`r`n`r`n$jsonContent"
Write-Host "=== Test 1: No database configuration ===" -ForegroundColor Yellow
$mcpMessage | & ".\target\release\sqlx-mcp.exe"
Write-Host "`n=== Test 2: With DATABASE_URL environment variable ===" -ForegroundColor Yellow
$env:DATABASE_URL = "postgresql://test_user:test_password@localhost:15432/test_db"
$mcpMessage | & ".\target\release\sqlx-mcp.exe"
Write-Host "`n=== Test 3: With command line argument ===" -ForegroundColor Yellow
Remove-Item env:DATABASE_URL -ErrorAction SilentlyContinue
$mcpMessage | & ".\target\release\sqlx-mcp.exe" --database-url "mysql://root:rootpass@localhost:13306/testdb"
Write-Host "`nTesting completed!" -ForegroundColor Green