18 行
984 B
PowerShell
18 行
984 B
PowerShell
$ErrorActionPreference = 'Stop'
|
|
$mcpPython = 'D:\kicad-mcp\.venv\Scripts\python.exe'
|
|
$kicadCli = 'D:\KiCad\bin\kicad-cli.exe'
|
|
$projectRoot = Split-Path -Parent $PSScriptRoot
|
|
foreach ($requiredPath in @($mcpPython, $kicadCli)) {
|
|
if (-not (Test-Path -LiteralPath $requiredPath)) {
|
|
throw "Required executable missing: $requiredPath"
|
|
}
|
|
}
|
|
Get-Command codex -ErrorAction Stop | Out-Null
|
|
& $mcpPython -B (Join-Path $PSScriptRoot 'verify_kicad_mcp.py')
|
|
if ($LASTEXITCODE -ne 0) { throw 'KiCad MCP verification failed.' }
|
|
& codex mcp add kicad --env "KICAD_CLI=$kicadCli" --env "KICAD_PROJECT_PATHS=$projectRoot" --env 'PYTHONIOENCODING=utf-8' --env 'PYTHONDONTWRITEBYTECODE=1' -- $mcpPython -B -m kicad_mcp_server
|
|
if ($LASTEXITCODE -ne 0) { throw 'Could not register KiCad MCP in Codex.' }
|
|
& codex mcp get kicad
|
|
if ($LASTEXITCODE -ne 0) { throw 'Could not read the registered MCP configuration.' }
|
|
Write-Host 'KiCad MCP registered. Restart Codex and open a new conversation.'
|