← Back to directory
M

mcp-server-mysql

Community
Query MySQL databases through MCP with read-only defaults.
GitHub source repository ↗
★ 2.0k Stars Category · Database Very popular
50FMRS · D
Reliability
8/20
Security and permissions
10/20
Maintenance
9/20
Documentation
11/20
Setup experience
12/20

This server is suited to using MCP with Claude and other clients to inspect MySQL schemas and query data. It defaults to read-only access and offers SSH tunneling, multi-database mode, PII redaction, and SSL/TLS support. Write operations require explicit environment flags, so database privileges and credentials should be configured carefully.

Read the FMRS scoring method →

An MCP server that gives Claude and other large language models access to MySQL databases for schema inspection and SQL queries. Access is read-only by default, with optional write operations controlled by environment flags.

Tools

mysql_query
Executes SQL queries; read-only by default, with write operations enabled through configuration.

Setup

Requires Node.js v20+, MySQL 5.7+ (8.0+ recommended), and a MySQL user with appropriate privileges. Start the server with npx and configure MYSQL_HOST, MYSQL_PORT, MYSQL_USER, MYSQL_PASS, and MYSQL_DB. Claude Desktop can use the JSON configuration shown in the README. Write operations are disabled by default; when needed, enable them individually with ALLOW_INSERT_OPERATION=true, ALLOW_UPDATE_OPERATION=true, or ALLOW_DELETE_OPERATION=true.

claude_desktop_config.json
{"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":"your_password","MYSQL_DB":"your_database"}}}}

Fit and risk

Best for

  • Developers and data teams that need AI-assisted MySQL schema inspection or querying
  • Workflows that prefer read-only database access by default
  • Deployments requiring SSH, SSL/TLS, or PII-redaction capabilities

Not for

  • Environments that do not use MySQL
  • Workflows requiring write access by default without explicit permission configuration
  • Environments unable to provide suitable database credentials or network connectivity

Required permissions

  • Requires configuration for the MySQL host, port, username, password, and database name
  • The database user needs privileges matching the intended queries and any enabled write operations
  • Remote database access may require SSH tunnel configuration
  • When write flags are enabled, the server can perform the corresponding insert, update, or delete operations

Risks and side effects

  • Although read-only by default, enabled write flags can modify or delete data
  • Database credentials are supplied through environment variables and should be protected
  • SQL queries may expose sensitive data; PII redaction can help reduce exposure
  • Misconfigured database privileges, SSL/TLS, or remote access may broaden data exposure

Troubleshooting

  1. Verify Node.js is v20 or newer and that the MySQL version meets the requirements
  2. Check MYSQL_HOST, MYSQL_PORT, MYSQL_USER, MYSQL_PASS, and MYSQL_DB values
  3. Confirm that the MySQL user has the required privileges and that the database is reachable
  4. For remote connection failures, inspect the SSH tunnel configuration
  5. When using SSL/TLS or mTLS, check the connection settings
  6. Run the repository tests and consult the troubleshooting documentation

Use cases

Inspecting MySQL tables and column metadata
Running read-only SQL queries with AI assistance
Connecting to remote databases through SSH tunnels
Querying multiple databases in multi-DB mode
Automatically masking sensitive data in query results

Supported clients

Claude DesktopFull support
Claude CodeFull support