Read-only MySQL tools for xmcp
. Connect via a connection-string env var; all operations are read-only.
- Node 20+
- pnpm
pnpm i
pnpm build
Set one of (first found wins): MYSQL_URL
, MYSQL_CONNECTION_STRING
, or DATABASE_URL
.
export MYSQL_URL="mysql://user:password@localhost:3306/mydb"
Add to your mcp.json
(use an absolute path to dist/stdio.js
):
{
"mcpServers": {
"mysql-reader": {
"command": "node",
"args": ["/ABSOLUTE/PATH/TO/mysql-reader/dist/stdio.js"],
"env": { "MYSQL_URL": "mysql://user:password@host:3306/db" }
}
}
}
pnpm dev
Then point your MCP client to http://localhost:3002/mcp
and provide the same env var.
mysql.listDatabases(includeSystem=false)
— list databasesmysql.listTables(database, includeViews=true)
— list tables/viewsmysql.getTableSchema(database, table)
— columns/constraints/indexesmysql.previewTable(database, table, limit=50, orderBy?)
— sample rowsmysql.query(sql, params?)
— read-only SQL (SELECT/SHOW/DESC/EXPLAIN/WITH)mysql.explainQuery(sql)
— EXPLAIN a SELECT
Read-only is enforced via session settings and SQL guards.
Docs: xmcp docs