Enables direct interaction with MySQL databases through natural language, allowing query execution, schema inspection, data analysis, and database management operations.
MCP MySQL Lens
A Model Context Protocol (MCP) server that enables Claude Desktop to interact with MySQL databases directly. This server allows Claude to query, analyze, and manage your MySQL databases through natural language.
Features
š Query Execution: Run SQL queries directly from Claude Desktop
š Schema Inspection: Explore database structure, tables, and relationships
š Data Analysis: Analyze and visualize data patterns
š”ļø Safe Operations: Built-in safeguards for database operations
š Easy Setup: Simple configuration with environment variables
Prerequisites
Claude Desktop installed
Node.js (v16 or higher)
MySQL Server (v5.7 or higher)
install npm
Valid MySQL credentials with appropriate permissions
NPM Link
Visit npm package mcp-mysql-lens
Installation
1. Install the MCP Server
2. Configure Claude Desktop
Add this configuration to your Claude Desktop config file:
Configuration File Location:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
Windows:
%APPDATA%\Claude\claude_desktop_config.json
Linux:
~/.config/Claude/claude_desktop_config.json
3. Restart Claude Desktop
After saving the configuration, restart Claude Desktop for the changes to take effect.
Configuration Parameters
Parameter | Description | Default | Required |
| MySQL server hostname | - | Yes |
| MySQL server port |
| Yes |
| Database username | - | Yes |
| Database password | - | Yes |
| Default database to connect to | - | Yes |
Usage Examples
Once configured, you can interact with your MySQL database through Claude Desktop:
Query Data
Analyze Schema
Data Analysis
Security Best Practices
ā ļø Important Security Considerations:
Use Read-Only Credentials: Create a dedicated MySQL user with read-only permissions for data analysis tasks
Never Commit Credentials: Don't commit the
claude_desktop_config.json
file with actual credentials to version controlUse Environment Variables: For production environments, consider using environment variable substitution
Limit Database Access: Only grant access to specific databases that Claude needs to work with
Use Strong Passwords: Ensure your MySQL password is strong and unique
Enable SSL/TLS: For remote connections, always use SSL/TLS encryption
Regular Auditing: Monitor database access logs regularly
Troubleshooting
Connection Issues
Problem: "Cannot connect to MySQL server"
Verify MySQL server is running:
systemctl status mysql
(Linux) or check Services (Windows)Check host and port are correct
Ensure firewall allows connections on MySQL port (default 3306)
Verify credentials are correct
Problem: "Access denied for user"
Confirm username and password are correct
Check user has appropriate permissions:
SHOW GRANTS FOR 'your_user'@'localhost';
Verify user can connect from the specified host
Configuration Issues
Problem: Claude Desktop doesn't show the MySQL server
Ensure the config file is in the correct location
Check JSON syntax is valid (use a JSON validator)
Restart Claude Desktop after making changes
Check Claude Desktop logs for errors
Performance Issues
Problem: Queries are slow
Add appropriate indexes to frequently queried columns
Optimize complex queries
Consider increasing MySQL connection timeout
Check database server resources (CPU, memory)
Limitations
Query Timeout: Long-running queries may timeout (default: 30 seconds)
Result Size: Large result sets may be truncated
Write Operations: Currently not supported
Concurrent Connections: Limited by MySQL server's max_connections setting
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Fork the repository
Create your feature branch (
git checkout -b feature/AmazingFeature
)Commit your changes (
git commit -m 'Add some AmazingFeature'
)Push to the branch (
git push origin feature/AmazingFeature
)Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
Built on the Model Context Protocol
Powered by Claude by Anthropic
MySQL connector by mysql2
Inspired by dpflucas mysql server
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
MCP server to connect MySQL DB for read-only queries. It offers accurate query execution.
Related MCP Servers
- AsecurityAlicenseAqualityAn MCP server that provides read-only access to MySQL databases.Last updated -428843MIT License