This MCP server provides integration between MySQL databases and LLMs, allowing secure database access with both read and write capabilities through a standardized Model Context Protocol interface.
Install the MySQL MCP server using npm:
npm install -g @kevinwatt/mysql-mcp
{
"mcpServers": {
"mysql": {
"command": "npx",
"args": [
"-y",
"@kevinwatt/mysql-mcp"
],
"env": {
"MYSQL_HOST": "127.0.0.1",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root",
"MYSQL_PASS": "",
"MYSQL_DB": "your_database"
}
}
}
}
Execute read-only SELECT queries against your database.
Input Parameters:
sql
(string): The SQL SELECT query to executeLimitations:
Execute data modification operations with transaction support.
Input Parameters:
sql
(string): SQL statement (INSERT/UPDATE/DELETE)params
(array, optional): Parameters for the SQL statementFeatures:
List all tables in the current database.
Input Parameters:
Show the structure of a specific table.
Input Parameters:
table
(string): Name of the table to describeYou can instruct your LLM to interact with the database using natural language. For example:
If you need to start the server manually:
npx @kevinwatt/mysql-mcp
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "mysql" '{"command":"npx","args":["-y","@kevinwatt/mysql-mcp"],"env":{"MYSQL_HOST":"127.0.0.1","MYSQL_PORT":"3306","MYSQL_USER":"root","MYSQL_PASS":"","MYSQL_DB":"your_database"}}'
See the official Claude Code MCP documentation for more details.
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 > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"mysql": {
"command": "npx",
"args": [
"-y",
"@kevinwatt/mysql-mcp"
],
"env": {
"MYSQL_HOST": "127.0.0.1",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root",
"MYSQL_PASS": "",
"MYSQL_DB": "your_database"
}
}
}
}
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 explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"mysql": {
"command": "npx",
"args": [
"-y",
"@kevinwatt/mysql-mcp"
],
"env": {
"MYSQL_HOST": "127.0.0.1",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root",
"MYSQL_PASS": "",
"MYSQL_DB": "your_database"
}
}
}
}
3. Restart Claude Desktop for the changes to take effect