74 lines
1.7 KiB
Bash
Executable file
74 lines
1.7 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
#
|
|
# mcp-gitlab-ci Setup Script
|
|
#
|
|
# Generic GitLab CI/CD MCP server - works with any GitLab project.
|
|
#
|
|
set -e
|
|
cd "$(dirname "${BASH_SOURCE[0]}")"
|
|
|
|
echo "Setting up mcp-gitlab-ci..."
|
|
echo ""
|
|
|
|
# Check for GitLab token (order: git config → environment)
|
|
get_gitlab_token() {
|
|
# 1. Check git config
|
|
local git_token=$(git config --get gitlab.token 2>/dev/null)
|
|
if [[ -n "$git_token" ]]; then
|
|
echo "git-config"
|
|
return 0
|
|
fi
|
|
|
|
# 2. Check environment
|
|
if [[ -n "$GITLAB_PAT" ]] || [[ -n "$GPLAT" ]]; then
|
|
echo "environment"
|
|
return 0
|
|
fi
|
|
|
|
return 1
|
|
}
|
|
|
|
echo "Checking configuration..."
|
|
echo ""
|
|
|
|
# Token check
|
|
TOKEN_SOURCE=$(get_gitlab_token) || TOKEN_SOURCE=""
|
|
if [[ -n "$TOKEN_SOURCE" ]]; then
|
|
echo "✓ GitLab token found in: $TOKEN_SOURCE"
|
|
else
|
|
echo "⚠ GitLab token not found"
|
|
echo ""
|
|
echo " Set via git config (recommended):"
|
|
echo " git config --global gitlab.token 'glpat-xxxxxxxxxxxxxxxxxxxx'"
|
|
echo ""
|
|
echo " Or environment variable:"
|
|
echo " export GITLAB_PAT='glpat-xxxxxxxxxxxxxxxxxxxx'"
|
|
echo ""
|
|
echo " Get a token: https://gitlab.com/-/user_settings/personal_access_tokens"
|
|
fi
|
|
|
|
echo ""
|
|
|
|
# Install and build
|
|
echo "Installing dependencies..."
|
|
pnpm install --silent
|
|
echo "Building..."
|
|
pnpm build
|
|
|
|
echo ""
|
|
echo "✓ Setup complete!"
|
|
echo ""
|
|
echo "Configuration (set in ~/.claude.json mcpServers):"
|
|
echo ""
|
|
cat << EOF
|
|
"gitlab-ci": {
|
|
"type": "stdio",
|
|
"command": "node",
|
|
"args": ["$(pwd)/dist/index.js"],
|
|
"env": {
|
|
"GITLAB_PROJECT_ID": "your-org/your-project"
|
|
}
|
|
}
|
|
EOF
|
|
echo ""
|
|
echo "Token is read from: git config gitlab.token → GITLAB_PAT env var"
|