Retrieves all available database schemas
Lists all tables in a specific schema
Gets detailed information about a specific table including columns and constraints
Executes a read-only SQL query against the database
Executes an INSERT SQL statement (when enabled)
Executes an UPDATE SQL statement (when enabled)
Executes a DELETE SQL statement (when enabled)
Switches to a different database in multi-DB mode
MySQL Database Access provides a secure interface for AI assistants to interact with MySQL databases. It enables database schema inspection and SQL query execution with configurable permission levels. This MCP server supports both read-only and write operations (optional), allowing AI assistants to retrieve data, analyze database structures, and even modify data when properly configured. With multi-database support and schema-specific permissions, it offers flexible and secure database access tailored to your needs.
The MySQL Database Access MCP enables AI assistants to interact with MySQL databases, providing capabilities to inspect database schemas and execute SQL queries. It supports both read-only and write operations (when enabled), making it a powerful tool for database exploration and management.
The simplest way to install and run the MySQL Database Access MCP is using NPX:
npx -y @benborla29/mcp-server-mysql
You can install this MCP through Smithery with:
smithery install @benborla29/mcp-server-mysql
Install with MCP Get using:
mcp-get install @benborla29/mcp-server-mysql
To install from the repository:
Clone the repository:
git clone https://github.com/benborla/mcp-server-mysql.git
Navigate to the directory:
cd mcp-server-mysql
Install dependencies:
npm install
Start the server:
npm start
Create a .env
file in the root directory with the following variables:
MYSQL_HOST=127.0.0.1
MYSQL_PORT=3306
MYSQL_USER=your_username
MYSQL_PASS=your_password
MYSQL_DB=your_database
ALLOW_INSERT_OPERATION=false
ALLOW_UPDATE_OPERATION=false
ALLOW_DELETE_OPERATION=false
By default, all write operations (INSERT, UPDATE, DELETE) are disabled for security. To enable them, set the corresponding environment variables to true
:
ALLOW_INSERT_OPERATION=true
ALLOW_UPDATE_OPERATION=true
ALLOW_DELETE_OPERATION=true
The MCP supports connecting to multiple databases. To enable this mode:
MULTI_DB_MODE=true
in your environment variablesdatabases.json
file in the root directory with your database configurations:[
{
"id": "db1",
"host": "localhost",
"port": 3306,
"user": "user1",
"password": "password1",
"database": "database1",
"allowInsert": false,
"allowUpdate": false,
"allowDelete": false
},
{
"id": "db2",
"host": "localhost",
"port": 3306,
"user": "user2",
"password": "password2",
"database": "database2",
"allowInsert": true,
"allowUpdate": false,
"allowDelete": false
}
]
You can configure permissions for specific schemas by adding a permissions.json
file:
{
"schemas": {
"public": {
"tables": {
"users": {
"allowSelect": true,
"allowInsert": false,
"allowUpdate": false,
"allowDelete": false
}
}
}
}
}
Add the following to your claude_desktop_config.json
file:
{
"mcpServers": {
"mcp_server_mysql": {
"command": "npx",
"args": [
"-y",
"@benborla29/mcp-server-mysql"
],
"env": {
"MYSQL_HOST": "127.0.0.1",
"MYSQL_PORT": "3306",
"MYSQL_USER": "your_username",
"MYSQL_PASS": "your_password",
"MYSQL_DB": "your_database",
"ALLOW_INSERT_OPERATION": "false",
"ALLOW_UPDATE_OPERATION": "false",
"ALLOW_DELETE_OPERATION": "false",
"PATH": "/path/to/node/bin:/usr/bin:/bin",
"NODE_PATH": "/path/to/node/lib/node_modules"
}
}
}
}
For Cursor, install with:
npx mcprunner -- MYS
For more detailed troubleshooting, check the console output when running the server.