The MCP MySQL App provides a way for AI systems to interact with MySQL databases through the Model Context Protocol (MCP). This tool allows AI assistants to execute SQL queries, check database connectivity, and manipulate MySQL data directly through AI interfaces.
git clone <repository-url>
cd mcp-mysql-app
npm install
.env
file in the root directory with your MySQL connection details:MYSQL_HOST=your_mysql_host
MYSQL_USER=your_mysql_username
MYSQL_PASSWORD=your_mysql_password
MYSQL_DATABASE=your_database_name
MYSQL_PORT=3306
npm run build
Locate your Cursor MCP configuration file:
C:\Users\<username>\.cursor\mcp.json
~/.cursor/mcp.json
~/.cursor/mcp.json
Add the MySQL MCP server configuration:
{
"mcpServers": {
"mysql": {
"command": "<path-to-node>",
"args": [
"<path-to-project>/dist/index.js"
],
"env": {
"MYSQL_HOST": "your_mysql_host",
"MYSQL_USER": "your_mysql_username",
"MYSQL_PASSWORD": "your_mysql_password",
"MYSQL_DATABASE": "your_database_name",
"MYSQL_PORT": "3306"
}
}
}
}
{
"mcpServers": {
"mysql": {
"command": "C:\\nvm4w\\nodejs\\node.exe",
"args": [
"H:\\mcp\\my-mysql\\dist\\index.js"
],
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_USER": "root",
"MYSQL_PASSWORD": "password123",
"MYSQL_DATABASE": "todo_app",
"MYSQL_PORT": "3306"
}
}
}
}
{
"tools": {
"mysql": {
"command": "<path-to-node>",
"args": [
"<path-to-project>/dist/index.js"
],
"env": {
"MYSQL_HOST": "your_mysql_host",
"MYSQL_USER": "your_mysql_username",
"MYSQL_PASSWORD": "your_mysql_password",
"MYSQL_DATABASE": "your_database_name",
"MYSQL_PORT": "3306"
}
}
}
}
{
"tools": {
"mysql": {
"command": "/usr/local/bin/node",
"args": [
"/Users/username/projects/mcp-mysql-app/dist/index.js"
],
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_USER": "root",
"MYSQL_PASSWORD": "password123",
"MYSQL_DATABASE": "todo_app",
"MYSQL_PORT": "3306"
}
}
}
}
For other AI platforms that support MCP:
dist/index.js
fileAfter configuration, your AI will have access to:
sql_check_connection
- Check if the MySQL connection is workingsql_query
- Execute SQL queries on the connected databaseOnce configured, you can interact with your MySQL database by simply asking the AI to perform database tasks:
Checking connection:
Ask: "Check if the MySQL connection is working."
The AI will use the sql_check_connection
tool
Viewing databases:
Ask: "Show me all the databases on this MySQL server."
The AI will run SHOW DATABASES;
Exploring tables:
Ask: "List all tables in the current database."
The AI will run SHOW TABLES;
Querying data:
Ask: "Show me the first 10 records from the users table."
The AI will run SELECT * FROM users LIMIT 10;
Creating tables: Ask: "Create a new table named 'products' with columns for id, name, price, and description." The AI will generate and run an appropriate CREATE TABLE statement
Inserting data: Ask: "Insert a new product with the name 'Smartphone', price 499.99, and description 'Latest model'." The AI will generate and run an INSERT statement
Updating records: Ask: "Update the price of the 'Smartphone' product to 449.99." The AI will generate and run an UPDATE statement
If you encounter issues:
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.