MCP Directory

How to add MySQL MCP Server to Cursor

Secure, structured access to MySQL databases for AI clients — query, sample, and inspect schemas via MCP. Paste the config into ~/.cursor/mcp.json and restart Cursor.

Last updated June 14, 2026 · 1.3k · stdio · no auth

Cursor config for MySQL MCP Server

pip install mysql-mcp-server
{
  "mcpServers": {
    "mysql-mcp-server": {
      "command": "uv",
      "args": [
        "--directory",
        "path/to/mysql_mcp_server",
        "run",
        "mysql_mcp_server"
      ],
      "env": {
        "MYSQL_HOST": "localhost",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "your_username",
        "MYSQL_PASSWORD": "your_password",
        "MYSQL_DATABASE": "your_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

  • Python with pip (or uv/uvx) to install and run the server
  • A running MySQL database with reachable host/port
  • MySQL credentials supplied via MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD (and optionally MYSQL_DATABASE) environment variables
  • uv installed when using the uv/uvx-based config

What MySQL MCP Server can do in Cursor

execute_sql

Executes any standard SQL query. Argument: query (string). Supports SELECT, SHOW, DESCRIBE, and DML (INSERT, UPDATE, DELETE); DML operations are marked with a destructive hint. Single statements only — multi-statement queries are not supported. Use database.table notation to query any database regardless of the MYSQL_DATABASE setting.

get_schema_info

Provides detailed metadata about database structures. Argument: table_name (optional string). Outputs column names, types, nullability, default values, and comments. Pass database.table for cross-database lookups; bare names use the configured database. Identifiers must contain only alphanumeric characters, underscores, and $ (a dot is allowed as a database/table separator).

get_table_sample

Fetches a representative sample of data. Arguments: table_name (string), limit (optional integer, max 20). Useful for quickly understanding data formats and content without fetching large result sets. Pass database.table for cross-database sampling; bare names use the configured database. Same identifier validation rules as get_schema_info.

Security

Requires database access to function. Table/database identifiers passed to get_schema_info and get_table_sample are validated against a strict whitelist (alphanumeric, underscore, and $; a single dot allowed as database.table separator) to prevent SQL injection. Supports SSL/TLS and SSH tunneling for encrypted remote connections. Passwords and SSH private keys are masked in logs. Use a dedicated MySQL user with minimal permissions; never use root or administrative credentials. See SECURITY.md for hardening guidance.

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?

Requires database access to function. Table/database identifiers passed to get_schema_info and get_table_sample are validated against a strict whitelist (alphanumeric, underscore, and $; a single dot allowed as database.table separator) to prevent SQL injection. Supports SSL/TLS and SSH tunneling for encrypted remote connections. Passwords and SSH private keys are masked in logs. Use a dedicated MySQL user with minimal permissions; never use root or administrative credentials. See SECURITY.md for hardening guidance.

Which transports are supported?

Both standard input/output (STDIO) and Streamable HTTP (SSE). SSE mode (MCP_TRANSPORT=sse) is recommended for remote/self-hosted deployments.

Why do I see 'Missing required database configuration' in Claude Desktop/Code?

Those hosts launch the server from their own working directory, so a project .env file is not found. Put your MYSQL_* values in the env block of the MCP config instead of relying on .env.

Can I query more than one database?

Yes. Omit MYSQL_DATABASE to enable multi-database mode; list_resources then returns all user databases and you use fully qualified database.table names in queries. Only single SQL statements are supported.

View repo Full MySQL MCP Server page