MySQL MCP server for cursor
Configuration
View docs{
"mcpServers": {
"vitalydv-mysql-mcp": {
"command": "node",
"args": [
"./mysql-mcp/index.js"
],
"env": {
"MYSQL_DB": "db",
"MYSQL_HOST": "127.0.0.1",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root"
}
}
}
}This MCP server lets you interact with a MySQL database through a lightweight MCP interface. It exposes read-only capabilities to run safe SQL queries and fetch table schemas, making it easy to integrate MySQL data into your MCP workflows without exposing direct database access.
You run the MCP server locally and connect to it with an MCP client. This server provides three read-only endpoints: query to execute safe SELECT-like queries, table-schema to retrieve a table’s structure, and list-tables to list all tables in the database. You can request data from a specific table using the table://{name} resource to fetch up to 100 rows.
Prerequisites you need on your machine: Node.js with npm and access to a MySQL server.
# Install Node.js and npm if not already installed
# On macOS with Homebrew
brew install node
# On Debian/Ubuntu
sudo apt-get update
sudo apt-get install nodejs npmConfigure the MCP server to connect to your MySQL instance by defining the MCP server in your mcp.json. The following configuration runs the MCP server locally using Node.js and points it at your MySQL instance.
{
"mcpServers": {
"mysql_mcp_readonly": {
"command": "node",
"args": [
"./mysql-mcp/index.js"
],
"env": {
"MYSQL_HOST": "127.0.0.1",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root",
"MYSQL_PASS": "",
"MYSQL_DB": "db"
}
}
}
}Because this server exposes read-only database access, ensure it runs in a trusted network and limit access to authorized clients. Use strong MySQL credentials and consider network-level restrictions (firewalls/VPN) to prevent unauthorized connections.
If the MCP server does not start, verify that Node.js is installed and that the environment variables for MySQL are correct. Check that your MySQL server is reachable at the specified host and port, and that the database name exists.
This MCP server is designed for safe, read-only interaction with a MySQL database. Adjust access controls and credential handling according to your security policies.
Execute read-only SQL queries (SELECT, SHOW, EXPLAIN, DESCRIBE) against the configured MySQL database.
Retrieve the structure of a specified table, including columns and data types.
Return a list of all tables in the configured database.