This MCP server for MySQL enables LLMs to inspect database schemas and execute read-only queries against MySQL databases. It provides a secure interface for language models to interact with your database while maintaining data security through read-only access.
The easiest installation method is through Smithery:
# Install the MCP server
npx -y @smithery/cli@latest install @benborla29/mcp-server-mysql --client claude
Smithery will guide you through entering MySQL connection details and automatically set up environment variables, configure your LLM application, test the connection, and provide troubleshooting if needed.
You can also install via MCP Get:
npx @michaellatman/mcp-get@latest install @benborla29/mcp-server-mysql
For manual installation:
# Using npm
npm install -g @benborla29/mcp-server-mysql
# Using pnpm
pnpm add -g @benborla29/mcp-server-mysql
If you installed using Smithery, your configuration is already set up. View or modify it with:
smithery configure @benborla29/mcp-server-mysql
To manually configure the MCP server, add the following to your claude_desktop_config.json
file:
{
"mcpServers": {
"mcp_server_mysql": {
"command": "npx",
"args": [
"-y",
"@benborla29/mcp-server-mysql"
],
"env": {
"MYSQL_HOST": "127.0.0.1",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root",
"MYSQL_PASS": "",
"MYSQL_DB": "db_name"
}
}
}
}
Replace db_name
with your database name or leave it blank to access all databases.
For more control over the server's behavior:
{
"mcpServers": {
"mcp_server_mysql": {
"command": "/path/to/npx/binary/npx",
"args": [
"-y",
"@benborla29/mcp-server-mysql"
],
"env": {
"MYSQL_HOST": "127.0.0.1",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root",
"MYSQL_PASS": "",
"MYSQL_DB": "db_name",
"PATH": "/path/to/node/bin:/usr/bin:/bin",
"MYSQL_POOL_SIZE": "10",
"MYSQL_QUERY_TIMEOUT": "30000",
"MYSQL_CACHE_TTL": "60000",
"MYSQL_RATE_LIMIT": "100",
"MYSQL_MAX_QUERY_COMPLEXITY": "1000",
"MYSQL_SSL": "true",
"MYSQL_ENABLE_LOGGING": "true",
"MYSQL_LOG_LEVEL": "info",
"MYSQL_METRICS_ENABLED": "true"
}
}
}
}
MYSQL_HOST
: MySQL server host (default: "127.0.0.1")MYSQL_PORT
: MySQL server port (default: "3306")MYSQL_USER
: MySQL username (default: "root")MYSQL_PASS
: MySQL passwordMYSQL_DB
: Target database nameMYSQL_POOL_SIZE
: Connection pool size (default: "10")MYSQL_QUERY_TIMEOUT
: Query timeout in milliseconds (default: "30000")MYSQL_CACHE_TTL
: Cache time-to-live in milliseconds (default: "60000")MYSQL_RATE_LIMIT
: Maximum queries per minute (default: "100")MYSQL_MAX_QUERY_COMPLEXITY
: Maximum query complexity score (default: "1000")MYSQL_SSL
: Enable SSL/TLS encryption (default: "false")MYSQL_ENABLE_LOGGING
: Enable query logging (default: "false")MYSQL_LOG_LEVEL
: Logging level (default: "info")MYSQL_METRICS_ENABLED
: Enable performance metrics (default: "false")The server provides comprehensive database information:
# Check the status of your MCP server
smithery status @benborla29/mcp-server-mysql
# Run diagnostics
smithery diagnose @benborla29/mcp-server-mysql
# View logs
smithery logs @benborla29/mcp-server-mysql
# Check the status
mcp-get status @benborla29/mcp-server-mysql
# View logs
mcp-get logs @benborla29/mcp-server-mysql
Connection Issues
Performance Issues
Path Resolution If you encounter "Could not connect to MCP server mcp-server-mysql", explicitly set the path:
{
"env": {
"PATH": "/path/to/node/bin:/usr/bin:/bin"
}
}
Authentication Issues
caching_sha2_password
authentication pluginCREATE USER 'user'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "mcp_server_mysql" '{"command":"npx","args":["-y","@benborla29/mcp-server-mysql"],"env":{"MYSQL_HOST":"127.0.0.1","MYSQL_PORT":"3306","MYSQL_USER":"root","MYSQL_PASS":"","MYSQL_DB":"db_name"}}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"mcp_server_mysql": {
"command": "npx",
"args": [
"-y",
"@benborla29/mcp-server-mysql"
],
"env": {
"MYSQL_HOST": "127.0.0.1",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root",
"MYSQL_PASS": "",
"MYSQL_DB": "db_name"
}
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"mcp_server_mysql": {
"command": "npx",
"args": [
"-y",
"@benborla29/mcp-server-mysql"
],
"env": {
"MYSQL_HOST": "127.0.0.1",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root",
"MYSQL_PASS": "",
"MYSQL_DB": "db_name"
}
}
}
}
3. Restart Claude Desktop for the changes to take effect