Supports MariaDB-specific features including Galera cluster monitoring and analysis, alongside standard MySQL performance tuning capabilities.
Provides comprehensive MySQL database performance analysis, query optimization, index recommendations, health monitoring, InnoDB analysis, memory usage tracking, replication monitoring, and security auditing through performance_schema and information_schema.
MySQL Performance Tuning MCP
A Model Context Protocol (MCP) server for MySQL performance tuning and analysis.
Overview
mysqltuner_mcp provides AI-powered MySQL database performance analysis through the Model Context Protocol. It offers tools for query optimization, index recommendations, health monitoring
Features
Performance Analysis
Slow Query Detection: Identify slow queries from performance_schema
Query Analysis: Get detailed EXPLAIN plans with recommendations
Table Statistics: Analyze table sizes, row counts, and fragmentation
Statement Analysis: Analyze SQL statements for temp tables, sorting, and full scans
Index Optimization
Index Recommendations: AI-powered suggestions based on query patterns
Unused Index Finder: Identify indexes that are never read
Duplicate Detection: Find redundant and overlapping indexes
Index Statistics: Cardinality, selectivity, and usage metrics
Health Monitoring
Health Check: Comprehensive database health assessment with scoring
Active Queries: Real-time query monitoring
Wait Event Analysis: Identify I/O and lock bottlenecks
Configuration Review: Settings analysis with recommendations
Storage Engine Analysis
Engine Statistics: Analyze storage engine usage and distribution
Fragmentation Detection: Find fragmented tables with OPTIMIZE recommendations
Auto-Increment Analysis: Detect columns approaching overflow limits
InnoDB Analysis
InnoDB Status: Parse and analyze SHOW ENGINE INNODB STATUS
Buffer Pool Analysis: Detailed buffer pool usage by schema and table
Transaction Analysis: Monitor transactions, lock waits, and deadlocks
Memory Analysis
Memory Calculations: Calculate per-thread and global buffer usage
Memory by Host/User: Breakdown memory usage by connection source
Table Cache Analysis: Analyze table open cache efficiency
Replication Monitoring
Master/Slave Status: Monitor replication health and lag
Galera Cluster: Full Galera cluster status for MariaDB/Percona
Group Replication: MySQL Group Replication monitoring
Security Analysis
Security Audit: Check for anonymous users, weak passwords, dangerous privileges
User Privileges: Analyze user privileges at all levels
Audit Log: Check audit logging configuration
Resources & Prompts
Built-in best practices documentation
Pre-configured prompts for common tuning tasks
Index optimization guidelines
Configuration optimization guide
Installation
From Source
Using pip (when published)
Configuration
Environment Variables
Variable | Description | Default |
| MySQL connection URI (required) | - |
| Connection pool size |
|
| Enable SSL/TLS connection |
|
| Path to CA certificate file | - |
| Path to client certificate file | - |
| Path to client private key file | - |
| Verify server certificate |
|
| Verify server hostname matches certificate |
|
Connection URI Format
Environment Variables
Connection URI Query Parameters
Usage
Running the Server
The server supports three transport modes: stdio (default), SSE, and streamable-http.
SSE Mode (Server-Sent Events)
HTTP transport using Server-Sent Events, suitable for web-based MCP clients:
SSE Endpoints:
http://<host>:<port>/sse- SSE connection endpointhttp://<host>:<port>/messages/- Message posting endpoint
Streamable HTTP Mode
Modern HTTP transport with session management:
Streamable HTTP Endpoint:
http://<host>:<port>/mcp- Single endpoint for all MCP communication
Command-Line Options
Option | Description | Default |
| Server mode:
,
, or
|
|
| Host to bind to (HTTP modes only) |
|
| Port to listen on (HTTP modes only) |
or
env var |
| Run in stateless mode (streamable-http only) |
|
| Enable debug logging |
|
MCP Client Configuration
Add to your MCP client configuration (e.g., Claude Desktop):
With SSL/TLS Enabled
Available Tools
Performance Tools
Tool | Description |
| Retrieve slow queries from performance_schema with detailed statistics |
| Get EXPLAIN plan and analysis for a query with optimization recommendations |
| Get table statistics including size, row counts, fragmentation, and indexes |
Index Tools
Tool | Description |
| AI-powered index suggestions based on query patterns from performance_schema |
| Find unused, duplicate, and redundant indexes with DROP statements |
| Detailed index statistics including cardinality, selectivity, and usage metrics |
Health Tools
Tool | Description |
| Comprehensive health check with scoring (connections, buffer pool, queries, etc.) |
| Monitor currently running queries and identify long-running/blocked queries |
| Analyze MySQL configuration settings with best practice recommendations |
| Identify wait event bottlenecks (I/O, locks, buffer, log waits) |
Storage Engine Tools
Tool | Description |
| Analyze storage engine usage, statistics, and recommendations |
| Find tables with significant fragmentation and wasted space |
| Check auto-increment columns for potential overflow issues |
InnoDB Tools
Tool | Description |
| Parse and analyze SHOW ENGINE INNODB STATUS output |
| Detailed InnoDB buffer pool analysis by schema and table |
| Analyze InnoDB transactions, lock waits, and deadlocks |
Memory Tools
Tool | Description |
| Calculate MySQL memory usage (per-thread and global buffers) |
| Get memory usage breakdown by host, user, or event |
| Analyze table cache and InnoDB buffer pool by table |
Replication Tools
Tool | Description |
| Get master/slave replication status and health |
| Get Galera cluster status (MariaDB/Percona XtraDB Cluster) |
| Get MySQL Group Replication status |
Security Tools
Tool | Description |
| Comprehensive security analysis (users, passwords, SSL, privileges) |
| Analyze privileges for specific users or all users |
| Check audit log configuration and status |
Statement Analysis Tools
Tool | Description |
| Comprehensive SQL statement analysis from performance_schema |
| Find statements creating temporary tables (memory and disk) |
| Find statements with sorting operations and file sorts |
| Find statements performing full table scans |
| Find statements producing errors or warnings |
Available Prompts
Prompt | Description |
| Analyze and optimize a slow query |
| Perform comprehensive health assessment |
| Review indexes for a database |
| Full performance audit |
Requirements
Python 3.10+
MySQL 5.7+ or MySQL 8.0+
performance_schemaenabled (for full functionality)
MySQL Permissions
The MySQL user needs the following privileges: