Forked from sshaaf/kai-mcp-solution-server-pre-reqs
Created
September 22, 2025 17:45
-
-
Save karstengresch/114ab258651dea74089213d653b2c0b7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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