Skip to content

Commit 10c91eb

Browse files
committed
db setup
1 parent 7b504a3 commit 10c91eb

File tree

2 files changed

+59
-15
lines changed

2 files changed

+59
-15
lines changed

README.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,15 +371,20 @@ After running `source .claude/shortcuts.sh`:
371371

372372
### Common Installation Issues
373373

374-
**Database MCP Integration Skipped**
374+
**Database MCP Server Installed But Not Configured**
375375
```bash
376-
# Issue: "No database configured in .env file"
377-
# Solution: Configure database in .env
376+
# Issue: "Database MCP server installed but project-specific config skipped"
377+
# Explanation: Database MCP server installs globally but needs project configuration
378+
379+
# Solution: Ensure DB_DATABASE is set in .env
378380
DB_DATABASE=your_project_name
379381
DB_HOST=127.0.0.1
380382
DB_PORT=3306
381383
DB_USERNAME=root
382384
DB_PASSWORD=
385+
386+
# Then re-run setup to configure project-specific database access
387+
./setup.sh
383388
```
384389

385390
**Playwright Browser Installation Warning**
@@ -409,6 +414,22 @@ npx playwright install
409414
# Solution: This is expected - the official server is deprecated but still functional
410415
```
411416

417+
**Understanding Database MCP Server Installation**
418+
```bash
419+
# The setup process has two phases for database integration:
420+
421+
# Phase 1: Global Installation (always runs if Go is available)
422+
[STEP] Installing Database MCP Server (FreePeak)...
423+
[SUCCESS] Database MCP Server installed!
424+
425+
# Phase 2: Project Configuration (only if DB_DATABASE is set)
426+
[STEP] Generating database configuration...
427+
[WARNING] No database name found. Skipping project-specific database MCP configuration.
428+
429+
# This is normal behavior - the server is installed globally but needs
430+
# project-specific configuration to access your database
431+
```
432+
412433
### Quick Fixes
413434

414435
```bash

setup.sh

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ install_context7() {
360360
# Install Database MCP Server (FreePeak version)
361361
install_database() {
362362
print_step "Installing Database MCP Server (FreePeak)..."
363+
print_status "Note: Installing database MCP server globally (project-specific config handled later)"
363364

364365
if ! check_go; then
365366
print_warning "Go installation failed. Skipping database MCP server."
@@ -534,10 +535,22 @@ parse_env() {
534535

535536
# Source the .env file safely
536537
if [ -f ".env" ]; then
537-
# Export variables that don't start with # and contain =
538-
set -a
539-
source <(grep -v '^#' .env | grep '=' | sed 's/^/export /')
540-
set +a
538+
# Parse .env more reliably
539+
while IFS='=' read -r key value; do
540+
# Skip comments and empty lines
541+
[[ $key =~ ^[[:space:]]*# ]] && continue
542+
[[ -z $key ]] && continue
543+
544+
# Clean key and value
545+
key=$(echo "$key" | tr -d '[:space:]')
546+
# Remove surrounding quotes only (double or single)
547+
if [[ $value =~ ^\".*\"$ ]]; then
548+
value="${value:1:${#value}-2}"
549+
elif [[ $value =~ ^\'.*\'$ ]]; then
550+
value="${value:1:${#value}-2}"
551+
fi
552+
export "$key=$value"
553+
done < .env
541554
fi
542555

543556
# Get database connection details with defaults
@@ -550,7 +563,14 @@ parse_env() {
550563

551564
print_success "Environment variables parsed!"
552565
print_status "Database: $DB_CONNECTION on $DB_HOST:$DB_PORT"
553-
if [ ! -z "$DB_DATABASE" ]; then
566+
567+
# Debug: Show what we parsed for DB_DATABASE
568+
if [ -f ".env" ] && grep -q "^DB_DATABASE=" .env; then
569+
local env_db_value=$(grep "^DB_DATABASE=" .env | cut -d'=' -f2- | sed 's/^["\x27]\|["\x27]$//g')
570+
print_status "Found DB_DATABASE in .env: '$env_db_value'"
571+
fi
572+
573+
if [ ! -z "$DB_DATABASE" ] && [ "$DB_DATABASE" != "" ]; then
554574
print_status "Database name: $DB_DATABASE"
555575
else
556576
print_warning "No database name configured in .env file"
@@ -562,12 +582,14 @@ parse_env() {
562582
# Generate database configuration for the MCP server
563583
generate_database_config() {
564584
print_step "Generating database configuration..."
585+
print_status "Creating project-specific database MCP configuration..."
565586

566587
PROJECT_PATH="$PWD"
567588

568-
if [ -z "$DB_DATABASE" ]; then
569-
print_warning "No database configured in .env file. Skipping database MCP configuration."
570-
print_status "To enable database MCP integration:"
589+
if [ -z "$DB_DATABASE" ] || [ "$DB_DATABASE" = "" ]; then
590+
print_warning "No database name found. Skipping project-specific database MCP configuration."
591+
print_status "Note: Database MCP server is installed globally but won't be configured for this project"
592+
print_status "To enable database MCP integration for this project:"
571593
print_status "1. Set DB_DATABASE in your .env file (e.g., DB_DATABASE=your_project_name)"
572594
print_status "2. Create the database in MySQL/PostgreSQL"
573595
print_status "3. Run the setup script again to configure database MCP access"
@@ -785,10 +807,11 @@ configure_claude_mcp() {
785807
print_warning "Database binary not found or not executable"
786808
fi
787809
else
788-
if [ -z "$DB_DATABASE" ]; then
789-
print_status "No database configured in .env file, skipping Database MCP server"
810+
if [ -z "$DB_DATABASE" ] || [ "$DB_DATABASE" = "" ]; then
811+
print_status "No database name in .env file, skipping project-specific Database MCP server"
812+
print_status "Note: Global database MCP server is still available for manual configuration"
790813
else
791-
print_warning "Database configuration file not found"
814+
print_warning "Database configuration file not found (database-config.json missing)"
792815
fi
793816
fi
794817

@@ -1663,7 +1686,7 @@ install_fluxui_and_volt() {
16631686
# Main installation function
16641687
main() {
16651688
echo "================================================"
1666-
echo "Laravel Claude Code Setup Script v3.2"
1689+
echo "Laravel Claude Code Setup Script v3.3"
16671690
echo "Laravel 12 + FluxUI + Playwright MCP Server"
16681691
echo "================================================"
16691692
echo ""

0 commit comments

Comments
 (0)