mysql-analyzer-mcp

Ray0907/mysql-analyzer-mcp

3.2

If you are the rightful owner of mysql-analyzer-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

The MySQL Analyzer MCP Server is a standalone server designed to provide static analysis tools for MySQL databases, focusing on schema integrity, naming conventions, and performance metrics.

Tools
6
Resources
0
Prompts
0

MySQL Analyzer MCP Server

A standalone Model Context Protocol (MCP) server providing a suite of tools for static analysis of MySQL databases, focusing on schema integrity, naming conventions, and performance metrics.

šŸ·ļø Naming Conventions

This MCP server enforces modern, consistent naming conventions:

  • Tables: CamelCase (e.g., Users, ProductCategories)
  • Columns: snake_case (e.g., user_id, created_at)
  • Indexes & Constraints: snake_case with prefixes (e.g., uk_users_email, idx_orders_status)

šŸš€ Quick Start

1. Setup Environment

Create a .env file from the example:

cp .env.example .env

Then, edit the .env file with your database credentials.

2. Build and Install

Run the build script to set up the virtual environment and install dependencies:

./build.sh

3. Run the MCP Server

Activate the virtual environment and run the server:

source .venv/bin/activate
python src/mysql_analyzer_mcp/server.py

4. Test with MCP Inspector

You can test the server using the MCP inspector:

npx @modelcontextprotocol/inspector python src/mysql_analyzer_mcp/server.py

šŸ› ļø MCP Tools

This server provides a suite of tools to analyze and improve your MySQL database.

Available Tools

  • analyze_naming_conventions: Analyzes table and column names and can generate SQL patches to fix them.
  • analyze_database_indexes: Checks for redundant or missing indexes.
  • analyze_database_performance: Identifies potential performance bottlenecks.
  • analyze_database_schema: Validates schema best practices (e.g., charset, collation).
  • comprehensive_analysis: Runs all analyses and provides a summary report.
  • generate_sql_patches: Generates SQL patches for specific issues.

Example Usage in Claude

  • "Analyze my MySQL database naming conventions and generate fixes."
  • "Run a comprehensive analysis of my database."
  • "Check my database indexes for redundancy."

šŸ—ļø Project Structure

mysql-analyzer-mcp/
ā”œā”€ā”€ src/
│   └── mysql_analyzer_mcp/
│       ā”œā”€ā”€ __init__.py
│       └── server.py              # Main MCP server logic using the official MCP SDK
ā”œā”€ā”€ analyzers/
│   ā”œā”€ā”€ __init__.py
│   ā”œā”€ā”€ naming_analyzer.py
│   ā”œā”€ā”€ index_analyzer.py
│   ā”œā”€ā”€ schema_analyzer.py
│   ā”œā”€ā”€ performance_analyzer.py
│   └── utils.py                 # Shared database utility functions
ā”œā”€ā”€ build.sh                       # Build and setup script
ā”œā”€ā”€ config.py                      # Centralized configuration management
ā”œā”€ā”€ db_connector.py                # Database connection handling
ā”œā”€ā”€ patch_generator.py             # SQL patch generation logic
ā”œā”€ā”€ pyproject.toml                 # Package configuration
ā”œā”€ā”€ requirements.txt               # Dependencies
└── .env.example                   # Environment template

šŸ”§ Configuration

All tool arguments and environment variables are documented within the server's tool definitions and can be inspected via MCP.


Built with ā¤ļø following Model Context Protocol standards.