mcp-mysql-lens
Enables direct interaction with MySQL databases through natural language, allowing query execution, schema inspection, data analysis, and database management operations.
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-lens show me the top 5 customers by total orders"
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 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
Related MCP server: mysql-mcp
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
npm install -g mcp-mysql-lens2. Configure Claude Desktop
Add this configuration to your Claude Desktop config file:
{
"mcpServers": {
"mysql": {
"command": "npx",
"args": [
"mcp-mysql-lens"
],
"env": {
"MYSQL_HOST": "<YOUR_MYSQL_HOST>",
"MYSQL_PORT": "<YOUR_MYSQL_PORT>",
"MYSQL_USER": "<YOUR_MYSQL_USERNAME>",
"MYSQL_PASSWORD": "<YOUR_MYSQL_PASSWORD>",
"MYSQL_DATABASE": "<YOUR_MYSQL_DEFAULT_DB>"
}
}
}
}Configuration File Location:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.jsonLinux:
~/.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
"Show me all users from the users table"
"What are the top 10 products by sales?"
"Find all orders from the last 30 days"Analyze Schema
"What tables are in my database?"
"Describe the structure of the customers table"
"Show me the relationships between tables"Data Analysis
"Calculate the average order value by month"
"Find duplicate records in the products table"
"Show me user registration trends"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.jsonfile 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
Available Tools
4 toolsdescribe_tableB
Show the schema for a specific table
Inputs: table (required), database.
execute_queryB
Execute a read-only SQL query
Inputs: query (required), database.
list_databasesA
List all accessible databases on the MySQL server
Inputs: no named parameters.
list_tablesC
List all tables in a specified database
Inputs: database.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool has a clearly distinct purpose: describe_table shows schema, execute_query runs SQL queries, list_databases lists databases, and list_tables lists tables. There is no overlap or ambiguity between these functions.
All tool names follow a consistent verb_noun pattern (describe_table, execute_query, list_databases, list_tables) with clear, descriptive verbs and nouns that match their functions.
With 4 tools, the count is reasonable for a MySQL server interface, though it feels slightly thin as it lacks write operations (e.g., insert, update, delete) which are common in database contexts. However, the tools cover essential read and metadata functions well.
The tool surface covers read operations and metadata well (list databases/tables, describe schema, execute queries), but there are notable gaps: no write operations (insert, update, delete), no transaction management, and no user or permission management tools, which limits full database lifecycle coverage.
Maintenance
Related MCP Connectors
MCP server for querying and analyzing data from ad platforms, analytics tools, and spreadsheets
Hosted MySQL MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Read-only MCP server for The Quiet Protocol's engines, benchmarks, proof, and business data.
Read-only MCP server for ClassQuill, a tutoring-business-management platform.
Related MCP Servers
- AlicenseAqualityBmaintenanceAn MCP server that provides read-only access to MySQL databases.4824 npm74MIT
- AlicenseNot gradedqualityDmaintenanceA lightweight MCP server providing safe, read-only access to MySQL databases. It enables users to query multiple MySQL instances securely while preventing write operations.1,492 npmMIT
- AlicenseNot gradedqualityDmaintenanceRead-only MySQL MCP server for safe schema inspection and SELECT-style queries.8 npmMIT
- AlicenseAqualityCmaintenanceRead-only MySQL/MariaDB MCP server for running SELECT queries safely, with automatic read-only enforcement and query limits.36 npmMIT