Skip to main content
Glama
gistrec

mcp-mysql-client

MySQL MCP

npm CI License: MIT

MySQL MCP connects an AI application to a single MySQL or MariaDB database: view the schema, ask questions about the data in natural language, find out why a query is slow, and — if you have explicitly allowed it — change the data.

The server is bound to one database: the database is set through the configuration, and no tool can escape into any other. By default, only read access is available.

  • 6 tools. Connection and permissions, list tables, table structure, read query, query plan, modifying query.

  • The server determines the request type. SQL is parsed before connecting: DELETE in the read tool is rejected even if write permissions are enabled.

  • Reads cannot write. Read queries run inside START TRANSACTION READ ONLY — MySQL itself rejects the write even if the SQL parser is tricked.

  • The response will not overflow the context. Rows are read as a stream and are cut off at the limit instead of being loaded entirely; the response carries an honest truncated marker.

  • Permissions are only granted from outside. INSERT, UPDATE, and DELETE are switched on by environment variables and require a restart — they cannot be granted from a chat. DDL is always unavailable.

Start with a query that only reads data:

Show me the database schema and count how many records were added in the last week.


Quick start

Claude Code:

claude mcp add mysql-myapp \
  -e MYSQL_HOST=db.example.com \
  -e MYSQL_USER=myapp_ro \
  -e MYSQL_PASS='пароль' \
  -e MYSQL_DB=myapp \
  -e MYSQL_SSL=true \
  -- npx -y mcp-mysql-client

Or in .mcp.json / claude_desktop_config.json:

{
  "mcpServers": {
    "mysql-myapp": {
      "command": "npx",
      "args": ["-y", "mcp-mysql-client"],
      "env": {
        "MYSQL_HOST": "db.example.com",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "myapp_ro",
        "MYSQL_PASS": "пароль",
        "MYSQL_DB": "myapp",
        "MYSQL_SSL": "true"
      }
    }
  }
}

One server — one database. Need several databases? Add several entries with their own credentials: this keeps permissions isolated, and a server connected to the test database physically cannot see the production one.

Related MCP server: MySQL MCP Server

What can you assign

Request

What the server does

"What is there at all in this database?"

list_tables — tables, sizes, estimated row counts

"How is the orders table structured?"

describe_table — columns, indexes, foreign keys both ways

"How many orders were placed in July, and for how much?"

query — SELECT with aggregation

"Why is this query slow?"

explain — plan, indexes, row estimate

"Who am I connected as and what am I allowed to do?"

server_info — database, user, GRANT, server limits

"Set the status of the canceled orders."

execute — only when ALLOW_UPDATE_OPERATION=true

What can change

By default, nothing: the server starts in read-only mode. Writing is enabled per operation:

"ALLOW_INSERT_OPERATION": "true",
"ALLOW_UPDATE_OPERATION": "true",
"ALLOW_DELETE_OPERATION": "false"

What remains impossible:

What

Why

DDL

CREATE, ALTER, DROP, TRUNCATE, RENAME — under no settings.

Switching databases, SET, CALL, PREPARE, LOAD DATA, locks, and GRANT

Changes the meaning of the next query or executes untrusted text.

SELECT ... INTO OUTFILE

Writing a file on the database server.

UPDATE and DELETE without WHERE

Requires explicit allow_full_table=true in the call.

Multiple statements in one call

Executes exactly one.

MySQL privileges are a separate restriction on top of the above. The ALLOW_UPDATE_OPERATION permission does not give anything to a user without a GRANT UPDATE. Best practice: a dedicated user with minimal privileges, not root.

Environment variables

Variable

Default

Purpose

MYSQL_HOST

127.0.0.1

Database server host

MYSQL_PORT

3306

Port

MYSQL_SOCKET_PATH

Unix socket instead of host/port

MYSQL_USER

User (required)

MYSQL_PASS

Password (alias of MYSQL_PASSWORD)

MYSQL_PASS_FILE

Read the password from a file instead of a variable

MYSQL_DB

Database (required, alias of MYSQL_DATABASE)

MYSQL_SSL

false

Require TLS

MYSQL_SSL_CA

Path to the root certificate; it alone enables TLS

MYSQL_SSL_REJECT_UNAUTHORIZED

true

Verify the server certificate

ALLOW_INSERT_OPERATION

false

Allow INSERT

ALLOW_UPDATE_OPERATION

false

Allow UPDATE

ALLOW_DELETE_OPERATION

false

Allow DELETE

MYSQL_MAX_ROWS

1000

Maximum rows in one response

MYSQL_TIMEOUT_MS

30000

Query timeout

MYSQL_CONNECT_TIMEOUT_MS

10000

Connection timeout

MYSQL_POOL_SIZE

3

Connections in the pool

MYSQL_MAX_RETRIES

2

Retries on connection loss or deadlocks

MYSQL_READ_ONLY_TX

true

Run reads in a read-only transaction

ASKADS_TELEMETRY

0 turns off anonymous launch statistics

The password is present in the MCP client config in plain text. MYSQL_PASS_FILE lets you keep it in a file with the required permissions.

Migration from @benborla29/mcp-server-mysql

The variable names are the same, so just replace the package in the launch command:

-  "args": ["-y", "@benborla29/mcp-server-mysql"]
+  "args": ["-y", "mcp-mysql-client"]

What will change in behavior:

Behavior

Change

MYSQL_DB is mandatory

The server is always bound to one database.

Responses are limited by MYSQL_MAX_ROWS

Answers are marked as truncated.

DDL is unavailable

Even if write permissions are enabled.

UPDATE/DELETE without WHERE

They require explicit confirmation in the call.

The toolset is different

query, execute, explain, list_tables, describe_table, server_info.

Diagnostics

First, call server_info: it shows where the server has connected, what permissions the MySQL user has, and which limits are enabled.

Symptom

Cause

errno 1045

Invalid MYSQL_USER / MYSQL_PASS

errno 1044

The user exists, but has no access to the database.

errno 1142

Missing GRANT for the operation or table. ALLOW_* does not help here.

errno 3159

The server requires TLS: set MYSQL_SSL=true.

ECONNREFUSED / ETIMEDOUT

Host, port, firewall, or a VPN that isn’t up.

ER_NOT_SUPPORTED_AUTH_MODE

TLS is required for caching_sha2_password.

Server doesn’t connect

The configuration error is visible directly in the dialog: the server starts without credentials and explains what is missing.

Technical documentation

  • Tools — parameters and responses

  • Development — building, tests, live verification

  • Publishing — releases in npm and the MCP registry

  • CLAUDE.md — repository layout for AI agents

License

MIT

Install Server
A
license - permissive license
A
quality
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
1Releases (12mo)
Commit activity

Related MCP Servers

  • F
    license
    Not graded
    quality
    B
    maintenance
    An MCP server that enables AI agents to safely explore and interact with MySQL databases through dynamic tool generation from stored procedures. It provides database discovery capabilities and intelligent procedure categorization while enforcing security restrictions to prevent data modification.
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables AI agents to safely interact with MySQL/MariaDB databases, supporting read-only queries by default with optional write operations and access control.
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    Enables AI agents to query and manage MySQL databases through a structured MCP interface, supporting SQL execution, table inspection, and database operations.
    9
    14
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    A robust MCP server for interacting with MySQL databases through AI agents, providing tools for schema analysis, query execution, and dynamic connection management with read-only security.
    61
    MIT

View all related MCP servers

Related MCP Connectors

  • Analytical memory for AI agents: a real Postgres queried in plain English over MCP. One command.

  • Security firewall for AI agents — scans MCP calls for injection, secrets, and risks.

  • Shared, governed long-term memory for AI agents across tools and sessions via MCP and REST.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/gistrec/mcp-mysql-client'

If you have feedback or need assistance with the MCP directory API, please join our Discord server