MCP Directory

MCP Server for MySQL

Read-only (optionally write) access to MySQL databases for LLMs — inspect schemas and run SQL queries.

Unverified
stdio (local)
No auth
JavaScript

Add to your client

Copy the config for your MCP client and paste it into its config file.

Install / run
npm install -g @benborla29/mcp-server-mysql

Paste into ~/Library/Application Support/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "mcp-server-for-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",
        "ALLOW_INSERT_OPERATION": "false",
        "ALLOW_UPDATE_OPERATION": "false",
        "ALLOW_DELETE_OPERATION": "false"
      }
    }
  }
}

Step-by-step guides: Add to Claude Desktop · Add to Cursor · Add to Windsurf

Before you start

  • Node.js v20 or higher
  • MySQL 5.7 or higher (MySQL 8.0+ recommended)
  • A MySQL user with appropriate permissions for the operations you need (INSERT/UPDATE/DELETE privileges required for write operations)

About MCP Server for MySQL

MCP Server for MySQL connects Claude and other LLMs to MySQL databases over the Model Context Protocol. It exposes a mysql_query tool (read-only by default) and table-schema resources, with opt-in write/DDL operations, prepared statements, connection pooling, query caching, rate limiting, SSL/TLS and mTLS support, multi-database mode, schema-specific permissions, and an optional remote streamable HTTP transport.

Tools & capabilities (1)

mysql_query

Execute a SQL query against the connected database. Input: sql (string). Read-only by default; INSERT/UPDATE/DELETE require the corresponding ALLOW_*_OPERATION flag. Runs within a transaction with commit/rollback handling, supports prepared statements, configurable timeouts, result pagination, and built-in execution statistics.

What this server can do

MCP Server for MySQL provides tools for these capabilities — tap one to see every MCP server that does the same:

When to use it

  • Letting an LLM inspect a MySQL database schema (tables, columns, indexes, foreign keys) before writing queries
  • Running ad-hoc read-only analytical SQL queries against application data
  • Safely exploring production data with write operations disabled and rate limiting enforced
  • Querying across multiple databases the MySQL user can access via multi-DB mode
  • Granting controlled write/DDL access per schema (e.g. read-write on dev/test, read-only on production)

Security notes

All write operations are disabled by default; enable INSERT/UPDATE/DELETE/DDL only via the ALLOW_*_OPERATION env flags and only with a MySQL user holding the corresponding privileges. MYSQL_DISABLE_READ_ONLY_TRANSACTIONS removes read-only transaction enforcement — only enable for full write capability when you trust the LLM with your database. For credentials, use local or user scope to keep them private; the MYSQL_CONNECTION_STRING should only be set via environment variables, never committed to version control. Remote MCP mode requires a strong REMOTE_SECRET_KEY (sent as an Authorization: Bearer header).

MCP Server for MySQL FAQ

Is the server read-only by default?

Yes. Only read operations are allowed unless you explicitly set ALLOW_INSERT_OPERATION, ALLOW_UPDATE_OPERATION, ALLOW_DELETE_OPERATION, or ALLOW_DDL_OPERATION to "true" (and ensure the MySQL user has the matching privileges).

How do I enable multi-database mode?

Leave the MYSQL_DB environment variable empty. Queries then require schema-qualified table names (e.g. database_name.table_name) or USE statements. Writes in multi-DB mode additionally require MULTI_DB_WRITE_MODE=true.

Can it run as a remote server instead of stdio?

Yes. Set IS_REMOTE_MCP=true and a REMOTE_SECRET_KEY, optionally a PORT (default 3000), then point your agent at http://your-host:3000/mcp using the streamableHttp transport with an Authorization: Bearer <REMOTE_SECRET_KEY> header.

It can't find the MCP server / Node binary. What do I do?

Explicitly set the PATH (and NODE_PATH for local installs) in the env block. Find them with `echo "$(which node)/../"` for PATH and `echo "$(which node)/../../lib/node_modules"` for NODE_PATH.

Alternatives to MCP Server for MySQL

Compare all alternatives →

Google's official MCP server with prebuilt BigQuery tools, querying datasets via Application Default Credentials.

Verified
stdio (local)
OAuth
Go
10 tools
Updated 15 days agoRepo

Read/write Postgres access plus index tuning, EXPLAIN plans, and database health analysis for AI agents.

Verified
stdio (local)
API key
Python
9 tools
Updated 3 months agoRepo

Official Supabase server: manage tables, run SQL, branches, configs and edge functions from your AI client.

Verified
HTTP (remote)
OAuth
TypeScript
12 tools
Updated 1 month agoRepo