MySQL MCP Server
Connects to a MySQL database, allowing LLMs to execute SQL queries, retrieve database information (databases, tables, and table structures), with configurable query timeout and result size limits.
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 top 10 customers by total purchases"
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
The MySQL Model Context Protocol (MCP) Server is a tool that allows you to connect to a local MySQL database and allow large language models (LLMs) to execute SQL queries against it.
Requirements
Node.js : 20.0.0 or later
MySQL : MySQL or MariaDB server version 5.7 or later
Related MCP server: MCP MySQL Server
function
Run MySQL queries : Run SQL queries directly from LLM
Obtaining database information : List of databases, list of tables, confirm table structure
MCP Compliant : Supports Model Context Protocol and can be integrated with LLM
stdio communication : communicate with LLM using standard input/output, no port binding
Save connection information : Save database connection information locally and reuse it
Installation and Usage
Temporary execution in NPX
npx -y https://github.com/yuki777/mysql-mcp-server --host 127.0.0.1 --port 13306 --user rootoption
option | explanation | Default value |
| MySQL Host | localhost |
| MySQL Port | 13306 |
| MySQL User | root |
| MySQL Password | (empty string) |
| Default Database | (option) |
| Configuration File Path | (option) |
| Automatically connect to database at server startup | false |
| MCP server port (not used in stdio mode) | 3000 |
| MCP server host (not used in stdio mode) | localhost |
| Query Timeout (ms) | 30000 |
| Maximum Result Rows | 1000 |
| Debug Mode | false |
Save and reuse connection information
MySQL MCP Server locally saves information about databases that it has successfully connected to, so that it can automatically reuse the connection information the next time it starts. Saved connection information is stored in .mysql-mcp-connections.json file in the user's home directory.
Connection information includes:
Hostname
Port number
Username
password
Database name (if set)
Using configuration files
You can also configure the connection information using a configuration file (in JSON format):
{
"server": {
"port": 3000,
"host": "localhost"
},
"mysql": {
"host": "localhost",
"port": 13306,
"user": "root",
"password": "yourpassword",
"database": "mydb"
},
"debug": false,
"queryTimeout": 30000,
"maxResultSize": 1000
}If you use a configuration file:
npx -y https://github.com/yuki777/mysql-mcp-server -c ./mysql-mcp-config.jsonCommunication method
MySQL MCP Server operates in "stdio" mode according to the MCP (Model Context Protocol), which means it does not bind to a specific port but communicates via standard input and output. This has the following advantages:
Avoid port conflicts : No specific ports are used, so no port conflict issues occur
Improved security : No network communication is used, reducing the risk of network-level attacks
Simple Inter-Process Communication : Simplified communication with LLM
Important points to note
In stdio mode, messages are sent in JSON format.
You must send one JSON message per line
Error information and connection logs are output to standard error (stderr).
MCP Tools Provided
Database Connection Management
Tool Name | explanation | Required parameters |
connect_database | Connect to the database | host, port, user |
disconnect_database | Disconnects the current database connection | none |
get_connection_status | Gets the status of the database connection | none |
SQL Query Operations
Tool Name | explanation | Required parameters |
execute_query | Run a MySQL query | query: SQL statement |
get_databases | Get a list of available databases | none |
get_tables | Gets a list of tables in a specified database. | database (optional) |
describe_table | Gets the structure of the specified table. | table |
Connection Management Function
MySQL MCP Server allows you to separate server startup and database connections. This approach provides the following benefits:
Start without connection information : The server can be started without database connection information.
Multiple database connections : You can switch connections to different databases after the server is started.
Simple installation : just run
npx -y https://github.com/yuki777/mysql-mcp-server
How to use Connection Management
Start the server without auto-connect :
npx -y https://github.com/yuki777/mysql-mcp-serverConnect to the database using the connection tool :
{ "type": "tool_call", "request_id": "req_1", "tool": "connect_database", "arguments": { "host": "localhost", "port": 3306, "user": "root", "password": "your_password", "database": "your_db" } }Check your connection status :
{ "type": "tool_call", "request_id": "req_2", "tool": "get_connection_status", "arguments": {} }Loss of connection :
{ "type": "tool_call", "request_id": "req_3", "tool": "disconnect_database", "arguments": {} }
Test script
The repository contains a test script called test-connection-management.js , which you can use to test the connection management functionality:
node test-connection-management.jsDeveloper Information
Setting up your development environment
# リポジトリのクローン
git clone [repository-url]
cd mysql-mcp-server
# 依存関係のインストール
npm install
# 開発モードでの実行
npm run devBuild
npm run buildlicense
ISC
contribution
Bug reports, feature requests and pull requests are welcome.
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.
Related MCP Servers
- AlicenseBqualityDmaintenanceA Model Context Protocol server that enables AI models to interact with MySQL databases, providing tools for querying, executing statements, listing tables, and describing table structures.5466MIT
- FlicenseBqualityDmaintenanceA Model Context Protocol server that enables AI models to interact with MySQL databases through a standardized interface, providing tools for querying, executing commands, and managing database schemas.7
- FlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that enables AI models to interact with MySQL databases through natural language, supporting SQL queries, table creation, and schema exploration.3
- AlicenseBqualityDmaintenanceA server based on Model Context Protocol that enables AI models to interact with MySQL databases through a standardized interface, supporting features like query execution, table listing, and automated connection management.42510MIT
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
GibsonAI MCP server: manage your databases with natural language
Self-hosted MCP gateway: turn any API, database or MCP server into AI connectors — no code.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- 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/yuki777/mysql-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server