mysql-mcp-lite
This MCP server lets an AI agent safely explore a MySQL database and run SQL, read-only by default.
List databases visible to the configured MySQL user.
List tables and views in a database, with approximate row counts.
Describe a table via SHOW CREATE TABLE, including columns, types, indexes, and foreign keys.
Run one SQL statement and get compact JSON with columns, rows, and truncation status; write results are possible only when MYSQL_ALLOW_WRITE=true.
Target operations at an optional database; results are capped by MYSQL_MAX_ROWS and protected by read-only safeguards.
Provides tools for interacting with MySQL databases, including listing databases and tables, describing table schemas, and running read-only SQL queries with configurable row limits and timeouts. Optionally supports write-mode queries when enabled.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mysql-mcp-lite show me the schema of the orders table in the shop database"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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 |
| Databases visible to the configured user |
| Tables and views, with approximate row counts |
|
|
| One SQL statement → |
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-liteThe 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-litecodex 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-liteThey 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 |
|
|
Gemini CLI |
| Gemini turns MCP servers off in folders you haven't trusted |
Claude Desktop |
| If it can't find |
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-liteOr 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=shopOptional: 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-liteShell 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 |
|
| |
|
| |
|
| |
| empty | |
| none | Default database for tables, describe and query |
| off |
|
|
| Rows returned per call; |
|
| Per-SELECT limit ( |
Safety
Read-only mode stacks three layers:
The statement must start with
SELECT,SHOW,DESCRIBE,EXPLAIN,WITH,TABLEorVALUES, andINTO OUTFILE/DUMPFILEis rejected. One statement per call:SELECT 1; DROP …fails in MySQL.Every call runs inside
START TRANSACTION READ ONLYand is rolled back, so DML that slips past layer 1 (such asWITH … DELETE) fails in MySQL.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/ logoDevelopment
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.4uv run tests/test_e2e.pyIt 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
Available Tools
4 toolsdescribe_tableBRead-only
Return the CREATE TABLE statement: columns, types, indexes and foreign keys.
Inputs: table (required), database.
list_databasesARead-only
List the databases visible to the configured MySQL user.
Inputs: no named parameters.
list_tablesARead-only
List tables and views in a database (default: MYSQL_DATABASE), with approximate row counts.
Inputs: database.
queryARead-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
Scored across 4 tools
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.
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.
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.
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
Related MCP Connectors
PostgreSQL, MySQL, and SQL Server in one session. 26 read-only MCP tools for AI agents.
Safe, read-only Postgres and MySQL access for AI agents. Audit log + column-level controls.
Read-only search of 2,189 AI agent tools (MCP servers, x402 APIs) with daily automated trust scores.
Guard AI agents' PostgreSQL/MySQL access via MCP: SQL audit, auth, masking, write approval
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables 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 npmMIT
- AlicenseAqualityCmaintenanceEnables AI assistants to inspect and query a MySQL database through safe, structured tools, including schema discovery and read-only queries.951 npmMIT
- AlicenseAqualityDmaintenanceEnables AI agents to explore MySQL database schemas and execute read-only queries through a safe, MCP interface.6ISC
- FlicenseAqualityBmaintenanceEnables AI assistants to connect to MySQL databases, execute read-only queries, list tables, and describe table schemas via MCP.101-