Provides direct access to MySQL databases for AI agents to run SQL queries and manage content.
Configuration
View docs{
"mcpServers": {
"mysql": {
"command": "node",
"args": [
"/path/to/mysql-server/build/index.js"
],
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_USER": "your_username",
"MYSQL_PASSWORD": "your_password",
"MYSQL_DATABASE": "your_database"
}
}
}
}You run a MySQL MCP Server that lets AI agents connect to your MySQL databases, run SQL queries, and manage content through a straightforward interface. It exposes common database actions as tools and keeps data accessible via simple URIs and plain text content.
You interact with the server through an MCP client to perform actions such as listing tables, describing table structures, executing SQL, and creating notes stored in the database. The available tools are designed to be intuitive and cover the core database tasks you need for AI-assisted data management.
Key capabilities you can leverage in conversations include: - Listing all tables in your connected database. - Describing the schema of a specific table. - Executing custom SQL queries directly. - Creating text notes that are stored inside the MySQL database and retrievable via note:///{id} URIs. - Accessing note titles and content as plain text.
To access a note, reference its URI in your queries or prompts, and obtain the title and content as plain text. Use execute_sql for complex queries, and describe_table to inspect table structures before querying.
Prerequisites you need before installing: - Node.js 18 or higher - MySQL server installed and running - A database with appropriate permissions for access and manipulation
Step-by-step setup flow you should follow to get the server running locally:
1. Clone this project to your working directory
git clone [email protected]:LeonMelamud/mysql-mcp.git
cd mysql-mcp2. Install dependencies for the server
npm install3. Create a .env file in the root directory with your MySQL connection details
MYSQL_HOST=localhost
MYSQL_USER=your_username
MYSQL_PASSWORD=your_password
MYSQL_DATABASE=your_database4. Build the server
npm run buildThe MCP server uses a local stdio-based runtime. You invoke it with Node and point to the built entry file. You can run the server directly in your environment using the following configuration snippet.
{
"mcpServers": {
"mysql": {
"type": "stdio",
"command": "node",
"args": ["/path/to/mysql-server/build/index.js"],
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_USER": "your_username",
"MYSQL_PASSWORD": "your_password",
"MYSQL_DATABASE": "your_database"
}
}
}
}Create a new text note in the database with a title and content.
List all tables in the connected database.
Return the total number of tables in the database.
Search for tables using a LIKE pattern.
Get the structure of a specific table.
Execute a custom SQL query against the database.