guohanghui/graph-theory
0
1cd $PSScriptRoot2 3$ErrorActionPreference = "Stop"4 5$entryName = if ($env:MCP_ENTRY_NAME) { $env:MCP_ENTRY_NAME } else { "graph-theory" }6$entryUrl = if ($env:MCP_ENTRY_URL) { $env:MCP_ENTRY_URL } else { "http://localhost:7860/mcp" }7$imageName = if ($env:MCP_IMAGE_NAME) { $env:MCP_IMAGE_NAME } else { "graph-theory-mcp" }8 9$mcpDir = Join-Path $env:USERPROFILE ".cursor"10$mcpPath = Join-Path $mcpDir "mcp.json"11if (!(Test-Path $mcpDir)) { New-Item -ItemType Directory -Path $mcpDir | Out-Null }12 13$config = @{}14if (Test-Path $mcpPath) {15 try { $config = Get-Content $mcpPath -Raw | ConvertFrom-Json } catch { $config = @{} }16}17 18# Rebuild mcpServers as ordered and append the entry last19$serversOrdered = [ordered]@{}20if ($config -and ($config.PSObject.Properties.Name -contains "mcpServers") -and $config.mcpServers) {21 $existing = $config.mcpServers22 if ($existing -is [pscustomobject]) {23 foreach ($p in $existing.PSObject.Properties) { if ($p.Name -ne $entryName) { $serversOrdered[$p.Name] = $p.Value } }24 } elseif ($existing -is [System.Collections.IDictionary]) {25 foreach ($k in $existing.Keys) { if ($k -ne $entryName) { $serversOrdered[$k] = $existing[$k] } }26 }27}28$serversOrdered[$entryName] = @{ url = $entryUrl }29$config = @{ mcpServers = $serversOrdered }30 31$config | ConvertTo-Json -Depth 10 | Set-Content -Path $mcpPath -Encoding UTF832Write-Host ("Updated $entryName in " + $mcpPath + " -> " + $entryUrl)33 34docker build -t $imageName .35docker run --rm -p 7860:7860 $imageName36 