add mcp switch

This commit is contained in:
vasilije 2025-07-01 13:12:11 +02:00
parent cb905bba45
commit d14e5149c1

View file

@ -4,6 +4,10 @@ set -e # Exit on error
echo "Debug mode: $DEBUG"
echo "Environment: $ENVIRONMENT"
# Set default transport mode if not specified
TRANSPORT_MODE=${TRANSPORT_MODE:-"stdio"}
echo "Transport mode: $TRANSPORT_MODE"
# Run Alembic migrations with proper error handling.
# Note on UserAlreadyExists error handling:
# During database migrations, we attempt to create a default user. If this user
@ -28,19 +32,31 @@ fi
echo "Database migrations done."
echo "Starting Cognee MCP Server..."
echo "Starting Cognee MCP Server with transport mode: $TRANSPORT_MODE"
# Add startup delay to ensure DB is ready
sleep 2
# Modified Gunicorn startup with error handling
# Modified startup with transport mode selection and error handling
if [ "$ENVIRONMENT" = "dev" ] || [ "$ENVIRONMENT" = "local" ]; then
if [ "$DEBUG" = "true" ]; then
echo "Waiting for the debugger to attach..."
exec python -m debugpy --wait-for-client --listen 0.0.0.0:5678 -m cognee
if [ "$TRANSPORT_MODE" = "sse" ]; then
exec python -m debugpy --wait-for-client --listen 0.0.0.0:5678 -m cognee --transport sse
else
exec python -m debugpy --wait-for-client --listen 0.0.0.0:5678 -m cognee --transport stdio
fi
else
exec cognee
if [ "$TRANSPORT_MODE" = "sse" ]; then
exec cognee --transport sse
else
exec cognee --transport stdio
fi
fi
else
exec cognee
if [ "$TRANSPORT_MODE" = "sse" ]; then
exec cognee --transport sse
else
exec cognee --transport stdio
fi
fi