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 listTable 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
Related MCP server: MySql MCP Server
Installation
Configuration
The server can be configured using environment variables:
Variable | Default | Description |
|
| MySQL server hostname |
|
| MySQL server port |
|
| MySQL username |
| (empty) | MySQL password |
|
| Default database name |
|
| 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:
Use the list_tables toolGet table structure:
Use get_table_info with table_name: "users"Query data:
Use execute_query with sql: "SELECT * FROM users LIMIT 10"Insert data:
Use insert_data with table_name: "users" and data: {"name": "John", "email": "john@example.com"}
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.