Taskfile.yml•8.38 kB
version: '3'
vars:
BINARY_NAME: ksm-mcp
VERSION: '{{default "dev" .VERSION}}'
BUILD_DIR: bin
DOCKER_IMAGE: keepersecurityinc/ksm-mcp-scratch
DOCKER_TAG: '{{default "latest" .DOCKER_TAG}}'
SRC_DIR: ./cmd/{{.BINARY_NAME}}
LDFLAGS: '-ldflags "-X main.version={{.VERSION}} -w -s"'
BUILD_FLAGS: '-trimpath {{.LDFLAGS}}'
tasks:
default:
desc: Default task - clean, format, lint, test, and build
cmds:
- task: clean
- task: fmt
- task: lint
- task: test
- task: build
# Build tasks
build:
desc: Build the binary
cmds:
- echo "Building {{.BINARY_NAME}} version {{.VERSION}}..."
- mkdir -p {{.BUILD_DIR}}
- go build {{.BUILD_FLAGS}} -o {{.BUILD_DIR}}/{{.BINARY_NAME}} {{.SRC_DIR}}
- echo "Binary built - {{.BUILD_DIR}}/{{.BINARY_NAME}}"
build-all:
desc: Build for multiple platforms with quality checks
cmds:
- task: clean
- task: quality
- echo "Building for multiple platforms..."
- mkdir -p {{.BUILD_DIR}}
# Linux amd64
- GOOS=linux GOARCH=amd64 go build {{.BUILD_FLAGS}} -o {{.BUILD_DIR}}/{{.BINARY_NAME}}-linux-amd64 {{.SRC_DIR}}
# Linux arm64
- GOOS=linux GOARCH=arm64 go build {{.BUILD_FLAGS}} -o {{.BUILD_DIR}}/{{.BINARY_NAME}}-linux-arm64 {{.SRC_DIR}}
# macOS amd64
- GOOS=darwin GOARCH=amd64 go build {{.BUILD_FLAGS}} -o {{.BUILD_DIR}}/{{.BINARY_NAME}}-darwin-amd64 {{.SRC_DIR}}
# macOS arm64
- GOOS=darwin GOARCH=arm64 go build {{.BUILD_FLAGS}} -o {{.BUILD_DIR}}/{{.BINARY_NAME}}-darwin-arm64 {{.SRC_DIR}}
# Windows amd64
- GOOS=windows GOARCH=amd64 go build {{.BUILD_FLAGS}} -o {{.BUILD_DIR}}/{{.BINARY_NAME}}-windows-amd64.exe {{.SRC_DIR}}
# Windows arm64
- GOOS=windows GOARCH=arm64 go build {{.BUILD_FLAGS}} -o {{.BUILD_DIR}}/{{.BINARY_NAME}}-windows-arm64.exe {{.SRC_DIR}}
- echo "✅ Multi-platform build completed with quality checks!"
- echo "Built binaries:"
- ls -la {{.BUILD_DIR}}/
# Clean tasks
clean:
desc: Clean build artifacts
cmds:
- echo "Cleaning..."
- go clean
- rm -rf {{.BUILD_DIR}}
- rm -rf dist/
- rm -f ksm-mcp
- rm -f coverage.out coverage.html
# Quality assurance tasks
quality:
desc: Run all quality checks (tests, lint, security)
cmds:
- task: test-coverage
- task: lint
- task: security
- echo "✅ All quality checks passed!"
ci:
desc: Run CI pipeline locally (mirrors GitHub Actions)
cmds:
- echo "🚀 Running CI pipeline locally..."
- task: test-coverage
- task: lint
- task: security
- task: build-all
- echo "✅ CI pipeline completed successfully!"
# Test tasks
test:
desc: Run tests
cmds:
- echo "Running tests..."
- go test -v ./...
test-coverage:
desc: Run tests with coverage (matches CI)
cmds:
- echo "Running tests with coverage and race detection..."
- go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
- go tool cover -func=coverage.out
- echo "✅ Tests passed with coverage report"
test-race:
desc: Run tests with race detection
cmds:
- echo "Running tests with race detection..."
- go test -race ./...
test-local:
desc: Test Docker image locally
deps: [docker-build]
cmds:
- echo "Testing Docker image..."
- docker run --rm -e KSM_CONFIG_BASE64=dGVzdA== -e KSM_MCP_PROFILE=production -e KSM_MCP_BATCH_MODE=true {{.DOCKER_IMAGE}}:{{.DOCKER_TAG}} serve --batch 2>&1 | head -20 || true
# Code quality tasks
lint:
desc: Run linter (matches CI)
cmds:
- echo "Running golangci-lint..."
- |
if ! command -v golangci-lint &> /dev/null; then
echo "Installing golangci-lint..."
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
fi
- |
if command -v golangci-lint &> /dev/null; then
golangci-lint run --timeout=5m
else
~/go/bin/golangci-lint run --timeout=5m
fi
- echo "✅ Linting passed"
fmt:
desc: Format code
cmds:
- echo "Formatting code..."
- go fmt ./...
security:
desc: Run security scan (matches CI)
cmds:
- echo "Running gosec security scanner..."
- |
if ! command -v gosec &> /dev/null; then
echo "Installing gosec..."
go install github.com/securego/gosec/v2/cmd/gosec@latest
fi
- |
if command -v gosec &> /dev/null; then
gosec ./...
else
~/go/bin/gosec ./...
fi
- echo "✅ Security scan passed"
# Dependency tasks
deps:
desc: Install dependencies
cmds:
- echo "Installing dependencies..."
- go mod download
- go mod tidy
deps-update:
desc: Update dependencies
cmds:
- echo "Updating dependencies..."
- go get -u ./...
- go mod tidy
deps-verify:
desc: Verify dependencies
cmds:
- echo "Verifying dependencies..."
- go mod verify
# Docker tasks
docker-build:
desc: Build Docker image
vars:
BYPASS_SSL: '{{default "false" .BYPASS_SSL}}'
cmds:
- echo "Building Docker image with BYPASS_SSL={{.BYPASS_SSL}}..."
- docker build --build-arg BYPASS_SSL={{.BYPASS_SSL}} -t {{.DOCKER_IMAGE}}:{{.DOCKER_TAG}} .
- docker tag {{.DOCKER_IMAGE}}:{{.DOCKER_TAG}} {{.DOCKER_IMAGE}}:latest
- echo "Docker image built - {{.DOCKER_IMAGE}}:{{.DOCKER_TAG}}"
docker-run:
desc: Run Docker container
cmds:
- docker run -it --rm -v ~/.keeper/ksm-mcp:/home/ksm/.keeper/ksm-mcp {{.DOCKER_IMAGE}}:{{.DOCKER_TAG}}
docker-push:
desc: Build and push Docker image to Docker Hub
deps: [docker-build]
cmds:
- echo "Pushing Docker image to Docker Hub..."
- docker push {{.DOCKER_IMAGE}}:{{.DOCKER_TAG}}
- |
if [ "{{.DOCKER_TAG}}" != "latest" ]; then
docker tag {{.DOCKER_IMAGE}}:{{.DOCKER_TAG}} {{.DOCKER_IMAGE}}:latest
docker push {{.DOCKER_IMAGE}}:latest
fi
docker-push-multi:
desc: Build and push multi-platform Docker image
cmds:
- echo "Building and pushing multi-platform Docker image..."
- docker buildx create --use --name ksm-mcp-builder || true
- docker buildx build --platform linux/amd64,linux/arm64 -t {{.DOCKER_IMAGE}}:{{.DOCKER_TAG}} -t {{.DOCKER_IMAGE}}:latest --push .
- docker buildx rm ksm-mcp-builder
# Installation tasks
install:
desc: Install binary to local system
deps: [build]
cmds:
- echo "Installing {{.BINARY_NAME}} to /usr/local/bin..."
- sudo cp {{.BUILD_DIR}}/{{.BINARY_NAME}} /usr/local/bin/
uninstall:
desc: Uninstall binary from local system
cmds:
- echo "Removing {{.BINARY_NAME}} from /usr/local/bin..."
- sudo rm -f /usr/local/bin/{{.BINARY_NAME}}
# Run tasks
run:
desc: Build and run the application
deps: [build]
cmds:
- ./{{.BUILD_DIR}}/{{.BINARY_NAME}}
quick:
desc: Quick build and run
cmds:
- task: docker-build
vars:
DOCKER_TAG: "{{.DOCKER_TAG}}"
- task: docker-run
# Claude configuration helper
test-claude:
desc: Show Claude config for local testing
cmds:
- |
echo ""
echo "Add this to your Claude Desktop config:"
echo "~/Library/Application Support/Claude/claude_desktop_config.json"
echo ""
echo '{'
echo ' "mcpServers": {'
echo ' "ksm": {'
echo ' "command": "docker",'
echo ' "args": ['
echo ' "run", "-i", "--rm",'
echo ' "-e", "KSM_CONFIG_BASE64=YOUR_BASE64_CONFIG_HERE",'
echo ' "-e", "KSM_MCP_PROFILE=production",'
echo ' "-e", "KSM_MCP_BATCH_MODE=true",'
echo ' "-e", "KSM_MCP_LOG_LEVEL=error",'
echo ' "-v", "ksm-mcp-data:/home/ksm/.keeper/ksm-mcp",'
echo ' "{{.DOCKER_IMAGE}}:{{.DOCKER_TAG}}",'
echo ' "serve"'
echo ' ]'
echo ' }'
echo ' }'
echo '}'
echo ""
echo "Note: Replace YOUR_BASE64_CONFIG_HERE with your actual config"
# Help task
help:
desc: Show available tasks
cmds:
- task --list