INNER CODE UNIT · TypeScript
$response
AmrDab/clawdcursor · src/surface/cli.ts:1000
$response = Invoke-RestMethod -Uri http://127.0.0.1:${opts.port}/mcp -Method POST -Headers $headers -Body $body
if ($response.error) {
Write-Host ("MCP error: " + ($response.error.message)) -ForegroundColor Red
} elseif ($response.result -and $response.result.content) {
foreach ($block in $response.result.content) {
if ($block.type -eq 'text') { Write-Host $block.text }
}
} else {
$response | ConvertTo-Json -Depth 5
}
} catch {
if ($_.Exception.Response) {
$code = [int]$_.Exception.Response.StatusCode
if ($code -eq 401) {
Write-Host 'Auth failed (401). Token mismatch. Run: clawdcursor stop then clawdcursor agent' -ForegroundColor Red
} else {
Write-Host "Server error ($code). Check server logs." -ForegroundColor Red
}