MySQL MCP Server
Provides tools for interacting with MySQL databases, including database exploration, CRUD operations, schema management, performance monitoring, and transaction handling.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MySQL MCP ServerShow me all tables in my database"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MySQL MCP Server
A production-ready Model Context Protocol (MCP) server for MySQL database integration with AI agents
Last Updated: 2026-01-25 14:00:00
Installation · Quick Start · Configuration · Permissions · Tools · Documentation
TL;DR - Quick Setup
Run directly with npx:
npx @berthojoris/mcp-mysql-server mysql://user:pass@localhost:3306/mydb "list,read,utility"Add to your AI agent config (.mcp.json, .cursor/mcp.json, etc.):
{
"mcpServers": {
"mysql": {
"command": "npx",
"type": "stdio",
"args": [
"-y",
"@berthojoris/mcp-mysql-server",
"mysql://user:pass@localhost:3306/mydb",
"list,read,utility"
]
}
}
}For agent-specific examples (Codex TOML, Zed, local path, multi-DB), see DOCUMENTATIONS.md → Setup & Configuration.
Related MCP server: MySQL MCP Server
Installation
Option 1: Quick Start with npx (Recommended)
No installation required - run directly:
npx @berthojoris/mcp-mysql-server mysql://user:pass@localhost:3306/db "list,read,utility"Option 2: Global Installation
npm install -g @berthojoris/mcp-mysql-server
mcp-mysql mysql://user:pass@localhost:3306/db "list,read,utility"Quick Start
1. Set Up Environment (Optional)
Create .env file for local development:
DB_HOST=localhost
DB_PORT=3306
DB_USER=root
DB_PASSWORD=yourpassword
DB_NAME=yourdatabase
MCP_CONFIG=list,read,utility2. Build Project (If Cloned Locally)
npm install
npm run build3. Configure Your AI Agent
See AI Agent Configuration section below.
4. Restart Your AI Agent
Completely restart your AI agent application to load the MCP server.
5. Test It!
Try asking your AI:
"What databases are available?" "Show me all tables in my database" "What's the structure of the users table?" "Show me the first 5 records from users"
AI Agent Configuration
Standard JSON Configuration
Most AI agents use a similar JSON configuration format (the file location varies by tool).
If you want ready-to-copy snippets per client (Claude Code/Cursor/Windsurf/Cline/Codex/Zed), see DOCUMENTATIONS.md → Agent Configuration Examples.
Universal Configuration Template:
Option 1: Single-Layer (Permissions Only) - Simple Setup
{
"mcpServers": {
"mysql": {
"command": "npx",
"type": "stdio",
"args": [
"-y",
"@berthojoris/mcp-mysql-server",
"mysql://user:password@localhost:3306/database",
"list,read,utility,create,update,ddl"
]
}
}
}Option 2: Dual-Layer (Permissions + Categories) - Recommended for Fine Control
{
"mcpServers": {
"mysql": {
"command": "npx",
"type": "stdio",
"args": [
"-y",
"@berthojoris/mcp-mysql-server",
"mysql://user:password@localhost:3306/database_name_here",
"list,read,utility,create,update,ddl",
"database_discovery,crud_operations,custom_queries,schema_management,index_management,constraint_management,table_maintenance,query_optimization,analysis"
]
}
}
}💡 Tip: The dual-layer approach provides granular control. The 4th argument (permissions) controls broad access levels, while the 5th argument (categories) fine-tunes which specific tools are available.
Environment Variables Configuration
Alternative approach using environment variables instead of connection string:
Option 1: Permissions Only (Simple)
{
"mcpServers": {
"mysql": {
"command": "npx",
"type": "stdio",
"args": ["-y", "@berthojoris/mcp-mysql-server"],
"env": {
"DB_HOST": "localhost",
"DB_PORT": "3306",
"DB_USER": "root",
"DB_PASSWORD": "your_password",
"DB_NAME": "your_database",
"MCP_PERMISSIONS": "list,read,utility,create,update,delete"
}
}
}
}Option 2: Permissions + Categories (Recommended)
{
"mcpServers": {
"mysql": {
"command": "npx",
"type": "stdio",
"args": ["-y", "@berthojoris/mcp-mysql-server"],
"env": {
"DB_HOST": "localhost",
"DB_PORT": "3306",
"DB_USER": "root",
"DB_PASSWORD": "your_password",
"DB_NAME": "your_database",
"MCP_PERMISSIONS": "list,read,utility,create,update,delete",
"MCP_CATEGORIES": "database_discovery,performance_monitoring,custom_queries"
}
}
}
}For more client-specific config snippets, see DOCUMENTATIONS.md → Setup & Configuration.
Permission System
Control database access with a dual-layer filtering system that provides both broad and fine-grained control:
Layer 1 (Permissions): Broad operation-level control using legacy categories
Layer 2 (Categories): Optional fine-grained tool-level filtering using documentation categories
Filtering Logic: Tool enabled = (Has Permission) AND (Has Category OR No categories specified)
Permissions
Permission | Operations | Use Case |
| List databases, tables, schemas | Database exploration |
| SELECT queries, read data | Analytics, reporting |
| INSERT new records | Data entry |
| UPDATE existing records | Data maintenance |
| DELETE records | Data cleanup |
| Execute custom SQL (DML) + Advanced SQL | Complex operations |
| CREATE/ALTER/DROP tables | Schema management |
| Stored procedures (CREATE/DROP/EXECUTE) | Procedure management |
| BEGIN, COMMIT, ROLLBACK | ACID operations |
| Connection testing, diagnostics | Troubleshooting |
Common configuration examples are documented in DOCUMENTATIONS.md → Category Filtering System.
Documentation Categories (Recommended)
Use documentation categories to fine-tune which tools are exposed (Layer 2):
Category List | Use Case | List Tools |
| Explore databases, tables, and schema structure |
|
| Create, read, update, delete operations on data |
|
| High-performance batch processing operations |
|
| Execute custom SQL queries and advanced operations |
|
| Manage database schema, tables, and structure |
|
| Database utilities, diagnostics, and helper functions |
|
| Handle ACID transactions and rollback operations |
|
| Create, execute, and manage stored procedures |
|
| Create and manage database views |
|
| Create and manage database triggers |
|
| Create and manage database functions |
|
| Optimize performance with index management |
|
| Manage data integrity constraints |
|
| Table optimization, repair, and maintenance |
|
| MySQL server configuration and administration |
|
| Monitor and analyze database performance |
|
| Manage query cache and optimization |
|
| Analyze and optimize SQL queries |
|
| Create backups and restore databases |
|
| Import and export data in various formats |
|
| Migrate data between databases or systems |
|
| Version control for database schema changes |
|
| Data analysis and reporting tools |
|
| AI-powered features and smart automation |
|
database_discovery,crud_operations,bulk_operations,custom_queries,schema_management,utilities,transaction_management,stored_procedures,views_management,triggers_management,functions_management,index_management,constraint_management,table_maintenance,server_management,performance_monitoring,cache_management,query_optimization,backup_restore,import_export,data_migration,schema_migrations,analysis,ai_enhancementFull category → tool mapping (and examples) lives in DOCUMENTATIONS.md → Category Filtering System.
Available Tools
The server exposes 150 tools organized into categories (CRUD, schema, backups, migrations, perf/monitoring, and AI enhancement).
Complete list of tools: DOCUMENTATIONS.md → Complete Tools Reference
AI enhancement tools overview: DOCUMENTATIONS.md → AI Enhancement Tools
🤖 AI Enhancement Tools
The full Phase 1–3 (implemented) overview, examples, and per-tool documentation lives in DOCUMENTATIONS.md.
Detailed Documentation
For comprehensive documentation, see DOCUMENTATIONS.md:
DDL Operations - Create, alter, and drop tables
Data Export Tools - Export to CSV, JSON, and SQL formats
Data Import Tools - Import from CSV and JSON sources
Database Backup & Restore - Full backup/restore with SQL dumps
Data Migration Tools - Copy, move, clone, compare, and sync data
Schema Versioning - Version control for database schema changes
Transaction Management - ACID transactions
Stored Procedures - Create and execute with IN/OUT/INOUT parameters
🤖 AI Enhancement - Natural language to SQL, smart data discovery, schema design, security audit, index recommendations, data generation, visualization, and forecasting (Phase 1-3)
Query Logging - See all SQL queries executed automatically
Security Features - Built-in security and best practices
Bulk Operations - High-performance batch processing
Troubleshooting - Common issues and solutions
MySQL MCP vs Manual Database Access
This MySQL MCP is a powerful intermediary layer between AI assistants and MySQL databases.
For full feature coverage and usage examples, see DOCUMENTATIONS.md.
License
MIT License - see LICENSE file for details.
Made with care for the AI development community
Enabling AI agents to interact with MySQL databases safely and efficiently
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/moki74/mysql-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server