# Ghost MCP Development Makefile .PHONY: help install install-local deps-install-python deps-install-dev deps-deps-install-uv install-pip venv start-ghost stop-ghost restart-ghost setup-tokens test test-unit test-integration test-coverage test-fast test-parallel test-e2e test-connection clean-test run dev format lint clean logs status check-deps setup release docs .PHONY: help help: ## Show this help message @echo "Available targets:" @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' # Python environment setup venv: ## Create a virtual environment python3 -m venv venv ./venv/bin/pip install -U pip setuptools ./venv/bin/pip install -e ".[dev]" deps-deps-install-uv: ## Install uv package manager @echo "๐Ÿ“ฆ Installing uv package manager..." @if command -v uv >/dev/null 2>&1; then \ echo "โœ… uv is already installed"; \ uv --version; \ else \ echo "Installing uv..."; \ curl -LsSf https://astral.sh/uv/install.sh | sh; \ echo "โœ… uv installed successfully"; \ fi # Install the MCP server system-wide install-user: ## Install the MCP server system-wide claude mcp remove ghost -s user || true claude mcp add ghost -s user -- \ bash -c "cd $(PWD) && uv run python -m ghost_mcp.server" # Install the MCP server in the project scope only install-project: ## Install the MCP server in the project scope only claude mcp remove -s project ghost || true claude mcp add ghost -s project -- \ bash -c "cd $(PWD) && uv run python -m ghost_mcp.server" deps-install-python: ## Install Python dependencies using uv @echo "๐Ÿ“ฆ Installing Python dependencies with uv..." @if ! command -v uv >/dev/null 2>&1; then \ echo "โŒ uv not found. Run 'make deps-deps-install-uv' first"; \ exit 1; \ fi uv sync @echo "โœ… Dependencies installed successfully" # Install dev dependencies deps-install-dev: ## Install development dependencies uv sync --extra dev install-pip: ## Install Python dependencies using pip (fallback) @echo "๐Ÿ“ฆ Installing Python dependencies with pip..." python -m pip install -e ".[dev]" @echo "โœ… Dependencies installed successfully" # Docker environment start-ghost: ## Start Ghost and database containers @echo "๐Ÿณ Starting Ghost development environment..." docker-compose up -d @echo "โณ Waiting for containers to be healthy..." @timeout=60; \ while [ $$timeout -gt 0 ]; do \ if docker-compose ps | grep -q "ghost-mcp-dev.*Up" && docker-compose ps | grep -q "ghost-db-dev.*Up.*healthy"; then \ echo "โœ… Ghost containers are running and healthy"; \ break; \ fi; \ echo " Waiting for containers... ($$timeout seconds remaining)"; \ sleep 2; \ timeout=$$((timeout - 2)); \ done; \ if [ $$timeout -le 0 ]; then \ echo "โŒ Containers did not start properly"; \ make logs; \ exit 1; \ fi @echo "" @echo "๐ŸŽ‰ Ghost is ready!" @echo " Ghost admin: http://localhost:2368/ghost/" @echo " Ghost site: http://localhost:2368/" @echo " Database: Available on port 3306" stop-ghost: ## Stop Ghost and database containers @echo "๐Ÿ›‘ Stopping Ghost development environment..." docker-compose down @echo "โœ… Ghost containers stopped" restart-ghost: ## Restart Ghost and database containers @echo "๐Ÿ”„ Restarting Ghost development environment..." docker-compose restart @echo "โœ… Ghost containers restarted" # API token setup setup-tokens: ## Extract API keys from Ghost database and create .env file @echo "๐Ÿ”‘ Setting up API tokens..." ./scripts/setup-tokens.sh # Testing targets test: ## Run all tests uv run pytest tests/ -v test-unit: ## Run unit tests only uv run pytest tests/test_models.py tests/test_client.py -v test-integration: ## Run integration tests uv run pytest tests/test_mcp_tools.py tests/test_server.py -v test-coverage: ## Run tests with coverage report uv run pytest tests/ --cov=. --cov-report=html --cov-report=term test-fast: ## Run tests with fail-fast and short traceback uv run pytest tests/ -x --tb=short test-parallel: ## Run tests in parallel uv run pytest tests/ -n auto test-e2e: ## Run end-to-end tests against real Ghost instance @echo "๐Ÿงช Running end-to-end tests..." @if [ ! -f .env ]; then \ echo "โŒ .env file not found. Run 'make setup-tokens' first"; \ exit 1; \ fi @echo "โš ๏ธ Note: These tests require a running Ghost instance (make start-ghost)" uv run pytest tests/e2e/ -v -m e2e test-connection: ## Test Ghost API connectivity @if [ ! -f .env ]; then \ echo "โŒ .env file not found. Run 'make setup-tokens' first"; \ exit 1; \ fi @python scripts/test-connection.py # Clean up test artifacts clean-test: ## Clean up test artifacts rm -rf .coverage htmlcov/ .pytest_cache/ tests/__pycache__/ __pycache__/ # Running the server run: check-deps ## Run the Ghost MCP server @echo "๐Ÿš€ Starting Ghost MCP server..." @if [ ! -f .env ]; then \ echo "โŒ .env file not found. Run 'make setup-tokens' first"; \ exit 1; \ fi python -m ghost_mcp.server dev: check-deps ## Run the Ghost MCP server in development mode with auto-reload @echo "๐Ÿš€ Starting Ghost MCP server in development mode..." @if [ ! -f .env ]; then \ echo "โŒ .env file not found. Run 'make setup-tokens' first"; \ exit 1; \ fi python -m ghost_mcp.server --dev # Utilities logs: ## Show Docker container logs @echo "๐Ÿ“‹ Showing container logs..." docker-compose logs -f status: ## Show status of all components @echo "๐Ÿ“Š Ghost MCP Status" @echo "==================" @echo "" @echo "๐Ÿณ Docker Containers:" @docker-compose ps || echo " No containers running" @echo "" @echo "๐Ÿ“ Configuration:" @if [ -f .env ]; then \ echo " โœ… .env file exists"; \ echo " ๐Ÿ“ Ghost URL: $$(grep GHOST_URL .env | cut -d= -f2)"; \ echo " ๐Ÿ”‘ Content API: $$(grep GHOST_CONTENT_API_KEY .env | cut -d= -f2 | cut -c1-10)..."; \ echo " ๐Ÿ”‘ Admin API: $$(grep GHOST_ADMIN_API_KEY .env | cut -d= -f2 | cut -c1-10)..."; \ else \ echo " โŒ .env file missing"; \ fi @echo "" @echo "๐Ÿ Python Environment:" @if command -v uv >/dev/null 2>&1; then \ echo " โœ… uv: $$(uv --version)"; \ else \ echo " โŒ uv not installed"; \ fi @echo " ๐Ÿ Python: $$(python --version)" @if python -c "import ghost_mcp" 2>/dev/null; then \ echo " โœ… ghost_mcp package installed"; \ else \ echo " โŒ ghost_mcp package not installed"; \ fi check-deps: ## Check if all dependencies are available @if [ ! -f .env ]; then \ echo "โŒ .env file not found. Run 'make setup-tokens' first"; \ exit 1; \ fi @if ! python -c "import ghost_mcp" 2>/dev/null; then \ echo "โŒ ghost_mcp package not installed. Run 'make install' first"; \ exit 1; \ fi # Code quality .PHONY: format format: ## Format code with ruff and black @echo "๐ŸŽจ Formatting code..." uv run ruff format . uv run black . @echo "โœ… Code formatting completed" .PHONY: lint lint: ## Run linting with ruff and mypy @echo "๐Ÿ” Running linters..." uv run ruff check . uv run mypy src/ @echo "โœ… Linting completed" clean: ## Clean up temporary files and development environment @echo "๐Ÿงน Cleaning up development environment..." find . -type f -name "*.pyc" -delete || true find . -type d -name "__pycache__" -delete || true find . -type d -name ".pytest_cache" -delete || true rm -rf .ruff_cache/ || true rm -rf venv/ || true rm -rf .pytest_cache/ || true rm -rf htmlcov/ || true rm -f .coverage* coverage.xml || true docker-compose down -v || true rm -f .env || true @if command -v uv >/dev/null 2>&1; then \ uv clean; \ fi @echo "โœ… Cleanup complete" # Development workflow setup: deps-deps-install-uv deps-install-python start-ghost setup-tokens ## Complete setup from scratch @echo "" @echo "๐ŸŽ‰ Ghost MCP setup complete!" @echo "" @echo "Ready to use:" @echo " make test # Test the implementation" @echo " make run # Run the MCP server" @echo " make status # Check system status" # Release release: ## Create a new GitHub release with the current package version @echo "๐Ÿš€ Creating GitHub release..." ./scripts/create-release.sh # Documentation docs: ## Show important URLs and information @echo "๐Ÿ“š Ghost MCP Documentation" @echo "=========================" @echo "" @echo "๐ŸŒ Web Interfaces:" @echo " Ghost Admin: http://localhost:2368/ghost/" @echo " Ghost Site: http://localhost:2368/" @echo " phpMyAdmin: http://localhost:8080/ (if enabled)" @echo "" @echo "๐Ÿ“ Important Files:" @echo " Configuration: .env" @echo " Project: pyproject.toml" @echo " Docker: docker-compose.yml" @echo " Setup Script: scripts/setup-tokens.sh" @echo "" @echo "๐Ÿ”ง Development Commands:" @echo " make setup # Complete initial setup" @echo " make test # Test functionality" @echo " make run # Run MCP server" @echo " make logs # View container logs" @echo " make status # Check system status"