Enables full database management including schema inspection, CRUD operations, query execution, and administration of MySQL databases, stored procedures, functions, triggers, and views.
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 the schema for the users table"
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 powerful Model Context Protocol (MCP) server that connects your AI assistant (like Claude Desktop) directly to your MySQL database. This server enables safe, controlled access to inspect schemas, query data, and even perform administrative tasks, all through natural language.
π Features
This server implements a wide range of MCP capabilities to give you full visibility and control over your MySQL database.
π οΈ Tools
Table Management
list-tables: List all tables in the database.describe-table: Get the schema (columns, types, keys) of a specific table.create-table: Create a new table using a SQL query.
Data Operations (CRUD)
insert-row: Insert a new row into a table using JSON data.update-row: Update existing rows with a convenient JSON-based WHERE clause.delete-row: Delete rows with a safety-first JSON-based WHERE clause.
Query Execution
execute-query: Execute read-only SQL queries (SELECT,SHOW,DESCRIBE). Safe for exploration.execute-write-query: Execute write SQL queries (INSERT,UPDATE,DELETE,ALTER, etc.). Use with caution.
Database Administration
create-database: Create a new database.
Advanced Objects Inspection
Stored Procedures:
list-procedures,show-procedure(view CREATE statement).Functions:
list-functions,show-function(view CREATE statement).Triggers:
list-triggers,show-trigger.Views:
list-views,show-view.
π¦ Resources
Access database content directly as standard MCP resources:
mysql://<table_name>/schema: View the full JSON schema of a table.mysql://<table_name>/data: View the first 100 rows of a table as JSON.
π¬ Prompts
Pre-built templates to help the AI perform complex tasks:
analyze-table: "Analyze the structure and sample data for table 'Users'..."Automatically fetches schema and sample data to provide insights.
optimize-query: "Analyze this query for performance..."Helps you write faster, more efficient SQL.
π¦ Installation
Clone the repository:
git clone <repository-url> cd mysql-mcp-serverInstall dependencies:
npm installBuild the server:
npm run build
βοΈ Configuration
1. Environment Variables
The server uses mysql2 and requires connection details. You can pass these via environment variables.
Variable | Description | Default |
| Database hostname |
|
| Database username | - |
| Database password | - |
| Database name | - |
| Database port |
|
2. Claude Desktop Config
Add the following to your claude_desktop_config.json:
Note: Make sure to replace
π‘ Usage Examples
Once connected, you can ask Claude questions like:
Exploration: "What tables are in my database?"
Schema: "Show me the schema for the
orderstable."Data Analysis: "Select the top 5 customers who spent the most money."
Modification: "Insert a new user named 'Alice' into the
userstable."Optimization: "Analyze this query and tell me why it's slow:
SELECT * FROM logs"
π Security Note
This server has powerful capabilities, including write access (execute-write-query, delete-row, etc.). Always ensure you are connecting to a database where you have appropriate permissions, and be careful when asking the AI to modify data.
π License
ISC