The MySQL MCP Server provides direct access to MySQL databases for AI agents. It enables executing SQL queries, managing database content, and interacting with notes stored in a database through a simple interface, all via the Model Context Protocol (MCP).
Clone the repository:
git clone [email protected]:LeonMelamud/mysql-mcp.git
cd mysql-mcp
Install dependencies:
npm install
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_database
Build the server:
npm run build
Add the server config to your Claude Desktop configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%/Claude/claude_desktop_config.json
{
"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"
}
}
}
}
Add the server config to your Cline MCP settings file:
~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
%APPDATA%\Code\User\globalStorage\saoudrizwan.claude-dev\settings\cline_mcp_settings.json
{
"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"
},
"disabled": false,
"autoApprove": []
}
}
}
Once installed, you can use the MySQL MCP server in your conversations with Claude.
note:///{id}
URIsList Tables: View all tables in the connected database
Please list all the tables in my MySQL database.
Count Tables: Get the total number of tables
How many tables are in my database?
Search Tables: Find tables matching a pattern
Search for tables containing "user" in their name.
Describe Table: View a table's structure
Describe the structure of the "customers" table.
Run this SQL query: SELECT * FROM users LIMIT 5
Create a note titled "Meeting Notes" with the content "Discussed project timeline and assigned tasks."
First, check what tables are available:
Please list all tables in my database.
Examine a specific table's structure:
Describe the structure of the "products" table.
Query specific information:
Run this SQL query: SELECT name, price FROM products WHERE category = 'electronics' ORDER BY price DESC LIMIT 10
Store information as a note:
Create a note titled "Top Electronics" with the content from our query results.
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.