Provides safe MCP access to MySQL databases for schema inspection, data querying, and admin tasks.
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.
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.
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.
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.
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.
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?
List all tables in the connected database.
Show the schema (columns, types, keys) for a specific table.
Create a new table using a SQL query.
Insert a new row into a table using JSON data.
Update existing rows with a JSON-based WHERE clause.
Delete rows with a safety-first JSON-based WHERE clause.
Execute read-only SQL queries (SELECT, SHOW, DESCRIBE) for exploration.
Execute write SQL queries (INSERT, UPDATE, DELETE, ALTER, etc.) with caution.
Create a new database.
List stored procedures.
View the CREATE statement for a procedure.
List functions in the database.
View the CREATE statement for a function.
List triggers.
View the CREATE statement for a trigger.
List views.
View the CREATE statement for a view.