UNPKG

@spaik/mcp-server-roi

Version:

MCP server for AI ROI prediction and tracking with Monte Carlo simulations

71 lines (50 loc) 2.3 kB
# Applying Database Functions to Supabase The MCP Server ROI requires several PostgreSQL functions to be created in your Supabase database for full functionality. ## Functions to Apply The file `002_transactional_functions.sql` contains 5 essential functions: 1. **`create_project_with_details`** - Atomically creates projects with use cases 2. **`update_project_with_use_cases`** - Updates projects and related data 3. **`create_projection_with_simulation`** - Creates projections with optional simulations 4. **`delete_project_cascade`** - Safely deletes projects and all related data 5. **`validate_project_data`** - Validates project data before operations ## How to Apply ### Option 1: Supabase Dashboard (Recommended) 1. Go to your Supabase project dashboard 2. Navigate to the **SQL Editor** section 3. Copy the entire contents of `002_transactional_functions.sql` 4. Paste it into the SQL editor 5. Click **Run** to execute ### Option 2: Supabase CLI ```bash # Install Supabase CLI if not already installed npm install -g supabase # Apply the functions supabase db push --db-url "postgresql://postgres:[YOUR-PASSWORD]@db.[PROJECT-REF].supabase.co:5432/postgres" ``` ### Option 3: Using psql ```bash psql "postgresql://postgres:[YOUR-PASSWORD]@db.[PROJECT-REF].supabase.co:5432/postgres" < database/002_transactional_functions.sql ``` ## Verification After applying the functions, you can verify they were created successfully: ```sql -- Check if functions exist SELECT proname FROM pg_proc WHERE proname IN ( 'create_project_with_details', 'update_project_with_use_cases', 'create_projection_with_simulation', 'delete_project_cascade', 'validate_project_data' ); ``` You should see all 5 function names in the result. ## Troubleshooting If you encounter errors: 1. **Permission errors**: Ensure you're using the service role key or database owner credentials 2. **Syntax errors**: Make sure you copied the entire SQL file contents 3. **Function already exists**: The functions use `CREATE OR REPLACE`, so this shouldn't occur ## Notes - These functions use `SECURITY DEFINER` to run with elevated privileges - They include proper error handling and transaction management - The `validate_project_data` function is particularly important for the `predict_roi` tool