Skip to main content
Glama

MySQL Database Server

setup.sh5.16 kB
#!/bin/bash # MCP MySQL Server Setup Script # This script helps you quickly set up and configure the MCP MySQL Server set -e # Exit on error echo "======================================" echo "MCP MySQL Server Setup" echo "======================================" echo "" # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' # No Color # Check for Bun or Node.js USE_BUN=false if command -v bun &> /dev/null; then echo -e "${BLUE}Checking Bun...${NC}" echo -e "${GREEN}✓ Bun $(bun --version) detected (using Bun - faster!)${NC}" USE_BUN=true PKG_MANAGER="bun" echo "" elif command -v node &> /dev/null; then echo -e "${BLUE}Checking Node.js version...${NC}" NODE_VERSION=$(node -v | cut -d'v' -f2 | cut -d'.' -f1) if [ "$NODE_VERSION" -lt 18 ]; then echo -e "${RED}Error: Node.js version 18 or higher is required${NC}" echo "Current version: $(node -v)" exit 1 fi echo -e "${GREEN}✓ Node.js $(node -v) detected${NC}" if ! command -v npm &> /dev/null; then echo -e "${RED}Error: npm is not installed${NC}" exit 1 fi echo -e "${GREEN}✓ npm $(npm -v) detected${NC}" PKG_MANAGER="npm" echo -e "${YELLOW}💡 Tip: Consider using Bun for faster performance: https://bun.sh/${NC}" echo "" else echo -e "${RED}Error: Neither Bun nor Node.js is installed${NC}" echo "Please install either:" echo " - Bun (recommended, faster): https://bun.sh/" echo " - Node.js 18+: https://nodejs.org/" exit 1 fi # Install dependencies echo -e "${BLUE}Installing dependencies using $PKG_MANAGER...${NC}" $PKG_MANAGER install if [ $? -eq 0 ]; then echo -e "${GREEN}✓ Dependencies installed successfully${NC}" else echo -e "${RED}✗ Failed to install dependencies${NC}" exit 1 fi echo "" # Create .env file if it doesn't exist if [ ! -f .env ]; then echo -e "${BLUE}Creating .env file from template...${NC}" cp .env.example .env echo -e "${GREEN}✓ .env file created${NC}" echo -e "${YELLOW}⚠ Please edit .env with your MySQL credentials${NC}" echo "" # Interactive configuration read -p "Would you like to configure MySQL settings now? (y/n): " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]]; then read -p "MySQL Host (default: localhost): " MYSQL_HOST MYSQL_HOST=${MYSQL_HOST:-localhost} read -p "MySQL Port (default: 3306): " MYSQL_PORT MYSQL_PORT=${MYSQL_PORT:-3306} read -p "MySQL User: " MYSQL_USER read -sp "MySQL Password: " MYSQL_PASS echo read -p "MySQL Database: " MYSQL_DB # Update .env file cat > .env << EOF # MySQL Connection Configuration MYSQL_HOST=$MYSQL_HOST MYSQL_PORT=$MYSQL_PORT MYSQL_USER=$MYSQL_USER MYSQL_PASS=$MYSQL_PASS MYSQL_DB=$MYSQL_DB # Operation Permissions (default: read-only mode) ALLOW_INSERT_OPERATION=false ALLOW_UPDATE_OPERATION=false ALLOW_DELETE_OPERATION=false EOF echo -e "${GREEN}✓ Configuration saved to .env${NC}" echo "" fi else echo -e "${GREEN}✓ .env file already exists${NC}" echo "" fi # Build the project echo -e "${BLUE}Building TypeScript project...${NC}" $PKG_MANAGER run build if [ $? -eq 0 ]; then echo -e "${GREEN}✓ Build completed successfully${NC}" else echo -e "${RED}✗ Build failed${NC}" exit 1 fi echo "" # Test database connection (if .env is configured) if [ -f .env ]; then source .env if [ ! -z "$MYSQL_HOST" ] && [ ! -z "$MYSQL_USER" ] && [ ! -z "$MYSQL_DB" ]; then echo -e "${BLUE}Testing database connection...${NC}" if command -v mysql &> /dev/null; then if mysql -h "$MYSQL_HOST" -P "$MYSQL_PORT" -u "$MYSQL_USER" -p"$MYSQL_PASS" -e "SELECT 1" "$MYSQL_DB" &> /dev/null; then echo -e "${GREEN}✓ Database connection successful${NC}" else echo -e "${YELLOW}⚠ Could not connect to database${NC}" echo "Please verify your MySQL credentials in .env" fi else echo -e "${YELLOW}⚠ mysql client not found, skipping connection test${NC}" fi echo "" fi fi # Display setup summary echo "======================================" echo -e "${GREEN}Setup Complete!${NC}" echo "======================================" echo "" echo "Next Steps:" echo "" echo "1. If you haven't configured .env yet:" echo " nano .env" echo "" echo "2. Test the server:" if [ "$USE_BUN" = true ]; then echo " bun run start" else echo " npm start" fi echo "" echo "3. Configure your MCP client (Claude Code or Codex CLI):" echo " See examples/claude-code-setup.md" echo " See examples/codex-cli-setup.md" echo "" echo "4. Verify the build:" echo " ls -la dist/index.js" echo "" echo "Documentation:" echo "- README.md - Main documentation" echo "- docs/QUICKSTART.md - Quick start guide" echo "- docs/SETUP_CHECKLIST.md - Setup checklist" echo "- examples/ - Integration guides and usage examples" echo "- CONTRIBUTING.md - Development guidelines" echo "" echo -e "${GREEN}Happy querying! 🚀${NC}"

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/thebusted/mcp-mysql-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server