-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquick_setup.sh
More file actions
185 lines (163 loc) · 5.55 KB
/
Copy pathquick_setup.sh
File metadata and controls
185 lines (163 loc) · 5.55 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#!/bin/bash
#===============================================================================
# ESMFold MCP Quick Setup Script
#===============================================================================
# This script sets up the complete environment for ESMFold MCP server.
#
# After cloning the repository, run this script to set everything up:
# cd esmfold_mcp
# bash quick_setup.sh
#
# Once setup is complete, register in Claude Code with the config shown at the end.
#
# Options:
# --skip-env Skip conda environment creation
# --skip-repo Skip cloning ESM repository
# --help Show this help message
#===============================================================================
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Configuration
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ENV_DIR="${SCRIPT_DIR}/env"
ENV_ESMFOLD_DIR="${SCRIPT_DIR}/env_esmfold"
PYTHON_VERSION="3.10"
REPO_DIR="${SCRIPT_DIR}/repo"
ESM_REPO="https://github.com/facebookresearch/esm.git"
# Print banner
echo -e "${BLUE}"
echo "=============================================="
echo " ESMFold MCP Quick Setup Script "
echo "=============================================="
echo -e "${NC}"
# Helper functions
info() { echo -e "${BLUE}[INFO]${NC} $1"; }
success() { echo -e "${GREEN}[SUCCESS]${NC} $1"; }
warn() { echo -e "${YELLOW}[WARNING]${NC} $1"; }
error() { echo -e "${RED}[ERROR]${NC} $1"; }
# Check for conda/mamba
check_conda() {
if command -v mamba &> /dev/null; then
CONDA_CMD="mamba"
info "Using mamba (faster package resolution)"
elif command -v conda &> /dev/null; then
CONDA_CMD="conda"
info "Using conda"
else
error "Neither conda nor mamba found. Please install Miniconda or Mambaforge first."
exit 1
fi
}
# Parse arguments
SKIP_ENV=false
SKIP_REPO=false
while [[ $# -gt 0 ]]; do
case $1 in
--skip-env) SKIP_ENV=true; shift ;;
--skip-repo) SKIP_REPO=true; shift ;;
-h|--help)
echo "Usage: ./quick_setup.sh [OPTIONS]"
echo ""
echo "Options:"
echo " --skip-env Skip conda environment creation"
echo " --skip-repo Skip cloning ESM repository"
echo " -h, --help Show this help message"
exit 0
;;
*) warn "Unknown option: $1"; shift ;;
esac
done
# Check prerequisites
info "Checking prerequisites..."
check_conda
if ! command -v git &> /dev/null; then
error "git is not installed. Please install git first."
exit 1
fi
success "Prerequisites check passed"
# Step 1: Create main conda environment
echo ""
echo -e "${BLUE}Step 1: Setting up main conda environment${NC}"
if [ "$SKIP_ENV" = true ]; then
info "Skipping environment creation (--skip-env)"
elif [ -d "$ENV_DIR" ] && [ -f "$ENV_DIR/bin/python" ]; then
info "Environment already exists at: $ENV_DIR"
else
info "Creating conda environment with Python ${PYTHON_VERSION}..."
$CONDA_CMD create -p "$ENV_DIR" python=${PYTHON_VERSION} pip -y
fi
# Step 2: Clone repository
echo ""
echo -e "${BLUE}Step 2: Cloning ESM repository${NC}"
if [ "$SKIP_REPO" = true ]; then
info "Skipping repository clone (--skip-repo)"
elif [ -d "$REPO_DIR/esm" ]; then
info "ESM repository already exists"
else
info "Cloning ESM repository..."
mkdir -p "$REPO_DIR"
git clone "$ESM_REPO" "$REPO_DIR/esm"
success "Repository cloned"
fi
# Step 3: Install dependencies
echo ""
echo -e "${BLUE}Step 3: Installing dependencies${NC}"
if [ "$SKIP_ENV" = true ]; then
info "Skipping dependency installation (--skip-env)"
else
info "Installing MCP dependencies to main env..."
"${ENV_DIR}/bin/pip" install fastmcp loguru
# Create ESMFold environment if environment.yml exists
if [ -f "$REPO_DIR/esm/environment.yml" ]; then
echo ""
echo -e "${BLUE}Step 3b: Setting up ESMFold environment${NC}"
if [ -d "$ENV_ESMFOLD_DIR" ] && [ -f "$ENV_ESMFOLD_DIR/bin/python" ]; then
info "ESMFold environment already exists"
else
info "Creating ESMFold environment from environment.yml..."
$CONDA_CMD env create -f "$REPO_DIR/esm/environment.yml" -p "$ENV_ESMFOLD_DIR" || warn "ESMFold environment creation failed"
fi
if [ -d "$ENV_ESMFOLD_DIR" ]; then
info "Installing ESM in editable mode..."
"${ENV_ESMFOLD_DIR}/bin/pip" install -e "$REPO_DIR/esm/"
fi
fi
info "Reinstalling fastmcp..."
"${ENV_DIR}/bin/pip" install --ignore-installed fastmcp
success "Dependencies installed"
fi
# Step 4: Verify installation
echo ""
echo -e "${BLUE}Step 4: Verifying installation${NC}"
"${ENV_DIR}/bin/python" -c "import fastmcp; import loguru; print('Core packages OK')" && success "Core packages verified" || error "Package verification failed"
# Print summary
echo ""
echo -e "${GREEN}=============================================="
echo " Setup Complete!"
echo "==============================================${NC}"
echo ""
echo "Main Environment: $ENV_DIR"
echo "ESMFold Environment: $ENV_ESMFOLD_DIR"
echo "Repository: $REPO_DIR/esm"
echo ""
echo -e "${YELLOW}Claude Code Configuration:${NC}"
echo ""
cat << EOF
{
"mcpServers": {
"esmfold": {
"command": "${ENV_DIR}/bin/python",
"args": ["${SCRIPT_DIR}/src/server.py"]
}
}
}
EOF
echo ""
echo "To add to Claude Code:"
echo " claude mcp add esmfold -- ${ENV_DIR}/bin/python ${SCRIPT_DIR}/src/server.py"
echo ""