Skip to content

Commit 61ecd26

Browse files
authored
[dev] Install git and linear MCP servers (#20647)
Tool: gitpod/catfood.gitpod.cloud
1 parent 23c3e83 commit 61ecd26

File tree

3 files changed

+226
-0
lines changed

3 files changed

+226
-0
lines changed

.gitpod.yml

+7
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ tasks:
4242
gp env -u GCP_ADC_FILE
4343
fi
4444
exit 0
45+
- name: MCP Servers Setup
46+
init: |
47+
# Run Git MCP install script with current workspace as repository
48+
./scripts/install-git-mcp-go.sh /workspace/gitpod "$GIT_WRITE_ACCESS"
49+
50+
# Run Linear MCP install script
51+
./scripts/install-linear-mcp-go.sh "$LINEAR_WRITE_ACCESS"
4552
- name: Install `gitpod` CLI
4653
command: |
4754
leeway run components/local-app:install-cli

scripts/install-git-mcp-go.sh

+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
#!/bin/bash
2+
3+
# This script installs the Git MCP server and registers it for use with the cline VSCode extension: https://github.com/cline/cline
4+
#
5+
# Usage:
6+
# ./register-cline.sh <repository-path> [write-access] [mode]
7+
#
8+
# Parameters:
9+
# repository-path: Required. Path to a Git repository to use.
10+
# write-access: Optional. Set to "true" to enable write operations. Default is "false".
11+
# mode: Optional. Git operation mode: 'shell' or 'go-git'. Default is "shell".
12+
#
13+
# Examples:
14+
# ./register-cline.sh ~/my-repo # Install with read-only mode (default)
15+
# ./register-cline.sh ~/my-repo true # Install with write operations enabled
16+
# ./register-cline.sh ~/my-repo false go-git # Specify mode
17+
18+
# Get parameters with defaults
19+
REPO_PATH=$1
20+
WRITE_ACCESS=${2:-false}
21+
MODE=${3:-shell}
22+
23+
# Check for required tools
24+
if ! command -v jq &> /dev/null; then
25+
echo "Error: jq is required but not installed. Please install jq first."
26+
exit 1
27+
fi
28+
29+
MCP_SERVERS_DIR="$HOME/mcp-servers"
30+
mkdir -p "$MCP_SERVERS_DIR"
31+
32+
# Check if the Git MCP server binary is on the path already
33+
GIT_MCP_BINARY="$(which git-mcp-go)"
34+
if [ -z "$GIT_MCP_BINARY" ]; then
35+
echo "Did not find git-mcp-go on the path, installing from latest GitHub release..."
36+
37+
# This fetches information about the latest release to determine the download URL
38+
LATEST_RELEASE=$(curl -s https://api.github.com/repos/geropl/git-mcp-go/releases/latest)
39+
40+
# Determine platform for download
41+
PLATFORM="linux"
42+
if [[ "$OSTYPE" == "darwin"* ]]; then
43+
PLATFORM="darwin"
44+
elif [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
45+
PLATFORM="windows"
46+
fi
47+
48+
# Extract the download URL for the appropriate binary
49+
DOWNLOAD_URL=$(echo "$LATEST_RELEASE" | jq -r ".assets[] | select(.name | contains(\"$PLATFORM\")) | .browser_download_url")
50+
51+
if [ -z "$DOWNLOAD_URL" ]; then
52+
echo "Error: Could not find appropriate binary in the latest release"
53+
exit 1
54+
fi
55+
56+
# Download the Git MCP server binary
57+
echo "Downloading Git MCP server from $DOWNLOAD_URL..."
58+
curl -L -o "$MCP_SERVERS_DIR/git-mcp-go" "$DOWNLOAD_URL"
59+
60+
# Make the binary executable
61+
chmod +x "$MCP_SERVERS_DIR/git-mcp-go"
62+
63+
echo "Git MCP server installed successfully at $MCP_SERVERS_DIR/git-mcp-go"
64+
GIT_MCP_BINARY="$MCP_SERVERS_DIR/git-mcp-go"
65+
fi
66+
67+
# Configure cline to use the MCP server
68+
# This is where Cline looks for MCP server configurations
69+
CLINE_CONFIG_DIR="$HOME/.vscode-server/data/User/globalStorage/saoudrizwan.claude-dev/settings"
70+
mkdir -p "$CLINE_CONFIG_DIR"
71+
72+
CLINE_MCP_SETTINGS="$CLINE_CONFIG_DIR/cline_mcp_settings.json"
73+
74+
# Build the args array based on parameters
75+
SERVER_ARGS="["
76+
77+
# Add repository path if provided
78+
if [ -n "$REPO_PATH" ]; then
79+
# Expand the path to absolute path
80+
REPO_PATH=$(realpath "$REPO_PATH")
81+
SERVER_ARGS="$SERVER_ARGS\"--repository=$REPO_PATH\""
82+
fi
83+
84+
# Add write-access flag if enabled
85+
if [ "$WRITE_ACCESS" = "true" ]; then
86+
if [ -n "$SERVER_ARGS" ] && [ "$SERVER_ARGS" != "[" ]; then
87+
SERVER_ARGS="$SERVER_ARGS, "
88+
fi
89+
SERVER_ARGS="$SERVER_ARGS\"--write-access=true\""
90+
fi
91+
92+
# Add mode if not the default
93+
if [ -n "$MODE" ]; then
94+
if [ -n "$SERVER_ARGS" ] && [ "$SERVER_ARGS" != "[" ]; then
95+
SERVER_ARGS="$SERVER_ARGS, "
96+
fi
97+
SERVER_ARGS="$SERVER_ARGS\"--mode=$MODE\""
98+
fi
99+
100+
SERVER_ARGS="$SERVER_ARGS]"
101+
102+
# Merge the existing settings with the new MCP server configuration
103+
cat <<EOF > "$CLINE_MCP_SETTINGS.new"
104+
{
105+
"mcpServers": {
106+
"git": {
107+
"command": "$GIT_MCP_BINARY",
108+
"args": $SERVER_ARGS,
109+
"disabled": false,
110+
"autoApprove": []
111+
}
112+
}
113+
}
114+
EOF
115+
116+
if [ -f "$CLINE_MCP_SETTINGS" ]; then
117+
echo "Found existing Cline MCP settings at $CLINE_MCP_SETTINGS"
118+
echo "Merging with new MCP server configuration..."
119+
jq -s '.[0] * .[1]' "$CLINE_MCP_SETTINGS" "$CLINE_MCP_SETTINGS.new" > "$CLINE_MCP_SETTINGS.tmp"
120+
mv "$CLINE_MCP_SETTINGS.tmp" "$CLINE_MCP_SETTINGS"
121+
else
122+
echo "Creating new Cline MCP settings at $CLINE_MCP_SETTINGS"
123+
mv "$CLINE_MCP_SETTINGS.new" "$CLINE_MCP_SETTINGS"
124+
fi
125+
rm -f "$CLINE_MCP_SETTINGS.new"
126+
127+
echo "Cline MCP settings updated at $CLINE_MCP_SETTINGS"
128+
echo "Git MCP server has been registered with the following configuration:"
129+
echo " - Write Access: $WRITE_ACCESS"
130+
if [ -n "$REPO_PATH" ]; then
131+
echo " - Repository Path: $REPO_PATH"
132+
fi
133+
echo " - Mode: $MODE"

scripts/install-linear-mcp-go.sh

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#!/bin/bash
2+
3+
# This script installs the Linear MCP server and registers it for use with the cline VSCode extension: https://github.com/cline/cline
4+
# Note: to use this, you need to have a) cline installed, and b) set LINEAR_API_KEY in your environment
5+
#
6+
# Usage:
7+
# ./register-cline.sh [write-access]
8+
#
9+
# Parameters:
10+
# write-access: Optional. Set to "true" to enable write operations. Default is "false".
11+
#
12+
# Examples:
13+
# ./register-cline.sh # Install with read-only mode (default)
14+
# ./register-cline.sh true # Install with write operations enabled
15+
16+
# Get the write-access parameter (default: false)
17+
WRITE_ACCESS=${1:-false}
18+
19+
MCP_SERVERS_DIR="$HOME/mcp-servers"
20+
mkdir -p "$MCP_SERVERS_DIR"
21+
22+
# Check if the Linear MCP server binary is on the path already
23+
LINEAR_MCP_BINARY="$(which linear-mcp-go)"
24+
if [ -z "$LINEAR_MCP_BINARY" ]; then
25+
echo "Did not find linear-mcp-go on the path, installing from latest GitHub release..."
26+
27+
# This fetches information about the latest release to determine the download URL
28+
LATEST_RELEASE=$(curl -s https://api.github.com/repos/geropl/linear-mcp-go/releases/latest)
29+
# Extract the download URL for the Linux binary
30+
DOWNLOAD_URL=$(echo "$LATEST_RELEASE" | jq -r '.assets[] | select(.name | contains("linux")) | .browser_download_url')
31+
32+
if [ -z "$DOWNLOAD_URL" ]; then
33+
echo "Error: Could not find Linux binary in the latest release"
34+
exit 1
35+
fi
36+
37+
# Download the Linear MCP server binary
38+
echo "Downloading Linear MCP server from $DOWNLOAD_URL..."
39+
curl -L -o "$MCP_SERVERS_DIR/linear-mcp-go" "$DOWNLOAD_URL"
40+
41+
# Make the binary executable
42+
chmod +x "$MCP_SERVERS_DIR/linear-mcp-go"
43+
44+
echo "Linear MCP server installed successfully at $MCP_SERVERS_DIR/linear-mcp-go"
45+
LINEAR_MCP_BINARY="$MCP_SERVERS_DIR/linear-mcp-go"
46+
fi
47+
48+
# Configure cline to use the MCP server
49+
# This is where Cline looks for MCP server configurations
50+
CLINE_CONFIG_DIR="$HOME/.vscode-server/data/User/globalStorage/saoudrizwan.claude-dev/settings"
51+
mkdir -p "$CLINE_CONFIG_DIR"
52+
53+
CLINE_MCP_SETTINGS="$CLINE_CONFIG_DIR/cline_mcp_settings.json"
54+
55+
# Determine args based on write-access parameter
56+
if [ "$WRITE_ACCESS" = "true" ]; then
57+
SERVER_ARGS='["--write-access=true"]'
58+
else
59+
SERVER_ARGS='[]'
60+
fi
61+
62+
# Merge the existing settings with the new MCP server configuration
63+
cat <<EOF > "$CLINE_MCP_SETTINGS.new"
64+
{
65+
"mcpServers": {
66+
"linear": {
67+
"command": "$LINEAR_MCP_BINARY",
68+
"args": $SERVER_ARGS,
69+
"disabled": false,
70+
"autoApprove": []
71+
}
72+
}
73+
}
74+
EOF
75+
76+
if [ -f "$CLINE_MCP_SETTINGS" ]; then
77+
echo "Found existing Cline MCP settings at $CLINE_MCP_SETTINGS"
78+
echo "Merging with new MCP server configuration..."
79+
jq -s '.[0] * .[1]' "$CLINE_MCP_SETTINGS" "$CLINE_MCP_SETTINGS.new" > "$CLINE_MCP_SETTINGS.tmp"
80+
mv "$CLINE_MCP_SETTINGS.tmp" "$CLINE_MCP_SETTINGS"
81+
else
82+
mv "$CLINE_MCP_SETTINGS.tmp" "$CLINE_MCP_SETTINGS"
83+
fi
84+
rm -f "$CLINE_MCP_SETTINGS.new"
85+
86+
echo "Cline MCP settings updated at $CLINE_MCP_SETTINGS"

0 commit comments

Comments
 (0)