Registry / database / dynamic-mysql-mcp

dynamic-mysql-mcp

JSON →
library2.0.1jsnpmunverified

A Model Context Protocol (MCP) server for MySQL that enables AI assistants to query and mutate MySQL data at runtime. Version 2.0.1 requires Node >=18 and ships TypeScript types. Unlike static MySQL MCP servers that require credentials at startup, this server accepts authentication at runtime via the auth_mysql tool, allowing dynamic switching between databases and environments without restart. It provides 13 tools including row operations (select_rows, insert_row, update_rows, delete_rows), schema discovery, and custom SQL execution with parameterized queries.

npm install dynamic-mysql-mcp
INSTALL
IMPORT
SIG · DYNAMIC-MYSQL-MCP
D
dynamic-mysql-mcp
databasejavascriptv2.0.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.

default
import Server from 'dynamic-mysql-mcp'
const Server = require('dynamic-mysql-mcp')
ESM-only package; no CommonJS support. Use 'import' syntax.
MCPMySQLServer
import { MCPMySQLServer } from 'dynamic-mysql-mcp'
import { Server } from 'dynamic-mysql-mcp'
Main class export name is MCPMySQLServer, not Server. Check docs for exact named export.
MySQLTool
import { MySQLTool } from 'dynamic-mysql-mcp'
Type export for Tool type, only available in TypeScript.
version
import { version } from 'dynamic-mysql-mcp'
String constant for the package version.

Creates and starts the MCP server programmatically, which then listens for MCP client connections.

import { MCPMySQLServer } from 'dynamic-mysql-mcp'; const server = new MCPMySQLServer(); await server.start(); // Then connect via MCP client // Example: npx dynamic-mysql-mcp
Debug
Known issues
gotchaThe MCP server does not accept credentials at startup; auth must be called via the auth_mysql tool, or tools will fail with 'No authenticated connection'.
fix
Call auth_mysql tool with host/user/password before using other tools.
affects: >=2.0.0
breakingIn version 2.0.0, the package switched to ESM-only and dropped CommonJS support. require() will throw a runtime error.
fix
Use import syntax and ensure your project is configured for ESM (e.g., type: 'module' in package.json).
affects: >=2.0.0
deprecatedThe execute_sql tool allows raw SQL execution and bypasses ORM-style safety checks.
fix
Use parameterized queries with the 'params' option to prevent SQL injection; avoid executing DDL or DROP statements.
affects: all
gotchaThe server does not support SSL/TLS by default; connections are unencrypted unless you pass ssl options to auth_mysql.
fix
Pass an ssl object with necessary CA/cert keys to auth_mysql for encrypted connections.
affects: all
gotchaThe logout tool disconnects the current auth session, requiring re-authentication to use tools again.
fix
Only call logout when you intend to end the session; otherwise, the session persists until logout or server restart.
affects: >=2.0.0
Errors
Common errors & fixes
Error: Cannot find module 'dynamic-mysql-mcp' Require stack: - /path/to/app.js
Running a CommonJS require() on an ESM-only package.
fix
Switch to ESM: add 'type': 'module' in package.json, or rename file to .mjs and use import syntax.
No authenticated connection. Use auth_mysql tool first.
Attempting to use a MySQL tool before calling auth_mysql.
fix
Call auth_mysql with valid credentials before using any data access tools.
ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server
MySQL server uses caching_sha2_password and the mysql2 driver may need updated auth plugin.
fix
Enable 'mysql_native_password' on the MySQL user, or upgrade the mysql2 library to latest version.
Error: getaddrinfo ENOTFOUND hostname
The host provided to auth_mysql is unreachable or misspelled.
fix
Verify the hostname and ensure the MySQL server is running and accessible from the MCP server host.
Upgrade
Version history
2.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
20 hits · last 30 days
node
18
OpenAI (training)
1
Resources
dynamic-mysql-mcp — npm install dynamic-mysql-mcp · libregistry