https://github.com/teamsrunner/mysql-mcp/blob/main/README.md
1.2K
A secure and efficient Model Context Protocol (MCP) Server for MySQL database operations. This Docker image provides a standardized interface for database interactions using the MCP protocol, enabling seamless integration with AI assistants and automation tools.
curl -O https://raw.githubusercontent.com/teamsrunner/mysql-mcp-server/main/examples/docker-compose.standalone.yml
docker-compose -f docker-compose.standalone.yml up -d
docker exec mysql-mcp-server node -e "console.log('MCP Server is running!')"
# Start with existing MySQL
docker run -d \
--name mysql-mcp-server \
-e MYSQL_HOST=your-mysql-host \
-e MYSQL_USER=your-username \
-e MYSQL_PASSWORD=your-password \
-e MYSQL_DATABASE=your-database \
teamsrunner/mysql-mcp-server:latest
The MCP server provides these database operation tools:
| Tool | Description | Security Level |
|---|---|---|
query | Execute SELECT queries | โ Read-only |
execute | Execute INSERT/UPDATE/DELETE/DDL | โ ๏ธ Write access |
describe_table | Get table structure | โ Read-only |
list_tables | List all tables | โ Read-only |
list_databases | List all databases | โ Read-only |
create_database | Create new database | โ ๏ธ Admin access |
drop_database | Drop database | โ ๏ธ Admin access |
| Variable | Description | Default | Required |
|---|---|---|---|
MYSQL_HOST | MySQL server hostname | mysql | โ |
MYSQL_PORT | MySQL server port | 3306 | No |
MYSQL_USER | MySQL username | root | โ |
MYSQL_PASSWORD | MySQL password | (empty) | โ |
MYSQL_DATABASE | Default database | (none) | No |
NODE_ENV | Node.js environment | production | No |
MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_USER=myuser
MYSQL_PASSWORD=mypassword
MYSQL_DATABASE=mydatabase
This repository includes several Docker Compose examples for different use cases:
Complete setup with MySQL database included. Perfect for development and testing.
services:
mysql:
image: mysql:8.0
environment:
MYSQL_ROOT_PASSWORD: change_this_password
MYSQL_DATABASE: example_db
mcp-server:
image: teamsrunner/mysql-mcp-server:latest
environment:
MYSQL_HOST: mysql
MYSQL_PASSWORD: change_this_password
MYSQL_DATABASE: example_db
Connect to existing MySQL database server.
Integration with existing application infrastructure.
Production-ready configuration with secrets and monitoring.
query tool# Test MCP protocol communication
docker exec -i mysql-mcp-server node -e "
const msg = {
jsonrpc: '2.0',
id: 1,
method: 'tools/list',
params: {}
};
process.stdin.write(JSON.stringify(msg) + '\\n');
process.stdin.end();
"
# Connect to MySQL and verify
docker exec mysql-container mysql -u root -p -e "SHOW DATABASES;"
# Check MCP server logs
docker logs mysql-mcp-server
The MCP server enables AI assistants to perform database operations:
{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "query",
"arguments": {
"database": "sales",
"query": "SELECT * FROM customers WHERE city = 'New York' LIMIT 10"
}
}
}
Use in CI/CD pipelines for database setup and testing:
# GitHub Actions example
- name: Setup Test Database
run: |
docker run --rm \
-e MYSQL_HOST=${{ secrets.DB_HOST }} \
-e MYSQL_USER=${{ secrets.DB_USER }} \
-e MYSQL_PASSWORD=${{ secrets.DB_PASSWORD }} \
teamsrunner/mysql-mcp-server:latest
Connection Refused
# Check if MySQL is running
docker ps --filter "name=mysql"
# Verify network connectivity
docker exec mcp-server ping mysql
Authentication Failed
# Verify credentials
docker exec mysql-container mysql -u $MYSQL_USER -p$MYSQL_PASSWORD -e "SELECT 1"
Permission Denied
# Check user permissions
GRANT ALL PRIVILEGES ON database_name.* TO 'username'@'%';
FLUSH PRIVILEGES;
For more troubleshooting information, see docs/TROUBLESHOOTING.mdโ .
git clone https://github.com/teamsrunner/mysql-mcp-server.git
cd mysql-mcp-server
docker build -t mysql-mcp-server:local .
# Install dependencies
npm install
# Run comprehensive tests
npm test
# Test with real database
docker-compose -f examples/docker-compose.standalone.yml up -d
node test-comprehensive.js
This project is licensed under the MIT License - see the LICENSEโ file for details.
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
git checkout -b feature/AmazingFeature)git commit -m 'Add some AmazingFeature')git push origin feature/AmazingFeature)If this project helped you, please consider giving it a โญ on GitHub!
Note: This is an unofficial implementation of the Model Context Protocol for MySQL. Always follow security best practices when deploying in production environments.
Content type
Image
Digest
sha256:33d0ca231โฆ
Size
58.9 MB
Last updated
about 1 year ago
docker pull teamsrunner/mysql-mcp-server