# =============================================================================
# SUPABASE COOLIFY MCP SERVER - ENVIRONMENT CONFIGURATION
# =============================================================================
# Copy this file to .env and fill in your actual values
# Command: cp env.example .env
# =============================================================================
# =============================================================================
# REQUIRED CONFIGURATION
# =============================================================================
# Coolify API Configuration (REQUIRED)
# Get your API token from Coolify: Settings > API Tokens > Create New Token
COOLIFY_API_URL=http://localhost:8000
COOLIFY_API_TOKEN=your-coolify-api-token-here
# Supabase Configuration (REQUIRED)
# These are required for managing your Supabase instance
SUPABASE_URL=https://your-supabase-instance.example.com
SUPABASE_SERVICE_ROLE_KEY=your-supabase-service-role-key
# =============================================================================
# OPTIONAL CONFIGURATION
# =============================================================================
# Coolify Team ID (Optional)
# Only needed if you're part of multiple teams in Coolify
# COOLIFY_TEAM_ID=your-team-id
# Supabase Anon Key (Optional)
# The public anonymous key for client-side access
# Found in: Supabase Dashboard > Settings > API
# SUPABASE_ANON_KEY=your-supabase-anon-key
# =============================================================================
# SUPABASE CLI CONFIGURATION (Optional, for CLI tools)
# =============================================================================
# Supabase Access Token (Optional)
# Personal access token for Supabase CLI authenticated operations
# Get from: https://app.supabase.com/account/tokens
# Required for: supabase_link, supabase_db_push, supabase_functions_deploy
# SUPABASE_ACCESS_TOKEN=sbp_your-access-token-here
# Supabase Project Reference (Optional)
# Your project's reference ID (e.g., abcdefghijklmnopqrst)
# Found in: Supabase Dashboard > Settings > General > Reference ID
# Used by CLI tools for remote operations
# SUPABASE_PROJECT_REF=your-project-ref
# Supabase Project ID (Optional)
# Your project's UUID
# Found in: Supabase Dashboard > Settings > General > Project ID
# SUPABASE_PROJECT_ID=your-project-id
# =============================================================================
# DIRECT DATABASE ACCESS (Optional)
# =============================================================================
# Direct PostgreSQL Database Connection (Optional)
# Only needed if you want direct database access (bypassing REST API)
# Useful for advanced operations, migrations, and better performance
# Individual connection parameters:
# SUPABASE_DB_HOST=db.your-supabase-instance.example.com
# SUPABASE_DB_PORT=5432
# SUPABASE_DB_NAME=postgres
# SUPABASE_DB_USER=postgres
# SUPABASE_DB_PASSWORD=your-secure-db-password
# OR use a full connection string:
# SUPABASE_DB_URL=postgresql://postgres:password@host:5432/postgres
# =============================================================================
# EDGE FUNCTIONS CONFIGURATION (Optional)
# =============================================================================
# Edge Functions URL (Optional)
# Custom URL for edge functions if different from main URL
# For Supabase Cloud: https://your-project-ref.functions.supabase.co
# For Self-hosted: Usually https://your-domain.com/functions/v1
# SUPABASE_FUNCTIONS_URL=https://your-supabase-instance.example.com/functions/v1
# =============================================================================
# DEVELOPMENT SETTINGS (Optional)
# =============================================================================
# Node Environment (Optional)
# Set to 'development' for development mode, 'production' for production
# NODE_ENV=development
# Debug Mode (Optional)
# Enable detailed logging for troubleshooting
# DEBUG=supabase-coolify:*
# =============================================================================
# CONFIGURATION GUIDE
# =============================================================================
#
# MINIMUM REQUIRED VARIABLES FOR BASIC USAGE:
# ✓ COOLIFY_API_URL - Your Coolify instance URL
# ✓ COOLIFY_API_TOKEN - API token from Coolify
# ✓ SUPABASE_URL - Your Supabase instance URL
# ✓ SUPABASE_SERVICE_ROLE_KEY - Service role key (admin access)
#
# ADDITIONAL VARIABLES BY USE CASE:
#
# FOR CLI TOOLS (supabase_* commands):
# + SUPABASE_ACCESS_TOKEN - For authenticated CLI operations
# + SUPABASE_PROJECT_REF - For linking to remote project
#
# FOR DIRECT DATABASE ACCESS:
# + SUPABASE_DB_HOST - Database hostname
# + SUPABASE_DB_PORT - Database port (usually 5432)
# + SUPABASE_DB_NAME - Database name (usually postgres)
# + SUPABASE_DB_USER - Database user (usually postgres)
# + SUPABASE_DB_PASSWORD - Database password
# OR
# + SUPABASE_DB_URL - Full PostgreSQL connection string
#
# FOR MIGRATION ROLLBACK:
# (Uses SUPABASE_URL and SUPABASE_SERVICE_ROLE_KEY - no extra config needed)
#
# FOR EDGE FUNCTIONS:
# + SUPABASE_FUNCTIONS_URL - Custom functions URL if different
#
# =============================================================================
# WHERE TO FIND YOUR CREDENTIALS
# =============================================================================
#
# COOLIFY:
# 1. Log into your Coolify instance
# 2. Go to "Keys & Tokens" > "API tokens"
# 3. Click "Create New Token"
# 4. Copy the token (save it - you won't see it again!)
#
# SUPABASE (Self-hosted):
# 1. Check your Coolify deployment environment variables
# 2. Look for SERVICE_ROLE_KEY and ANON_KEY
# 3. Or check your Supabase configuration files
#
# SUPABASE (Cloud):
# 1. Go to https://app.supabase.com
# 2. Select your project
# 3. Go to Settings > API
# 4. Copy the service_role key and anon key
#
# SUPABASE ACCESS TOKEN (for CLI):
# 1. Go to https://app.supabase.com/account/tokens
# 2. Click "Generate New Token"
# 3. Give it a name and copy the token
#
# SUPABASE PROJECT REF:
# 1. Go to your project in Supabase Dashboard
# 2. Settings > General > Reference ID
# 3. Copy the reference ID (short alphanumeric string)
#
# =============================================================================
# SECURITY BEST PRACTICES
# =============================================================================
#
# ⚠️ CRITICAL SECURITY REMINDERS:
#
# 1. NEVER commit .env files to version control
# - Add .env to .gitignore (already done)
# - Use .env.example (this file) as a template
#
# 2. Keep service role keys SECURE
# - Service role key has ADMIN access to your database
# - Never expose it in client-side code
# - Never commit it to repos
#
# 3. Use strong passwords
# - Minimum 32 characters for database passwords
# - Minimum 64 characters for JWT secrets
# - Use password generators
#
# 4. Rotate credentials regularly
# - API tokens: every 90 days
# - JWT secrets: annually or after security incidents
# - Database passwords: as needed
#
# 5. Use environment-specific files
# - .env.development - for local development
# - .env.staging - for staging environment
# - .env.production - for production (keep secure!)
#
# 6. Set proper file permissions
# - chmod 600 .env (read/write for owner only)
# - Keep credentials in secure password manager
#
# 7. Use secrets management in production
# - Consider using: AWS Secrets Manager, HashiCorp Vault, etc.
# - Or environment variables from your hosting platform
#
# =============================================================================
# TROUBLESHOOTING
# =============================================================================
#
# ERROR: "Missing required environment variables"
# → Make sure COOLIFY_API_URL and COOLIFY_API_TOKEN are set
# → Make sure SUPABASE_URL and SUPABASE_SERVICE_ROLE_KEY are set
#
# ERROR: "CLI not found" or CLI commands fail
# → Install Supabase CLI: npm install -g supabase
# → Set SUPABASE_ACCESS_TOKEN if using authenticated commands
#
# ERROR: "Database connection failed"
# → Check SUPABASE_DB_* variables are correct
# → Verify database is accessible from your network
# → Check firewall rules
#
# ERROR: "Unauthorized" or 401 errors
# → Verify API tokens are correct and not expired
# → Check you're using service_role key (not anon key) for admin operations
#
# =============================================================================
# EXAMPLES
# =============================================================================
#
# Example 1: Basic Setup (Self-hosted Supabase on Coolify)
# COOLIFY_API_URL=https://coolify.mycompany.com
# COOLIFY_API_TOKEN=clf_abc123...
# SUPABASE_URL=https://supabase.mycompany.com
# SUPABASE_SERVICE_ROLE_KEY=eyJhbGc...
#
# Example 2: With CLI Integration
# (Add to Example 1)
# SUPABASE_ACCESS_TOKEN=sbp_xyz789...
# SUPABASE_PROJECT_REF=myproject
#
# Example 3: With Direct Database Access
# (Add to Example 1)
# SUPABASE_DB_HOST=db.supabase.mycompany.com
# SUPABASE_DB_PORT=5432
# SUPABASE_DB_NAME=postgres
# SUPABASE_DB_USER=postgres
# SUPABASE_DB_PASSWORD=VerySecurePassword123!
#
# =============================================================================
# ADDITIONAL RESOURCES
# =============================================================================
#
# Documentation:
# - Main README: ./README.md
# - Deployment Guide: ./DEPLOYMENT_GUIDE.md
# - CLI Guide: ./docs/SUPABASE_CLI.md
# - Rollback Guide: ./docs/MIGRATION_ROLLBACK.md
#
# External Links:
# - Coolify Docs: https://coolify.io/docs
# - Supabase Docs: https://supabase.com/docs
# - Supabase CLI: https://supabase.com/docs/guides/cli
#
# =============================================================================