mysql-mcp-server

mukul975/mysql-mcp-server

3.2

If you are the rightful owner of mysql-mcp-server 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.

A comprehensive Model Context Protocol (MCP) server for MySQL databases, designed to empower AI assistants and LLMs with advanced database access, management, and diagnostic capabilities.

Tools
5
Resources
0
Prompts
0

๐Ÿš€ MySQL MCP Server โ€” AI-Driven MySQL Control & Diagnostics for LLMs

A fully featured Model Context Protocol (MCP) server for MySQL โ€” designed to empower AI assistants, LLMs (like ChatGPT, Claude, Gemini), and automation tools with deep MySQL database access, diagnostics, and intelligent control.

โšก Ideal for building AI-powered database agents, DevOps automation, or managing MySQL with natural language.

License: MIT Python MySQL Support Open Source


๐Ÿ“† Repository Info

  • GitHub: mcp-mysql-server
  • Author: @mukul975
  • License: MIT
  • Keywords: MySQL, MCP Server, AI MySQL interface, LLM database tool, MySQL automation, chatbot SQL

๐Ÿง  Key Features

This MySQL MCP Server provides LLMs and AI tools with:

  • โœ… Secure Query Execution: Handles SELECT, INSERT, UPDATE, DELETE, etc. with read-only validation.
  • ๐Ÿ” Schema Introspection: List tables, inspect structures, indexes, keys.
  • ๐Ÿ“Š Performance Diagnostics: Analyze fragmentation, slow queries, buffer pool stats.
  • ๐Ÿ›ก๏ธ Security Auditing: Manage users, audit SSL, monitor roles & privileges.
  • ๐Ÿงฉ Backup & Replication Monitor: View replication lag, log status, recovery readiness.
  • โš™๏ธ System Monitoring: Get process list, memory usage, plugin state.
  • ๐Ÿ“ˆ Query Insights: Index recommendations, event scheduler overview.

๐Ÿ› ๏ธ Installation

pip install -r requirements.txt
# Or install manually:
pip install "mcp[cli]"
pip install mysql-connector-python

โš™๏ธ Environment Configuration

VariableDescriptionDefault
MYSQL_HOSTMySQL server hostnamelocalhost
MYSQL_PORTMySQL port3306
MYSQL_USERUsernameroot
MYSQL_PASSWORDPassword(empty)
MYSQL_DATABASETarget DB(empty)

๐Ÿ’ก Use .env or export variables manually


โ–ถ๏ธ Run & Usage

python mysql_server.py                # Default (stdin transport)
python mysql_server.py --transport sse  # For web clients (SSE)
python mysql_server.py --help        # Command help

๐Ÿ”— Claude Desktop Integration

{
  "mcpServers": {
    "mysql": {
      "command": "python",
      "args": ["path/to/mysql_server.py"],
      "env": {
        "MYSQL_HOST": "localhost",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "your_user",
        "MYSQL_PASSWORD": "your_pass",
        "MYSQL_DATABASE": "your_db"
      }
    }
  }
}

๐Ÿงช Example Workflows

  • list_tables: Lists all tables
  • describe_table: Schema of a specific table
  • execute_sql: Run select or data modification queries
  • mysql_slow_query_analysis: Detect slow queries
  • mysql_user_privileges: Audit user access
  • mysql_replication_lag_monitoring: Check lag in replication

๐Ÿงฐ Toolset Highlights

Access tools via code or LLM prompts:

  • mysql_query, list_mysql_tables, mysql_table_schema
  • mysql_index_optimization_suggestions, mysql_deadlock_detection
  • mysql_ssl_tls_configuration_audit, mysql_backup_health_check
  • mysql_server_health_dashboard, mysql_event_scheduler, and dozens more

๐Ÿ” Security Considerations

  • Store secrets in env vars or vault
  • Do not expose server publicly
  • Privilege validation and SSL audit included

๐Ÿงช Error Handling

  • Connection errors
  • SQL syntax issues
  • Network timeouts
  • Returns structured error response

๐Ÿ’ก Development Structure

mcp-mysql-server/
โ”œโ”€โ”€ mysql_server.py        # Entry point
โ”œโ”€โ”€ requirements.txt       # Dependencies
โ”œโ”€โ”€ README.md              # Docs
โ””โ”€โ”€ pyproject.toml         # Project metadata (optional)

โœ… Testing Steps

  1. Ensure MySQL is running
  2. Set environment vars
  3. Run python mysql_server.py
  4. Try with mcp dev mysql_server.py (if using MCP CLI)

๐Ÿค Contributing

  • Fork the repo
  • Create feature/bug branches
  • Submit PRs with description & tests

๐Ÿ“„ FAQ

Q: What is MCP? A: Model Context Protocol (MCP) is an interface to give LLMs access to structured tools like databases, APIs, and system utilities.

Q: Can I use this with ChatGPT or Claude? Yes! It's designed for direct integration with AI/LLM tools that support tool-use or system-level automation.

Q: Is it safe to run this in production? It depends on your environment. Always restrict access, use read-only roles, and monitor logs.


๐Ÿ“„ License

MIT License โ€” Open source and free to use.


๐Ÿ”Ž GitHub SEO Tips (apply on GitHub)


๐Ÿ“ฃ Promote It


Let me know if you need an HTML version, web preview, or GitHub Pages site for this!