Establish connection to MySQL database using provided credentials.
Execute SELECT queries with optional prepared statement parameters.
Execute INSERT, UPDATE, or DELETE queries with optional prepared statement parameters.
List all tables in the connected database.
Get the structure of a specific table.
A Model Context Protocol server that provides MySQL database operations. This server enables AI models to interact with MySQL databases through a standardized interface, allowing for secure connections, prepared statements, and comprehensive error handling. With this MCP, AI assistants can perform database queries, execute commands, and explore database structure without direct database access.
The MySQL Database Operations MCP provides a secure and standardized way for AI models to interact with MySQL databases. It handles connection management, query execution, and database structure exploration while maintaining security through prepared statements and proper validation.
To install the MySQL Database Operations MCP automatically via Smithery:
npx -y @smithery/cli install @f4ww4z/mcp-mysql-server --client claude
You can also install and run the MCP manually:
npx @f4ww4z/mcp-mysql-server
The server requires database connection information to be provided. You can configure it in two ways:
{
"mcpServers": {
"mysql": {
"command": "npx",
"args": ["-y", "@f4ww4z/mcp-mysql-server", "mysql://user:password@localhost:port/database"]
}
}
}
{
"mcpServers": {
"mysql": {
"command": "npx",
"args": ["-y", "@f4ww4z/mcp-mysql-server"],
"env": {
"MYSQL_HOST": "your_host",
"MYSQL_USER": "your_user",
"MYSQL_PASSWORD": "your_password",
"MYSQL_DATABASE": "your_database"
}
}
}
}
The server provides detailed error messages for common issues:
After configuring the MCP, you can use it to interact with your MySQL database. Here are some examples:
use_mcp_tool({
server_name: "mysql",
tool_name: "list_tables",
arguments: {}
});
use_mcp_tool({
server_name: "mysql",
tool_name: "query",
arguments: {
sql: "SELECT * FROM users WHERE id = ?",
params: [1]
}
});
use_mcp_tool({
server_name: "mysql",
tool_name: "execute",
arguments: {
sql: "INSERT INTO users (name, email) VALUES (?, ?)",
params: ["John Doe", "john@example.com"]
}
});