Supports connections to DigitalOcean managed MySQL databases for remote database operations.
Enables connections to Google Cloud SQL MySQL instances for database operations and management.
Supports OAuth 2.1 authentication integration with Keycloak for enterprise-grade security with granular access control scopes and RFC-compliant identity provider integration.
Provides comprehensive MySQL database management with 191 specialized tools for CRUD operations, JSON functions, spatial/GIS, schema management, performance tuning, replication monitoring, and cluster administration. Includes 18 observability resources for real-time metrics and InnoDB diagnostics.
Provides connectivity to PlanetScale MySQL databases with SSL support for serverless database operations.
mysql-mcp
Last updated January 4, 2026 - Production/Stable v2.1.0
📚 Full Documentation (Wiki) • Changelog • Security • Release Article
The Most Comprehensive MySQL MCP Server Available
mysql-mcp is the definitive Model Context Protocol server for MySQL — empowering AI assistants like AntiGravity, Claude, Cursor, and other MCP clients with unparalleled database capabilities. Built for developers who demand enterprise-grade features without sacrificing ease of use.
🎯 What Sets Us Apart
Feature | Description |
191 Specialized Tools | The largest MySQL tool collection for MCP — from core CRUD and native JSON functions (MySQL 5.7+) to advanced spatial/GIS, document store, and cluster management |
18 Observability Resources | Real-time schema, performance metrics, process lists, status variables, replication status, and InnoDB diagnostics |
19 AI-Powered Prompts | Guided workflows for query building, schema design, performance tuning, and infrastructure setup |
OAuth 2.1 + Access Control | Enterprise-ready security with RFC 9728/8414 compliance, granular scopes ( |
Smart Tool Filtering | 24 tool groups + 7 meta-groups let you stay within IDE limits while exposing exactly what you need |
HTTP Streaming Transport | SSE-based streaming with |
High-Performance Pooling | Built-in connection pooling for efficient, concurrent database access |
Ecosystem Integrations | First-class support for MySQL Router, ProxySQL, and MySQL Shell utilities |
Advanced Encryption | Full TLS/SSL support for secure connections, plus tools for managing data masking, encryption monitoring, and compliance |
Production-Ready Security | SQL injection protection, parameterized queries, input validation, and audit capabilities |
Strict TypeScript | 100% type-safe codebase with 1550+ tests and 97% coverage |
MCP 2025-11-25 Compliant | Full protocol support with tool safety hints, resource priorities, and progress notifications |
🚀 Quick Start
Prerequisites
Node.js 18+
MySQL 5.7+ or 8.0+ server
npm or yarn
Installation
NPM (Recommended)
Docker
From Source
⚡ MCP Client Configuration
HTTP/SSE Server Usage (Advanced)
When to use HTTP mode: Use HTTP mode when deploying
mysql-mcpas a standalone server that multiple clients can connect to remotely. For local development with Claude Desktop or Cursor IDE, use the defaultstdiomode shown below instead.
Use cases for HTTP mode:
Running the server in a Docker container accessible over a network
Deploying to cloud platforms (AWS, GCP, Azure)
Enabling OAuth 2.1 authentication for enterprise security
Allowing multiple AI clients to share one database connection
OAuth 2.1 Authentication
For enterprise deployments, mysql-mcp supports OAuth 2.1 authentication with Keycloak or any RFC-compliant provider.
Quick Setup
1. Start with OAuth disabled (default)
2. Enable OAuth with an identity provider
Start the HTTP server:
Available endpoints:
GET /sse- Establish MCP connection via Server-Sent EventsPOST /messages- Send JSON-RPC messages to the serverGET /health- Health check endpointGET /.well-known/oauth-protected-resource- OAuth 2.1 metadata (when OAuth enabled)
💡 Tip: Most users should skip this section and use the stdio configuration below for local AI IDE integration.
Cursor IDE / Claude Desktop
Using Environment Variables (Recommended)
📖 See the for more configuration options.
🔗 Database Connection Scenarios
Scenario | Host to Use | Example Connection String |
MySQL on host machine |
|
|
MySQL in Docker | Container name or network |
|
Remote/Cloud MySQL | Hostname or IP |
|
MySQL on Host Machine
If MySQL is installed directly on your computer (via installer, Homebrew, etc.):
MySQL in Another Docker Container
Add both containers to the same Docker network, then use the container name:
Remote/Cloud MySQL (RDS, Cloud SQL, etc.)
Use the remote hostname directly:
Provider | Example Hostname |
AWS RDS |
|
Google Cloud SQL |
|
Azure MySQL |
|
PlanetScale |
|
DigitalOcean |
|
Tip: For remote connections, ensure your MySQL server allows connections from Docker's IP range and that firewalls/security groups permit port 3306.
🛠️ Tool Filtering
AI IDEs like Cursor have tool limits (typically 40-50 tools). With 191 tools available, you MUST use tool filtering to stay within your IDE's limits. We recommend starter (38 tools) as a starting point.
What Can You Filter?
The --tool-filter argument accepts shortcuts, groups, or tool names — mix and match freely:
Filter Pattern | Example | Tools | Description |
Shortcut only |
| 38 | Use a predefined bundle |
Groups only |
| 32 | Combine individual groups |
Shortcut + Group |
| 50 | Extend a shortcut |
Shortcut - Tool |
| 37 | Remove specific tools |
Shortcuts (Predefined Bundles)
Shortcut | Tools | Use Case | What's Included |
| 38 | 🌟 Recommended | Core, JSON, trans, text |
| 15 | Minimal footprint | Core, trans |
| 45 | Power Developer | Core, schema, perf, stats, fulltext, trans |
| 44 | AI Data Analyst | Core, JSON, docstore, text, fulltext |
| 43 | AI Spatial Analyst | Core, spatial, stats, perf, trans |
| 35 | DBA Monitoring | Core, monitor, perf, sysschema, opt |
| 33 | DBA Management | Core, admin, backup, repl, parts, events |
| 42 | DBA Security | Core, security, roles, cluster, trans |
| 48 | Base Ops | Core, JSON, trans, text, schema |
| 39 | Advanced Features | DocStore, spatial, stats, fulltext, events |
| 31 | External Tools | Router, ProxySQL, Shell |
Tool Groups (24 Available)
Group | Tools | Description |
| 8 | Read/write queries, tables, indexes |
| 7 | BEGIN, COMMIT, ROLLBACK, savepoints |
| 17 | JSON functions, merge, diff, stats |
| 6 | REGEXP, LIKE, SOUNDEX |
| 4 | Natural language search |
| 8 | EXPLAIN, query analysis, slow queries |
| 4 | Index hints, recommendations |
| 6 | OPTIMIZE, ANALYZE, CHECK |
| 7 | PROCESSLIST, status variables |
| 4 | Export, import, mysqldump |
| 5 | Master/slave, binlog |
| 4 | Partition management |
| 9 | MySQL Router REST API |
| 12 | ProxySQL management |
| 10 | MySQL Shell utilities |
| 10 | Views, procedures, triggers, constraints |
| 6 | Event Scheduler management |
| 8 | sys schema diagnostics |
| 8 | Statistical analysis tools |
| 12 | Spatial/GIS operations |
| 9 | Audit, SSL, encryption, masking |
| 10 | Group Replication, InnoDB Cluster |
| 8 | MySQL 8.0 role management |
| 9 | Document Store collections |
Quick Start: Recommended IDE Configuration
Add one of these configurations to your IDE's MCP settings file (e.g., cline_mcp_settings.json, .cursorrules, or equivalent):
Option 1: Starter (38 Essential Tools)
Best for: General MySQL database work - CRUD operations, schema management, and monitoring.
Option 2: Cluster (10 Tools for InnoDB Cluster Monitoring)
Best for: Monitoring InnoDB Cluster, Group Replication status, and cluster topology.
⚠️ Prerequisites:
InnoDB Cluster must be configured and running with Group Replication enabled
Connect to a cluster node directly (e.g.,
localhost:3307) — NOT a standalone MySQL instanceUse
cluster_adminorrootuser with appropriate privilegesSee MySQL Ecosystem Setup Guide for cluster setup instructions
Option 3: Ecosystem (31 Tools for InnoDB Cluster Deployments)
Best for: MySQL Router, ProxySQL, MySQL Shell, and InnoDB Cluster deployments.
⚠️ Prerequisites:
InnoDB Cluster with MySQL Router requires the cluster to be running for Router REST API authentication (uses
metadata_cachebackend)Router REST API uses HTTPS with self-signed certificates by default — set
MYSQL_ROUTER_INSECURE=trueto bypass certificate verificationSee MySQL Ecosystem Setup Guide for detailed instructions
Customization Notes:
Replace
/path/to/mysql-mcp/with your actual installation pathUpdate credentials with your actual values
For Windows: Use forward slashes (e.g.,
C:/mysql-mcp/dist/cli.js) or escape backslashesFor Windows MySQL Shell:
"MYSQLSH_PATH": "C:\\Program Files\\MySQL\\MySQL Shell 9.5\\bin\\mysqlsh.exe"Router Authentication: Router REST API authenticates against the InnoDB Cluster metadata. The cluster must be running for authentication to work.
Cluster Resource: The
mysql://clusterresource is only available when connected to an InnoDB Cluster node
Legacy Syntax (still supported):
If you start with a negative filter (e.g., -ecosystem), it assumes you want to start with all tools enabled and then subtract.
Syntax Reference
Prefix | Target | Example | Effect |
(none) | Shortcut |
| Whitelist Mode: Enable ONLY this shortcut |
(none) | Group |
| Whitelist Mode: Enable ONLY this group |
| Group |
| Add tools from this group to current set |
| Group |
| Remove tools in this group from current set |
| Tool |
| Add one specific tool |
| Tool |
| Remove one specific tool |
📖 See the for advanced examples.
💡 Usage Instructions
Usage instructions areautomatically provided to AI agents via the MCP protocol during server initialization.
For debugging or manual reference, see the source: src/constants/ServerInstructions.ts
🤖 AI-Powered Prompts
This server includes 19 intelligent prompts for guided workflows:
Prompt | Description |
| Construct SQL queries with security best practices |
| Design table schemas with indexes and relationships |
| Analyze slow queries with optimization recommendations |
| Generate migration scripts with rollback options |
| Comprehensive database health assessment |
| Enterprise backup planning with RTO/RPO |
| Index analysis and optimization workflow |
| MySQL Router configuration guide |
| ProxySQL configuration guide |
| Replication setup guide |
| MySQL Shell usage guide |
| Complete tool index with categories |
| Quick query execution shortcut |
| Quick schema exploration |
| Event Scheduler setup guide |
| sys schema usage and diagnostics |
| Spatial/GIS data setup guide |
| InnoDB Cluster/Group Replication guide |
| Document Store / X DevAPI guide |
📊 Resources
This server exposes 18 resources for database observability:
Resource | Description |
| Full database schema |
| Table listing with metadata |
| Server configuration variables |
| Server status metrics |
| Active connections and queries |
| Connection pool statistics |
| Server version, features, tool categories |
| Comprehensive health status |
| Query performance metrics |
| Index usage and statistics |
| Replication status and lag |
| InnoDB buffer pool and engine metrics |
| Event Scheduler status and scheduled events |
| sys schema diagnostics summary |
| InnoDB lock contention detection |
| Group Replication/InnoDB Cluster status |
| Spatial columns and indexes |
| Document Store collections |
🔧 Advanced Configuration
For specialized setups, see these Wiki pages:
Topic | Description |
Configure Router REST API access for InnoDB Cluster | |
Configure ProxySQL admin interface access | |
Configure MySQL Shell for dump/load operations |
⚡ Performance Tuning
Variable | Default | Description |
|
| Cache TTL for schema metadata (milliseconds) |
|
| Log verbosity: |
Tip: Lower
METADATA_CACHE_TTL_MSfor development (e.g.,5000), or increase it for production with stable schemas (e.g.,300000= 5 min).
CLI Options
Option | Environment Variable | Description |
|
| Enable OAuth authentication |
|
| Authorization server URL |
|
| Expected token audience |
|
| JWKS URI (auto-discovered) |
|
| Clock tolerance in seconds |
Scopes
Scope | Access Level |
| Read-only queries |
| Read + write operations |
| Administrative operations |
| All operations |
📖 See the for Keycloak setup and detailed configuration.
Development
MCP Inspector
Use MCP Inspector to visually test and debug mysql-mcp:
Open http://localhost:6274 to browse all 191 tools, 18 resources, and 19 prompts interactively.
CLI mode for scripting:
📖 See the for detailed usage.
Unit Testing
The project maintains high test coverage (~97%) using Vitest.
Test Infrastructure:
Centralized mock factories in
src/__tests__/mocks/All 101 test files use shared mocks for consistency
Tests run without database connection (fully mocked)
~53 second total runtime
Test Coverage:
Component | Coverage | Notes |
Global | 97%+ | Statement coverage |
MySQLAdapter | 93%+ | Adapter logic covered |
Branch Coverage | ~86% | High branch coverage |
Tools (All) | 99%+ | 1590 tests passing |
Contributing
Contributions are welcome! Please read our Contributing Guidelines before submitting a pull request.
Security
For security concerns, please see our Security Policy.
⚠️ Never commit credentials - Store secrets in
.env(gitignored)
License
This project is licensed under the MIT License - see the LICENSE file for details.
Code of Conduct
Please read our Code of Conduct before participating in this project.