Files
diodiogod-TTS-Audio-Suite/tests/codex_fl_mcp_server.ps1
diodiogod 517d11ed4c Add DramaBox and ChatterBox V3 support
- Integrate DramaBox with unified TTS and SRT generation, duration targeting, prompt templates, memory strategies, FP8, compile, and silence diagnostics
- Add ChatterBox 23-Lang V3 checkpoint support and artifact handling
- Extend parameter switching, generated-audio caching, tag editor controls, model downloads, and engine registration
- Add user documentation, engine metadata, generated comparison tables, and FL-MCP launcher reliability updates
2026-07-25 11:38:52 -03:00

65 lines
2.4 KiB
PowerShell

$ErrorActionPreference = "Stop"
. (Join-Path $PSScriptRoot "fl_mcp_validation_helpers.ps1")
$settingsPath = Join-Path $PSScriptRoot ".env.local"
if (-not (Test-Path -LiteralPath $settingsPath)) {
throw "Missing tests/.env.local."
}
$settings = Read-DotEnv $settingsPath
$comfyRoot = $settings["TTS_SUITE_TEST_COMFY_ROOT"]
$flRoot = Join-Path $comfyRoot "custom_nodes\ComfyUI_FL-MCP"
$flPython = Join-Path $flRoot ".mcp_venv\Scripts\python.exe"
$mcpServer = Join-Path $flRoot "backend\mcp_server.py"
$backendServer = Join-Path $flRoot "backend\server.py"
$canonicalLauncher = Join-Path $flRoot "codex_mcp_server.cmd"
foreach ($requiredPath in @($flPython, $mcpServer, $backendServer, $canonicalLauncher)) {
if (-not (Test-Path -LiteralPath $requiredPath)) {
throw "Required FL-MCP path not found: $requiredPath"
}
}
$backendHealth = Wait-JsonEndpoint "http://127.0.0.1:8000/health" 2
if (-not $backendHealth) {
$root = Quote-PowerShell $flRoot
$python = Quote-PowerShell $flPython
$command = "`$env:PYTHONUTF8='1'; `$env:PYTHONIOENCODING='utf-8'; Set-Location -LiteralPath $root; & $python 'backend/server.py'"
Start-VisibleTerminal "FL-MCP bridge :8000" $flRoot $command
$backendHealth = Wait-JsonEndpoint "http://127.0.0.1:8000/health" 30
}
if (-not $backendHealth) {
throw "FL-MCP backend did not become ready on port 8000."
}
$sessionLine = Get-Content -LiteralPath $canonicalLauncher |
Where-Object { $_ -match '^set "FL_MCP_SESSION_ID=(.+)"$' } |
Select-Object -First 1
if ($sessionLine -notmatch '^set "FL_MCP_SESSION_ID=(.+)"$') {
throw "FL_MCP_SESSION_ID was not found in $canonicalLauncher."
}
$env:COMFYUI_SERVER_URL = "http://127.0.0.1:8188"
$env:FL_MCP_MODE = "subprocess"
$env:FL_MCP_SESSION_ID = $Matches[1]
$env:FL_MCP_WS_URL = "ws://127.0.0.1:8000/ws"
# Keep the stdio transport owned by this wrapper alive across unexpected MCP
# subprocess exits. Codex can continue using the same task while the child
# reconnects to the bridge.
$restartDelaySeconds = 1
while ($true) {
& $flPython $mcpServer
$mcpExitCode = $LASTEXITCODE
if ($mcpExitCode -eq 0) {
exit 0
}
[Console]::Error.WriteLine(
"FL-MCP stdio server exited with code $mcpExitCode; restarting in $restartDelaySeconds second(s)."
)
Start-Sleep -Seconds $restartDelaySeconds
$restartDelaySeconds = [Math]::Min($restartDelaySeconds * 2, 10)
}