MySQL MCP Server

by dkabx

Not rated
GitHub

About

Provides tools for AI assistants to interact with a MySQL database.

Details

Author
dkabx
Categories
Database, Other

Setup

Install MySQL MCP Server in your MCP client (Claude Desktop, Cursor, Windsurf, and others).

Repository: https://github.com/dkabx/mcp-mysql-server

Follow the installation instructions in the repository README, then restart your MCP client.

A Model Context Protocol (MCP) server that provides MySQL database access tools for AI assistants like Cursor.

This MCP server enables AI assistants to interact with MySQL databases by providing three essential tools:

- Execute SQL queries
- Describe table structures
- List all database tables

- Query Execution: Run any SQL query against your MySQL database
- Table Description: Get detailed schema information for any table
- Table Listing: View all tables in your database
- Error Handling: Comprehensive error handling for database operations
- MCP Protocol Compliance: Fully compatible with MCP 2024-11-05 specification

- Node.js (v14 or higher)
- MySQL database (local or remote)
- Cursor IDE (for MCP integration)
- Clone or download this repository
- Install dependencies:

The server uses environment variables for database configuration:

- MYSQL_HOST: MySQL server hostname
- MYSQL_USER: Database username
- MYSQL_PASSWORD: Database password
- MYSQL_DATABASE: Database name
- MYSQL_PORT: MySQL port (default: 3306)

To use this MCP server with Cursor, add the following configuration to your Cursor MCP settings file (~/.cursor/mcp.json):

{ "mcpServers": { "mysql-mcp": { "label": "MySQL MCP", "command": "node", "args": ["/path/to/your/mysql-mcp-server.js"], "env": { "MYSQL_HOST": "your-mysql-host", "MYSQL_USER": "your-username", "MYSQL_PASSWORD": "your-password", "MYSQL_DATABASE": "your-database", "MYSQL_PORT": "3306" } } } }

Replace/path/to/your/mysql-mcp-server.jswith the actual path to your server file and update the environment variables with your database credentials.

Execute any SQL query against the database.

- query(string): The SQL query to execute

SELECT * FROM users WHERE role = 'admin'

Get the structure and schema information for a specific table.

- table_name(string): Name of the table to describe

Once configured in Cursor, you can use natural language to interact with your database:

- "Show me all tables in the database"
- "Describe the structure of the users table"
- "Get all admin users from the user table"
- "Show me recent appointments"

- Database Credentials: Store sensitive credentials securely and never commit them to version control
- Query Permissions: The server executes queries with the provided database user's permissions
- Network Access: Ensure your database is properly secured and accessible only from authorized sources
- Input Validation: While the server handles errors, always validate and sanitize inputs in production

- Check that all environment variables are correctly set
- Verify database connectivity
- Ensure Node.js and mysql2 package are properly installed
- Check Cursor's developer console for error messages

- Verify database host, port, and credentials
- Check network connectivity to the database
- Ensure the database allows connections from your IP
- Verify the database name exists

- Restart Cursor after making configuration changes
- Check the MCP server file path in the configuration
- Ensure the server implements the MCP protocol correctly

mcp/ ├── mysql-mcp-server.js # Main MCP server implementation ├── package.json # Node.js dependencies └── README.md # This file

- mysql2: MySQL client for Node.js with promise support

Feel free to submit issues, feature requests, or pull requests to improve this MCP server.

This project is open source and available under the MIT License.

- Initial release
- Basic MCP protocol implementation
- Three core database tools (query, describe, list)
- Error handling and logging
- Cursor integration support

Multi-database agent access (PostgreSQL, SQLite, MySQL, Oracle, SQL Server) with batch queries, pre-configured connections, and SQLGlot-enforced read-only safety

Production safe MCP server that gives AI agents direct access to MySQL databases.

MCP server for MySQL/MariaDB — schema inspection, queries, and data manipulation for AI assistants

Provides AI agents with direct access to query, search, and analyze MySQL databases.

A read-only MySQL database server for LLMs to inspect schemas and execute queries.

Provides direct access to MySQL databases, allowing AI agents to execute SQL queries and manage database content.

Provides access to a MySQL database, allowing agents to execute SQL queries.

A MySQL database server for AI assistants, enabling full CRUD operations, transaction management, and intelligent rollback.

Provides read-only access to MySQL databases, allowing LLMs to inspect schemas and execute queries.

A read-only MCP server for MySQL, enabling LLMs to query live data using the CData JDBC Driver.

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.