# @abelmferreira/mcp-mysql [Health: Active]

**Category:** 🗄️ Databases  
**Repository:** https://github.com/abelmferreira/mcp-mysql  
**GitHub Stars:** 0  
**npm Downloads (last month):** 800  
**Views:** 0  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/abelmferreira-mcp-mysql

## Description
MCP server for MySQL/MariaDB: query, monitor and analyze with read-only mode and SSH tunnel

## Tools
Capabilities this server exposes over MCP:

- **sql_execute**
- **rows**
- **rowCount**
- **fields**
- **duration**
- **truncated**
- **true**
- **analyze_query**
- **SELECT**
- **WITH**
- **performance_schema**
- **sys**
- **monitor_wait_stats**
- **analyze_suggest_indexes**
- **analyze_unused_indexes**
- **schema_list_indexes**
- **monitor_performance_counters**

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "mcp-mysql": {
    "command": "npx",
    "args": ["-y","@abelmferreira/mcp-mysql"],
    "env": {
      "READONLY": "",
      "SQL_CONNECTION_URL": "",
      "SQL_SERVER": "",
      "SQL_DATABASE": "",
      "SQL_USER": "",
      "SQL_PASSWORD": ""
    }
  }
}
```

**Requires environment variables:** `READONLY`, `SQL_CONNECTION_URL`, `SQL_SERVER`, `SQL_DATABASE`, `SQL_USER`, `SQL_PASSWORD` — the values above are empty placeholders; fill in real credentials before running (see the repository for what each one is for).

## Documentation

## What @abelmferreira/mcp-mysql does

@abelmferreira/mcp-mysql exposes MySQL and MariaDB databases to MCP-compatible clients. Its database features cover four main areas: executing permitted SQL, exploring schemas, monitoring runtime activity, and examining query or index performance.

The server supports SELECT, WITH, EXPLAIN, DESCRIBE, and read-only SHOW statements. Queries can use named `@param` placeholders. Results include row data and metadata such as row counts, fields, execution duration, and whether output was truncated. Schema tools can inspect tables, views, columns, indexes, stored procedures, and complete table descriptions.

## How it works

The recommended deployment uses `npx -y @abelmferreira/mcp-mysql` as an MCP stdio process. Docker is also supported through the `abelmferreira/mcp-mysql` image. Connection details can be supplied with a MySQL or MariaDB URL, individual `SQL_*` variables, or a dotenv file referenced by `ENV_FILE`.

For private databases, set `SSH_HOST` to have the server create an in-process local port forward. The database host and port are then interpreted from the SSH host's network perspective. The SSH host fingerprint is mandatory, keys can be protected with a passphrase, and dropped sessions are re-established automatically. The tunnel key should be restricted on the bastion to local forwarding and the intended database destination.

## Setup and configuration

Node.js 20.12 or newer is required for the npx method. MySQL 8.0+ or MariaDB 10.5+ is recommended. Monitoring and analysis functions depend in part on the `performance_schema` and `sys` schemas.

A minimal client configuration sets `READONLY` and either `SQL_CONNECTION_URL` or the individual connection variables. `SQL_SSL` enables TLS; certificate verification is enabled by default, and `SQL_SSL_CA` can identify a custom certificate authority. `QUERY_TIMEOUT`, `MAX_ROWS`, `MAX_RESULT_BYTES`, and `POOL_MAX` limit execution time, result size, and connection usage. Environment variables supplied directly by the MCP client take precedence over values loaded from `ENV_FILE`.

## Tools and capabilities

- Execute read-only SQL and inspect returned rows, fields, counts, duration, and truncation status.
- Analyze query plans with `EXPLAIN` and identify possible index improvements.
- List schemas and inspect indexes, including unused or redundant indexes.
- Monitor active queries, connections, InnoDB lock waits, wait statistics, database size, and performance counters.
- Review fragmentation and statistics freshness through the database's metadata systems.
- Enable INSERT, UPDATE, and DELETE tools only by setting `READONLY=false`.

## Limitations and notes

Results are capped by `MAX_ROWS` and `MAX_RESULT_BYTES`; oversized results are cut and marked as truncated. Query execution is bounded by `QUERY_TIMEOUT`, with a maximum configured timeout of 120 seconds. The connection pool defaults to three database connections and should remain below the account's connection limit.

Some monitoring and analysis tools require suitable MySQL or MariaDB versions and populated `performance_schema` or `sys` data. With Docker, the SSH key must be mounted into the container, and a database running on the Docker host should be addressed through `host.docker.internal` rather than `localhost`.

_Full upstream README: https://allmcps.com/mcp/abelmferreira-mcp-mysql/readme_

