Makefile•4.77 kB
.PHONY: help install install-dev clean test test-unit test-integration test-cov lint format typecheck check run init validate health docs build docker-build docker-run pre-commit
# Default target
.DEFAULT_GOAL := help
# Python and pip
PYTHON := python3
PIP := pip3
# Project directories
SRC_DIR := src
TEST_DIR := tests
CONFIG_DIR := config
help: ## Show this help message
@echo "MCP Template - Makefile Commands"
@echo ""
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
install: ## Install production dependencies
$(PIP) install -r requirements.txt
install-dev: ## Install development dependencies
$(PIP) install -e ".[dev]"
@echo "Development environment installed successfully!"
clean: ## Clean build artifacts and cache files
find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
find . -type f -name "*.pyc" -delete
find . -type f -name "*.pyo" -delete
find . -type d -name "*.egg-info" -exec rm -rf {} + 2>/dev/null || true
find . -type d -name ".pytest_cache" -exec rm -rf {} + 2>/dev/null || true
find . -type d -name ".mypy_cache" -exec rm -rf {} + 2>/dev/null || true
find . -type d -name ".ruff_cache" -exec rm -rf {} + 2>/dev/null || true
rm -rf build/ dist/ htmlcov/ .coverage coverage.xml
@echo "Cleaned build artifacts and cache files"
test: ## Run all tests
pytest -v
test-unit: ## Run unit tests only
pytest tests/unit -v
test-integration: ## Run integration tests only
pytest tests/integration -v -m integration
test-cov: ## Run tests with coverage report
pytest --cov=$(SRC_DIR) --cov-report=html --cov-report=term-missing --cov-report=xml
@echo "Coverage report generated in htmlcov/index.html"
lint: ## Run code linters
ruff check $(SRC_DIR) $(TEST_DIR)
@echo "Linting complete!"
format: ## Format code with black and ruff
black $(SRC_DIR) $(TEST_DIR)
ruff check --fix $(SRC_DIR) $(TEST_DIR)
@echo "Code formatting complete!"
typecheck: ## Run type checking with mypy
mypy $(SRC_DIR)
@echo "Type checking complete!"
check: lint typecheck test ## Run all code quality checks
@echo "All checks passed!"
run: ## Run the MCP server
mcp-template run
run-debug: ## Run the MCP server in debug mode
mcp-template run --debug
init: ## Initialize configuration files
mcp-template init
@echo "Configuration initialized!"
validate: ## Validate configuration
mcp-template validate
health: ## Check server health
mcp-template health
docs: ## Generate documentation (placeholder)
@echo "Documentation generation not yet implemented"
@echo "Add your docs generation command here (e.g., sphinx-build)"
build: ## Build distribution packages
$(PYTHON) -m build
@echo "Distribution packages built in dist/"
docker-build: ## Build Docker image
docker build -t mcp-template:latest .
@echo "Docker image built: mcp-template:latest"
docker-run: ## Run Docker container
docker run --rm -it \
-e REGISTRY_API_KEY=${REGISTRY_API_KEY} \
-v $(PWD)/config:/app/config \
mcp-template:latest
pre-commit: ## Install pre-commit hooks
pre-commit install
@echo "Pre-commit hooks installed!"
pre-commit-run: ## Run pre-commit on all files
pre-commit run --all-files
pre-commit-update: ## Update pre-commit hooks
pre-commit autoupdate
# Development workflow shortcuts
dev-setup: install-dev pre-commit init ## Complete development setup
@echo ""
@echo "Development environment ready!"
@echo "Next steps:"
@echo " 1. Edit config/config.yaml"
@echo " 2. Copy .env.template to .env and configure"
@echo " 3. Run: make run"
dev-check: clean format lint typecheck test ## Run full development check
@echo "All development checks passed!"
# Quick test and format cycle
tdd: format test ## Quick test-driven development cycle (format + test)
@echo "TDD cycle complete!"
# Show project info
info: ## Show project information
@echo "MCP Template Project Information"
@echo "================================="
@echo "Python: $(shell $(PYTHON) --version)"
@echo "Pip: $(shell $(PIP) --version)"
@echo "Project structure:"
@tree -L 2 -I '__pycache__|*.egg-info|.git' . 2>/dev/null || find . -maxdepth 2 -type d | grep -v '.git' | grep -v '__pycache__'
# Watch tests (requires pytest-watch)
watch: ## Watch for changes and run tests (requires pytest-watch)
@command -v ptw >/dev/null 2>&1 || { echo "pytest-watch not installed. Run: pip install pytest-watch"; exit 1; }
ptw
# Create a new release (placeholder)
release: ## Create a new release (placeholder)
@echo "Release process not yet implemented"
@echo "TODO: Add version bumping, tagging, and publishing"
# Show configuration
show-config: ## Display current configuration
mcp-template validate