Production Safe Mysql Mcp Server

by turkeryildirim

1 stars
268 downloads
Not rated
GitHub

Description

# mysql-mcp A Model Context Protocol (MCP) server that gives AI agents direct access to MySQL databases. ## What It Can Do ### Data Query & Mutation - `execute_query` — Run SELECT, INSERT, UPDATE, or DELETE statements with parameterized query support (`?` placeholders) -…

About

# mysql-mcp A Model Context Protocol (MCP) server that gives AI agents direct access to MySQL databases. ## What It Can Do ### Data Query & Mutation - `execute_query` — Run SELECT, INSERT, UPDATE, or DELETE statements with parameterized query support (`?` placeholders) - `execute_transaction` — Execute multiple…

Details

Author
turkeryildirim
GitHub stars
1
Downloads
268
Categories
Database, Other

- execute_query – Run SELECT, INSERT, UPDATE, DELETE with parameterized queries
- execute_transaction – Execute atomic batches with automatic rollback on failure
- Schema management: create_table, alter_table, drop_table (with flag)
- Database management: list_databases, create_database, drop_database (with flag)
- Introspection tools: ping, show_columns, get_server_info
- Multi-database support via database parameter on every tool
- Security filter permanently blocks user/privilege/replication/file/plugin commands

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name Production Safe Mysql Mcp Server
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Install Node.js 20+, clone the repository, run npm install and npm run build, then copy .env.example to .env and configure MySQL credentials. Integrate with Claude Desktop via claude_desktop_config.json or with Claude CLI using .mcp.json or claude mcp add. All tools accept a database parameter for multi-database access within the same session.

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "production safe mysql mcp server": {
            "mysql": {
                "command": "node",
                "args": [
                    "/absolute/path/to/mysql-mcp/dist/index.js"
                ],
                "env": {
                    "MYSQL_HOST": "localhost",
                    "MYSQL_PORT": "3306",
                    "MYSQL_USER": "mcp_user",
                    "MYSQL_PASSWORD": "your_password",
                    "MYSQL_DATABASE": "",
                    "MAX_ROWS": "1000",
                    "ALLOW_DESTRUCTIVE_DDL": "false"
                }
            }
        }
    }
}

McpServers

{
    "mysql": {
        "command": "node",
        "args": [
            "/absolute/path/to/mysql-mcp/dist/index.js"
        ],
        "env": {
            "MYSQL_HOST": "localhost",
            "MYSQL_PORT": "3306",
            "MYSQL_USER": "mcp_user",
            "MYSQL_PASSWORD": "your_password",
            "MYSQL_DATABASE": "",
            "MAX_ROWS": "1000",
            "ALLOW_DESTRUCTIVE_DDL": "false"
        }
    }
}

mysql-mcp

A Model Context Protocol (MCP) server that gives AI agents direct access to MySQL databases.

What It Can Do

Data Query & Mutation

- execute_query — Run SELECT, INSERT, UPDATE, or DELETE statements with parameterized query support (? placeholders) - execute_transaction — Execute multiple statements as an atomic batch; if any statement fails the entire transaction is automatically rolled back

Schema Management

- create_table — Create a new table - alter_table — Add/drop columns, rename columns, add indexes, and more - drop_table — Drop a table (requires ALLOW_DESTRUCTIVE_DDL=true) - show_tables — List all tables in a database - describe_table — Show column structure of a table

Database Management

- list_databases — List all user databases (system databases excluded) - create_database — Create a new database with optional charset and collation - drop_database — Drop a database (requires ALLOW_DESTRUCTIVE_DDL=true)

Introspection

- ping — Check MySQL connection health - show_columns — Show detailed column information for a table - get_server_info — Return MySQL version, character set, and collation (read-only)

Multi-Database Support

Every tool accepts a database parameter. You can query different databases within the same session without any extra configuration.

---

What It Cannot Do

The following operations are permanently blocked by the security filter and cannot be bypassed under any circumstances:

| Category | Blocked Commands |
|---|---|
| MySQL settings | SET GLOBAL, SET @@global.*, SET @@SESSION.sql_mode |
| User management | CREATE USER, DROP USER, ALTER USER, RENAME USER |
| Privilege management | GRANT, REVOKE |
| System commands | FLUSH, KILL, SHUTDOWN |
| Replication | RESET MASTER/REPLICA, START/STOP SLAVE/REPLICA, CHANGE MASTER |
| File access | LOAD DATA INFILE, SELECT INTO OUTFILE/DUMPFILE |
| Plugins | INSTALL PLUGIN, UNINSTALL PLUGIN |

Additional constraints:
- Multiple statements separated by ; in a single call are not allowed — use execute_transaction instead
- drop_table and drop_database are disabled by default and will return an error unless ALLOW_DESTRUCTIVE_DDL=true is set
- Query results are capped at MAX_ROWS rows (default: 1000); add a LIMIT clause for large tables

---

Installation

Requirements: Node.js 20+

git clone https://github.com/turkeryildirim/mysql-mcp
cd mysql-mcp
npm install
npm run build

Copy the example environment file and fill in your credentials:

cp .env.example .env

```env
MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_USER=mcp_user
MYSQL_PASSWORD=your_password

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.