forked from driosalido/mcp-karma
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjustfile
More file actions
164 lines (124 loc) · 4.18 KB
/
Copy pathjustfile
File metadata and controls
164 lines (124 loc) · 4.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# Karma MCP Server - Modern task runner with Just
# https://github.com/casey/just
# Variables
python := "python3"
uv := "uv"
docker_image := "driosalido/karma-mcp"
docker_tag := "latest"
karma_url := env_var_or_default("KARMA_URL", "http://localhost:8080")
# Default command - show available recipes
default:
@just --list
# === Installation ===
# Install dependencies
install:
{{uv}} sync --all-extras
@echo "✅ Dependencies installed"
# Install development dependencies
install-dev:
{{uv}} sync --all-extras --dev
@echo "✅ Development dependencies installed"
# === Testing ===
# Run all tests
test:
{{uv}} run pytest tests/ -v
# Run only unit tests
test-unit:
{{uv}} run pytest tests/unit/ -v
# Run only integration tests (requires KARMA_URL)
test-integration:
KARMA_URL={{karma_url}} {{uv}} run pytest tests/integration/ -v
# Run tests with coverage
test-coverage:
{{uv}} run pytest --cov=src/karma_mcp --cov-report=html --cov-report=term-missing tests/
@echo "📊 Coverage report generated in htmlcov/"
# Test specific MCP tools
test-mcp-tools:
{{uv}} run pytest tests/unit/test_mcp_tools.py -v
# === Code Quality ===
# Run linting checks
lint:
{{uv}} run ruff check src/ tests/
# Format code
format:
{{uv}} run ruff format src/ tests/
@echo "✅ Code formatted"
# Run type checking
type-check:
{{uv}} run mypy src/
# Run all quality checks
check: lint type-check test-unit
@echo "✅ All checks passed"
# === Development ===
# Run MCP server locally for testing
serve-mcp:
KARMA_URL={{karma_url}} {{uv}} run python -m karma_mcp.server
# Debug Karma API responses
debug-karma:
KARMA_URL={{karma_url}} {{uv}} run python -c 'import asyncio; from karma_mcp.server import check_karma; asyncio.run(check_karma())'
# === Docker ===
# Build Docker image for multiple platforms
docker-build:
docker buildx build --platform linux/amd64,linux/arm64 -t {{docker_image}}:{{docker_tag}} -f docker/Dockerfile . --push
# Build Docker image locally
docker-build-local:
docker buildx build -t {{docker_image}}:{{docker_tag}} -f docker/Dockerfile . --load
# Run Docker image locally
docker-run:
docker run --rm -p 8080:8080 -e KARMA_URL={{karma_url}} {{docker_image}}:{{docker_tag}}
# Test Docker image
docker-test:
docker run --rm {{docker_image}}:{{docker_tag}} python -m pytest tests/unit/ -v
# === Kubernetes/Helm ===
# Install Helm chart (requires kubectl context)
helm-install:
helm install karma-mcp ./helm/karma-mcp -n monitoring --create-namespace
# Upgrade Helm chart
helm-upgrade:
helm upgrade karma-mcp ./helm/karma-mcp -n monitoring
# Uninstall Helm chart
helm-uninstall:
helm uninstall karma-mcp -n monitoring
# === Cleanup ===
# Clean up generated files
clean:
rm -rf htmlcov/
rm -rf .coverage
rm -rf .pytest_cache/
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
find . -type f -name "*.pyc" -delete
@echo "🧹 Cleaned up generated files"
# Clean up Docker images
clean-docker:
docker image prune -f
@echo "🐳 Docker images cleaned"
# === Utilities ===
# Show current version
version:
@echo "Karma MCP Server"
@grep -E '^version = ' pyproject.toml | head -1
@echo "Docker image: {{docker_image}}:{{docker_tag}}"
# Validate configuration files
validate:
@echo "Validating pyproject.toml..."
@{{python}} -c "import tomllib; tomllib.load(open('pyproject.toml', 'rb'))" && echo "✅ pyproject.toml is valid"
# Set up development environment
dev-setup: install-dev
@echo "🚀 Development environment ready!"
@echo ""
@echo "Next steps:"
@echo " just test-unit # Run unit tests"
@echo " just serve-mcp # Start MCP server"
@echo " just check # Run all checks"
# === CI/CD ===
# Run tests in CI environment
ci-test:
{{uv}} run pytest --cov=src/karma_mcp --cov-report=xml --cov-report=term-missing -v
# Run quality checks for CI
ci-quality: lint type-check
@echo "✅ Quality checks completed"
# === Karma Integration ===
# Quick test with real Karma server (requires port-forward)
test-with-karma:
@echo "Testing with Karma at {{karma_url}}"
KARMA_URL={{karma_url}} {{uv}} run python scripts/test_karma.py