master
sh 49 lines 1.14 KB
Raw
1 #!/bin/bash
2 set -e
3
4 # Get the directory where the script is located
5 SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6 cd "$SCRIPT_DIR"
7
8 echo "Working directory: $SCRIPT_DIR"
9
10 # Check if Go is installed
11 if ! command -v go &> /dev/null; then
12 echo "Error: Go is not installed or not in the PATH"
13 echo "Please install Go from https://golang.org/doc/install"
14 exit 1
15 fi
16
17 echo "Go is installed: $(go version)"
18 echo "Creating Go module for Netdata MCP bridge..."
19
20 # Initialize Go module if it doesn't exist
21 if [ ! -f "go.mod" ]; then
22 go mod init netdata/nd-mcp-bridge
23 echo "Initialized new Go module"
24 else
25 echo "Go module already exists"
26 fi
27
28 # Add required dependencies
29 echo "Adding dependencies..."
30 go get github.com/coder/websocket
31 go mod tidy
32
33 # Build the binary
34 echo "Building nd-mcp binary..."
35 go build -o nd-mcp nd-mcp.go
36
37 # Make binary executable
38 chmod +x nd-mcp
39
40 # Get the full path to the executable
41 EXECUTABLE_PATH="$SCRIPT_DIR/nd-mcp"
42
43 echo "Build complete!"
44 echo ""
45 echo "You can now run the bridge using the full path:"
46 echo "$EXECUTABLE_PATH ws://ip:19999/mcp"
47 echo ""
48 echo "Or from this directory:"
49 echo "./nd-mcp ws://ip:19999/mcp"