Registry / database / mysql-readonly-mcp

mysql-readonly-mcp

JSON →
library1.0.7jsnpmunverified

A Model Context Protocol (MCP) server providing secure, read-only access to a single MySQL database. Version 1.0.7 enables MCP clients (Claude Desktop, editor integrations) to inspect schema, preview data, and run analytical queries without mutation risk. Key differentiators: built-in query validation and row limits (prevents dangerous queries), schema inspection tools (list_tables, describe_table, show_relations), and multi-instance support for multiple databases. Configurable via environment variables with a 1-second minimum query timeout.

npm install mysql-readonly-mcp
INSTALL
IMPORT
SIG · MYSQL-READONLY-MCP
M
mysql-readonly-mcp
databasejavascriptv1.0.7
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

mysql-readonly-mcp
npx -y mysql-readonly-mcp
node path/to/mysql-readonly-mcp/dist/index.js
MCP servers are run as CLI commands, not imported as modules. Use npx for isolation; do not point to local checkout.

Configures MCP client to run the MySQL read-only server securely using npx and environment variables for credentials.

{ "mcpServers": { "mysql-production": { "command": "npx", "args": ["-y", "mysql-readonly-mcp"], "env": { "MYSQL_HOST": "localhost", "MYSQL_PORT": "3306", "MYSQL_USER": "readonly_user", "MYSQL_PASSWORD": "your-password", "MYSQL_DATABASE": "production_db" } } } }
Debug
Known issues
gotchaDo not point MCP clients to a local repository checkout (e.g., /path/to/mysql-readonly-mcp/dist/index.js). Some clients may treat it as part of the active workspace, causing unintended file access.
fix
Use npx -y mysql-readonly-mcp or globally installed binary in MCP configuration.
affects: all
gotchaSingle database per instance; to connect to multiple databases, you must configure separate MCP server entries with different MYSQL_DATABASE values.
fix
Add one MCP server entry per database under mcpServers.
affects: all
gotchaMYSQL_QUERY_TIMEOUT_MS has a minimum of 1000 ms; setting it lower will be ignored or cause errors.
fix
Ensure timeout value >= 1000.
affects: all
gotchaThe server enforces read-only queries; any write operation (INSERT, UPDATE, DELETE, DROP, etc.) will be rejected.
fix
Use only SELECT, SHOW, DESCRIBE, EXPLAIN, or other read-only statements.
affects: all
Errors
Common errors & fixes
Error: MYSQL_HOST is not set
Environment variable MYSQL_HOST missing or empty.
fix
Set MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, and MYSQL_DATABASE in the MCP client configuration env block.
Error: Client closed during shutdown
Connection to MySQL failed or credentials are invalid.
fix
Verify MySQL credentials, host, port, and ensure MySQL is running and accessible.
Error: Query timeout exceeded
Query ran longer than MYSQL_QUERY_TIMEOUT_MS (default 30000 ms).
fix
Optimize the query or increase MYSQL_QUERY_TIMEOUT_MS (minimum 1000).
Error: Write statements are not permitted
Attempted to execute INSERT, UPDATE, DELETE, or other write query.
fix
Use only read-only SQL queries (SELECT, SHOW, DESCRIBE, etc.).
Upgrade
Version history
1.0.7latest on npm
Audit
Dependencies
noderequiredRequires Node.js >=18.0.0 to run
Agent activity
6 hits · last 30 days
node
6
Resources
mysql-readonly-mcp — npm install mysql-readonly-mcp · libregistry