
How to add MySQL MCP Server to Cursor
MCP server for MySQL database operations: query, execute, list and describe tables via prepared statements. Paste the config into ~/.cursor/mcp.json and restart Cursor.
Last updated June 14, 2026 · 162★ · stdio · no auth
Cursor config for MySQL MCP Server
npx @f4ww4z/mcp-mysql-server{
"mcpServers": {
"mysql-mcp-server": {
"command": "npx",
"args": [
"-y",
"@f4ww4z/mcp-mysql-server",
"mysql://user:password@localhost:port/database"
]
}
}
}Setup steps
- 1Open Cursor → Settings → MCP → Add new MCP server (or edit ~/.cursor/mcp.json directly).
- 2Paste the MySQL MCP Server config below into the "mcpServers" object.
- 3Fill in placeholder secrets, then save.
- 4Cursor reloads MCP servers automatically — check Settings → MCP for a green status dot.
- 5Ask Cursor to use one of MySQL MCP Server's tools to confirm it's connected.
Before you start
- Node.js (for npx)
- A reachable MySQL database with valid credentials
What MySQL MCP Server can do in Cursor
connect_dbEstablish connection to MySQL database using provided credentials (host, user, password, database).
queryExecute SELECT queries with optional prepared statement parameters.
executeExecute INSERT, UPDATE, or DELETE queries with optional prepared statement parameters.
list_tablesList all tables in the connected database.
describe_tableGet the structure of a specific table.
Security
Uses prepared statements to prevent SQL injection and validates queries before execution. Supports secure password handling through environment variables and automatically closes connections when done.
MySQL MCP Server + Cursor FAQ
Where is the Cursor config file?
Cursor reads MCP servers from ~/.cursor/mcp.json. Paste the MySQL MCP Server config there under the "mcpServers" key and restart the client.
Is MySQL MCP Server safe to use with Cursor?
Uses prepared statements to prevent SQL injection and validates queries before execution. Supports secure password handling through environment variables and automatically closes connections when done.
How do I provide database credentials?
Either pass a MySQL connection URL (mysql://user:password@host:port/database) as an argument in the args array, or set the MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, and MYSQL_DATABASE environment variables in your MCP settings.
Does it protect against SQL injection?
Yes. The server uses prepared statements for query parameters and validates queries before execution.
How do I install it for Claude Desktop?
You can install it automatically via Smithery with: npx -y @smithery/cli install @f4ww4z/mcp-mysql-server --client claude, or configure it manually with npx @f4ww4z/mcp-mysql-server.