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
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.
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 -74127
- 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 -9017MIT 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 -
- AsecurityAlicenseAqualityA tool service that enables AI agents to interact with MySQL databases through natural language, supporting SQL queries, table structure retrieval, and connection testing.Last updated -74121Apache 2.0