myheisenberg/mysql-mcp-server
If you are the rightful owner of mysql-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
A Model Context Protocol (MCP) server for MySQL database operations, enabling seamless interaction with MySQL databases through any MCP-compatible client.
š§ MySQL MCP Server
A Model Context Protocol (MCP) server for MySQL database operations. Provides 4 powerful tools for database interaction through any MCP-compatible client.
⨠Features
- š Execute SQL Queries - Run any SELECT, INSERT, UPDATE, DELETE commands
- š List Databases - View all available databases
- š List Tables - Show tables in any database
- šļø Describe Tables - Get detailed table structure information
- š Secure - Environment-based configuration, no hardcoded credentials
- ā” Fast - Built with TypeScript and connection pooling
š Quick Start
Installation
# Clone the repository
git clone https://github.com/myheisenberg/mysql-mcp-server.git
cd mysql-mcp-server
# Install dependencies
npm install
# Build the project
npm run build
Configuration
The server uses environment variables for database configuration:
DB_HOST=localhost # MySQL host (default: localhost)
DB_USER=root # MySQL username (default: root)
DB_PASSWORD= # MySQL password (default: empty)
DB_PORT=3306 # MySQL port (default: 3306)
š Usage
With Claude Desktop
Add to your claude_desktop_config.json
:
{
"mcpServers": {
"mysql": {
"command": "node",
"args": ["path/to/mysql-mcp-server/dist/index.js"],
"env": {
"DB_HOST": "localhost",
"DB_USER": "your_username",
"DB_PASSWORD": "your_password",
"DB_PORT": "3306"
}
}
}
}
With Cursor IDE
Add to your MCP configuration:
{
"mcpServers": {
"mysql": {
"command": "node",
"args": ["path/to/mysql-mcp-server/dist/index.js"],
"env": {
"DB_HOST": "localhost",
"DB_USER": "your_username",
"DB_PASSWORD": "your_password",
"DB_PORT": "3306"
}
}
}
}
š ļø Available Tools
1. mysql_query
Execute any MySQL query and get formatted results.
Example: "Run a SELECT query on the users table"
2. mysql_databases
List all available databases on the MySQL server.
Example: "Show me all databases"
3. mysql_tables
List all tables in a specific database.
Example: "What tables are in the blog database?"
4. mysql_describe
Get detailed information about a table's structure.
Example: "Describe the structure of the users table"
š§ Development
# Install dependencies
npm install
# Development mode (watch for changes)
npm run dev
# Build for production
npm run build
# Start the server
npm start
š¦ Project Structure
mysql-mcp-server/
āāā src/
ā āāā index.ts # Main MCP server implementation
āāā dist/ # Compiled JavaScript (auto-generated)
āāā package.json # Project dependencies and scripts
āāā tsconfig.json # TypeScript configuration
āāā .gitignore # Git ignore rules
āāā README.md # This file
š Security
- No hardcoded credentials - All database connection details come from environment variables
- Connection pooling - Efficient and secure database connections
- Error handling - Proper error messages without exposing sensitive information
š¤ Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
š License
This project is licensed under the MIT License - see the file for details.
š Acknowledgments
- Built with the Model Context Protocol SDK
- Uses mysql2 for MySQL connectivity
- Inspired by the MCP community
š Support
If you encounter any issues or have questions:
- Check the Issues page
- Create a new issue if your problem isn't already reported
- Provide as much detail as possible including error messages and configuration
Made with ā¤ļø for the MCP community