Enables AI models to interact with MySQL databases via Model Context Protocol, offering secure connection handling, prepared statement support, schema management, and comprehensive database operations including querying, executing, and table management.
Unlock the full potential of MCP MySQL Server through LangDB's AI Gateway. Get enterprise-grade security, analytics, and seamless integration with zero configuration.
Free tier available • No credit card required
A Model Context Protocol server that provides MySQL database operations. This server enables AI models to interact with MySQL databases through a standardized interface.
To install MySQL Database Server for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @enemyrr/mcp-mysql-server --client claude
git clone https://github.com/enemyrr/mcp-mysql-server.git cd mcp-mysql-server npm install npm run build
mysql
command
node /absolute/path/to/mcp-mysql-server/build/index.js
Note: Replace
/absolute/path/to/
with the actual path where you cloned and built the project.
You can configure the database connection in three ways:
DATABASE_URL=mysql://user:password@host:3306/database
DB_HOST=localhost DB_USER=your_user DB_PASSWORD=your_password DB_DATABASE=your_database
use_mcp_tool({ server_name: "mysql", tool_name: "connect_db", arguments: { url: "mysql://user:password@host:3306/database" // OR workspace: "/path/to/your/project" // Will use project's .env // OR host: "localhost", user: "your_user", password: "your_password", database: "your_database" } });
Connect to MySQL database using URL, workspace path, or direct credentials.
Execute SELECT queries with optional prepared statement parameters.
use_mcp_tool({ server_name: "mysql", tool_name: "query", arguments: { sql: "SELECT * FROM users WHERE id = ?", params: [1] } });
Execute INSERT, UPDATE, or DELETE queries with optional prepared statement parameters.
use_mcp_tool({ server_name: "mysql", tool_name: "execute", arguments: { sql: "INSERT INTO users (name, email) VALUES (?, ?)", params: ["John Doe", "john@example.com"] } });
List all tables in the connected database.
use_mcp_tool({ server_name: "mysql", tool_name: "list_tables" });
Get the structure of a specific table.
use_mcp_tool({ server_name: "mysql", tool_name: "describe_table", arguments: { table: "users" } });
Create a new table with specified fields and indexes.
use_mcp_tool({ server_name: "mysql", tool_name: "create_table", arguments: { table: "users", fields: [ { name: "id", type: "int", autoIncrement: true, primary: true }, { name: "email", type: "varchar", length: 255, nullable: false } ], indexes: [ { name: "email_idx", columns: ["email"], unique: true } ] } });
Add a new column to an existing table.
use_mcp_tool({ server_name: "mysql", tool_name: "add_column", arguments: { table: "users", field: { name: "phone", type: "varchar", length: 20, nullable: true } } });
The server provides detailed error messages for:
Contributions are welcome! Please feel free to submit a Pull Request to https://github.com/enemyrr/mcp-mysql-server
MIT
Discover shared experiences
Shared threads will appear here, showcasing real-world applications and insights from the community. Check back soon for updates!