MySQL MCP Server

MySQL MCP server for cursor

Local serverstdio

What is the MySQL MCP server?

MySQL MCP server exists for a simple reason — assistants are far more useful when they can act on MySQL directly instead of describing what you should do. MySQL MCP server for cursor.

What you get

This project implements an MCP (Model Context Protocol) server for working with MySQL database.

What the assistant can call

Once MySQL is connected, these are the calls the assistant has available:

  • query — execute SQL queries (only SELECT, SHOW, EXPLAIN, DESCRIBE)
  • table-schema — get table structure
  • list-tables — get list of all tables in the database

Setting it up

Setup follows the usual MCP pattern — install or clone the server, register it in your client's configuration file, restart the client. The configuration blocks on this page cover the common clients.

Configuration and credentials

You will need 5 environment variables: MYSQL_HOST, MYSQL_PORT, MYSQL_USER, MYSQL_PASS, MYSQL_DB. Keep credentials in your client's env block or a secrets manager rather than in a file you might commit.

Choosing this one

Plenty of database access servers cover similar ground. The differences that matter in practice are scope of access and how much setup stands between you and a working tool call. MySQL's toolset — query, table-schema, list-tables — is a fair guide to whether it matches your workflow. It is maintained by vitalyDV; worth a glance at recent repository activity before you build anything load-bearing on it.

We check each listing at SyncDev against the project's documentation before it goes live — if something here drifts out of date, it is a bug worth reporting.

Before you rely on it

  • It runs with your machine's permissions. That is convenient and also the reason to think about what you point it at before you approve a tool call.
  • MCP clients confirm each tool call by default. Leave that on until you have watched what the mysql mcp server does with a few real requests.

Available tools

ToolWhat it does
queryexecute SQL queries (only SELECT, SHOW, EXPLAIN, DESCRIBE)
table-schemaget table structure
list-tablesget list of all tables in the database

How to install the MySQL MCP server

## add config to mcp.json
```json
{
  "mcpServers": {
    "mysql_mcp_readonly": {
      "command": "node",
      "args": [
        "./mysql-mcp/index.js"
      ],
      "env": {
        "MYSQL_HOST": "127.0.0.1",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "root",
        "MYSQL_PASS": "",
        "MYSQL_DB": "db",
      }
    }
  }
}

Configuration as documented by the project. Restart the client after saving.

Configuration

VariableDescriptionRequired
MYSQL_HOSTEndpoint or connection string the server talks to.Optional
MYSQL_PORTConfiguration value read at startup.Optional
MYSQL_USERConfiguration value read at startup.Optional
MYSQL_PASSConfiguration value read at startup.Optional
MYSQL_DBConfiguration value read at startup.Optional

Example prompts to try

  • Use MySQL to query.
  • Use MySQL to table-schema.
  • Use MySQL to list-tables.

Frequently asked questions

Only SELECT, SHOW, EXPLAIN, and DESCRIBE statements. The server enforces read‑only access, so INSERT, UPDATE, DELETE, and other write commands are not allowed.