# mcp-mysql-connector [Health: Active]

**Category:** 🗄️ Databases  
**Repository:** https://github.com/daedalus/mcp-mysql-connector  
**GitHub Stars:** 0  
**Views:** 2  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/mcp-mysql-connector

## Description
MCP server exposing MySQL database functionalities as tools

## Tools
Capabilities this server exposes over MCP:

- **connect** — Connect to a MySQL database
- **disconnect** — Disconnect from MySQL
- **is_connected** — Check connection status
- **commit** — Commit current transaction
- **rollback** — Rollback current transaction
- **execute_query** — Execute raw SQL query and return results
- **list_databases** — List all databases on server
- **create_database** — Create a new database
- **drop_database** — Drop a database
- **database_exists** — Check if database exists
- **list_tables** — List tables in a database
- **describe_table** — Get table schema
- **create_table** — Create a new table
- **drop_table** — Drop a table
- **table_exists** — Check if table exists
- **show_columns** — Show column details
- **show_indexes** — Show index details
- **create_index** — Create an index
- **drop_index** — Drop an index
- **create_user** — Create a MySQL user
- **drop_user** — Drop a MySQL user
- **grant_privileges** — Grant privileges to user
- **revoke_privileges** — Revoke privileges from user
- **show_privileges** — Show user privileges
- **server_status** — Get MySQL server status

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

```json
"mcpServers": {
  "mcp-mysql-connector": {
    "command": "uvx",
    "args": ["mcp-mysql-connector"],
    "env": {
      "MYSQL_HOST": "",
      "MYSQL_PORT": "",
      "MYSQL_USER": "",
      "MYSQL_PASSWORD": "",
      "MYSQL_DATABASE": ""
    }
  }
}
```

**Requires environment variables:** `MYSQL_HOST`, `MYSQL_PORT`, `MYSQL_USER`, `MYSQL_PASSWORD`, `MYSQL_DATABASE` — the values above are empty placeholders; fill in real credentials before running (see the repository for what each one is for).

## Documentation

## What mcp-mysql-connector MCP server does

The mcp-mysql-connector MCP server gives an MCP-compatible agent access to MySQL operations. It covers both data access and administrative tasks: agents can run raw SQL, inspect database structures, create or remove databases and tables, manage indexes, and check server status.

Connection and transaction controls are included. An agent can connect, disconnect, check connection state, commit changes, or roll back the current transaction. User administration tools support creating and removing MySQL users, granting and revoking privileges, and viewing a user’s privileges.

The server also publishes dynamic metadata resources. A `database://{name}` resource represents database metadata and its table list, while `table://{db}/{table}` provides table metadata, including schema, columns, and indexes.

## How it works

The server uses the Model Context Protocol to expose MySQL functions as callable tools. It starts with stdio transport by default, making it suitable for MCP clients that launch local servers through standard input and output.

A connection must be established through `connect` before database operations can be used. The connection parameters include the MySQL host, port, username, password, and optionally a database. Once connected, an agent can call `execute_query` with SQL text or use the narrower management tools for databases, tables, columns, indexes, users, and privileges.

Transaction handling is explicit. An agent can issue SQL such as `BEGIN` through `execute_query`, perform subsequent operations, then call `commit` or `rollback` as appropriate. The available tools do not describe a separate query language or ORM layer; SQL execution is provided directly through the raw-query tool.

## Setup and configuration

Install the package with:

```bash
pip install mcp-mysql-connector
```

The documented runtime requires Python 3.11 or newer. The package lists `fastmcp >= 2.0.0`, `pymysql >= 1.1.0`, and `sqlparse >= 0.4.0` as requirements.

Start the default stdio server with:

```bash
mcp-mysql-connector
```

It can also be started programmatically with `mcp.run()` from the `mcp_mysql` package. Database settings may be supplied through the `connect` tool or environment variables: `MYSQL_HOST`, `MYSQL_PORT`, `MYSQL_USER`, `MYSQL_PASSWORD`, and `MYSQL_DATABASE`.

## Tools and capabilities

The mcp-mysql-connector MCP server exposes these groups of tools:

- Connection and transactions: `connect`, `disconnect`, `is_connected`, `commit`, and `rollback`.
- SQL execution: `execute_query`, which runs raw SQL and returns results.
- Database administration: list, create, remove, and check databases.
- Table administration: list, describe, create, remove, and check tables.
- Schema details: inspect columns and indexes, and create or remove indexes.
- User and privilege management: create or remove users, grant or revoke privileges, and show privileges.
- Server information: retrieve MySQL server status.

These capabilities make the server applicable to database exploration, schema changes, controlled SQL workflows, and MySQL account administration. Operations that change databases, tables, indexes, users, or privileges should be exposed only to agents with appropriate database permissions.

## Limitations and notes

The server exposes raw SQL execution, so the connected MySQL account and the agent’s instructions determine which SQL operations can be attempted. The material also does not specify authentication enhancements, query safety checks, or a read-only mode beyond the permissions enforced by MySQL.

The project includes development instructions for running tests, formatting, linting, and type checking, but those commands are for contributors rather than normal installation. It is licensed under the MIT License.

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

