MCP MySQL Server
Provides comprehensive database management capabilities including query execution, schema inspection, index management, and database connection handling for MySQL databases and cloud instances like AWS RDS and Google Cloud SQL.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP MySQL Server show me all tables in the database"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP MySQL Server
A Model Context Protocol (MCP) server for MySQL databases, including support for AWS RDS and other cloud MySQL instances. This server provides comprehensive database management capabilities through a standardized MCP interface.
📋 Quick Start for VS Code Users: See VSCODE_SETUP.md for step-by-step VS Code and GitHub Copilot integration instructions.
Features
✅ Database Connection Management: Connect to local MySQL or cloud instances (AWS RDS, Google Cloud SQL, etc.)
✅ Query Execution: Execute SQL queries with prepared statement support
✅ Schema Inspection: List databases, tables, and describe table structures
✅ Index Management: View table indexes and statistics
✅ Security: Secure connection handling with SSL support
✅ Error Handling: Comprehensive error reporting and connection management
Related MCP server: MySQL MCP Server
Installation
From NPM (Recommended)
npm install -g @sajithrw/mcp-mysql@1.0.0Or run ad‑hoc without global install using npx (shown later in config).
From Source
git clone https://github.com/sajithrw/mcp-mysql.git
cd mcp-mysql
npm install
npm run buildConfiguration
VS Code (mcp.json) Setup (Recommended)
Create (or update) .vscode/mcp.json in your project or in your global VS Code user settings folder. Use the published package via npx so you always invoke the correct version.
{
"servers": {
"mcp-mysql": {
"type": "stdio",
"command": "npx",
"args": [
"@sajithrw/mcp-mysql@1.0.0"
],
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "your_username",
"MYSQL_PASSWORD": "your_password",
"MYSQL_DATABASE": "your_database"
}
}
}
}Then:
Reload VS Code window (Command Palette: "Developer: Reload Window").
Open Command Palette and run: "MCP: Start Server" (pick
mcp-mysql).Use Copilot / MCP clients to call tools (e.g., ask to list tables).
Previous
settings.jsonbasedgithub.copilot.advanced.mcpconfiguration is deprecated in favor ofmcp.jsondiscovery.
Alternative: Local Build Path
If working from a local clone/build instead of the published package:
{
"servers": {
"mcp-mysql": {
"type": "stdio",
"command": "node",
"args": ["/absolute/path/to/mcp-mysql/build/index.js"],
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_USER": "your_username",
"MYSQL_PASSWORD": "your_password"
}
}
}
}Using with Claude Desktop
Add the server to your Claude Desktop configuration:
{
"mcpServers": {
"mysql": {
"command": "npx",
"args": ["@sajithrw/mcp-mysql@1.0.0"],
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_USER": "your_username",
"MYSQL_PASSWORD": "your_password"
}
}
}
}Using with MCP Inspector
For testing and development:
npx @modelcontextprotocol/inspector npx @sajithrw/mcp-mysql@1.0.0Using with VS Code and GitHub Copilot
Once configured, you can use the MySQL MCP server with GitHub Copilot in VS Code to interact with your databases using natural language.
Example Interactions
Database Exploration:
"Show me all tables in the database"
"Describe the structure of the users table"
"What indexes are on the products table?"
Data Analysis:
"Show me the top 10 customers by order count"
"Find all users created in the last 30 days"
"Get statistics about the orders table"
Schema Management:
"List all databases on this server"
"Show me table sizes and row counts"
"Find tables with specific column names"
Step-by-Step (Recap)
Create
.vscode/mcp.jsonwith config above.Reload VS Code window.
Run "MCP: Start Server".
Use Copilot Chat / MCP-aware client to issue requests.
Troubleshooting Quick Tips
Ensure the package version (
1.0.0) matches what you intend to use.If the server won't start, run it manually:
npx @sajithrw/mcp-mysql@1.0.0to see logs.Verify environment variables are present (you can also place them in a
.envif your shell loads them before launching VS Code).
Available Tools
1. mysql_connect
Connect to a MySQL database.
Parameters:
host(required): MySQL server hostname or IP addressport(optional): MySQL server port (default: 3306)user(required): Database usernamepassword(required): Database passworddatabase(optional): Database name to connect tossl(optional): Use SSL connection (default: false)
Example:
{
"host": "localhost",
"port": 3306,
"user": "myuser",
"password": "mypassword",
"database": "mydb",
"ssl": false
}2. mysql_query
Execute a SQL query on the connected database.
Parameters:
query(required): SQL query to executeparameters(optional): Array of parameters for prepared statements
Examples:
Simple query:
{
"query": "SELECT * FROM users LIMIT 10"
}Prepared statement:
{
"query": "SELECT * FROM users WHERE age > ? AND city = ?",
"parameters": ["25", "New York"]
}3. mysql_list_databases
List all databases on the MySQL server.
Parameters: None
4. mysql_list_tables
List all tables in the current or specified database.
Parameters:
database(optional): Database name (uses current database if not specified)
5. mysql_describe_table
Get the structure/schema of a specific table.
Parameters:
table(required): Table name to describedatabase(optional): Database name (uses current database if not specified)
6. mysql_show_indexes
Show indexes for a specific table.
Parameters:
table(required): Table name to show indexes fordatabase(optional): Database name (uses current database if not specified)
7. mysql_get_table_stats
Get statistics about a table (row count, size, etc.).
Parameters:
table(required): Table name to get statistics fordatabase(optional): Database name (uses current database if not specified)
8. mysql_disconnect
Disconnect from the MySQL database.
Parameters: None
Common Use Cases
1. Connecting to AWS RDS
{
"host": "mydb.abc123.us-west-2.rds.amazonaws.com",
"port": 3306,
"user": "admin",
"password": "mypassword",
"database": "production",
"ssl": true
}2. Exploring Database Schema
Connect to database using
mysql_connectList all databases with
mysql_list_databasesList tables with
mysql_list_tablesDescribe specific tables with
mysql_describe_tableCheck indexes with
mysql_show_indexes
3. Data Analysis
Connect to database
Execute analytical queries with
mysql_queryGet table statistics with
mysql_get_table_stats
Security Considerations
Credentials: Never hardcode database credentials. Use environment variables or secure configuration management.
SSL/TLS: Always use SSL when connecting to production databases or cloud instances.
Permissions: Use database users with minimal required permissions.
Query Validation: The server uses prepared statements to prevent SQL injection.
Environment Variables
You can set default connection parameters using environment variables:
export MYSQL_HOST=localhost
export MYSQL_PORT=3306
export MYSQL_USER=myuser
export MYSQL_PASSWORD=mypassword
export MYSQL_DATABASE=mydb
export MYSQL_SSL=trueDevelopment
Building
npm run buildTesting
npm run testDevelopment Mode
npm run devTroubleshooting
Connection Issues
Connection Refused: Check that MySQL server is running and accessible
Authentication Failed: Verify username and password
SSL Errors: Ensure SSL is properly configured on both client and server
Timeout: Check network connectivity and firewall settings
Common Error Messages
"Not connected to MySQL": Usemysql_connectbefore executing other commands"Query execution failed": Check SQL syntax and table/column names"Connection failed": Verify connection parameters and network connectivity
Contributing
Fork the repository
Create a feature branch
Make your changes
Add tests
Submit a pull request
License
MIT License - see LICENSE file for details.
Support
Related Projects
Available Tools
8 toolsmysql_connectC
Connect to a MySQL database with provided connection parameters
Inputs: host (required), user (required), password (required), port, +2 more.
mysql_describe_tableB
Get the structure/schema of a specific table
Inputs: table (required), database.
mysql_disconnectB
Disconnect from the MySQL database
Inputs: no named parameters.
mysql_get_table_statsC
Get statistics about a table (row count, size, etc.)
Inputs: table (required), database.
mysql_list_databasesB
List all databases on the MySQL server
Inputs: no named parameters.
mysql_list_tablesB
List all tables in the current or specified database
Inputs: database.
mysql_queryC
Execute a SQL query on the connected MySQL database
Inputs: query (required), parameters.
mysql_show_indexesC
Show indexes for a specific table
Inputs: table (required), database.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Each tool has a clearly distinct purpose with no ambiguity. Tools like mysql_describe_table, mysql_get_table_stats, and mysql_show_indexes all target different aspects of table metadata without overlap, while mysql_query handles general SQL execution separately from specific operations.
All tools follow a perfect mysql_verb_noun pattern with consistent snake_case throughout. The naming is highly predictable, making it easy for agents to understand and locate tools (e.g., mysql_list_databases, mysql_list_tables, mysql_describe_table).
With 8 tools, this server is well-scoped for MySQL database operations. Each tool earns its place by covering essential functions like connection management, metadata inspection, and query execution without being overly sparse or bloated.
The toolset provides strong coverage for core MySQL operations, including connection lifecycle, database/table listing, schema inspection, and query execution. A minor gap exists in lacking explicit CRUD operations (e.g., insert, update, delete), but agents can work around this using mysql_query for such tasks.
Maintenance
Related MCP Connectors
Query, explore, and manage your databases through natural conversation.
Work with your database from AI tools: ask, export, approved changes, and scheduled jobs.
Hosted MySQL MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Query Postgres, MySQL, SQL Server, Oracle, BigQuery, ClickHouse and Redshift from your AI client.
Related MCP Servers
- AlicenseBqualityDmaintenanceEnables AI assistants to manage MySQL databases through natural language commands. Supports database operations, table management, data queries, and import/export functionality with built-in security features.1517 npm1MIT
- AlicenseNot gradedqualityDmaintenanceEnables comprehensive MySQL database management including CRUD operations, schema queries, and natural language to SQL conversion support through complete database structure analysis.716 npm2MIT
- FlicenseNot gradedqualityDmaintenanceEnables management and querying of multiple MySQL databases through natural language, allowing AI assistants to list databases, execute SQL queries, and explore database schemas.1-
- FlicenseNot gradedqualityNot gradedmaintenanceEnables direct interaction with MySQL databases through SQL queries, table exploration, and schema inspection with support for prepared statements and connection pooling.-