This repository provides a Model Context Protocol (MCP) server enabling AI models to interact with MySQL databases through a standardized interface for executing queries and managing data. This repository provides
A Model Context Protocol (MCP) server that allows AI models to interact with MySQL databases through a standardized interface. It facilitates database operations by providing a set of tools accessible via the MCP.
Install via Smithery using the command: npx -y @smithery/cli install @f4ww4z/mcp-mysql-server --client claude
. Alternatively, install manually using npx @f4ww4z/mcp-mysql-server
.
Configure the server by setting environment variables in your MCP settings file, including MYSQL_HOST
, MYSQL_USER
, MYSQL_PASSWORD
, and MYSQL_DATABASE
.
Key features include secure connection handling, prepared statement support, comprehensive error handling, TypeScript support, and automatic connection management.
The server uses prepared statements to prevent SQL injection, supports secure password handling via environment variables, validates queries, and automatically closes connections.
Detailed error messages are provided for connection failures, invalid queries, missing parameters, and database errors.
Contributions are welcome via Pull Requests to the GitHub repository.
MIT
f4ww4z/mcp-mysql-server
December 13, 2024
March 28, 2025
JavaScript