MCP MySQL Connector
A Model Context Protocol (MCP) plugin for connecting to MySQL databases from Cursor IDE.
Installation
Option 1: Use with npx (Recommended)
You can use the plugin directly with npx without installing it:
npx -y mcp-mysql-connector mysql://user:password@host:port/database
Option 2: Install globally
npm install -g mcp-mysql-connector
mcp-mysql-connector mysql://user:password@host:port/database
Option 3: Clone the repository
git clone https://github.com/yourusername/mcp-mysql-connector.git
cd mcp-mysql-connector
npm install
node index.js mysql://user:password@host:port/database
Setup with Cursor IDE
For easier setup with Cursor IDE, you can use the setup script:
npx -y mcp-mysql-connector-setup
This will guide you through the process of setting up the MCP MySQL Connector with Cursor IDE.
Connection String Format
The connection string should be in the following format:
mysql://user:password@host:port/database
Example:
mysql://root:password@localhost:3306/mydatabase
You can also add SSL support by appending ?ssl=true
to the connection string:
mysql://user:password@host:port/database?ssl=true
How It Works
This plugin creates a simple HTTP server that implements the Model Context Protocol. It connects to your MySQL database and allows Cursor IDE to run SQL queries against it.
The server listens on port 3000 by default and accepts POST requests with SQL queries. The results are returned as JSON.
Important Note: The MySQL connection uses the port specified in the connection string (default: 3306), while the MCP server runs on port 3000. Make sure Cursor is configured to use port 3000 for the MCP connection.
Using with Cursor IDE
Once the MCP server is running, you can use it with Cursor IDE to run SQL queries against your MySQL database.
- Open Cursor
- Go to MCP Servers
- Click "Add new MCP server"
- Enter a name (e.g., "MySQL")
- Enter the command:
npx -y mcp-mysql-connector mysql://user:password@host:port/database
Publishing to npm
If you want to publish this package to npm, follow these steps:
- Create an npm account if you don't have one: https://www.npmjs.com/signup
- Login to npm from the command line:
npm login
- Publish the package:
npm publish
License
MIT