# Midaz MCP Server - Makefile
# Automates setup, configuration, and running of the MCP server
.PHONY: help setup build start dev test test-security secrets secrets-status lint clean install demo validate docs docs-serve docs-clean typecheck audit ci-install ci-lint ci-test ci-audit ci-all
# Default target
help:
@echo "π Midaz MCP Server - Available Commands"
@echo "========================================"
@echo ""
@echo "π Setup & Configuration:"
@echo " setup Setup project (copy config files, install deps)"
@echo " install Install npm dependencies"
@echo " config Copy configuration files (.env, JSON config)"
@echo ""
@echo "π¨ Development:"
@echo " build Build TypeScript to JavaScript"
@echo " start Start MCP server (production mode)"
@echo " dev Start MCP server (development mode)"
@echo " test Run all tests"
@echo " test-security Run security test suite (CRT/MED/LOW fixes)"
@echo " test-logging Test logging functionality"
@echo " lint Run ESLint"
@echo " lint-fix Run ESLint with auto-fix"
@echo " typecheck Run TypeScript type checking"
@echo " audit Run npm security audit"
@echo ""
@echo "π Security:"
@echo " secrets Generate CURSOR_SECRET and CACHE_ENCRYPTION_KEY"
@echo " secrets-status Check secrets configuration status"
@echo ""
@echo "π Documentation:"
@echo " docs Generate TypeDoc API documentation"
@echo " docs-serve Generate and serve docs locally"
@echo " docs-clean Clean generated documentation"
@echo ""
@echo "π€ CI/CD Commands (align with pipeline):"
@echo " ci-install Install dependencies (like CI)"
@echo " ci-lint Run lint + typecheck (like CI)"
@echo " ci-test Run build + test (like CI)"
@echo " ci-audit Run security audit (like CI)"
@echo " ci-all Run complete CI pipeline locally"
@echo ""
@echo "π§Ή Maintenance:"
@echo " clean Clean build artifacts"
@echo " clean-all Clean everything (build + node_modules)"
@echo " demo Run interactive Makefile demo"
@echo " validate Validate that setup process works"
@echo ""
@echo "π§ Environment Variables:"
@echo " MIDAZ_LOG_LEVEL=debug|info|warning|error"
@echo " MIDAZ_CONSOLE_LOGS=true|false"
@echo " MIDAZ_DETAILED_LOGS=true|false"
@echo ""
@echo "π Examples:"
@echo " make setup # Initial project setup"
@echo " make dev # Start development server"
@echo " make ci-all # Run complete CI pipeline locally"
@echo " make docs-serve # Generate and serve documentation"
@echo " MIDAZ_LOG_LEVEL=debug make start # Start with debug logging"
# Setup project from scratch
setup: config install build
@echo "β
Project setup complete!"
@echo "π Next steps:"
@echo " 1. Edit .env with your configuration"
@echo " 2. Run 'make start' to start the server"
# Copy configuration files
config:
@echo "π Setting up configuration files..."
@if [ ! -f .env ]; then \
cp .env.example .env && \
echo "β
Created .env from .env.example"; \
else \
echo "βΉοΈ .env already exists, skipping"; \
fi
# Install dependencies
install:
@echo "π¦ Installing dependencies..."
npm install
# Build TypeScript
build:
@echo "π¨ Building TypeScript..."
npm run build
# Start server (production)
start: build
@echo "π Starting MCP server..."
npm run start
# Start server (development)
dev:
@echo "π§ Starting MCP server in development mode..."
npm run dev
# Run tests
test:
@echo "π§ͺ Running tests..."
npm run test
# Run security test suite
test-security:
@echo "π Running security test suite..."
@echo "π Tests cover: CRT-001 through CRT-008, MED-005, LOW-002, LOW-005"
@if [ -f test/security-fixes.test.js ]; then \
node test/security-fixes.test.js; \
else \
echo "β οΈ Security test suite not found at test/security-fixes.test.js"; \
echo " Run basic tests instead..."; \
npm test; \
fi
# Test logging functionality
test-logging:
@echo "π Testing logging functionality..."
node scripts/test-logging.js
# Lint code
lint:
@echo "π Running ESLint..."
npm run lint
# Lint with auto-fix
lint-fix:
@echo "π§ Running ESLint with auto-fix..."
npm run lint:fix
# TypeScript type checking
typecheck:
@echo "π Running TypeScript type checking..."
npm run typecheck
# Security audit
audit:
@echo "π Running npm security audit..."
npm run audit
# Generate cryptographic secrets
secrets:
@echo "π Generating cryptographic secrets..."
@echo ""
@echo "CURSOR_SECRET (for HMAC-signed pagination cursors):"
@node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
@echo ""
@echo "CACHE_ENCRYPTION_KEY (for encrypted caching):"
@node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
@echo ""
@echo "π Add these to your .env file or set as environment variables"
@echo "π‘ Or let the server auto-generate and persist them to ~/.lerian/secrets.json"
# Check secrets configuration status
secrets-status:
@echo "π Checking secrets configuration..."
@echo ""
@if [ -n "$$CURSOR_SECRET" ]; then \
echo "β
CURSOR_SECRET set via environment variable"; \
elif [ -f ~/.lerian/secrets.json ]; then \
echo "β
CURSOR_SECRET auto-generated at ~/.lerian/secrets.json"; \
else \
echo "β οΈ CURSOR_SECRET not set (will auto-generate on first run)"; \
fi
@if [ -n "$$CACHE_ENCRYPTION_KEY" ]; then \
echo "β
CACHE_ENCRYPTION_KEY set via environment variable"; \
elif [ -f ~/.lerian/secrets.json ]; then \
echo "β
CACHE_ENCRYPTION_KEY auto-generated at ~/.lerian/secrets.json"; \
else \
echo "β οΈ CACHE_ENCRYPTION_KEY not set (will auto-generate on first run)"; \
fi
@echo ""
@if [ -f ~/.lerian/secrets.json ]; then \
echo "π Secrets file: ~/.lerian/secrets.json"; \
echo "π Permissions: $$(ls -l ~/.lerian/secrets.json | awk '{print $$1}')"; \
fi
# Maintenance
clean:
@echo "π§Ή Cleaning build artifacts..."
rm -rf dist
rm -rf logs/*.log 2>/dev/null || true
clean-all: clean docs-clean
@echo "π§Ή Cleaning everything..."
rm -rf node_modules
rm -rf .env 2>/dev/null || true
# CI/CD aligned commands
ci-install:
@echo "π€ Installing dependencies (CI mode)..."
npm ci
ci-lint:
@echo "π€ Running lint + typecheck (like CI)..."
npm run ci:lint
ci-test:
@echo "π€ Running build + test (like CI)..."
npm run ci:test
ci-audit:
@echo "π€ Running security audit (like CI)..."
npm run ci:audit
ci-all:
@echo "π€ Running complete CI pipeline locally..."
npm run ci:all
# Development shortcuts with different log levels
dev-debug:
@echo "π Starting development server with debug logging..."
MIDAZ_LOG_LEVEL=debug MIDAZ_DETAILED_LOGS=true npm run dev
dev-quiet:
@echo "π Starting development server with minimal logging..."
MIDAZ_LOG_LEVEL=error MIDAZ_CONSOLE_LOGS=true npm run dev
# Production shortcuts
start-debug:
@echo "π Starting production server with debug logging..."
MIDAZ_LOG_LEVEL=debug MIDAZ_DETAILED_LOGS=true npm run start
start-quiet:
@echo "π Starting production server with minimal logging..."
MIDAZ_LOG_LEVEL=error npm run start
# Quick development cycle
quick: lint-fix typecheck build test
@echo "β
Quick development cycle complete!"
# Full CI/CD cycle (matches pipeline exactly)
ci: clean ci-install ci-lint ci-test ci-audit
@echo "β
CI/CD cycle complete!"
# Demo Makefile capabilities
demo:
@echo "π― Running Makefile demo..."
./scripts/demo-makefile.sh
# Documentation generation
docs:
@echo "π Generating TypeDoc API documentation..."
npm run docs
@echo "β
Documentation generated in docs/ directory"
@echo "π Open docs/index.html in your browser to view"
# Generate and serve docs locally (requires Python or Node.js HTTP server)
docs-serve: docs
@echo "π Starting local documentation server..."
@if command -v python3 >/dev/null 2>&1; then \
echo "π Serving docs at http://localhost:8080"; \
echo "π΄ Press Ctrl+C to stop the server"; \
cd docs && python3 -m http.server 8080; \
elif command -v python >/dev/null 2>&1; then \
echo "π Serving docs at http://localhost:8080"; \
echo "π΄ Press Ctrl+C to stop the server"; \
cd docs && python -m SimpleHTTPServer 8080; \
elif command -v npx >/dev/null 2>&1; then \
echo "π Serving docs at http://localhost:8080"; \
echo "π΄ Press Ctrl+C to stop the server"; \
cd docs && npx http-server -p 8080; \
else \
echo "β No HTTP server available. Install Python or Node.js http-server"; \
echo "π‘ Alternative: Open docs/index.html directly in your browser"; \
fi
# Clean generated documentation
docs-clean:
@echo "π§Ή Cleaning generated documentation..."
rm -rf docs
@echo "β
Documentation cleaned"
# Validate setup process
validate:
@echo "π§ͺ Validating setup process..."
./scripts/validate-setup.sh