A VS Code extension that enables AI agents to interact with MySQL databases through the Model Context Protocol (MCP). This extension installs and manages the mcp-mysql-tool
server, providing comprehensive MySQL database operations for AI assistants like Claude.
🚀 Features
Core Database Operations
- mysql_query - Execute any SQL query with parameters
- mysql_select - Smart SELECT with WHERE, LIMIT, ORDER BY, and database support
- mysql_insert - Insert data with key-value pairs across databases
- mysql_update - Update with required WHERE clause (safety) across databases
- mysql_delete - Delete with required WHERE clause (safety) across databases
Database Discovery
- mysql_show_databases - List all available databases
- mysql_show_tables - List all tables in specified or current database
- mysql_describe_table - Show table structure and columns from any database
- mysql_table_info - Comprehensive table analysis (structure, indexes, constraints) from any database
- mysql_count_rows - Count rows with optional WHERE conditions from any database
Advanced Features
- mysql_custom_connection - Execute queries with custom host/user/password (password optional)
- mysql_test_connection - Test connection with environment or custom parameters
- Cross-database operations - All tools support database parameter for multi-database workflows
- Safe parameterized queries to prevent SQL injection
- Environment-based configuration
- Comprehensive error handling
- JSON responses optimized for AI parsing
📦 Quick Start
- Install the extension from the VS Code marketplace
- Run the setup command - Press
Ctrl+Shift+P
and type "mcp-mysql: Install & Configure Server"
- Configure database connection - Set environment variables or use custom connection tools
- Choose configuration scope - Global (for all projects) or Workspace (current project only)
- Start the server - The extension will prompt you to start the server automatically
🛠️ Available Commands
Press Ctrl+Shift+P
and type "mcp-mysql:" to see all available commands:
- mcp-mysql: Install & Configure Server - Install the Python package and add server to MCP configuration
- mcp-mysql: Start Server - Start the MCP MySQL server
- mcp-mysql: Stop Server - Stop the running server
- mcp-mysql: Restart Server - Restart the server
- mcp-mysql: Check Server Status - View current server status
- mcp-mysql: Edit Configuration - Open mcp.json file to edit MCP server configuration
⚙️ Requirements
- Python 3.7+ with pip installed
- MySQL Server running and accessible
- VS Code 1.102.0 or newer
- AI assistant that supports MCP (like Claude Desktop)
🔧 Configuration
Environment Variables
Set these environment variables for default connection:
MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_USER=your_username
MYSQL_PASSWORD=your_password
MYSQL_DATABASE=your_database # Optional
MCP Configuration
The server is added to your MCP configuration under the servers
section in either:
- Global:
%USERPROFILE%\AppData\Roaming\Code\User\mcp.json
(Windows)
- Workspace:
.vscode/mcp.json
in your current workspace
You can choose to install it globally (all workspaces) or locally (current workspace only).
The extension adds this configuration to your mcp.json file:
{
"servers": {
"mysql": {
"command": "mcp-mysql-tool",
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_USER": "root",
"MYSQL_PASSWORD": "password",
"MYSQL_DATABASE": "mydb"
},
"type": "stdio"
}
}
}
💡 Usage Examples
Basic Operations
# List all databases
mysql_show_databases()
# Smart SELECT with conditions
mysql_select({
"table": "users",
"columns": ["id", "name", "email"],
"where": "active = 1",
"limit": 10,
"order_by": "created_at DESC"
})
# SELECT from specific database
mysql_select({
"table": "posts",
"database": "wordpress",
"where": "post_status = 'publish'",
"limit": 5
})
# Safe INSERT
mysql_insert({
"table": "users",
"data": {
"name": "John Doe",
"email": "john@example.com",
"active": 1
}
})
# INSERT into specific database
mysql_insert({
"table": "products",
"database": "ecommerce",
"data": {
"name": "Widget",
"price": 29.99,
"category": "tools"
}
})
# Safe UPDATE (WHERE required)
mysql_update({
"table": "users",
"data": {"last_login": "2024-01-01"},
"where": "id = 123"
})
# UPDATE across databases
mysql_update({
"table": "orders",
"database": "shop",
"data": {"status": "shipped"},
"where": "order_id = 456"
})
Database Exploration Examples
# List tables in current database
mysql_show_tables()
# List tables in specific database
mysql_show_tables({"database": "wordpress"})
# Describe table structure
mysql_describe_table({"table_name": "users"})
# Describe table from specific database
mysql_describe_table({
"table_name": "wp_posts",
"database": "wordpress"
})
# Get comprehensive table info
mysql_table_info({"table_name": "users"})
# Get table info from specific database
mysql_table_info({
"table_name": "wp_users",
"database": "wordpress"
})
Custom Connection
# Connect to different server (password now optional)
mysql_custom_connection({
"host": "remote-server.com",
"user": "remote_user",
"query": "SELECT COUNT(*) FROM products"
})
Row Counting
# Count rows with conditions
mysql_count_rows({
"table": "orders",
"where": "status = 'completed' AND created_at > '2024-01-01'"
})
# Count from specific database
mysql_count_rows({
"table": "posts",
"database": "blog",
"where": "published = 1"
})
🔒 Safety Features
- Required WHERE clauses for UPDATE and DELETE operations
- Parameterized queries to prevent SQL injection
- Connection isolation for custom connections
- Comprehensive error handling with detailed error codes
- Input validation for all parameters
Tool |
Description |
Database Support |
Safety |
mysql_query |
Execute any SQL query |
✅ Full |
⚠️ Raw SQL |
mysql_select |
Smart SELECT builder with WHERE/LIMIT/ORDER BY |
✅ Parameter |
✅ Safe |
mysql_insert |
Insert with key-value pairs |
✅ Parameter |
✅ Safe |
mysql_update |
Update with required WHERE |
✅ Parameter |
🔒 WHERE required |
mysql_delete |
Delete with required WHERE |
✅ Parameter |
🔒 WHERE required |
mysql_custom_connection |
Custom host/user/password (password optional) |
✅ Full |
⚠️ Raw SQL |
mysql_show_databases |
List databases |
✅ N/A |
✅ Safe |
mysql_show_tables |
List tables in database |
✅ Parameter |
✅ Safe |
mysql_describe_table |
Table structure and columns |
✅ Parameter |
✅ Safe |
mysql_table_info |
Comprehensive table analysis |
✅ Parameter |
✅ Safe |
mysql_count_rows |
Count with optional WHERE |
✅ Parameter |
✅ Safe |
mysql_test_connection |
Test connection (env/custom) |
✅ Full |
✅ Safe |
🎯 Perfect for AI
This MCP server is specifically designed to be AI-friendly:
- Structured responses in JSON format
- Clear error messages with error codes
- Flexible parameters for different use cases
- Cross-database operations with database parameter
- Safety guardrails to prevent dangerous operations
- Comprehensive toolset for all database needs
🏗️ How it works
- The extension installs the
mcp-mysql-tool
Python package via pip
- Adds the server configuration to your MCP configuration file (mcp.json)
- Your AI assistant can then connect to the server to interact with MySQL databases
- AI can explore schemas, execute queries, and manage data across multiple databases
🔗 Other MCP Extensions by Mrbeandev
Marketplace Link
A VS Code extension that enables AI agents to perform HTTP requests through the Model Context Protocol (MCP). This extension allows AI assistants like Claude to make HTTP requests, interact with REST APIs, upload files, and perform web operations directly from your VS Code workspace.
Features:
- HTTP GET/POST requests
- File upload with multipart/form-data
- AI-driven request selection
- Authentication support
- Flexible data handling (JSON, form data, files)
Marketplace Link
A VS Code extension that enables AI agents to interact with SQLite databases through the Model Context Protocol (MCP). This extension allows AI assistants like Claude to read, query, and manipulate SQLite database files directly from your VS Code workspace.
Features:
- Execute SQL queries on SQLite files
- Read database schemas
- Query and manipulate data
- Manage SQLite database files in your workspace
🆘 Support
For issues or questions, please visit our mrbean.dev.