home / mcp / mysql mcp server

MySQL MCP Server

Provides safe MCP access to MySQL databases for schema inspection, data querying, and admin tasks.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "bhaveshrmahajan-mysql-mcp-server": {
      "command": "node",
      "args": [
        "/ABSOLUTE/PATH/TO/mysql-mcp-server/dist/index.js"
      ],
      "env": {
        "DB_HOST": "localhost",
        "DB_NAME": "your_database",
        "DB_PORT": "3306",
        "DB_USER": "root",
        "DB_PASSWORD": "your_password"
      }
    }
  }
}

This MySQL MCP Server lets your AI assistant safely interact with a MySQL database. You can inspect schemas, read data, run queries, and perform administrative tasks through natural language, with access controlled by explicit, structured MCP commands.

How to use

Connect your MCP client to the MySQL MCP Server to explore your database. You can ask for table schemas, view data, run read-only queries for exploration, and perform write operations with caution. Use the available tools to inspect structures, fetch sample data, and execute SQL in a controlled manner. Begin with small, safe requests and gradually move to more complex tasks as you confirm results.

How to install

Prerequisites: you need Node.js installed on your machine. You will also require access to the MySQL database you plan to connect to.

Step 1: Clone the project directory and navigate into it.

Step 2: Install dependencies.

Step 3: Build the server.

Step 4: Run the server with the required environment variables set for your database connection.

Configuration

The server connects to your MySQL database using standard environment variables. Provide the values for host, user, password, database name, and port when starting the server.

When running locally, start the server with the Node runtime and the compiled entry point, supplying the necessary environment variables.

Example initialization and environment block is shown below for configuring the local runtime. The block shows how the server is launched and which values you should replace with your own.

Security and notes

Keep in mind that this server has powerful capabilities, including write access. Only connect to databases where you have authorization, and exercise caution when issuing commands that modify data.

Use separate, restricted credentials for development and production environments to minimize risk.

Usage example templates

You can ask questions like: What tables exist in my database? What is the schema for a particular table? Which users have the highest spend in the dataset? How would I insert a new row into a table?

Available tools

list-tables

List all tables in the connected database.

describe-table

Show the schema (columns, types, keys) for a specific table.

create-table

Create a new table using a SQL query.

insert-row

Insert a new row into a table using JSON data.

update-row

Update existing rows with a JSON-based WHERE clause.

delete-row

Delete rows with a safety-first JSON-based WHERE clause.

execute-query

Execute read-only SQL queries (SELECT, SHOW, DESCRIBE) for exploration.

execute-write-query

Execute write SQL queries (INSERT, UPDATE, DELETE, ALTER, etc.) with caution.

create-database

Create a new database.

list-procedures

List stored procedures.

show-procedure

View the CREATE statement for a procedure.

list-functions

List functions in the database.

show-function

View the CREATE statement for a function.

list-triggers

List triggers.

show-trigger

View the CREATE statement for a trigger.

list-views

List views.

show-view

View the CREATE statement for a view.