# Barvinca hosted MCP installer for Codex on Windows Set-StrictMode -Version 3.0 $ErrorActionPreference = 'Stop' $ServerName = 'barvinca' $ServerUrl = 'https://mcp.barvinca.com/mcp' $Scopes = if ([string]::IsNullOrWhiteSpace($env:BARVINCA_MCP_SCOPES)) { 'barvinca.read' } else { $env:BARVINCA_MCP_SCOPES } $Codex = Get-Command codex -ErrorAction SilentlyContinue if ($null -eq $Codex) { throw 'Codex CLI was not found. Install or update Codex, sign in, and run this installer again. See https://learn.chatgpt.com/docs/codex' } $AddHelp = (& $Codex.Source mcp add --help 2>&1 | Out-String) if (-not $AddHelp.Contains('--oauth-resource')) { throw 'This Codex version is too old for Barvinca OAuth resource binding. Update Codex and run this installer again.' } Write-Host 'Barvinca MCP installer for Windows' Write-Host "Codex: $($Codex.Source)" Write-Host "Server: $ServerUrl" Write-Host "Scopes: $Scopes" $Existing = (& $Codex.Source mcp get $ServerName --json 2>$null | Out-String) $ExistingExitCode = $LASTEXITCODE if ($ExistingExitCode -eq 0) { if (-not $Existing.Contains($ServerUrl)) { throw "A different Codex MCP server already uses the name $ServerName. Review it with: codex mcp get $ServerName --json" } Write-Host 'The Barvinca endpoint is already configured; keeping the existing entry.' } else { & $Codex.Source mcp add $ServerName --url $ServerUrl --oauth-resource $ServerUrl if ($LASTEXITCODE -ne 0) { throw 'Codex could not add the Barvinca MCP server.' } } Write-Host 'Opening browser authorization...' & $Codex.Source mcp login $ServerName --scopes $Scopes if ($LASTEXITCODE -ne 0) { throw 'Barvinca OAuth login did not complete.' } Write-Host 'Verifying saved configuration...' & $Codex.Source mcp get $ServerName --json if ($LASTEXITCODE -ne 0) { throw 'Codex could not read the saved Barvinca configuration.' } Write-Host 'Barvinca MCP setup is complete. Restart Codex before starting a new task.'