-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
Β·149 lines (125 loc) Β· 4.44 KB
/
install.sh
File metadata and controls
executable file
Β·149 lines (125 loc) Β· 4.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/bin/bash
# MCP Server for Claude - Installation Script
# https://github.com/hylmithecoder/mcp-cpp-claude
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
VERSION="release-0.3-stable"
REPO="hylmithecoder/mcp-cpp-claude"
BASE_URL="https://github.com/$REPO/releases/download/$VERSION"
echo -e "${BLUE}---------------------------------------${NC}"
echo -e "${BLUE} π₯οΈ MCP C++ Server Installation ${NC}"
echo -e "${BLUE}---------------------------------------${NC}"
# Detect OS and Architecture
OS="$(uname -s)"
ARCH="$(uname -m)"
IS_ANDROID=false
if [[ "$OS" == "Linux" ]] && [[ "$(uname -o 2>/dev/null)" == "Android" ]]; then
IS_ANDROID=true
echo -e "${YELLOW}π± Android (Termux) detected.${NC}"
fi
BINARY_NAME="mcp"
DOWNLOAD_URL=""
if [[ "$OS" == "Darwin" ]]; then
if [[ "$ARCH" == "arm64" ]]; then
DOWNLOAD_URL="$BASE_URL/mcp-mac-arm64"
else
DOWNLOAD_URL="$BASE_URL/mcp-mac-x86_64"
fi
elif [[ "$IS_ANDROID" == true ]]; then
if [[ "$ARCH" == "aarch64" ]]; then
DOWNLOAD_URL="$BASE_URL/mcp-android-arm64-v8a"
elif [[ "$ARCH" == "armv7l" || "$ARCH" == "armv8l" ]]; then
DOWNLOAD_URL="$BASE_URL/mcp-android-armeabi-v7a"
fi
elif [[ "$OS" == "Linux" ]]; then
DOWNLOAD_URL="$BASE_URL/mcp-linux-x86_64"
fi
install_binary() {
if [[ -z "$DOWNLOAD_URL" ]]; then
return 1
fi
echo -e "${YELLOW}π Downloading pre-built binary for $OS ($ARCH)...${NC}"
if curl -L --progress-bar "$DOWNLOAD_URL" -o "$BINARY_NAME"; then
chmod +x "$BINARY_NAME"
echo -e "${GREEN}β
Download successful!${NC}"
INSTALL_PATH="/usr/local/bin"
if [[ "$IS_ANDROID" == true ]]; then
INSTALL_PATH="$PREFIX/bin"
fi
read -p "Do you want to install '$BINARY_NAME' to $INSTALL_PATH? (y/N) " -n 1 -r REPLY </dev/tty
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
if [ -w "$INSTALL_PATH" ]; then
cp "$BINARY_NAME" "$INSTALL_PATH/mcp"
else
echo -e "Requires sudo to copy to $INSTALL_PATH"
sudo cp "$BINARY_NAME" "$INSTALL_PATH/mcp"
fi
echo -e "${GREEN}β
Installed! You can now run 'mcp' from anywhere.${NC}"
else
echo -e "Binary is available at: ${BLUE}$(pwd)/$BINARY_NAME${NC}"
fi
return 0
else
echo -e "${RED}β Download failed.${NC}"
return 1
fi
}
build_from_source() {
echo -e "${YELLOW}π οΈ Building from source...${NC}"
# Check for dependencies
if ! command -v cmake &> /dev/null; then
echo -e "${RED}β cmake not found. Please install it (e.g., sudo apt install cmake).${NC}"
exit 1
fi
mkdir -p build && cd build
echo -e "${YELLOW}βοΈ Configuring with CMake...${NC}"
CMAKE_FLAGS="-DCMAKE_BUILD_TYPE=Release"
if [[ "$IS_ANDROID" == true ]]; then
# For Termux native build, we don't need a cross-toolchain
CMAKE_FLAGS="$CMAKE_FLAGS"
elif [[ "$OS" == "Darwin" ]]; then
CMAKE_FLAGS="$CMAKE_FLAGS -DCMAKE_OSX_ARCHITECTURES=$ARCH"
fi
if ! cmake $CMAKE_FLAGS ..; then
echo -e "${RED}β CMake configuration failed.${NC}"
exit 1
fi
echo -e "${YELLOW}π¨ Compiling...${NC}"
if ! cmake --build . --parallel $(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 2); then
echo -e "${RED}β Compilation failed.${NC}"
exit 1
fi
echo -e "${GREEN}β¨ Build successful!${NC}"
INSTALL_PATH="/usr/local/bin"
if [[ "$IS_ANDROID" == true ]]; then
INSTALL_PATH="$PREFIX/bin"
fi
read -p "Do you want to install '$BINARY_NAME' to $INSTALL_PATH? (y/N) " -n 1 -r REPLY </dev/tty
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
if [ -w "$INSTALL_PATH" ]; then
cp "$BINARY_NAME" "$INSTALL_PATH/mcp"
else
sudo cp "$BINARY_NAME" "$INSTALL_PATH/mcp"
fi
echo -e "${GREEN}β
Installed! You can now run 'mcp' from anywhere.${NC}"
else
echo -e "Binary is available at: ${BLUE}$(pwd)/$BINARY_NAME${NC}"
fi
}
if [[ -n "$DOWNLOAD_URL" ]]; then
if ! install_binary; then
build_from_source
fi
else
build_from_source
fi
echo -e "${BLUE}---------------------------------------${NC}"
echo -e "${GREEN}π MCP Server is ready!${NC}"
echo -e "Refer to README.md for configuration and connection steps."