Skip to content
This repository was archived by the owner on Jan 28, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 147 additions & 0 deletions setup.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
@echo off
setlocal enabledelayedexpansion

REM Colors and formatting (using ASCII codes where possible)
REM Note: Batch doesn't support ANSI colors natively, so we'll use simple text formatting

REM Function to check if command exists
:command_exists
where %1 >nul 2>nul
if %errorlevel% equ 0 (
exit /b 0
) else (
exit /b 1
)

REM Function to display error message for claude
:show_claude_installation_error
echo.
echo Error: 'claude' is not installed!
echo Please follow the documentation at: https://www.anthropic.com/claude-code
echo Summary: Install Node.js and run 'npm install -g @anthropic-ai/claude-code'
echo.
exit /b 1

REM Function to display error message for docker
:show_docker_installation_error
echo.
echo Error: 'docker' is not installed!
echo Please install Docker Desktop from: https://www.docker.com/products/docker-desktop/
echo.
exit /b 1

REM Function to prompt for API token
:prompt_for_api_token
echo.
echo System Initiative API Token Required
echo To get your API token:
echo 1. Go to: https://auth.systeminit.com/workspaces
echo 2. Click the 'gear' icon for your workspace
echo 3. Select 'API Tokens'
echo 4. Name it 'claude code'
echo 5. Generate a new token with 1y expiration
echo 6. Copy the token from the UI
echo.

:token_input_loop
set /p "token=Please paste your API token: "

if "!token!"=="" (
echo Error: Token cannot be empty
goto token_input_loop
)

REM Basic validation - check if token contains dots (JWT format)
echo !token! | findstr /r "^[A-Za-z0-9_-]*\.[A-Za-z0-9_-]*\.[A-Za-z0-9_-]*$" >nul
if %errorlevel% neq 0 (
echo Error: Invalid token format. System Initiative tokens are JWTs
goto token_input_loop
)

set "SI_API_TOKEN=!token!"
echo API token set successfully
exit /b 0

REM Function to create .mcp.json file
:create_mcp_config
setlocal enabledelayedexpansion
set "mcp_file=%~1"

if "!mcp_file!"=="" (
set "mcp_file=%~dp0.mcp.json"
)

echo Creating MCP configuration file

(
echo {
echo "mcpServers": {
echo "system-initiative": {
echo "type": "stdio",
echo "command": "docker",
echo "args": [
echo "run",
echo "-i",
echo "--rm",
echo "--pull=always",
echo "-e",
echo "SI_API_TOKEN",
echo "systeminit/si-mcp-server:stable"
echo ],
echo "env": {
echo "SI_API_TOKEN": "!SI_API_TOKEN!"
echo }
echo }
echo }
echo }
) > "!mcp_file!"

echo Created .mcp.json at: !mcp_file!
endlocal
exit /b 0

REM Main script logic
:main
set "mcp_config_file=%~1"

REM Check if claude is installed
where claude >nul 2>nul
if %errorlevel% neq 0 (
call :show_claude_installation_error
exit /b 1
)
echo Check: claude is installed and available

REM Check if docker is installed
where docker >nul 2>nul
if %errorlevel% neq 0 (
call :show_docker_installation_error
exit /b 1
)
echo Check: docker is installed and available

REM Check if API token is already set in environment
if not "!SI_API_TOKEN!"=="" (
echo Found existing SI_API_TOKEN in environment
set /p "use_existing=Use existing token? (y/n): "

if /i "!use_existing!"=="y" (
echo Using existing SI_API_TOKEN
call :create_mcp_config "!mcp_config_file!"
exit /b 0
)
)

REM Prompt for API token
call :prompt_for_api_token
if %errorlevel% neq 0 (
exit /b 1
)

REM Create MCP configuration file
call :create_mcp_config "!mcp_config_file!"

exit /b 0

REM Execute main function
call :main %*
158 changes: 158 additions & 0 deletions setup.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
#Requires -Version 5.0
Set-StrictMode -Version Latest

# Colors for output
$RED = "`e[0;31m"
$YELLOW = "`e[1;33m"
$GREEN = "`e[0;32m"
$BLUE = "`e[0;34m"
$NC = "`e[0m" # No Color

# Function to check if command exists
function Command-Exists {
param([string]$Command)

try {
if (Get-Command $Command -ErrorAction Stop) {
return $true
}
}
catch {
return $false
}
}

# Function to display error message for claude
function Show-ClaudeInstallationError {
Write-Host "${RED}❌ Error: 'claude' is not installed!${NC}" -ForegroundColor Red
Write-Host "${YELLOW}📖 Please follow the documentation at: https://www.anthropic.com/claude-code${NC}" -ForegroundColor Yellow
Write-Host "${YELLOW}💡 Summary: Install Node.js and run 'npm install -g @anthropic-ai/claude-code'${NC}" -ForegroundColor Yellow
}

# Function to display error message for docker
function Show-DockerInstallationError {
Write-Host "${RED}❌ Error: 'docker' is not installed!${NC}" -ForegroundColor Red
Write-Host "${YELLOW}🐳 Please install Docker Desktop from: https://www.docker.com/products/docker-desktop/${NC}" -ForegroundColor Yellow
}

# Function to prompt for API token
function Prompt-ForApiToken {
Write-Host ""
Write-Host "${BLUE}🔑 System Initiative API Token Required${NC}" -ForegroundColor Cyan
Write-Host "${YELLOW}To get your API token:${NC}" -ForegroundColor Yellow
Write-Host "${YELLOW}1. Go to: https://auth.systeminit.com/workspaces${NC}" -ForegroundColor Yellow
Write-Host "${YELLOW}2. Click the 'gear' icon for your workspace${NC}" -ForegroundColor Yellow
Write-Host "${YELLOW}3. Select 'API Tokens'${NC}" -ForegroundColor Yellow
Write-Host "${YELLOW}4. Name it 'claude code'${NC}" -ForegroundColor Yellow
Write-Host "${YELLOW}5. Generate a new token with 1y expiration${NC}" -ForegroundColor Yellow
Write-Host "${YELLOW}6. Copy the token from the UI${NC}" -ForegroundColor Yellow
Write-Host ""

$token = ""
while ($true) {
Write-Host "${BLUE}Please paste your API token:${NC}" -ForegroundColor Cyan
$token = Read-Host -AsSecureString
$token = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToCoTaskMemUnicode($token))

if ([string]::IsNullOrWhiteSpace($token)) {
Write-Host "${RED}❌ Token cannot be empty${NC}" -ForegroundColor Red
continue
}

# Basic JWT format validation (three base64 parts separated by dots)
if ($token -match '^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$') {
Set-Item -Path "env:SI_API_TOKEN" -Value $token
Write-Host "${GREEN}✅ API token set successfully${NC}" -ForegroundColor Green
break
}
else {
Write-Host "${RED}❌ Invalid token format. System Initiative tokens are JWTs${NC}" -ForegroundColor Red
}
}
}

# Function to create .mcp.json file
function Create-McpConfig {
param(
[string]$McpFile = ""
)

if ([string]::IsNullOrWhiteSpace($McpFile)) {
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$McpFile = Join-Path $scriptDir ".mcp.json"
}

Write-Host "${BLUE}📄 Creating MCP configuration file${NC}" -ForegroundColor Cyan

$apiToken = $env:SI_API_TOKEN
if ([string]::IsNullOrWhiteSpace($apiToken)) {
$apiToken = ""
}

$mcpConfig = @{
mcpServers = @{
"system-initiative" = @{
type = "stdio"
command = "docker"
args = @(
"run",
"-i",
"--rm",
"--pull=always",
"-e",
"SI_API_TOKEN",
"systeminit/si-mcp-server:stable"
)
env = @{
SI_API_TOKEN = $apiToken
}
}
}
} | ConvertTo-Json -Depth 10

$mcpConfig | Out-File -FilePath $McpFile -Encoding UTF8 -Force

Write-Host "${GREEN}✅ Created .mcp.json at: $McpFile${NC}" -ForegroundColor Green
}

# Main script logic
function Main {
param(
[string]$McpConfigFile = ""
)

# Check if claude is installed
if (-not (Command-Exists "claude")) {
Show-ClaudeInstallationError
exit 1
}
Write-Host "✅ claude is installed and available" -ForegroundColor Green

# Check if docker is installed
if (-not (Command-Exists "docker")) {
Show-DockerInstallationError
exit 1
}
Write-Host "✅ docker is installed and available" -ForegroundColor Green

# Check if API token is already set in environment
if (-not [string]::IsNullOrWhiteSpace($env:SI_API_TOKEN)) {
Write-Host "${GREEN}🔑 Found existing SI_API_TOKEN in environment${NC}" -ForegroundColor Green
$useExisting = Read-Host "${BLUE}Use existing token? (y/n)${NC}"

if ($useExisting -match '^[Yy]$') {
Write-Host "✅ Using existing SI_API_TOKEN" -ForegroundColor Green
Create-McpConfig -McpFile $McpConfigFile
return
}
}

# Prompt for API token
Prompt-ForApiToken

# Create MCP configuration file
Create-McpConfig -McpFile $McpConfigFile
}

# Execute main function
Main @args