Forge
powershellf583a481
1# Publish Release (win-x64, self-contained) and mirror to a fixed path for Cursor MCP.
2# Run from repo: cd ...\AIGuiders.SampleMcp ; .\publish-and-deploy.ps1
3# Optional: -Target "D:\sample-mcp"
4[CmdletBinding()]
5param(
6 [string] $Target = "D:\sample-mcp"
7)
8
9$ErrorActionPreference = "Stop"
10$here = $PSScriptRoot
11$csproj = Join-Path $here "AIGuiders.SampleMcp.csproj"
12if (-not (Test-Path -LiteralPath $csproj)) {
13 Write-Error "AIGuiders.SampleMcp.csproj not found. Run this script from the MCP directory (PSScriptRoot=$here)."
14 exit 1
15}
16
17Push-Location $here
18try {
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 $outDir = Join-Path $here "publish"
24 $publishArgs = @(
25 "publish", $csproj,
26 "-c", "Release",
27 "-r", "win-x64",
28 "-o", $outDir,
29 "-v", "minimal"
30 )
31
32 & dotnet @publishArgs
33 if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
34
35 if (-not (Test-Path -LiteralPath $Target)) {
36 New-Item -ItemType Directory -Path $Target -Force | Out-Null
37 }
38
39 robocopy $outDir $Target /E /MIR /NFL /NDL /NJH /NJS /R:2 /W:1 | Out-Null
40 $robocode = $LASTEXITCODE
41 if ($robocode -ge 8) {
42 Write-Error "robocopy failed with exit code $robocode"
43 exit $robocode
44 }
45
46 $exe = Join-Path $Target "AIGuiders.SampleMcp.exe"
47 if (-not (Test-Path -LiteralPath $exe)) {
48 Write-Error "Expected exe not found: $exe"
49 exit 1
50 }
51
52 $ts = (Get-Item -LiteralPath $exe).LastWriteTimeUtc.ToString("o")
53 $exeJson = $exe.Replace('\', '\\')
54 Write-Host ""
55 Write-Host "OK: $exe (UTC $ts)"
56 Write-Host ""
57 Write-Host "Cursor MCP: paste into mcp.json ->"
58 Write-Host @"
59 "sample-mcp": {
60 "command": "$exeJson",
61 "args": []
62 }
63"@
64 Write-Host ""
65} finally {
66 Pop-Location
67}
68
69
View only · write via MCP/CIDE