mcp-mysql
A Model Context Protocol server for MySQL database operations
claude mcp add --transport stdio f4ww4z-mcp-mysql-server npx -y @f4ww4z/mcp-mysql-server mysql://user:password@localhost:port/database \ --env MYSQL_HOST="your_host" \ --env MYSQL_USER="your_user" \ --env MYSQL_DATABASE="your_database" \ --env MYSQL_PASSWORD="your_password"
How to use
This MCP server exposes a MySQL-focused interface that lets AI models interact with a MySQL database through a standardized set of tools. The available tools include: connect_db to establish a database connection using credentials, query to run SELECT statements with optional prepared parameters, execute to run INSERT/UPDATE/DELETE operations with optional prepared parameters, list_tables to enumerate tables in the connected database, and describe_table to fetch a table’s schema. To use these tools, you first ensure the server is running with the proper environment variables (host, user, password, and database) and then invoke the tool functions with the appropriate arguments. When using the provided code examples, you supply the server name (mysql) and the tool name (e.g., query) along with the required arguments, such as SQL statements and parameters. This setup supports secure parameterized queries via prepared statements and handles connection management automatically. You can run eval tests against this server using the mcp-eval workflow, which loads a client and executes the index.ts through the eval runner.
How to install
Prerequisites:
- Node.js and npm (or npx) installed on your system.
- Access to the internet to fetch the MCP server package.
Installation steps (via Smithery):
- Install the MCP server automatically for a client (e.g., Claude) using Smithery: npx -y @smithery/cli install @f4ww4z/mcp-mysql-server --client claude
Manual installation (no Smithery):
- Run the MCP server directly with npx: npx @f4ww4z/mcp-mysql-server
Configuration (example):
- Create or edit your MCP settings with the following mcpServers entry, replacing credentials as needed:
{
"mcpServers": {
"mysql": {
"command": "npx",
"args": ["-y", "@f4ww4z/mcp-mysql-server", "mysql://user:password@localhost:port/database"],
"env": {
"MYSQL_HOST": "your_host",
"MYSQL_USER": "your_user",
"MYSQL_PASSWORD": "your_password",
"MYSQL_DATABASE": "your_database"
}
}
}
}
Tip: You can also configure the server in platform-specific config files (Codex, etc.) as shown in the README, using identical command and args values.
Additional notes
Tips and notes:
- Use prepared statements to guard against SQL injection (supported by the server).
- Environment variables for MySQL credentials can be supplied via the env block in your MCP configuration or prefixed to the npx command when running evals.
- The server handles automatic connection cleanup, but ensure network access to your MySQL instance.
- If you encounter authentication or network errors, double-check host, port, user, and password values, and ensure MySQL permits connections from your environment.
- When testing, you can leverage the mcp-evals tooling to run a client against the index.ts entry point without rebuilding between tests.
Related MCP Servers
zen
Selfhosted notes app. Single golang binary, notes stored as markdown within SQLite, full-text search, very low resource usage
MCP -Deepseek_R1
A Model Context Protocol (MCP) server implementation connecting Claude Desktop with DeepSeek's language models (R1/V3)
mcp-fhir
A Model Context Protocol implementation for FHIR
mcp
Inkdrop Model Context Protocol Server
mcp-appium-gestures
This is a Model Context Protocol (MCP) server providing resources and tools for Appium mobile gestures using Actions API..
dubco -npm
The (Unofficial) dubco-mcp-server enables AI assistants to manage Dub.co short links via the Model Context Protocol. It provides three MCP tools: create_link for generating new short URLs, update_link for modifying existing links, and delete_link for removing short links.