-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStartMcp.ps1
More file actions
53 lines (44 loc) · 1.86 KB
/
StartMcp.ps1
File metadata and controls
53 lines (44 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# StartMcp.ps1 - Builds and runs the MCP Approval Server from a temp folder to avoid file locks
param(
[switch]$NoBuild,
[switch]$Debug
)
$ErrorActionPreference = "Stop"
$projectPath = "$PSScriptRoot\src\PostSharp.Engineering.McpApprovalServer\PostSharp.Engineering.McpApprovalServer.csproj"
$outputPath = "$PSScriptRoot\src\PostSharp.Engineering.McpApprovalServer\bin\Debug\net8.0-windows"
$tempPath = "$env:LOCALAPPDATA\PostSharp\McpApprovalServer\bin"
$exeName = "PostSharp.Engineering.McpApprovalServer.exe"
# Kill any running instance
$existingProcess = Get-Process -Name "PostSharp.Engineering.McpApprovalServer" -ErrorAction SilentlyContinue
if ($existingProcess) {
Write-Host "Stopping existing MCP server process..." -ForegroundColor Yellow
$existingProcess | Stop-Process -Force
Start-Sleep -Milliseconds 500
}
# Build unless -NoBuild is specified
if (-not $NoBuild) {
Write-Host "Building MCP Approval Server..." -ForegroundColor Cyan
$buildArgs = @("build", $projectPath, "-c", "Debug")
if (-not $Debug) {
$buildArgs += "-v:q"
}
& dotnet @buildArgs
if ($LASTEXITCODE -ne 0) {
Write-Host "Build failed!" -ForegroundColor Red
exit 1
}
Write-Host "Build succeeded." -ForegroundColor Green
}
# Ensure temp directory exists
if (-not (Test-Path $tempPath)) {
New-Item -ItemType Directory -Path $tempPath -Force | Out-Null
}
# Copy all files to temp folder
Write-Host "Copying to $tempPath..." -ForegroundColor Cyan
Copy-Item -Path "$outputPath\*" -Destination $tempPath -Recurse -Force
# Start the server
$exePath = Join-Path $tempPath $exeName
Write-Host "Starting MCP server from $exePath..." -ForegroundColor Cyan
Start-Process -FilePath $exePath
Write-Host "MCP Approval Server started." -ForegroundColor Green
Write-Host "Logs: $env:LOCALAPPDATA\PostSharp\McpApprovalServer\audit\" -ForegroundColor Gray