Provides tools for connecting to MySQL databases, executing SQL queries with prepared statements, listing databases and tables, inspecting table schemas, and managing database connections with connection pooling support.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MySQL MCP Servershow me the schema for the users table"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MySQL MCP Server
A Model Context Protocol (MCP) server for MySQL database integration with Cursor IDE. This server provides tools to connect to, query, and manage MySQL databases directly from Cursor.
Features
🔌 Easy Connection: Connect to MySQL databases with simple configuration
🔍 Query Execution: Run SQL queries and get structured results
📊 Database Management: List databases, tables, and table schemas
🛡️ Secure: Supports SSL connections and prepared statements
⚡ Performance: Connection pooling for optimal performance
🎯 TypeScript: Fully typed for better development experience
Installation
From npm (recommended)
From source
Usage
Cursor IDE Configuration
Add the following to your Cursor MCP settings:
Available Tools
1. mysql_connect
Connect to a MySQL database.
Parameters:
host(string, optional): MySQL host (default: "localhost")port(number, optional): MySQL port (default: 3306)user(string, required): MySQL usernamepassword(string, required): MySQL passworddatabase(string, optional): Database namessl(boolean, optional): Use SSL connection (default: false)connectionLimit(number, optional): Connection pool limit (default: 10)
Example:
2. mysql_query
Execute a SQL query.
Parameters:
query(string, required): SQL query to executeparams(array, optional): Query parameters for prepared statements
Example:
3. mysql_list_databases
List all available databases.
Example:
4. mysql_list_tables
List tables in a database.
Parameters:
database(string, optional): Database name (uses current if not provided)
Example:
5. mysql_describe_table
Get table structure and schema information.
Parameters:
table(string, required): Table namedatabase(string, optional): Database name (uses current if not provided)
Example:
6. mysql_disconnect
Close the MySQL connection.
Example:
Development
Prerequisites
Node.js 18.0.0 or higher
npm or yarn
Setup
Clone the repository:
Install dependencies:
Build the project:
Run in development mode:
Testing
Run the test suite:
Configuration
The server can be configured through environment variables or by passing parameters to the mysql_connect tool:
MYSQL_HOST: Default MySQL hostMYSQL_PORT: Default MySQL portMYSQL_USER: Default MySQL usernameMYSQL_PASSWORD: Default MySQL passwordMYSQL_DATABASE: Default database nameMYSQL_SSL: Use SSL connection (true/false)
Security Considerations
Always use strong passwords for database connections
Enable SSL for production environments
Use connection pooling to limit concurrent connections
Validate and sanitize all user inputs before executing queries
Consider using read-only database users for MCP connections
Error Handling
The server provides detailed error messages for common issues:
Connection failures
Invalid SQL queries
Authentication errors
Database access permissions
Network timeouts
Contributing
Fork the repository
Create a feature branch:
git checkout -b feature-nameMake your changes and add tests
Commit your changes:
git commit -am 'Add some feature'Push to the branch:
git push origin feature-nameSubmit a pull request
License
MIT License - see LICENSE file for details.
Support
📧 Email: udithamal.lk@gmail.com
🐛 Issues: GitHub Issues
📖 Documentation: GitHub Wiki
Changelog
1.0.0
Initial release
Basic MySQL connection and query functionality
Database and table listing
Table schema inspection
Connection pooling support
SSL connection support