Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save karstengresch/114ab258651dea74089213d653b2c0b7 to your computer and use it in GitHub Desktop.
Save karstengresch/114ab258651dea74089213d653b2c0b7 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Exit on any error
set -e
# Prompt for OpenAI API Key securely
echo -n "Enter your OpenAI API Key: "
read -s OPENAI_API_KEY
echo ""
# Clone the repository if not already present
if [ ! -d "kai" ]; then
git clone https://github.com/konveyor/kai.git
else
echo "πŸ“ 'kai' repo already exists. Skipping clone."
fi
# Navigate to the kai_mcp_solution_server directory
cd kai/kai_mcp_solution_server
# Create and activate virtual environment
if [ -z "$VIRTUAL_ENV" ]; then
python3 -m venv .venv
fi
source .venv/bin/activate
# Check if uv is installed
if ! command -v uv &> /dev/null; then
echo "❌ 'uv' is not installed. Please install it using: pip install uv"
exit 1
fi
# Sync dependencies
echo "πŸ“¦ Syncing dependencies with uv..."
uv sync
# Ensure greenlet is installed (workaround for missing wheel in uv on macOS/Py3.12)
if ! python -c "import greenlet" &> /dev/null; then
echo "⚠️ 'greenlet' missing. Installing it manually..."
uv pip install greenlet || pip install greenlet
else
echo "βœ… 'greenlet' is installed."
fi
# Export the provided API key
export OPENAI_API_KEY
# Set LLM model to GPT-4o
export KAI_LLM_PARAMS='{"model": "gpt-4o", "model_provider": "openai"}'
# Set Postgres DB connection
export KAI_DB_DSN='postgresql+asyncpg://postgres@localhost:5432/postgres'
export KAI_DB_PASSWORD='mysecretpassword'
# Check if Podman is installed
if ! command -v podman &> /dev/null; then
echo "❌ Podman is not installed. Please install Podman before running this script."
exit 1
fi
# Check if Podman is running
if ! podman info &> /dev/null; then
echo "❌ Podman is not running. Please start the Podman service and try again."
exit 1
fi
# Stop and remove any existing PostgreSQL container
if podman ps -a --format "{{.Names}}" | grep -q "^postgres$"; then
echo "πŸ›‘ Stopping and removing existing PostgreSQL container..."
podman stop postgres || true
podman rm postgres || true
fi
# Start fresh PostgreSQL container
echo "πŸš€ Starting fresh PostgreSQL container with Podman..."
podman run --name postgres \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=mysecretpassword \
-p 5432:5432 \
-d postgres || {
echo "❌ Failed to start PostgreSQL container. Exiting."
exit 1
}
# Start the HTTP server
echo "πŸš€ Starting the solution server on port 8000..."
uv run python -m kai_mcp_solution_server --transport streamable-http --host 0.0.0.0 --port 8000
echo "βœ… Solution server is now running at http://localhost:8000"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment