mysql-mcp-server
7
The MySQL MCP Service is an API designed for direct MySQL database access by Cursor AI, utilizing the MCP protocol to facilitate SQL operations and data retrieval. Notable features include real-time data access, secure connections, and standardized API responses for seamless integration.
MySQL MCP Service Overview
MySQL MCP Service is an API service developed using Node.js, designed to provide the Cursor AI with the ability to access MySQL databases directly. The service follows the Model Control Platform (MCP) protocol, allowing the AI to execute SQL queries, retrieve table structure information, and perform data operations via a standardized interface.
Features
- SQL Query Execution: Supports execution of SQL statements (SELECT, INSERT, UPDATE, DELETE, etc.)
- Table Structure Inquiries: Retrieves detailed database table structures
- Real-time Data Access: Allows AI real-time database access
- Secure Connection: Configurable database connection parameters
- Cross-Domain Support: Built-in CORS for easy front-end integration
- Standardized Response: Unified API response format
- MCP Protocol Support: Fully implements MCP protocol for easy integration with Cursor AI
Technology Stack
- Node.js environment
- Express.js framework
- mysql2 database driver
- dotenv for environment variables
- cors for cross-origin support
Installation and Deployment
Prerequisites
- Node.js 14.x or higher
- MySQL database connection
- Git (optional)
Installation Steps
- Clone the repository and navigate to the directory
- Install dependencies
- Configure environment variables in a .env file
- Start the service in development or production mode
API Documentation
Main Endpoints
- MCP Manifest:
/manifest.json
- OpenAPI Specification:
/openapi.yaml
- SQL Query:
/api/mysql/query
- Table Structure Query:
/api/mysql/schema
- DDL Query:
/api/mysql/ddl
Usage in Cursor
- Open the Cursor editor
- Add a new MCP service
- Enter the service URL
- Save and activate the service
Troubleshooting
- Service not starting: Check the port, Node.js version, or logs
- Database connection failed: Verify connection information and firewall settings
- API request failure: Check request format and server logs