Includes platform-specific configuration paths for setting up the MCP server with Claude Desktop on macOS systems.
Provides secure access to MySQL databases with tools for executing safe queries, retrieving table information, inserting data, and listing tables, all with built-in security features like SQL injection protection and query limits.
MySQL MCP Server
A Model Context Protocol (MCP) server that provides secure MySQL database operations for AI assistants and other MCP clients.
Features
🛠️ Tools
- execute_query - Execute safe SQL queries (SELECT, INSERT, SHOW, DESCRIBE)
- get_table_info - Get detailed table structure information
- insert_data - Convenient data insertion with automatic parameterization
- list_tables - List all tables in the database
📊 Resources
- Database Info (
mysql://database/info
) - Database metadata and table list - Table Structure (
mysql://table/{table_name}
) - Detailed table schema information
🔒 Security Features
- Limited Operations: Only allows safe operations (SELECT, INSERT, SHOW, DESCRIBE)
- SQL Injection Protection: Uses parameterized queries
- Automatic LIMIT: Adds LIMIT clauses to SELECT queries to prevent large data dumps
- Connection Pooling: Efficient database connection management
Installation
Configuration
The server can be configured using environment variables:
Variable | Default | Description |
---|---|---|
MYSQL_HOST | localhost | MySQL server hostname |
MYSQL_PORT | 3306 | MySQL server port |
MYSQL_USER | root | MySQL username |
MYSQL_PASSWORD | (empty) | MySQL password |
MYSQL_DB | mysql | Default database name |
MYSQL_TIMEZONE | +00:00 | MySQL timezone |
Usage with MCP Clients
Claude Desktop
Add to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json
Other MCP Clients
For other MCP clients, use the server with stdio transport:
Development
Prerequisites
- Node.js 18+
- TypeScript
- Access to a MySQL database
Setup
- Clone the repository:
- Install dependencies:
- Set up environment variables:
- Build the server:
Development Commands
Testing
You can test the server using the MCP Inspector:
This will start the inspector and provide a URL to test the server in your browser.
Example Usage
Once connected through an MCP client, you can:
- List all tables:
- Get table structure:
- Query data:
- Insert data:
Security Considerations
This server is designed with security in mind:
- Read-mostly operations: Only SELECT, INSERT, SHOW, and DESCRIBE operations are allowed
- No destructive operations: UPDATE and DELETE are explicitly forbidden
- Parameterized queries: All user inputs are properly escaped
- Connection limits: Uses connection pooling to prevent resource exhaustion
- Query limits: Automatic LIMIT clauses prevent large data dumps
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT License - see LICENSE file for details.
Related
This server cannot be installed
Provides secure access to MySQL databases for AI assistants, enabling safe SQL queries, table information retrieval, and data insertion with built-in security protections.
Related MCP Servers
- AsecurityAlicenseAqualityAllows AI assistants to list tables, read data, and execute SQL queries through a controlled interface, making database exploration and analysis safer and more structured.Last updated -1360PythonMIT License
- AsecurityAlicenseAqualityThis server enables AI models to interact with MySQL databases through a standardized interface.Last updated -564661JavaScriptMIT License
- AsecurityFlicenseAqualityEnables AI models to perform MySQL database operations through a standardized interface, supporting secure connections, query execution, and comprehensive schema management.Last updated -715222JavaScript
- -securityAlicense-qualityA server that enables AI models to interact with MySQL databases through a Model Control Protocol, providing tools for table creation, schema inspection, query execution, and data retrieval.Last updated -20PythonMIT License