v0.1.0 · MCP for MySQL

AI queries MySQL
with safety

Multi-instance MySQL MCP server with SQL static analysis, read-only enforcement, and built-in security layers. Connect your AI assistant to any MySQL database safely.

Star on GitHub go install github.com/phpgao/mysqlmcp@latest

Safe MySQL access for AI

Connect multiple MySQL instances with per-instance security policies. Your AI assistant queries safely.

Multi-Instance

Connect production, staging, and dev databases simultaneously. Each with its own connection pool.

Read-Only Enforcement

Prevent accidental writes on production replicas. AI cannot bypass per-instance security.

SQL Static Analysis

Vitess SQL parser validates every query. Reject dangerous operations before execution.

Timeout Control

Every query gets a per-instance timeout. Context deadline prevents runaway queries.

Dual Transport

Run locally via stdio or remotely via HTTP with Bearer Token authentication.

Row Limit

SELECT without LIMIT is rejected. Results truncated at max_rows to prevent memory exhaustion.

4 layers of query safety

Every SQL statement passes through 4 validation layers before touching your database.

1

Parse & Inject

Vitess parser validates SQL. DROP DATABASE and dangerous ops blocked.

2

Single Statement

Multiple statements separated by ; are rejected. One query per call.

3

LIMIT Check

SELECT must include LIMIT clause. Value checked against instance max_rows.

4

Read-Only

INSERT/UPDATE/DELETE rejected on read-only instances. Instance-aware enforcement.

4 tools for AI

Minimal toolset. AI picks the right tool for the task without confusion.

list_instancesList all configured MySQL instances with metadata
queryExecute SQL with full 4-layer validation and timeout
describe_tableShow table schema (DESCRIBE) — read-only safe
explain_queryShow execution plan (EXPLAIN) — validated, not executed

One config file, done

Add to your MCP client. Works with CodeBuddy Code, Claude Desktop, and any MCP-compatible assistant.

Need remote access? HTTP mode:
mysqlmcp -transport http -port 8000