Skip to main content
Glama
mysql-mcp-lite

mysql-mcp-lite

mysql-mcp-lite

MySQL for any AI agent: one MCP server, one install command. Works in Claude Code, Codex, Cursor, OpenCode, Gemini CLI, VS Code, Claude Desktop and any other MCP client.

Tool

Does

list_databases

Databases visible to the configured user

list_tables(database?)

Tables and views, with approximate row counts

describe_table(table, database?)

SHOW CREATE TABLE: columns, indexes, foreign keys

query(sql, database?)

One statement → compact JSON {columns, rows, truncated}

Plus a /mysql prompt: ask in plain words, and the agent reads the schema and writes the SQL.

Read-only by default. Needs uv and MySQL 5.7.8+ / 8.x.

Install

Every agent runs the same command:

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

From a local clone, give the folder instead: uvx --from /path/to/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 use a read-only user mcp_ro on database shop (see Safety). Swap in your values.

Claude Code

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

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

Cursor, Gemini CLI, Claude Desktop and most other clients

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

OpenCode

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"
      }
    }
  }
}

VS Code

.vscode/mcp.json, the same fields under servers:

{
  "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.

Related MCP server: easy-mysql-mcp

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.

Config

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 list_tables, describe_table, 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; 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 (e.g. 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'@'%';

Develop

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

Starts mysql_mcp_lite.py over stdio the way an agent does, then checks the 4 tools, the /mysql prompt, each read-only layer, write mode and truncation against a real MySQL.

License

MIT

Available Tools

4 tools
describe_tableB
Read-only

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

NameRequiredDescriptionDefault
tableYes
databaseNo

TDQS

B3.3/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

readOnlyHint=true already tells the agent this is a safe non-mutating call, so the bar is lower. The description does add real value by disclosing exactly what the payload contains (columns, types, indexes, foreign keys). It says nothing about failure behavior for a nonexistent table, dialect-specific DDL formatting, or whether the statement is reconstructed vs. stored.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single sentence, front-loaded with the returned artifact and followed by the enumerated contents. No filler, no restatement of the tool name, nothing to cut.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With only two parameters, no output schema, and a read-only annotation, the surface area is small, and the return-content clause covers the most important unknown. The remaining gap is parameter meaning — particularly how to disambiguate a table across databases — which an agent needs in order to call this correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%: neither `table` nor `database` carries any documentation. The description supplies none either, leaving open whether `table` accepts a qualified name, whether case matters, and what omitting the nullable `database` defaults to. With zero coverage the description was the only place to compensate, and it does not.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

Names a specific verb and resource ('Return the CREATE TABLE statement') and enumerates the content returned: columns, types, indexes, foreign keys. That is far more informative than a tautology. It stops short of contrasting itself with list_tables or query, though the DDL-returning nature makes it implicitly distinct.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There is no explicit when-to-use statement, no prerequisites, and no named alternative such as 'use list_tables to enumerate tables first' or 'use query to inspect rows'. The use case (inspecting a single table's structure) is strongly implied by the description but left to inference.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_databasesA
Read-only

List the databases visible to the configured MySQL user.

NameRequiredDescriptionDefault

No parameters

TDQS

A3.7/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true, so the safety profile is covered. The description adds real behavioral context in saying the results are limited to what the configured MySQL user can see, but it says nothing about the returned shape (names only?) or ordering, and there is no output schema to fill that gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

One front-loaded sentence with no filler; the scope qualifier follows the verb-resource statement rather than burying it. Nothing could be removed without losing information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a zero-parameter, read-only listing tool this is nearly sufficient: purpose and privilege scoping are clear and annotations cover safety. The only shortfall is that with no output schema, a brief note on what the list contains (database names) would fully close the loop.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool takes zero parameters, so there is no parameter semantics to explain and the baseline of 4 applies. The description correctly implies the call needs no arguments.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('List the databases') and adds a scoping qualifier ('visible to the configured MySQL user') that tells the agent the result is privilege-dependent. The resource is distinct enough from siblings list_tables and describe_table that no explicit contrast is needed, though the description never names them.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Usage is only implied: an agent can infer this is a discovery step before calling list_tables or query, but the description never says so or states any precondition. No when-not-to-use or alternative routing is provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_tablesA
Read-only

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

NameRequiredDescriptionDefault
databaseNo

TDQS

A3.9/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

readOnlyHint=true already covers the safety profile, and the description adds two useful facts beyond it: that views are included alongside tables, and that row counts are approximate rather than exact. It still omits cost/pagination behavior for large schemas, which keeps it from a 5.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single sentence that front-loads the action, resource, and default, with no redundant or filler wording.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple read-only listing tool with annotations and no output schema, the definition covers scope, defaults, and return fidelity adequately. Only the shape of the returned rows (name, type, row count columns) is left implicit.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage and a single optional parameter, the description supplies the missing meaning by naming the default database (MYSQL_DATABASE). This is exactly the compensation needed, though it does not explain the expected string format or how an unknown database is reported.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb and resource ('List tables and views in a database') plus a scope detail (approximate row counts), which clearly separates it from list_databases and describe_table. It does not name a sibling explicitly, so it falls short of a 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Usage is implied rather than stated: an agent can infer this is the schema-discovery step before describe_table or query. There is no explicit 'use this instead of X when Y' guidance or statement of prerequisites.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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.

NameRequiredDescriptionDefault
sqlYes
databaseNo

TDQS

A3.8/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Beyond the annotations, it discloses truncation behavior at MYSQL_MAX_ROWS and the different return shape for writes ({rows_affected, last_insert_id}), both of which an agent needs to reason about result handling. The caveat that writes are possible when the server runs with MYSQL_ALLOW_WRITE=true adds context the readOnlyHint annotation cannot express, though it sits in mild tension with a blanket readOnlyHint=true; it does not contradict the annotation for the default configuration. Missing: error behavior and whether multi-statement input is rejected.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two dense sentences plus a conditional clause; return shape and truncation semantics are front-loaded before the read-only caveat. Nothing is filler and no sentence merely restates the tool name.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no output schema, the description carries the burden of describing returns and does so for both read and write paths, including the truncation flag. It falls short only on the `database` parameter and on failure modes, which are meaningful for a tool that executes arbitrary SQL.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate for two undocumented parameters, and it only partially does. 'One SQL statement' usefully constrains the `sql` parameter's expected shape, but the `database` parameter (default null) is never explained at all — an agent must guess whether it overrides the session's current database.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb and resource ('Run one SQL statement'), which is unambiguous and clearly distinct in kind from the schema-introspection siblings list_databases/list_tables/describe_table. It never explicitly names those siblings as alternatives, but the gulf between 'arbitrary SQL' and 'enumerate schema objects' is large enough that an agent will not confuse them.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It gives a real constraint ('one SQL statement', read-only unless MYSQL_ALLOW_WRITE=true), which implicitly tells the agent this is the general-purpose path. However, it offers no explicit routing such as 'use describe_table instead of DESCRIBE via SQL', leaving the agent to infer when to prefer the specialized siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

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

  1. 4 tool updatesv0.1.0
    • First observeddescribe_table
    • First observedlist_databases
    • First observedlist_tables
    • First observedquery

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.
    11 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
    57 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
    -