Files
2026-06-24 09:13:18 +08:00

43 lines
1.0 KiB
PowerShell

param(
[string]$ConfigPath = "$PSScriptRoot\..\..\..\.cursorrules-mcp.json"
)
$ErrorActionPreference = "Stop"
$resolvedConfig = Resolve-Path -LiteralPath $ConfigPath
$config = Get-Content -Raw -LiteralPath $resolvedConfig | ConvertFrom-Json
$serverConfig = $config.mcpServers.mssql
if (-not $serverConfig) {
throw "Cannot find mcpServers.mssql in $resolvedConfig"
}
foreach ($property in $serverConfig.env.PSObject.Properties) {
[Environment]::SetEnvironmentVariable($property.Name, [string]$property.Value, "Process")
}
if (-not $env:ENABLE_DDL) {
$env:ENABLE_DDL = "true"
}
if (-not $env:MAX_ROWS) {
$env:MAX_ROWS = "1000"
}
if (-not $env:MAX_WRITE_ROWS) {
$env:MAX_WRITE_ROWS = "100"
}
$entry = Join-Path $PSScriptRoot "dist\index.js"
if (-not (Test-Path -LiteralPath $entry)) {
throw "MCP server is not built. Run npm install and npm run build in $PSScriptRoot first."
}
$nodeExe = $env:NODE_EXE
if (-not $nodeExe) {
$nodeExe = (Get-Command node -ErrorAction Stop).Source
}
& $nodeExe $entry @args
exit $LASTEXITCODE