mysql-mcp
by neverinfamous
Overview
Provides an MCP (Model Context Protocol) server for MySQL, enabling AI agents to programmatically interact with and manage MySQL databases.
Installation
npx @neverinfamous/mysql-mcp --transport stdio --mysql mysql://user:password@localhost:3306/databaseEnvironment Variables
- MYSQL_MCP_TOOL_FILTER
- TOOL_FILTER
- MYSQL_HOST
- MYSQL_PORT
- MYSQL_USER
- MYSQL_PASSWORD
- MYSQL_DATABASE
- MYSQL_XPORT
- MYSQL_POOL_SIZE
- LOG_LEVEL
- METADATA_CACHE_TTL_MS
- PROXYSQL_HOST
- PROXYSQL_PORT
- PROXYSQL_USER
- PROXYSQL_PASSWORD
- MYSQL_ROUTER_URL
- MYSQL_ROUTER_USER
- MYSQL_ROUTER_PASSWORD
- MYSQL_ROUTER_INSECURE
- MYSQL_ROUTER_API_VERSION
- MYSQLSH_PATH
- MYSQLSH_TIMEOUT
- MYSQLSH_WORK_DIR
Security Notes
1. Arbitrary Code Execution (CRITICAL): The `mysqlsh_run_script` tool allows direct execution of user-provided JavaScript, Python, or SQL code via the `mysqlsh` subprocess. This is a severe vulnerability, enabling any client (AI or malicious actor if unauthenticated/unauthorized) to execute arbitrary commands on the host system. 2. Insecure TLS Connection Option: MySQL Router tools (`mysql_router_status` etc.) support `MYSQL_ROUTER_INSECURE=true`, disabling TLS certificate verification. This creates a significant risk for Man-in-the-Middle attacks if used in production, despite documentation for development purposes. 3. Hardcoded Default Credentials: ProxySQL tools use hardcoded default credentials ('admin', 'admin') if environment variables (`PROXYSQL_USER`, `PROXYSQL_PASSWORD`) are not explicitly set, posing a common misconfiguration risk. 4. `local_infile` Vulnerability: `mysqlsh_import_table` and `mysqlsh_load_dump` tools can set `SET GLOBAL local_infile = ON`. While requiring high privileges, this command could be exploited for data exfiltration or arbitrary file reads if a malicious file path is provided and the MySQL server is compromised. 5. SQL Injection Protection: The project generally uses good practices like parameterized queries and includes `validateQuery` for detecting dangerous SQL patterns and enforcing read-only modes. Identifier escaping is also implemented. However, direct `rawQuery` calls for `SHOW` commands, while validated, present a slightly higher attack surface.
Similar Servers
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 Model Context Protocol (MCP) interface to a MySQL database, enabling AI models to execute SQL queries and retrieve database schema information.
db-mcp
An enterprise-grade Model Context Protocol (MCP) server providing advanced database operations, AI-native functionalities like vector search, and OAuth 2.1 authentication for SQLite databases.