Initial commit
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
$envFile = Join-Path (Split-Path -Parent $PSScriptRoot) 'gitea.env'
|
||||
if (-not (Test-Path -LiteralPath $envFile -PathType Leaf)) {
|
||||
throw "Gitea MCP configuration file not found: $envFile"
|
||||
}
|
||||
|
||||
$values = @{}
|
||||
foreach ($rawLine in Get-Content -LiteralPath $envFile) {
|
||||
$line = $rawLine.Trim()
|
||||
if (-not $line -or $line.StartsWith('#')) {
|
||||
continue
|
||||
}
|
||||
|
||||
$parts = $line -split '=', 2
|
||||
if ($parts.Count -ne 2) {
|
||||
throw "Invalid line in $envFile. Use KEY=VALUE format."
|
||||
}
|
||||
|
||||
$values[$parts[0].Trim()] = $parts[1].Trim()
|
||||
}
|
||||
|
||||
foreach ($name in @('GITEA_URL', 'GITEA_TOKEN')) {
|
||||
if (-not $values.ContainsKey($name) -or [string]::IsNullOrWhiteSpace($values[$name])) {
|
||||
throw "$name is missing or empty in $envFile"
|
||||
}
|
||||
Set-Item -Path "Env:$name" -Value $values[$name]
|
||||
}
|
||||
|
||||
# This self-hosted Gitea instance must not be sent through the system SOCKS proxy.
|
||||
$noProxyHost = 'ilaer.eicp.net'
|
||||
$existingNoProxy = @($env:NO_PROXY, $env:no_proxy) |
|
||||
Where-Object { -not [string]::IsNullOrWhiteSpace($_) } |
|
||||
Select-Object -First 1
|
||||
$noProxyEntries = @($existingNoProxy -split ',' | ForEach-Object { $_.Trim() } | Where-Object { $_ })
|
||||
if ($noProxyEntries -notcontains $noProxyHost) {
|
||||
$noProxyEntries += $noProxyHost
|
||||
}
|
||||
$env:NO_PROXY = $noProxyEntries -join ','
|
||||
$env:no_proxy = $env:NO_PROXY
|
||||
|
||||
# httpx initializes configured SOCKS transports before evaluating NO_PROXY.
|
||||
# Clear proxy variables only for this MCP child process so it connects directly.
|
||||
foreach ($proxyVariable in @('ALL_PROXY', 'all_proxy', 'HTTP_PROXY', 'http_proxy', 'HTTPS_PROXY', 'https_proxy')) {
|
||||
Remove-Item -Path "Env:$proxyVariable" -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
# Run the locally maintained build so custom Wiki tools are not replaced by
|
||||
# uvx resolving the latest published package on the next process start.
|
||||
$giteaMcpExecutable = 'D:\chengma\gitea-mcp\.venv\Scripts\gitea-mcp.exe'
|
||||
if (-not (Test-Path -LiteralPath $giteaMcpExecutable -PathType Leaf)) {
|
||||
throw "Local Gitea MCP executable not found: $giteaMcpExecutable"
|
||||
}
|
||||
|
||||
# Keep stdout exclusively for MCP JSON-RPC. FastMCP diagnostics are noisy on stderr.
|
||||
& $giteaMcpExecutable 2>> (Join-Path $PSScriptRoot ("gitea-mcp-$PID.stderr.log"))
|
||||
exit $LASTEXITCODE
|
||||
Reference in New Issue
Block a user