Skip to main content
Glama
mysql-mcp-lite

mysql-mcp-lite

flowchart LR
    A["AI agent<br/>Claude · Codex · Cursor · OpenCode · Gemini · VS Code"]
    A -- "MCP: 4 tools + /mysql prompt" --> S["mysql-mcp-lite"]
    A -- "Skill: shell commands, no MCP" --> S
    S -- "read-only by default" --> D[("MySQL")]

Why

  • Works in any agent. One install command for every MCP client, plus a skill for agents where MCP isn't allowed.

  • Safe by default. Read-only, enforced in three layers (see Safety).

  • Light on tokens. Results come back as compact JSON, capped at 500 rows.

Tool / command

Does

list_databases / databases

Databases visible to the configured user

list_tables / tables

Tables and views, with approximate row counts

describe_table / describe

SHOW CREATE TABLE: columns, indexes, foreign keys

query / query

One SQL statement → {columns, rows, truncated}

Needs uv and MySQL 5.7.8+ or 8.x.

Related MCP server: easy-mysql-mcp

Use it as an MCP server

Every MCP client runs the same command:

uvx --from git+https://github.com/aniketshukla1/mysql-mcp-lite mysql-mcp-lite

The first start downloads dependencies (about 10 seconds). If an agent shows the server as disconnected on its first launch, restart the agent. The examples below use a read-only user mcp_ro on database shop; swap in your values.

claude mcp add -s user mysql -e MYSQL_HOST=127.0.0.1 -e MYSQL_USER=mcp_ro -e MYSQL_PASSWORD=change-me -e MYSQL_DATABASE=shop -- uvx --from git+https://github.com/aniketshukla1/mysql-mcp-lite mysql-mcp-lite
codex mcp add mysql --env MYSQL_HOST=127.0.0.1 --env MYSQL_USER=mcp_ro --env MYSQL_PASSWORD=change-me --env MYSQL_DATABASE=shop -- uvx --from git+https://github.com/aniketshukla1/mysql-mcp-lite mysql-mcp-lite

They share one JSON shape:

{
  "mcpServers": {
    "mysql": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/aniketshukla1/mysql-mcp-lite", "mysql-mcp-lite"],
      "env": {
        "MYSQL_HOST": "127.0.0.1",
        "MYSQL_USER": "mcp_ro",
        "MYSQL_PASSWORD": "change-me",
        "MYSQL_DATABASE": "shop"
      }
    }
  }
}

Client

File

Note

Cursor

~/.cursor/mcp.json (all projects) or .cursor/mcp.json

cursor-agent: approve once with cursor-agent mcp enable mysql

Gemini CLI

~/.gemini/settings.json

Gemini turns MCP servers off in folders you haven't trusted

Claude Desktop

~/Library/Application Support/Claude/claude_desktop_config.json

If it can't find uvx, put the full path from which uvx in command

In opencode.json in the project, or ~/.config/opencode/opencode.json:

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "mysql": {
      "type": "local",
      "command": ["uvx", "--from", "git+https://github.com/aniketshukla1/mysql-mcp-lite", "mysql-mcp-lite"],
      "environment": {
        "MYSQL_HOST": "127.0.0.1",
        "MYSQL_USER": "mcp_ro",
        "MYSQL_PASSWORD": "change-me",
        "MYSQL_DATABASE": "shop"
      }
    }
  }
}

In .vscode/mcp.json:

{
  "servers": {
    "mysql": {
      "type": "stdio",
      "command": "uvx",
      "args": ["--from", "git+https://github.com/aniketshukla1/mysql-mcp-lite", "mysql-mcp-lite"],
      "env": { "MYSQL_HOST": "127.0.0.1", "MYSQL_USER": "mcp_ro", "MYSQL_PASSWORD": "change-me", "MYSQL_DATABASE": "shop" }
    }
  }
}

Checked: Claude Code, cursor-agent, Gemini CLI and OpenCode connected to the server from these configs, and Codex accepted its config. VS Code and Claude Desktop use their standard formats but weren't run.

The /mysql prompt

Clients that support MCP prompts show it as a command: /mcp__mysql__mysql in Claude Code, /mcp.mysql.mysql in VS Code, /mysql in Gemini CLI. Give it a question, such as top 5 customers by revenue last month; with no question it summarizes the database.

Use it as a skill (no MCP)

When an agent can't use MCP, the mysql skill teaches it to run the same operations as shell commands. Install it into the agents on your machine:

npx skills add aniketshukla1/mysql-mcp-lite

Or copy skills/mysql into your agent's skills folder by hand, for example ~/.claude/skills/mysql for Claude Code, where it becomes /mysql. Checked: with every MCP server turned off, Claude Code answered a question about the test database through this skill alone.

Then give the agent's environment your connection settings, for example in your shell profile:

export MYSQL_HOST=127.0.0.1 MYSQL_USER=mcp_ro MYSQL_PASSWORD=change-me MYSQL_DATABASE=shop

Optional: install the command once so the skill skips the uvx download step on each call.

uv tool install git+https://github.com/aniketshukla1/mysql-mcp-lite

Shell commands

The skill runs these, and you can too:

mysql-mcp-lite databases
mysql-mcp-lite tables -d shop
mysql-mcp-lite describe orders
mysql-mcp-lite query <<'SQL'
SELECT status, COUNT(*) AS n FROM orders GROUP BY status
SQL
{"columns":["status","n"],"rows":[["paid",42],["refunded",3]],"truncated":false}

With no command, mysql-mcp-lite runs the MCP server on stdio. Errors go to stderr with exit code 1.

Configuration

Env var

Default

Meaning

MYSQL_HOST

127.0.0.1

MYSQL_PORT

3306

MYSQL_USER

root

MYSQL_PASSWORD

empty

MYSQL_DATABASE

none

Default database for tables, describe and query

MYSQL_ALLOW_WRITE

off

true lets query run any statement, committed

MYSQL_MAX_ROWS

500

Rows returned per call; truncated: true when cut

MYSQL_TIMEOUT_MS

30000

Per-SELECT limit (MAX_EXECUTION_TIME)

Safety

Read-only mode stacks three layers:

  1. The statement must start with SELECT, SHOW, DESCRIBE, EXPLAIN, WITH, TABLE or VALUES, and INTO OUTFILE/DUMPFILE is rejected. One statement per call: SELECT 1; DROP … fails in MySQL.

  2. Every call runs inside START TRANSACTION READ ONLY and is rolled back, so DML that slips past layer 1 (such as WITH … DELETE) fails in MySQL.

  3. The real boundary: connect as a SELECT-only user.

CREATE USER 'mcp_ro'@'%' IDENTIFIED BY 'change-me';
GRANT SELECT, SHOW VIEW ON shop.* TO 'mcp_ro'@'%';

Project layout

src/mysql_mcp_lite/
├── db.py         shared core: connection, read-only guard, compact JSON
├── server.py     MCP server: 4 tools and the /mysql prompt
└── cli.py        the mysql-mcp-lite command: MCP server or shell commands
skills/mysql/     the Agent Skill (no MCP needed)
tests/            end-to-end test against a real MySQL
assets/           logo

Development

Start a throwaway MySQL, then run the end-to-end test:

docker run -d --name mysql-mcp-test -e MYSQL_ROOT_PASSWORD=testroot -p 127.0.0.1:33306:3306 mysql:8.4
uv run tests/test_e2e.py

It starts the MCP server the way an agent does and checks the 4 tools, the /mysql prompt, each read-only layer, write mode and truncation, then runs the skill's shell commands.

License

MIT

Available Tools

4 tools
describe_tableB
Read-only

Return the CREATE TABLE statement: columns, types, indexes and foreign keys.

Inputs: table (required), database.

list_databasesA
Read-only

List the databases visible to the configured MySQL user.

Inputs: no named parameters.

list_tablesA
Read-only

List tables and views in a database (default: MYSQL_DATABASE), with approximate row counts.

Inputs: database.

queryA
Read-only

Run one SQL statement. Returns JSON {columns, rows, truncated}: at most MYSQL_MAX_ROWS rows, truncated true when cut; writes return {rows_affected, last_insert_id}. Read-only (SELECT/SHOW/DESCRIBE/EXPLAIN/WITH) unless the server runs with MYSQL_ALLOW_WRITE=true.

Inputs: sql (required), database.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.8/5.0

    Scored across 4 tools

    Disambiguation5/5

    Each tool has a clear, non-overlapping role: list_databases scopes to the server, list_tables scopes to one database, describe_table details one table, and query executes SQL. An agent can pick correctly without hesitation, and the read-only/write gating on `query` is explicitly stated.

    Naming Consistency4/5

    list_databases, list_tables, describe_table follow a clean verb_noun pattern, with `query` being a single-verb outlier. That deviation is natural for a generic SQL execution tool and remains readable, so it is a minor inconsistency rather than a structural one.

    Tool Count5/5

    Four tools is a deliberately lean, well-scoped surface for a 'lite' MySQL server, and each one earns its place as a distinct discovery step. Nothing feels padded, and a generic `query` tool absorbs the long tail of operations without inflating the count.

    Completeness4/5

    Discovery (databases → tables → schema) plus arbitrary SQL execution covers the read-only exploration workflow end to end, including writes when MYSQL_ALLOW_WRITE is set. Minor gaps exist—no dedicated index/column listing, no EXPLAIN helper, and no separate DDL or transaction tools—but `query` lets an agent work around all of them.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to safely query MySQL databases with read-only access by default, supporting table listing, structure inspection, and SQL queries with optional write operation control.
      17 npm
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      Enables AI assistants to inspect and query a MySQL database through safe, structured tools, including schema discovery and read-only queries.
      9
      51 npm
      MIT
    • F
      license
      A
      quality
      B
      maintenance
      Enables AI assistants to connect to MySQL databases, execute read-only queries, list tables, and describe table schemas via MCP.
      10
      1
      -