Registry / database / mysql-query-mcp-server

mysql-query-mcp-server

JSON →
library1.2.2jsnpmunverified

MySQL Query MCP Server v1.2.2 is a read-only MCP server for AI assistants (Cursor IDE, Windsurf, Claude Desktop) to execute MySQL queries and explore database structures via the Model Context Protocol. It supports SELECT, SHOW, DESCRIBE queries with SSL, timeouts, and predefined environments (local, development, staging, production). Released under MIT, it is actively maintained with a focus on AI-tool integration and security (read-only enforcement). Ships TypeScript types. Requires Node >=22.13.0.

npm install mysql-query-mcp-server
INSTALL
IMPORT
SIG · MYSQL-QUERY-MCP-SE
M
mysql-query-mcp-server
databasejavascriptv1.2.2
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.

default
import mysqlQueryMcpServer from 'mysql-query-mcp-server'
const mysqlQueryMcpServer = require('mysql-query-mcp-server')
Package is ESM-only. Require will throw an error.
runServer
import { runServer } from 'mysql-query-mcp-server'
Named export available for programmatic control.
DatabaseEnvironment
import type { DatabaseEnvironment } from 'mysql-query-mcp-server'
TypeScript type export for environment configuration.

Starts the MySQL MCP server programmatically with READ-ONLY local database access, awaiting AI assistant connections.

import { runServer } from 'mysql-query-mcp-server'; import { createServer } from 'net'; // Environment variable configuration for database connections // Must set at least one environment (LOCAL, DEVELOPMENT, STAGING, PRODUCTION) process.env.LOCAL_DB_HOST = process.env.LOCAL_DB_HOST ?? 'localhost'; process.env.LOCAL_DB_USER = process.env.LOCAL_DB_USER ?? 'root'; process.env.LOCAL_DB_PASS = process.env.LOCAL_DB_PASS ?? ''; process.env.LOCAL_DB_NAME = process.env.LOCAL_DB_NAME ?? 'mydb'; process.env.LOCAL_DB_PORT = process.env.LOCAL_DB_PORT ?? '3306'; async function start() { const server = await runServer({ transport: 'stdio', allowedEnvironments: ['local'], }); console.log('MySQL MCP server started. Ready for AI assistant connections.'); } start().catch(console.error);
Debug
Known issues
breakingRequires Node.js >=22.13.0. Older versions will fail with syntax errors or missing API.
fix
Upgrade Node.js to >=22.13.0 via nvm or official installer.
affects: <22.13.0
gotchaWrite operations (INSERT, UPDATE, DELETE) are silently rejected. The server only allows SELECT, SHOW, DESCRIBE.
fix
Ensure your queries are read-only. If you need write access, this server is intentionally restrictive.
affects: all
gotchaEnvironment names are limited to local, development, staging, production. Custom names not supported.
fix
Use one of the predefined environment variable prefixes (LOCAL_, DEVELOPMENT_, STAGING_, PRODUCTION_).
affects: all
deprecatedUsing MCP_MYSQL_REJECT_UNAUTHORIZED=false disables SSL certificate validation, which is insecure in production.
fix
Set MCP_MYSQL_REJECT_UNAUTHORIZED=true in production and ensure your DB server has a valid SSL certificate.
affects: all
Errors
Common errors & fixes
Error: Environment variable LOCAL_DB_HOST is not set
Missing required environment variable for the 'local' environment.
fix
Set LOCAL_DB_HOST in your MCP configuration or environment variables.
Error: Cannot find module 'mysql-query-mcp-server'
Package not installed or not in Node's module resolution path.
fix
Install globally: npm install -g mysql-query-mcp-server, or run with npx.
Error: Query rejected: INSERT INTO users ... is not allowed
Attempted a write operation which is blocked by read-only enforcement.
fix
Only use SELECT, SHOW, or DESCRIBE queries.
Error: read ECONNRESET
Database connection closed unexpectedly, often due to timeout or firewall.
fix
Check database server availability, port, and SSL settings. Increase MYSQL_TIMEOUT if applicable.
Upgrade
Version history
1.2.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Resources
mysql-query-mcp-server — npm install mysql-query-mcp-server · libregistry