- Home
- MCP servers
- MySQL
MySQL
- typescript
62
GitHub Stars
typescript
Language
4 months ago
First Indexed
2 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
You set up a MySQL MCP Server to let an AI assistant safely manage one or more MySQL databases through a modern MCP interface. This server provides a streamable HTTP protocol, keeps credentials secure from AI, and supports dynamic AI-driven management for multiple databases with full CRUD capabilities.
How to use
Connect your MCP client to the server using the recommended HTTP-based MCP endpoint. You can manage multiple databases, switch between active connections, and run SQL queries through intuitive AI-driven tools. Typical workflows include adding a new database connection, listing all connections, selecting the active database, and executing standard SQL statements such as SELECT, INSERT, UPDATE, and DELETE. The AI can help you switch databases on the fly and run queries while keeping sensitive credentials hidden from the AI layer.
How to install
Prerequisites you need before installation are Node.js 18 or higher and a MySQL server (version 5.7 or newer). You also need an MCP client such as Claude Desktop or Cursor.
# Clone the project
git clone https://github.com/guangxiangdebizi/MySQL_MCP.git
cd MySQL_MCP
# Install dependencies
npm install
# Build the project
npm run build
# Start the server
npm start
Configuration and usage patterns
Mode 1 — Header preconfiguration (recommended): you provide credentials to the server through request headers so the AI never sees the raw password. This makes the setup secure and ready to use immediately.
{
"mcpServers": {
"mysql-mcp": {
"type": "streamableHttp",
"url": "http://localhost:3001/mcp",
"timeout": 600,
"headers": {
"X-MySQL-Host": "localhost",
"X-MySQL-Port": "3306",
"X-MySQL-User": "root",
"X-MySQL-Password": "your_password",
"X-MySQL-Database": "your_database"
}
}
}
}
Mode 1b — Multiple databases via headers: you can connect to more than one database by adding additional host/user/password/database pairs in the headers. This enables the AI to interact with several databases simultaneously.
{
"mcpServers": {
"mysql-mcp": {
"type": "streamableHttp",
"url": "http://localhost:3001/mcp",
"timeout": 600,
"headers": {
"X-MySQL-Host-1": "prod.mysql.com",
"X-MySQL-User-1": "prod_user",
"X-MySQL-Password-1": "prod_pass",
"X-MySQL-Database-1": "production",
"X-MySQL-Host-2": "test.mysql.com",
"X-MySQL-User-2": "test_user",
"X-MySQL-Password-2": "test_pass",
"X-MySQL-Database-2": "testing"
}
}
}
}
Mode 2 — AI dynamic connection (no header config required)
If you prefer dynamic management via AI, you can start without preconfiguring credentials. The AI will guide you through adding connections and selecting the active database.
{
"mcpServers": {
"mysql-mcp": {
"type": "streamableHttp",
"url": "http://localhost:3001/mcp",
"timeout": 600
}
}
}
Security considerations
Create a dedicated MySQL user for MCP with limited permissions and avoid exposing credentials to AI. Prefer HTTPS for production and restrict access by IP. Regularly rotate passwords and monitor access logs for anomalies.
Project notes
The MCP server design emphasizes modularity and clear separation between the HTTP interface and database operations. It supports multiple databases, provides a safe header-based credential bridge, and exposes a suite of tools to manage connections and run queries.
Available tools
add_connection
Add a new database connection to the MCP server so the AI can target it in future interactions.
list_connections
List all configured database connections along with their details and statuses.
select_database
Choose an active database to run queries against.
remove_connection
Remove a previously configured database connection.
execute_query
Execute a SQL query against the active database.
show_tables
Display all tables in the active database.
describe_table
Show the structure and sample data of a specific table.
show_databases
List all accessible databases.