forked from MagicBeansAI/magictunnel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
406 lines (354 loc) Β· 15.8 KB
/
Makefile
File metadata and controls
406 lines (354 loc) Β· 15.8 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
# MCP Proxy Development Makefile
.PHONY: help build build-release test test-verbose test-agent-router test-data-structures test-streaming test-performance test-grpc test-integration test-mcp-server test-registry test-capabilities check fmt fmt-check clippy clippy-all clean run run-config run-release-openai run-release-env run-dev-env setup-env dev dev-check watch-test watch-run docs audit update install-tools
# Default target
help:
@echo "MCP Proxy Development Commands:"
@echo ""
@echo "Build & Run:"
@echo " build - Build the project"
@echo " build-release - Build for release"
@echo " build-release-semantic - Build with semantic search env vars"
@echo " run - Run the proxy with default config"
@echo " run-config - Run with config.yaml"
@echo " run-release-openai - Run release with OpenAI API key"
@echo " run-release-env - Run release mode with .env file support"
@echo " run-dev-env - Run in dev mode with .env file support"
@echo " dev - Run in development mode with debug logging"
@echo ""
@echo "Smart Discovery Run Options (Real Semantic Search):"
@echo " run-release-ollama - Ollama server (RECOMMENDED for local development)"
@echo " run-release-semantic - OpenAI embeddings (RECOMMENDED for production)"
@echo " run-release-external - Custom embedding API"
@echo ""
@echo "Smart Discovery Run Options (Hash Fallbacks - Testing Only):"
@echo " run-release-local - Hash fallback (all-MiniLM-L6-v2)"
@echo " run-release-hq - Hash fallback (all-mpnet-base-v2)"
@echo ""
@echo "Embedding Pre-generation (Real Semantic Embeddings):"
@echo " pregenerate-embeddings-ollama - Ollama server (RECOMMENDED for local dev)"
@echo " pregenerate-embeddings-openai - OpenAI API (RECOMMENDED for production)"
@echo " pregenerate-embeddings-external - Custom embedding API"
@echo ""
@echo "Embedding Pre-generation (Hash Fallbacks - Testing Only):"
@echo " pregenerate-embeddings-local - Hash fallback (all-MiniLM-L6-v2)"
@echo " pregenerate-embeddings-hq - Hash fallback (all-mpnet-base-v2)"
@echo " pregenerate-embeddings - Uses config model (may be fallback)"
@echo ""
@echo "Environment Support:"
@echo " ENV=production make run-release-env - Use .env.production"
@echo " ENV=staging make run-release-env - Use .env.staging"
@echo " ENV=development make run-dev-env - Use .env.development"
@echo ""
@echo "Testing:"
@echo " test - Run all tests"
@echo " test-verbose - Run tests with output"
@echo " test-agent-router - Run agent router tests"
@echo " test-data-structures - Run data structure tests"
@echo " test-streaming - Run streaming protocol tests"
@echo " test-performance - Run performance tests"
@echo " test-grpc - Run gRPC integration tests"
@echo " test-integration - Run integration tests"
@echo " test-mcp-server - Run MCP server tests"
@echo " test-registry - Run registry service tests"
@echo " test-capabilities - Run capability file validation"
@echo ""
@echo "Code Quality:"
@echo " check - Run cargo check"
@echo " fmt - Format code with rustfmt"
@echo " fmt-check - Check code formatting"
@echo " clippy - Run clippy lints"
@echo " clippy-all - Run clippy with all features"
@echo " dev-check - Run full development check (fmt + clippy + test + build)"
@echo ""
@echo "Development:"
@echo " watch-test - Watch for changes and run tests"
@echo " watch-run - Watch for changes and run proxy"
@echo " docs - Generate and open documentation"
@echo " clean - Clean build artifacts"
@echo ""
@echo "Maintenance:"
@echo " install-tools - Install development tools"
@echo " setup-env - Set up .env file for development"
@echo " audit - Check for security vulnerabilities"
@echo " update - Update dependencies"
# Build the project
build:
cargo build
# Build for release
build-release:
MAGICTUNNEL_ENV=development cargo build --release && sleep 2 && cp target/release/magictunnel . && cp target/release/magictunnel-supervisor .
# Update version across all files
update-version:
cargo run --bin version-manager -- update
# Check version consistency
check-version:
cargo run --bin version-manager -- check
# Set new version
set-version:
@if [ -z "$(VERSION)" ]; then echo "Usage: make set-version VERSION=x.y.z"; exit 1; fi
cargo run --bin version-manager -- set $(VERSION)
# Build for release with semantic search environment variables
build-release-semantic:
MAGICTUNNEL_ENV=development \
MAGICTUNNEL_SEMANTIC_MODEL="ollama:nomic-embed-text" \
MAGICTUNNEL_DISABLE_SEMANTIC="false" \
OLLAMA_BASE_URL="http://localhost:11434" \
cargo build --release && sleep 2 && cp target/release/magictunnel . && cp target/release/magictunnel-supervisor .
# Run all tests
test:
cargo test
# Run tests with output
test-verbose:
cargo test -- --nocapture
# Run cargo check
check:
cargo check
# Format code
fmt:
cargo fmt
# Check formatting
fmt-check:
cargo fmt -- --check
# Run clippy
clippy:
cargo clippy -- -D warnings
# Run clippy with all features
clippy-all:
cargo clippy --all-features -- -D warnings
# Clean build artifacts
clean:
cargo clean
# Run the proxy
run-release-wo-config:
cargo run --bin magictunnel --release
# Run in development mode
run-dev-wo-config:
cargo run --bin magictunnel -- --log-level debug
# Run in development mode
run-dev:
cargo run --bin magictunnel -- --log-level debug --config magictunnel-config.yaml
# Run with custom config
run-release:
cargo run --bin magictunnel --release -- --config magictunnel-config.yaml --log-level info
# Run with OpenAI API key for smart discovery
run-release-openai:
@if [ -z "$(OPENAI_API_KEY)" ]; then \
echo "Error: OPENAI_API_KEY environment variable is not set"; \
echo "Usage: make run-openai OPENAI_API_KEY=sk-your-key-here"; \
exit 1; \
fi
OPENAI_API_KEY="$(OPENAI_API_KEY)" cargo run --bin magictunnel -- --config magictunnel-config.yaml --log-level info
# Run with semantic search environment variables override (OpenAI)
run-release-semantic:
@if [ -z "$(OPENAI_API_KEY)" ]; then \
echo "Error: OPENAI_API_KEY environment variable is not set for OpenAI embeddings"; \
echo "Usage: make run-release-semantic OPENAI_API_KEY=sk-your-key-here"; \
exit 1; \
fi
@echo "π§ Starting MagicTunnel with OpenAI semantic search..."
@echo " - Model: openai:text-embedding-3-small"
@echo " - Semantic search: enabled"
OPENAI_API_KEY="$(OPENAI_API_KEY)" \
MAGICTUNNEL_SEMANTIC_MODEL="openai:text-embedding-3-small" \
MAGICTUNNEL_DISABLE_SEMANTIC="false" \
cargo run --bin magictunnel --release -- --config magictunnel-config.yaml --log-level info
# Run with local transformer models (fallback embeddings - limited functionality)
run-release-local:
@echo "β οΈ Starting MagicTunnel with fallback embeddings (LIMITED FUNCTIONALITY)..."
@echo " - Model: all-MiniLM-L6-v2 (384-dim, hash-based fallback)"
@echo " - WARNING: Uses deterministic fallback, not real semantic embeddings"
@echo " - RECOMMENDED: Use 'make run-release-ollama' instead for real embeddings"
MAGICTUNNEL_SEMANTIC_MODEL="all-MiniLM-L6-v2" \
MAGICTUNNEL_DISABLE_SEMANTIC="false" \
cargo run --bin magictunnel --release -- --config magictunnel-config.yaml --log-level info
# Run with high-quality local model (fallback embeddings - limited functionality)
run-release-hq:
@echo "β οΈ Starting MagicTunnel with fallback embeddings (LIMITED FUNCTIONALITY)..."
@echo " - Model: all-mpnet-base-v2 (768-dim, hash-based fallback)"
@echo " - WARNING: Uses deterministic fallback, not real semantic embeddings"
@echo " - RECOMMENDED: Use 'make run-release-ollama' instead for real embeddings"
MAGICTUNNEL_SEMANTIC_MODEL="all-mpnet-base-v2" \
MAGICTUNNEL_DISABLE_SEMANTIC="false" \
cargo run --bin magictunnel --release -- --config magictunnel-config.yaml --log-level info
# Run with Ollama (local LLM server)
run-release-ollama:
@echo "π§ Starting MagicTunnel with Ollama..."
@echo " - Model: Uses your local Ollama server"
@echo " - Make sure Ollama is running with an embedding model!"
OLLAMA_BASE_URL="http://localhost:11434" \
MAGICTUNNEL_SEMANTIC_MODEL="ollama:nomic-embed-text" \
MAGICTUNNEL_DISABLE_SEMANTIC="false" \
cargo run --bin magictunnel --release -- --config magictunnel-config.yaml --log-level info
# Run with custom external API
run-release-external:
@if [ -z "$(EMBEDDING_API_URL)" ]; then \
echo "Error: EMBEDDING_API_URL environment variable is not set"; \
echo "Usage: make run-release-external EMBEDDING_API_URL=http://your-server:8080"; \
exit 1; \
fi
@echo "π§ Starting MagicTunnel with external embedding API..."
@echo " - API URL: $(EMBEDDING_API_URL)"
@echo " - Custom embedding service"
EMBEDDING_API_URL="$(EMBEDDING_API_URL)" \
MAGICTUNNEL_SEMANTIC_MODEL="external:api" \
MAGICTUNNEL_DISABLE_SEMANTIC="false" \
cargo run --bin magictunnel --release -- --config magictunnel-config.yaml --log-level info
# Pre-generate embeddings for all enabled capabilities
pregenerate-embeddings:
@if [ -z "$(OPENAI_API_KEY)" ]; then \
echo "Error: OPENAI_API_KEY environment variable is not set for embedding generation"; \
echo "Usage: make pregenerate-embeddings OPENAI_API_KEY=sk-your-key-here"; \
exit 1; \
fi
@echo "π§ Pre-generating embeddings for all enabled capabilities..."
@echo " - Model: configured in magictunnel-config.yaml"
@echo " - This will make server startup much faster!"
OPENAI_API_KEY="$(OPENAI_API_KEY)" \
cargo run --bin magictunnel --release -- --config magictunnel-config.yaml --log-level info --pregenerate-embeddings
# Pre-generate embeddings with OpenAI model override
pregenerate-embeddings-openai:
@if [ -z "$(OPENAI_API_KEY)" ]; then \
echo "Error: OPENAI_API_KEY environment variable is not set for OpenAI embeddings"; \
echo "Usage: make pregenerate-embeddings-openai OPENAI_API_KEY=sk-your-key-here"; \
exit 1; \
fi
@echo "π§ Pre-generating embeddings with OpenAI model override..."
@echo " - Model: openai:text-embedding-3-small (environment override)"
@echo " - This will make server startup much faster!"
OPENAI_API_KEY="$(OPENAI_API_KEY)" \
MAGICTUNNEL_SEMANTIC_MODEL="openai:text-embedding-3-small" \
MAGICTUNNEL_DISABLE_SEMANTIC="false" \
cargo run --bin magictunnel --release -- --config magictunnel-config.yaml --log-level info --pregenerate-embeddings
# Pre-generate embeddings with fallback models (limited functionality)
pregenerate-embeddings-local:
@echo "β οΈ Pre-generating fallback embeddings (LIMITED FUNCTIONALITY)..."
@echo " - Model: all-MiniLM-L6-v2 (384-dim, hash-based fallback)"
@echo " - WARNING: Uses deterministic fallback, not real semantic embeddings"
@echo " - RECOMMENDED: Use 'make pregenerate-embeddings-ollama' instead"
MAGICTUNNEL_SEMANTIC_MODEL="all-MiniLM-L6-v2" \
MAGICTUNNEL_DISABLE_SEMANTIC="false" \
cargo run --bin magictunnel --release -- --config magictunnel-config.yaml --log-level info --pregenerate-embeddings
# Pre-generate embeddings with fallback models (limited functionality)
pregenerate-embeddings-hq:
@echo "β οΈ Pre-generating fallback embeddings (LIMITED FUNCTIONALITY)..."
@echo " - Model: all-mpnet-base-v2 (768-dim, hash-based fallback)"
@echo " - WARNING: Uses deterministic fallback, not real semantic embeddings"
@echo " - RECOMMENDED: Use 'make pregenerate-embeddings-ollama' instead"
MAGICTUNNEL_SEMANTIC_MODEL="all-mpnet-base-v2" \
MAGICTUNNEL_DISABLE_SEMANTIC="false" \
cargo run --bin magictunnel --release -- --config magictunnel-config.yaml --log-level info --pregenerate-embeddings
# Pre-generate embeddings with Ollama (local LLM server)
pregenerate-embeddings-ollama:
@echo "π§ Pre-generating embeddings with Ollama..."
@echo " - Model: Uses your local Ollama server"
@echo " - Make sure Ollama is running with an embedding model!"
OLLAMA_BASE_URL="http://localhost:11434" \
MAGICTUNNEL_SEMANTIC_MODEL="ollama:nomic-embed-text" \
MAGICTUNNEL_DISABLE_SEMANTIC="false" \
cargo run --bin magictunnel --release -- --config magictunnel-config.yaml --log-level info --pregenerate-embeddings
# Pre-generate embeddings with custom external API
pregenerate-embeddings-external:
@if [ -z "$(EMBEDDING_API_URL)" ]; then \
echo "Error: EMBEDDING_API_URL environment variable is not set"; \
echo "Usage: make pregenerate-embeddings-external EMBEDDING_API_URL=http://your-server:8080"; \
exit 1; \
fi
@echo "π§ Pre-generating embeddings with external API..."
@echo " - API URL: $(EMBEDDING_API_URL)"
@echo " - Custom embedding service"
EMBEDDING_API_URL="$(EMBEDDING_API_URL)" \
MAGICTUNNEL_SEMANTIC_MODEL="external:api" \
MAGICTUNNEL_DISABLE_SEMANTIC="false" \
cargo run --bin magictunnel --release -- --config magictunnel-config.yaml --log-level info --pregenerate-embeddings
# Run in release mode with .env file support
run-release-env:
@if [ ! -f .env ] && [ ! -f .env.development ] && [ ! -f .env.production ]; then \
echo "π¨ No .env files found!"; \
echo ""; \
echo "π To get started:"; \
echo " 1. Copy the example: cp .env.example .env"; \
echo " 2. Edit .env and set your OPENAI_API_KEY"; \
echo " 3. Run: make run-release-env"; \
echo ""; \
echo "Or use environment-specific files:"; \
echo " make run-release-env ENV=production"; \
echo " make run-release-env ENV=staging"; \
echo ""; \
exit 1; \
fi
@echo "π Starting MagicTunnel (Release) with .env configuration..."
@echo " - Building in release mode..."
$(if $(ENV),MAGICTUNNEL_ENV=$(ENV)) cargo run --bin magictunnel --release -- --config magictunnel-config.yaml --log-level info
# Run in development mode with .env file support
run-dev-env:
@if [ ! -f .env ] && [ ! -f .env.development ] && [ ! -f .env.production ]; then \
echo "π¨ No .env files found!"; \
echo ""; \
echo "π To get started:"; \
echo " 1. Copy the example: cp .env.example .env"; \
echo " 2. Edit .env and set your OPENAI_API_KEY"; \
echo " 3. Run: make run-dev-env"; \
echo ""; \
echo "Or use environment-specific files:"; \
echo " make run-dev-env ENV=development"; \
echo " make run-dev-env ENV=staging"; \
echo ""; \
exit 1; \
fi
@echo "π Starting MagicTunnel with .env configuration..."
$(if $(ENV),MAGICTUNNEL_ENV=$(ENV)) cargo run --bin magictunnel -- --config magictunnel-config.yaml --log-level debug
# Set up .env file for development
setup-env:
@if [ -f .env ]; then \
echo "β
.env file already exists"; \
else \
echo "π Creating .env file from example..."; \
cp .env.example .env; \
echo "β
.env file created!"; \
echo ""; \
echo "β οΈ IMPORTANT: Edit .env file and set your OpenAI API key:"; \
echo " OPENAI_API_KEY=sk-your-actual-openai-key-here"; \
echo ""; \
echo "π Then run: make run-dev-env"; \
fi
# Install development tools
install-tools:
rustup component add rustfmt clippy
# Full development check (format, clippy, test, build)
dev-check: fmt clippy test build
@echo "β
All development checks passed!"
# Watch for changes and run tests
watch-test:
cargo watch -x test
# Watch for changes and run the proxy
watch-run:
cargo watch -x "run -- --log-level debug"
# Run specific test suite
test-agent-router:
cargo test --test agent_router_test
test-data-structures:
cargo test --test data_structures_test
test-streaming:
cargo test --test streaming_protocols_test
test-performance:
cargo test --test performance_test
test-grpc:
cargo test --test grpc_integration_test
test-integration:
cargo test --test integration_test
test-mcp-server:
cargo test --test mcp_server_test
test-registry:
cargo test --test registry_service_test
# Run capability file validation
test-capabilities:
cargo test --test yaml_parsing_test
# Generate documentation
docs:
cargo doc --open
# Check for security vulnerabilities
audit:
cargo audit
# Update dependencies
update:
cargo update