Back to Home
neverinfamous icon

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

Run Command
npx @neverinfamous/mysql-mcp --transport stdio --mysql mysql://user:password@localhost:3306/database

Environment 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

Stats

Interest Score35
Security Score2
Cost ClassMedium
Avg Tokens10000
Stars3
Forks1
Last Update2026-01-19

Tags

MCP ServerMySQLAIDatabase ManagementDeveloper Tool