| 1 | @echo off |
| 2 | setlocal enabledelayedexpansion |
| 3 | |
| 4 | REM Get the directory where the batch file is located |
| 5 | set "SCRIPT_DIR=%~dp0" |
| 6 | cd /d "%SCRIPT_DIR%" |
| 7 | |
| 8 | echo Working directory: %SCRIPT_DIR% |
| 9 | |
| 10 | REM Check if Go is installed |
| 11 | go version >nul 2>&1 |
| 12 | if !errorlevel! neq 0 ( |
| 13 | echo Error: Go is not installed or not in the PATH |
| 14 | echo Please install Go from https://golang.org/doc/install |
| 15 | echo. |
| 16 | echo After installation, make sure to: |
| 17 | echo 1. Restart your command prompt |
| 18 | echo 2. Verify Go is in your PATH by running: go version |
| 19 | pause |
| 20 | exit /b 1 |
| 21 | ) |
| 22 | |
| 23 | echo Go is installed: |
| 24 | go version |
| 25 | echo Creating Go module for Netdata MCP bridge... |
| 26 | |
| 27 | REM Initialize Go module if it doesn't exist |
| 28 | if not exist "go.mod" ( |
| 29 | go mod init netdata/nd-mcp-bridge |
| 30 | echo Initialized new Go module |
| 31 | ) else ( |
| 32 | echo Go module already exists |
| 33 | ) |
| 34 | |
| 35 | REM Add required dependencies |
| 36 | echo Adding dependencies... |
| 37 | go get github.com/coder/websocket |
| 38 | go mod tidy |
| 39 | |
| 40 | REM Build the binary |
| 41 | echo Building nd-mcp.exe binary... |
| 42 | go build -o nd-mcp.exe nd-mcp.go |
| 43 | |
| 44 | if !errorlevel! neq 0 ( |
| 45 | echo Build failed! |
| 46 | pause |
| 47 | exit /b 1 |
| 48 | ) |
| 49 | |
| 50 | REM Get the full path to the executable |
| 51 | set "EXECUTABLE_PATH=%SCRIPT_DIR%nd-mcp.exe" |
| 52 | |
| 53 | echo. |
| 54 | echo Build complete! |
| 55 | echo. |
| 56 | echo You can now run the bridge using the full path: |
| 57 | echo "%EXECUTABLE_PATH%" ws://ip:19999/mcp |
| 58 | echo. |
| 59 | echo Or from this directory: |
| 60 | echo nd-mcp.exe ws://ip:19999/mcp |
| 61 | echo. |
| 62 | echo Example usage: |
| 63 | echo nd-mcp.exe ws://localhost:19999/mcp |
| 64 | echo nd-mcp.exe ws://192.168.1.100:19999/mcp |
| 65 | echo. |
| 66 | pause |