Back to Home
wenjiachengy icon

mysql_mcp_server

by wenjiachengy

Overview

A Model Context Protocol (MCP) server that enables AI assistants to securely interact with MySQL databases for listing tables, reading data, and executing SQL queries.

Installation

Run Command
python -m mysql_mcp_server

Environment Variables

  • MYSQL_HOST
  • MYSQL_PORT
  • MYSQL_USER
  • MYSQL_PASSWORD
  • MYSQL_DATABASE

Security Notes

The `call_tool` function directly executes arbitrary SQL queries provided by the AI assistant (`cursor.execute(query)`). This is a critical SQL injection vulnerability if the AI's output is not strictly controlled or whitelisted. While the documentation explicitly warns about this and recommends 'query whitelisting for production use' and using a 'database user with minimal required permissions', the server itself exposes this high-risk functionality. The `read_resource` function dynamically constructs table names from the URI (`f"SELECT * FROM {table} LIMIT 100"`), which is also a potential, albeit lower, SQL injection risk if URI parsing is insufficient or an attacker can craft malicious URIs. No hardcoded secrets were found, and configuration uses environment variables, which is a good practice.

Similar Servers

Stats

Interest Score0
Security Score4
Cost ClassLow
Avg Tokens2000
Stars0
Forks0
Last Update2025-12-02

Tags

MySQLMCPAI assistantDatabaseSQL