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
Build Model Context Protocol (MCP) servers for AI agents, providing schema-agnostic tools, resources, and prompts, with optional OAuth 2.1 authentication and distributed session management.
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
This server provides a FastMCP interface to interact with a MySQL database, allowing retrieval of database schema and execution of arbitrary SQL queries.