.PHONY: build dev logs stop test-mcp test-health clean rebuild

# Build the Docker image locally
build:
	docker compose -f docker-compose.dev.yml build

# Start the development server
dev:
	docker compose -f docker-compose.dev.yml up -d
	@echo "Server starting at http://localhost:8001"
	@echo "Use 'make logs' to view output"

# View container logs
logs:
	docker compose -f docker-compose.dev.yml logs -f

# Stop the development server
stop:
	docker compose -f docker-compose.dev.yml down

# Test MCP endpoint (POST to /mcp)
test-mcp:
	@echo "Testing MCP endpoint..."
	@curl -s -X POST http://localhost:8001/mcp \
		-H "Content-Type: application/json" \
		-d '{"jsonrpc": "2.0", "method": "initialize", "params": {"protocolVersion": "2024-11-05", "capabilities": {}, "clientInfo": {"name": "test", "version": "1.0"}}, "id": 1}' | head -200

# Test root endpoint
test-root:
	@curl -s http://localhost:8001/ | head -20

# Test health endpoint (bypasses MCP_ALLOWED_HOSTS)
test-health:
	@echo "Testing health endpoint..."
	@curl -s http://localhost:8001/health

# Full rebuild (no cache)
rebuild:
	docker compose -f docker-compose.dev.yml build --no-cache

# Clean up containers and images
clean:
	docker compose -f docker-compose.dev.yml down --rmi local -v
