mysql-mcp-server
Enables to manage MySQL and MariaDB databases through natural language. Provides 50 tools for administration, development, and operations.
README
MySQL/MariaDB MCP Server
Complete MCP server for MySQL and MariaDB. 50 tools covering the full lifecycle of database administration, development, and operations.
Quick Start (Docker)
cp .env.example .env
# Edit .env with your settings
docker compose up -d
MCP server: http://localhost:4000/mcp
Health: http://localhost:4000/health
MariaDB: localhost:3307
Configuration
| Variable | Default | Description |
|---|---|---|
MYSQL_HOST |
localhost |
MySQL host |
MYSQL_PORT |
3306 |
MySQL port |
MYSQL_USER |
mcpuser |
MySQL user |
MYSQL_PASSWORD |
mcppassword |
MySQL password |
MYSQL_DATABASE |
mcpdb |
Default database |
MYSQL_ROOT_PASSWORD |
rootpassword |
Root password (Docker only) |
TRANSPORT |
stdio |
stdio or http |
PORT |
3000 |
HTTP server port |
MYSQL_EXPOSE_PORT |
3306 |
Host port for MySQL container |
MCP_PORT |
3000 |
Host port for MCP container |
Claude Desktop / Claude Code Integration
HTTP Transport
{
"mcpServers": {
"mysql": {
"url": "http://localhost:4000/mcp"
}
}
}
stdio Transport (local)
{
"mcpServers": {
"mysql": {
"command": "node",
"args": ["/path/to/mcp-mysql/dist/index.js"],
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root",
"MYSQL_PASSWORD": "password"
}
}
}
}
Tools (50 total)
Databases (5)
| Tool | Description |
|---|---|
mysql_list_databases |
List all databases |
mysql_create_database |
Create a database |
mysql_drop_database |
Drop a database |
mysql_show_create_database |
Show CREATE DATABASE statement |
mysql_server_info |
Server version, uptime, config |
Tables (8)
| Tool | Description |
|---|---|
mysql_list_tables |
List tables with stats |
mysql_describe_table |
Column definitions (SHOW FULL COLUMNS) |
mysql_show_create_table |
Full CREATE TABLE DDL |
mysql_create_table |
Create table from SQL |
mysql_drop_table |
Drop one or more tables |
mysql_truncate_table |
Remove all rows |
mysql_rename_table |
Rename / move between databases |
mysql_get_table_stats |
Size, rows, engine, collation |
Columns (4)
| Tool | Description |
|---|---|
mysql_add_column |
ALTER TABLE ADD COLUMN |
mysql_drop_column |
ALTER TABLE DROP COLUMN |
mysql_modify_column |
ALTER TABLE MODIFY COLUMN |
mysql_rename_column |
RENAME COLUMN (MySQL 8+/MariaDB 10.5+) |
Indexes (3)
| Tool | Description |
|---|---|
mysql_list_indexes |
All indexes with cardinality |
mysql_create_index |
Create BTREE/HASH/FULLTEXT/SPATIAL index |
mysql_drop_index |
Drop an index |
Foreign Keys (3)
| Tool | Description |
|---|---|
mysql_list_foreign_keys |
List FK constraints |
mysql_add_foreign_key |
Add FK with ON UPDATE/DELETE rules |
mysql_drop_foreign_key |
Drop FK constraint |
Data Operations (7)
| Tool | Description |
|---|---|
mysql_query |
SELECT with pagination and parameterized values |
mysql_execute |
Execute any SQL (DDL/DML) |
mysql_insert |
Insert single row |
mysql_update |
Update rows by WHERE condition |
mysql_delete |
Delete rows by WHERE condition |
mysql_bulk_insert |
Batch insert up to 5000 rows |
mysql_execute_transaction |
Atomic multi-statement transaction |
User Management (7)
| Tool | Description |
|---|---|
mysql_list_users |
List all MySQL accounts |
mysql_create_user |
Create user with password |
mysql_drop_user |
Drop user |
mysql_grant_privileges |
Grant privileges |
mysql_revoke_privileges |
Revoke privileges |
mysql_show_grants |
Show GRANT statements |
mysql_change_password |
Change user password |
Server Monitoring (6)
| Tool | Description |
|---|---|
mysql_show_status |
Global/session status variables |
mysql_show_variables |
Global/session config variables |
mysql_show_processlist |
Active connections and queries |
mysql_kill_process |
Kill connection or query |
mysql_show_warnings |
Last statement warnings |
mysql_flush_privileges |
Reload grant tables |
Query Analysis & Maintenance (5)
| Tool | Description |
|---|---|
mysql_explain_query |
EXPLAIN with traditional/JSON/TREE format |
mysql_analyze_table |
Update optimizer statistics |
mysql_optimize_table |
Defragment and reclaim space |
mysql_check_table |
Check for corruption |
mysql_repair_table |
Repair MyISAM/ARCHIVE tables |
Export & Import (2)
| Tool | Description |
|---|---|
mysql_export_table |
Export as JSON, CSV, or SQL INSERTs |
mysql_import_sql |
Execute SQL script |
Development
npm install
npm run dev # Development with auto-reload
npm run build # Production build
Switch to MySQL 8.4
Edit docker-compose.yml:
mysql:
image: mysql:8.4 # was mariadb:11.4
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-rootpassword}
MYSQL_DATABASE: ${MYSQL_DATABASE:-mcpdb}
MYSQL_USER: ${MYSQL_USER:-mcpuser}
MYSQL_PASSWORD: ${MYSQL_PASSWORD:-mcppassword}
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.