MySQL (security First) logo

MySQL (security First)

Validates MySQL SQL with AST parsing, whitelist rules, guarded writes, atomic scripts, and audit and statistics support.

Install MySQL (security First)

Run the project’s own setup commands, in order.

Setup steps from the project

MySQL (security-first) installs with its own steps rather than a config we can generate, so these are copied as-is. Follow them in order and run the commands in a terminal. Source: github.com

  1. 1. Install
    go install github.com/Kurok1/mcp-server-mysql/cmd/mcp-server-mysql@latest
    
  2. 2. Install
    docker pull ghcr.io/kurok1/mcp-server-mysql:latest
    
  3. 3. Configure
    mkdir -p ~/.mcp-server-mysql
    
  4. 4. Configure
    cp config.example.yaml ~/.mcp-server-mysql/config.yaml
    
  5. 5. Add to Claude Code
    claude mcp add mysql --env MYSQL_MCP_PASSWORD=your-password -- \
      ~/go/bin/mcp-server-mysql --config ~/.mcp-server-mysql/config.yaml
    
  6. 6. Start the server
    MYSQL_MCP_PASSWORD=your-password mcp-server-mysql \
      --config ~/.mcp-server-mysql/config.yaml \
      --transport streamable-http \
      --listen 127.0.0.1:3001
    

Overview

MySQL (security-first) MCP server connects AI agents to configured MySQL profiles through AST-validated SQL tools. It defaults to read-only access, requires an explicit profile, and applies statement gates, table whitelists, row limits, timeouts, and single-statement checks before database access. Use it when agents need controlled database inspection or carefully enabled writes rather than unrestricted SQL access. It also provides table metadata resources, query plans, atomic scripts without DDL, and process-lifetime query statistics.

Use cases

  • Inspect whitelisted production tables with read-only SQL
  • Enable narrowly scoped data changes for development profiles
  • Review query plans and identify slow statements
  • Run validated multi-statement data changes atomically

Key features

  • AST-based fail-closed SQL validation
  • Default-deny table whitelists
  • Per-statement-class write controls
  • Atomic non-DDL scripts
  • Query statistics and optional JSONL audit logs
  • Whitelisted table-schema MCP resources

Tools8

What MySQL (security First) lets your agent do. Expand a tool for its parameters.

Self-reported~229 tokens of context

Security & health

What it can reach and how reliably it runs — from our own checks, not the maintainer’s claims.

ActiveLast checked

Recent health check succeeded.

18/22 checks healthy over the last 111d

Adoption & maintenance

Factual signals from GitHub, npm, and our automated checks — not a rating.

GitHub stars2Stargazers on the source repository.
Last commit2mo agoMost recent push to the default branch.
Tools exposed8Callable tools this server registers over MCP.
Directory activity2 viewsConfig copies, upvotes, and views on AllMCPs.

How MySQL (security First) works

What MySQL (security-first) does

MySQL (security-first) MCP server exposes multiple configured MySQL connections as MCP tools. Each SQL operation must name a profile; there is no implicit default connection. list_profile returns available profile names and descriptions without probing the database or exposing credentials.

The server supports read-only queries, selectively enabled writes, table discovery, schema inspection, query-plan analysis, transactional scripts, and process-lifetime statistics. It can also publish whitelisted base-table schemas as MCP resources. These resources contain live normalized SHOW CREATE TABLE output, while the discovered resource set is refreshed on initialization or reconnect.

How it works

Before execution, SQL is parsed into an abstract syntax tree using the TiDB MySQL-compatible parser. Statements the parser cannot understand are rejected. Statement classes are allowlisted individually: reads cover SELECT, SHOW, DESCRIBE, and EXPLAIN, while INSERT, UPDATE, DELETE, and DDL require corresponding configuration. Statements such as SET, GRANT, CALL, USE, LOAD DATA, LOCK TABLES, and transaction-control commands are rejected.

The MySQL (security-first) MCP server checks every referenced table against a default-deny whitelist. The check covers joins, subqueries, CTEs, derived tables, multi-table writes, INSERT ... SELECT, and versioned comments. Additional execution controls include a maximum row count, query timeouts, single-statement enforcement, and a guard against UPDATE or DELETE statements without WHERE clauses.

mysql_script accepts semicolon-separated statements and executes them in one transaction after validating each statement. A failure rolls back the script. DDL is not allowed in scripts because MySQL can implicitly commit DDL and would undermine all-or-nothing behavior. mysql_explain handles one SELECT and supports traditional, JSON, and tree output, including EXPLAIN ANALYZE.

Setup and configuration

The project can run as a prebuilt static binary, a Go-installed command, or a Docker image from GitHub Container Registry.

Create ~/.mcp-server-mysql/config.yaml from the example configuration, then define profiles with connection details and security rules. The example uses a dedicated least-privilege MySQL account rather than root and obtains the password from MYSQL_MCP_PASSWORD. Profiles can have separate connection pools, whitelist rules, audit files, and statistics.

Resources are enabled by default. Set the root-level resources.enabled option to false to prevent initialization-time table discovery and disable schema resources and the interactive query-results app. The tools remain available when resources are disabled.

Tools and capabilities

  • mysql_query: Executes one permitted read statement.
  • mysql_execute: Performs an enabled write or DDL operation and reports affected rows.
  • mysql_script: Runs validated non-DDL statements atomically.
  • mysql_explain: Returns a plan for one SELECT.
  • mysql_list_tables: Lists whitelist-visible base tables.
  • mysql_describe_table: Returns the structure of a permitted table.
  • mysql_stats: Reports totals, denials, latency, slow queries, and per-table access counts for a profile.
  • mysql_query results can be rendered as filterable and sortable tables by MCP Apps-capable hosts; other hosts receive text results.

Limitations and notes

The MySQL (security-first) MCP server does not provide a default profile, and missing or unknown profiles are rejected before database access. The table-resource list is a discovery-time snapshot: newly created tables appear after discovery or reconnect, while resource content reflects later schema changes when read. Views are not registered.

Audit logging is opt-in and uses rotating JSONL files. Denied SQL includes the rule that caused rejection when auditing is enabled. Resource discovery and reads do not contribute to audit logs or mysql_stats. Resource visibility depends on both the MySQL account's privileges and the configured whitelist.

Written by AllMCPs with AI assistance from the project’s README and listing data. How we build listings

Reviews

No reviews yet — be the first to share how it worked for you.

Frequently Asked Questions about MySQL (security First)

MySQL (security-first) is an MCP server that connects AI agents to configured MySQL databases through named connection profiles. Its main tools query read-only SQL, execute enabled writes, run atomic scripts, inspect tables and schemas, analyze SELECT plans, and report query statistics, with AST validation and table whitelists applied before execution.

Install it by downloading a platform release, running the documented Go install command, or pulling the published Docker image. Then copy the example YAML into `~/.mcp-server-mysql/config.yaml`, define at least one profile, and provide its password through the configured environment variable.

Configure a named profile in `config.yaml` with its MySQL host, port, user, password reference, database, and security rules. Use a dedicated least-privilege account, define the table whitelist, and pass that profile name to every SQL tool.

Yes, read-only access is the default. Use `mysql_query` for permitted `SELECT`, `SHOW`, `DESCRIBE`, or `EXPLAIN` statements, while write statement classes remain disabled unless enabled in configuration. AST validation, whitelists, row limits, and timeouts still apply.

Related MCP servers

Add a badge to your READMEShow it’s listed — live SVG, Markdown or HTML.

AllMCPs Directory Badge

Full Badge Customizer

Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.

Badge Style:
Live Dynamic SVG PreviewMySQL (security First) AllMCPs Directory Badge
Markdown (GitHub README)
[![AllMCPs](https://allmcps.com/api/badge/mysql-security-first?style=directory)](https://allmcps.com/mcp/mysql-security-first)
HTML Embed
<a href="https://allmcps.com/mcp/mysql-security-first"><img src="https://allmcps.com/api/badge/mysql-security-first?style=directory" alt="MySQL (security First) on AllMCPs" /></a>