Provides an MCP server that executes SQL queries against a MySQL database and returns results in JSON.
Configuration
View docs{
"mcpServers": {
"mysql_mcp": {
"command": "node",
"args": [
"/path/to/mysql-mcp-server/build/index.js"
],
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "mcp101",
"MYSQL_PASSWORD": "123qwe",
"MYSQL_DATABASE": "mcpdb"
}
}
}
}You can run a MySQL MCP Server locally to execute SQL queries against a MySQL database and receive results in JSON. It enables read and write operations while keeping actions auditable through transaction logging, making it convenient to integrate SQL data access into your conversations or automated workflows.
You interact with the MySQL MCP Server from an MCP client. Start the local server as configured, then issue SQL commands through supported tools to run queries, create tables, insert data, update records, or delete data. The server executes your SQL statements on the configured MySQL database and returns results in JSON format for easy consumption in your application or chat workflow.
Prerequisites you need before installation:
Install and build the MCP server with these commands:
# 1) Clone or download the project
# 2) Install dependencies
cd mysql-mcp-server
npm install
# 3) Build the server
npm run buildConfigure the server by setting environment variables for the MySQL connection. The following variables are used by the MCP server to connect to the MySQL database. You can place these in your environment or in your MCP launcher configuration.
{
"mcpServers": {
"mysql_mcp": {
"type": "stdio",
"name": "mysql_mcp",
"command": "node",
"args": ["/path/to/mysql-mcp-server/build/index.js"],
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "mcp101",
"MYSQL_PASSWORD": "123qwe",
"MYSQL_DATABASE": "mcpdb"
}
}
}
}The server exposes a set of operations to interact with your MySQL database. You can perform read operations, create tables, insert data, update existing records, and delete rows. Results from queries are returned in JSON format for easy parsing in your client.
{
"tool": "run_sql_query",
"query": "SELECT * FROM test_users"
}Executes a read-only SQL SELECT query against the MySQL database and returns results in JSON.
Executes a SQL CREATE TABLE query to define new tables in the database.
Executes a SQL INSERT INTO query to add new rows to a table.
Executes a SQL UPDATE query to modify existing rows in a table.
Executes a SQL DELETE FROM query to remove rows from a table.