MCP Directory

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

  1. 1Open Cursor → Settings → MCP → Add new MCP server (or edit ~/.cursor/mcp.json directly).
  2. 2Paste the MySQL MCP Server config below into the "mcpServers" object.
  3. 3Fill in placeholder secrets, then save.
  4. 4Cursor reloads MCP servers automatically — check Settings → MCP for a green status dot.
  5. 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_db

Establish connection to MySQL database using provided credentials (host, user, password, database).

query

Execute SELECT queries with optional prepared statement parameters.

execute

Execute INSERT, UPDATE, or DELETE queries with optional prepared statement parameters.

list_tables

List all tables in the connected database.

describe_table

Get 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.

View repo Full MySQL MCP Server page