home / mcp / mysql mcp server

MySQL MCP Server

Provides MCP endpoints to connect, query, and manage MySQL databases directly from Cursor IDE.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "ashenud-mcp-mysql-server": {
      "url": "https://mcp.example.com/mcp",
      "headers": {
        "MYSQL_SSL": "true",
        "MYSQL_HOST": "localhost",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "root",
        "MYSQL_DATABASE": "mydb",
        "MYSQL_PASSWORD": "pa$$w0rd"
      }
    }
  }
}

You can connect to MySQL databases, run queries, and inspect schemas directly from Cursor using this MCP server. It provides secure, typed access with connection pooling and easy configuration, so you can manage databases from within your development environment without leaving your IDE.

How to use

To use this MCP server, configure your MCP client to launch the server process with the appropriate environment variables. Once running, you can connect to a MySQL database, execute queries, list databases and tables, and inspect table schemas from your Cursor workspace. Use the provided tools to perform common database tasks without writing client-side boilerplate.

How to install

Prerequisites: You need Node.js 18.0.0 or higher and npm or yarn installed on your system.

Step 1: Install the MCP MySQL server globally.

npm install -g @ashenud/mcp-mysql-server

Step 2: Prepare your environment with your MySQL credentials. You will provide these to the server via environment variables when you start it.

MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_USER=your_username
MYSQL_PASSWORD=your_password
MYSQL_DATABASE=your_database

Step 3: Start the MCP MySQL server. The command to run is the package command you installed, with the environment variables set as above.

MYSQL_HOST=localhost MYSQL_PORT=3306 MYSQL_USER=your_username MYSQL_PASSWORD=your_password MYSQL_DATABASE=your_database @ashenud/mcp-mysql-server

Configuration and environment variables

You configure the server by providing MySQL connection details through environment variables when you start the server. The following variables are used:

- MYSQL_HOST: Default MySQL host (e.g., localhost)

- MYSQL_PORT: MySQL port (e.g., 3306)

- MYSQL_USER: MySQL username

- MYSQL_PASSWORD: MySQL password

- MYSQL_DATABASE: Default database name

- MYSQL_SSL: Use SSL for the connection (true/false)

Available tools and usage patterns

The MCP server exposes a set of tools you can call from your Cursor workspace to interact with MySQL.

Available tools

mysql_connect

Establish a connection to a MySQL database using specified host, port, user, password, and optional SSL and pool settings.

mysql_query

Execute a SQL query with optional parameters for prepared statements and receive structured results.

mysql_list_databases

Retrieve a list of all available databases on the connected MySQL server.

mysql_list_tables

List tables in a given database or the current database if none is provided.

mysql_describe_table

Return the schema and column details for a specified table, with optional database context.

mysql_disconnect

Close the active MySQL connection and release resources.