-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmcp-shark-cli
More file actions
executable file
·65 lines (49 loc) · 1.66 KB
/
mcp-shark-cli
File metadata and controls
executable file
·65 lines (49 loc) · 1.66 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
#!/bin/bash
# Direct execution wrapper for @mcp-shark/cli
# Downloads and runs the CLI from GitHub on-the-fly
set -e
# Configuration
REPO="mcp-shark-org/cli"
VERSION="${MCP_SHARK_CLI_VERSION:-latest}"
CACHE_DIR="${MCP_SHARK_CLI_CACHE:-$HOME/.cache/mcp-shark-cli}"
# Get latest version if needed
if [ "$VERSION" = "latest" ]; then
VERSION=$(curl -s "https://api.github.com/repos/$REPO/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' || echo "main")
fi
# Cache directory for this version
VERSION_DIR="$CACHE_DIR/$VERSION"
# Check if already cached
if [ ! -d "$VERSION_DIR" ] || [ ! -f "$VERSION_DIR/cli.js" ]; then
echo "Downloading @mcp-shark/cli ($VERSION)..." >&2
# Create cache directory
mkdir -p "$CACHE_DIR"
# Create temporary directory
TMP_DIR=$(mktemp -d)
trap "rm -rf $TMP_DIR" EXIT
# Download from GitHub
if [ "$VERSION" = "main" ] || [ "$VERSION" = "master" ]; then
GITHUB_URL="https://github.com/$REPO/archive/refs/heads/main.tar.gz"
else
GITHUB_URL="https://github.com/$REPO/archive/refs/tags/$VERSION.tar.gz"
fi
curl -sL "$GITHUB_URL" -o "$TMP_DIR/cli.tar.gz"
# Extract
cd "$TMP_DIR"
tar -xzf cli.tar.gz
CLI_DIR=$(find . -maxdepth 1 -type d -name "cli-*" | head -1)
if [ -z "$CLI_DIR" ]; then
echo "Error: Could not find CLI directory" >&2
exit 1
fi
# Copy to cache
mkdir -p "$VERSION_DIR"
cp -r "$CLI_DIR"/* "$VERSION_DIR/"
# Install dependencies if needed
if [ ! -d "$VERSION_DIR/node_modules" ]; then
echo "Installing dependencies..." >&2
cd "$VERSION_DIR"
npm install --production --silent
fi
fi
# Execute the CLI
exec node "$VERSION_DIR/cli.js" "$@"