MCP server for MySQL database access
## MySQL MCP Server: Popular Relational Database The **MySQL MCP Server** integrates MySQL into Google Antigravity, enabling relational database operations with SQL queries, stored procedures, and replication management directly from your development environment. ### Why MySQL MCP? - **Industry Standard**: Most popular open-source database - **Proven Reliability**: Powers millions of applications - **Full SQL**: Complete SQL implementation - **Replication**: Master-slave and group replication - **Ecosystem**: Extensive tooling and documentation ### Key Features #### 1. SQL Queries ```python # Execute query result = await mcp.query(""" SELECT p.id, p.name, c.name as category, COUNT(o.id) as order_count FROM products p JOIN categories c ON p.category_id = c.id LEFT JOIN order_items o ON p.id = o.product_id WHERE p.status = ? GROUP BY p.id ORDER BY order_count DESC LIMIT 20 """, params=["active"]) for row in result: print(f"Product: {row['name']} - Orders: {row['order_count']}") ``` #### 2. Data Operations ```python # Insert with auto-increment result = await mcp.execute( "INSERT INTO users (name, email) VALUES (?, ?)", params=["John Doe", "john@example.com"] ) print(f"New user ID: {result['insertId']}") # Bulk insert await mcp.execute_many( "INSERT INTO logs (level, message, created_at) VALUES (?, ?, NOW())", params_list=[ ["INFO", "User logged in"], ["WARN", "Rate limit approaching"], ["ERROR", "Connection failed"] ] ) ``` #### 3. Transaction Management ```python # Execute transaction async with mcp.transaction() as tx: await tx.execute( "UPDATE inventory SET quantity = quantity - ? WHERE product_id = ?", params=[1, 123] ) await tx.execute( "INSERT INTO orders (user_id, product_id) VALUES (?, ?)", params=[456, 123] ) # Commits automatically, rolls back on exception ``` #### 4. Schema Operations ```python # Show tables tables = await mcp.query("SHOW TABLES") # Describe table schema = await mcp.query("DESCRIBE users") for column in schema: print(f"{column['Field']}: {column['Type']} ({column['Null']})") # Show create table create_stmt = await mcp.query("SHOW CREATE TABLE users") ``` ### Configuration ```json { "mcpServers": { "mysql": { "command": "npx", "args": ["-y", "@anthropic/mcp-mysql"], "env": { "MYSQL_HOST": "localhost", "MYSQL_PORT": "3306", "MYSQL_USER": "root", "MYSQL_PASSWORD": "your-password", "MYSQL_DATABASE": "myapp" } } } } ``` ### Use Cases **Web Applications**: Backend for PHP, Python, Node.js apps. **E-commerce**: Product and order management. **Content Management**: WordPress, Drupal, Joomla backends. **Enterprise Apps**: Business application databases. The MySQL MCP enables relational database operations within your development environment.
{
"mcpServers": {
"mysql": {
"mcpServers": {
"mysql": {
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root",
"MYSQL_DATABASE": "your_database",
"MYSQL_PASSWORD": "YOUR_PASSWORD"
},
"args": [
"-y",
"@benborla29/mcp-server-mysql"
],
"command": "npx"
}
}
}
}
}