mysql_mcp_server
by shengshengshengbuxi
Overview
This server provides a Model Context Protocol (MCP) interface to a MySQL database, enabling AI models to execute SQL queries and retrieve database schema information.
Installation
npm startEnvironment Variables
- MYSQL_HOST
- MYSQL_PORT
- MYSQL_USER
- MYSQL_PASSWORD
- MYSQL_DATABASE
Security Notes
The server's primary function is to execute arbitrary SQL queries provided as input via the MCP protocol. While the `mysql2` client supports parameterized queries (mitigating basic SQL injection within parameters), the `sql` string itself is passed directly from the tool's input without additional server-side validation. This means a malicious or compromised LLM (or any upstream caller) could instruct the server to execute destructive SQL commands (e.g., `DROP TABLE`, `DELETE FROM`) on the connected MySQL database. The system inherently trusts the `sql` input from the MCP caller. Additionally, the default `MYSQL_PASSWORD` '1234' for unconfigured environments is a minor security risk for local development setups.
Similar Servers
tmcp
A server implementation for the Model Context Protocol (MCP) to enable LLMs to access external context and tools.
mcp-mysql-server
Provides an MCP-compliant interface for AI models to securely interact with a MySQL database for CRUD operations, schema inspection, and performance analysis.
mcp_sql_demo
Provides secure, multi-database access for LLMs to inspect MySQL schemas and execute SQL queries, supporting both read and configurable write operations with fine-grained schema-specific permissions.
mysql-mcp-server
Provides a programmatic interface for interacting with a MySQL database, enabling schema retrieval and arbitrary SQL query execution through an MCP server.