-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·67 lines (61 loc) · 2.65 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·67 lines (61 loc) · 2.65 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
#!/usr/bin/env bash
# Sets up all three MCP servers in one local Python environment, for use on
# machines without outbound internet access at launch time (e.g. HPC compute
# nodes). Generates mcp.local.json pointing an MCP client at the installed
# console scripts.
#
# For normal desktop/laptop use with internet access, you likely don't need
# this at all -- just point your MCP client at mcp.json instead.
#
# crocodash-mcp requires ESMF/xesmf, which are conda-only compiled libraries
# that a plain venv cannot provide. If you already have a conda env with
# ESMF/xesmf installed (e.g. the env you use for the CrocoDash CLI itself),
# point this script at it instead of creating a fresh venv:
#
# PYTHON_BIN=/path/to/envs/CrocoDash/bin/python ./setup.sh
#
# Without PYTHON_BIN, a fresh venv is created using the first of
# python3.12/python3.11/python3.10/python3 found that satisfies the servers'
# minimum Python version (3.11) -- but crocodash-mcp will fail at import time
# in that venv unless ESMF/xesmf are separately made available to it.
set -euo pipefail
HUB_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
VENV_DIR="$HUB_ROOT/.venv"
echo "==> Syncing submodules"
git -C "$HUB_ROOT" submodule update --init --recursive
if [ -n "${PYTHON_BIN:-}" ]; then
echo "==> Using existing interpreter: $PYTHON_BIN"
BIN_DIR="$(dirname "$PYTHON_BIN")"
PIP_BIN="$BIN_DIR/pip"
else
PYTHON=""
for candidate in python3.12 python3.11 python3.10 python3; do
if command -v "$candidate" >/dev/null 2>&1; then
ver="$("$candidate" -c 'import sys; print("%d.%d" % sys.version_info[:2])')"
major="${ver%.*}"; minor="${ver#*.}"
if [ "$major" -eq 3 ] && [ "$minor" -ge 11 ]; then
PYTHON="$candidate"
break
fi
fi
done
if [ -z "$PYTHON" ]; then
echo "ERROR: no Python 3.11+ interpreter found (checked python3.12/3.11/3.10/python3)." >&2
echo "Install one, or pass an existing env via PYTHON_BIN=/path/to/python ./setup.sh" >&2
exit 1
fi
echo "==> Creating venv at $VENV_DIR using $PYTHON"
"$PYTHON" -m venv "$VENV_DIR"
BIN_DIR="$VENV_DIR/bin"
PIP_BIN="$BIN_DIR/pip"
fi
echo "==> Installing all three servers (editable)"
"$PIP_BIN" install --upgrade pip -q
"$PIP_BIN" install -e "$HUB_ROOT/servers/crocodash" \
-e "$HUB_ROOT/servers/regional-ocean-debugger" \
-e "$HUB_ROOT/servers/cesm-runner"
echo "==> Generating mcp.local.json"
sed "s#__VENV_BIN__#$BIN_DIR#g" "$HUB_ROOT/mcp.local.json.template" > "$HUB_ROOT/mcp.local.json"
echo
echo "Done. Point your MCP client at:"
echo " $HUB_ROOT/mcp.local.json"