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
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
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
- AsecurityFlicenseAqualityEnables AI models to perform MySQL database operations through a standardized interface, supporting secure connections, query execution, and comprehensive schema management.Last updated -73526JavaScript
- AsecurityAlicenseAqualityConnect and interact with MySQL databases seamlessly. Execute SQL queries, manage database connections, and retrieve data directly through AI assistants. Enhance your AI capabilities with structured access to your MySQL data.Last updated -9415TypeScriptMIT License
- -securityFlicense-qualityEnables secure interaction with MySQL databases, allowing AI assistants to list tables, read data, and execute SQL queries through a controlled interface.Last updated -Python
- -securityFlicense-qualityA powerful server that enables AI agents to interact with MySQL databases, execute SQL queries, and manage database content through a simple interface.Last updated -225JavaScript