| 1 | # Publish Release (win-x64, self-contained) and mirror to a fixed path for Cursor MCP. |
| 2 | # Run from repo: cd ...\agent-notes-mcp ; .\publish-and-deploy.ps1 |
| 3 | # Optional: -Target "D:\agent-notes-mcp" |
| 4 | [CmdletBinding()] |
| 5 | param( |
| 6 | [string] $Target = "D:\agent-notes-mcp" |
| 7 | ) |
| 8 | |
| 9 | $ErrorActionPreference = "Stop" |
| 10 | $here = $PSScriptRoot |
| 11 | $csproj = Join-Path $here "AgentNotesMcp.csproj" |
| 12 | if (-not (Test-Path -LiteralPath $csproj)) { |
| 13 | Write-Error "AgentNotesMcp.csproj not found. Run this script from the agent-notes-mcp directory (PSScriptRoot=$here)." |
| 14 | exit 1 |
| 15 | } |
| 16 | |
| 17 | Push-Location $here |
| 18 | try { |
| 19 | # Keep docs/manifests in sync with ToolCatalog. |
| 20 | & dotnet run --project (Join-Path $here "tools\\ExportMcpManifest\\ExportMcpManifest.csproj") -- --write | Out-Null |
| 21 | if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } |
| 22 | |
| 23 | # Prefer local tool (repo-pinned), but global install works too. |
| 24 | if (Test-Path -LiteralPath (Join-Path $here ".config\\dotnet-tools.json")) { |
| 25 | & dotnet tool restore | Out-Null |
| 26 | & dotnet aid-publish -Project $csproj -Target $Target -Runtime "win-x64" -Configuration "Release" -SelfContained -KillRunning |
| 27 | } else { |
| 28 | & aid-publish -Project $csproj -Target $Target -Runtime "win-x64" -Configuration "Release" -SelfContained -KillRunning |
| 29 | } |
| 30 | if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } |
| 31 | |
| 32 | $configSrc = Join-Path $here "config\agent-notes-mcp.toml" |
| 33 | if (-not (Test-Path -LiteralPath $configSrc)) { |
| 34 | Write-Error "Missing config template: $configSrc" |
| 35 | exit 1 |
| 36 | } |
| 37 | $configDst = Join-Path $Target "agent-notes-mcp.toml" |
| 38 | Copy-Item -LiteralPath $configSrc -Destination $configDst -Force |
| 39 | |
| 40 | $exe = Join-Path $Target "AgentNotesMcp.exe" |
| 41 | $exeJson = $exe.Replace('\', '\\') |
| 42 | $configJson = $configDst.Replace('\', '/') |
| 43 | Write-Host "" |
| 44 | Write-Host "Config: $configDst" |
| 45 | Write-Host "" |
| 46 | Write-Host "Cursor MCP: paste into mcp.json ->" |
| 47 | Write-Host @" |
| 48 | "agent-notes": { |
| 49 | "command": "$exeJson", |
| 50 | "args": ["--config", "$configJson"], |
| 51 | "env": {} |
| 52 | } |
| 53 | "@ |
| 54 | Write-Host "" |
| 55 | } finally { |
| 56 | Pop-Location |
| 57 | } |
| 58 | |
| 59 | |