#!/bin/bash
set -e
echo "Setting up MariaDB MCP Server..."
echo ""
# Get the absolute path of the project directory
PROJECT_DIR="$(cd "$(dirname "$0")" && pwd)"
# Check if MariaDB Connector/C is installed
if ! command -v mariadb_config &> /dev/null; then
echo "MariaDB Connector/C not found. Installing via Homebrew..."
if command -v brew &> /dev/null; then
brew install mariadb-connector-c
else
echo "Error: Homebrew not found. Please install MariaDB Connector/C manually."
echo "Visit: https://mariadb.com/downloads/connectors/c"
exit 1
fi
fi
# Set MariaDB config path
export MARIADB_CONFIG=$(brew --prefix mariadb-connector-c)/bin/mariadb_config
# Create virtual environment
echo "Creating virtual environment..."
python3 -m venv venv
# Activate virtual environment and install dependencies
echo "Installing dependencies..."
source venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
# Create config.json from example if it doesn't exist
if [ ! -f config.json ]; then
echo ""
echo "Creating config.json from template..."
cat > config.json << EOF
{
"mcpServers": {
"mariadb": {
"command": "${PROJECT_DIR}/venv/bin/python",
"args": ["${PROJECT_DIR}/mariadb_mcp_server.py"],
"env": {
"MARIADB_HOST": "127.0.0.1",
"MARIADB_PORT": "3306",
"MARIADB_USER": "root",
"MARIADB_PASSWORD": "your_password_here",
"MARIADB_DATABASE": "",
"MARIADB_READ_ONLY": "false",
"MARIADB_POOL_SIZE": "5"
}
}
}
}
EOF
echo "Created config.json with absolute paths"
fi
echo ""
echo "✓ Setup complete!"
echo ""
echo "Next steps:"
echo "1. Edit config.json and update MARIADB_PASSWORD and other database credentials"
echo "2. Copy the config to Claude Desktop:"
echo " cp config.json ~/Library/Application\\ Support/Claude/claude_desktop_config.json"
echo "3. Restart Claude Desktop"
echo ""
echo "Project directory: ${PROJECT_DIR}"