# Mineralis MCP bridge installer for PowerShell. Fetches the bridge from the service that # serves this script, installs its one dependency, and registers it with your MCP client. # # Usage: irm https://mineralis.digiearth.com.au/mineralis-mcp/install.ps1 | iex # $env:MINERALIS_API_TOKEN = 'mrl_...'; irm https://mineralis.digiearth.com.au/mineralis-mcp/install.ps1 | iex # # It creates one directory, runs npm install inside it, and - if the claude CLI is on your # PATH - registers the server with it. Your API token is never written to a file by this # script. # # No execution policy change is needed. Nothing here loads a .ps1 file from disk: npm and # claude are called through their .cmd or .exe shims, because a Restricted or AllSigned # policy refuses the .ps1 shim PowerShell would otherwise pick first. $ErrorActionPreference = 'Stop' $base = if ($env:MINERALIS_MCP_BASE) { $env:MINERALIS_MCP_BASE } else { 'https://mineralis.digiearth.com.au/mineralis-mcp/' } $dir = if ($env:MINERALIS_MCP_DIR) { $env:MINERALIS_MCP_DIR } else { Join-Path $HOME '.mineralis-mcp' } # The first shim for a command that is not itself a PowerShell script, so no execution # policy can refuse it. Get-Command on a bare name would hand back npm.ps1 or claude.ps1. function Find-NativeCommand([string] $name) { foreach ($candidate in @("$name.cmd", "$name.exe", "$name.bat", $name)) { $found = @(Get-Command $candidate -CommandType Application -ErrorAction SilentlyContinue) if ($found.Count -gt 0) { return $found[0].Source } } return $null } Write-Host "Installing the Mineralis MCP bridge into $dir" New-Item -ItemType Directory -Force -Path (Join-Path $dir 'src') | Out-Null $files = @('package.json','package-lock.json','README.md','AGENT_GUIDE.md','example_input.csv','src/server.mjs','src/tools.mjs','src/mineralis.mjs','src/packet.mjs','src/catalog.mjs','src/catalog.json','src/constants.mjs','src/summary.mjs') foreach ($file in $files) { Write-Host " $file" Invoke-WebRequest -Uri ($base + $file) -OutFile (Join-Path $dir $file) -UseBasicParsing } $nodeExe = Find-NativeCommand 'node' if (-not $nodeExe) { throw "Node 20 or newer is required and 'node' was not found on your PATH." } $npmExe = Find-NativeCommand 'npm' if (-not $npmExe) { throw "npm was not found on your PATH. It installs with Node; if Node has just been installed, open a new PowerShell window so the PATH is picked up and run this again." } Write-Host 'Installing dependencies with npm' # npm writes its warnings to stderr, which a 'Stop' preference can turn into a failure of its # own; a native command's exit code is the only honest signal either way. $strict = $ErrorActionPreference $ErrorActionPreference = 'Continue' Push-Location $dir try { & $npmExe install --omit=dev --no-audit --no-fund } finally { Pop-Location; $ErrorActionPreference = $strict } if ($LASTEXITCODE -ne 0) { throw "npm install failed in $dir with exit code $LASTEXITCODE. Fix what it reported and run this installer again - the downloaded files are already in place." } $server = Join-Path (Join-Path $dir 'src') 'server.mjs' $claudeExe = Find-NativeCommand 'claude' Write-Host '' if ($env:MINERALIS_API_TOKEN -and $claudeExe) { Write-Host 'Registering with Claude Code' $ErrorActionPreference = 'Continue' & $claudeExe mcp add mineralis --env "MINERALIS_API_TOKEN=$env:MINERALIS_API_TOKEN" -- $nodeExe $server $registration = $LASTEXITCODE $ErrorActionPreference = $strict if ($registration -eq 0) { Write-Host 'Done. Check it with /mcp inside Claude Code; the tools appear as mineralis_*.' return } Write-Host "claude mcp add exited with code $registration, so register it by hand:" } else { Write-Host 'Installed. To register it, run this with your own API credential:' } Write-Host '' Write-Host " claude mcp add mineralis --env MINERALIS_API_TOKEN=YOUR_TOKEN -- node $server" Write-Host '' Write-Host 'If PowerShell answers that claude.ps1 cannot be loaded because running scripts is' Write-Host 'disabled, type claude.cmd instead of claude: the .cmd shim is not a script, so the' Write-Host 'execution policy does not apply to it.' Write-Host '' Write-Host 'For Claude Desktop, Cursor or VS Code, add this to the client''s MCP config:' $json = @{ mcpServers = @{ mineralis = @{ command = 'node'; args = @($server); env = @{ MINERALIS_API_TOKEN = 'YOUR_TOKEN' } } } } $json | ConvertTo-Json -Depth 6 | Write-Host Write-Host '' Write-Host 'Create the credential on the Claude / Codex / Grok Integration tab of the dashboard. Give it the billing' Write-Host 'scope if the agent should read your balance or buy tokens.'