Registry / database / mysql-mcp

mysql-mcp

JSON →
library1.1.1jsnpmunverified

A Model Context Protocol (MCP) server for executing SELECT queries against MySQL databases. Version 1.1.1, released as an npm package. It is implemented in TypeScript and enforces a security-restricted scope (SELECT-only) to prevent data mutations. The server runs as a stdio-based MCP tool, configurable via environment variables. It is intended for AI agents (e.g., VS Code Copilot) to query databases safely. Differentiators: focuses exclusively on read-only queries, easy integration with MCP-compatible IDEs, and simple environment-based configuration without external configuration files.

npm install mysql-mcp
INSTALL
IMPORT
SIG · MYSQL-MCP
M
mysql-mcp
databasejavascriptv1.1.1
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.

(server binary)
npx -y mysql-mcp@latest
npm install -g mysql-mcp && mysql-client
This package is a CLI/server, not a library to import. Run via npx or install globally then execute 'mysql-client'.

Run the MCP server with environment variables for database connection, allowing AI agents to execute SELECT queries.

MYSQL_HOST=localhost MYSQL_PORT=3306 MYSQL_USER=root MYSQL_PASSWORD=password MYSQL_DATABASE=test npx -y mysql-mcp@latest
Debug
Known issues
breakingPackage splits into separate mysql-client vs mysql-mcp packages; version pinning required to avoid mismatch.
fix
Always pin the same version for both packages: use `mysql-mcp@1.0.2` and `mysql-client@1.0.2`.
affects: >=1.0.0
gotchaOnly SELECT queries are allowed; any DML (INSERT, UPDATE, DELETE) will be rejected.
fix
Review your queries before execution; use the server only for read-only operations.
affects: >=1.0.0
gotchaDatabase credentials are expected via environment variables; missing variables cause connection failures.
fix
Ensure MYSQL_HOST, MYSQL_PORT, MYSQL_USER, MYSQL_PASSWORD, and MYSQL_DATABASE are set.
affects: >=1.0.0
deprecatedVersion pinning to 1.0.1 or 1.0.2 is no longer recommended; use the latest version via `npx -y mysql-mcp@latest`.
fix
Update to latest version by using `npx -y mysql-mcp@latest`.
affects: <=1.0.2
Errors
Common errors & fixes
Error: Cannot find module 'mysql2'
Missing dependency when running locally without installing.
fix
Run `npm install` in the package directory or use `npx -y mysql-mcp` to auto-install.
Error: connect ECONNREFUSED 127.0.0.1:3306
MySQL server not running or wrong host/port.
fix
Start your MySQL service and verify MYSQL_HOST and MYSQL_PORT env vars.
Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'localhost'
Invalid credentials.
fix
Check MYSQL_USER and MYSQL_PASSWORD environment variables.
Error: Only SELECT queries are allowed
Attempted to execute a non-SELECT SQL statement.
fix
Only use SELECT statements with this server.
Upgrade
Version history
1.1.1latest on npm
Audit
Dependencies
mysql2requiredUsed to connect and query MySQL databases.
Agent activity
5 hits · last 30 days
node
4
Resources
mysql-mcp — npm install mysql-mcp · libregistry