loading…
Search for a command to run...
loading…
An MCP server for managing multiple MySQL and MariaDB database connections simultaneously, allowing users to run SQL queries and manage schemas through AI-power
An MCP server for managing multiple MySQL and MariaDB database connections simultaneously, allowing users to run SQL queries and manage schemas through AI-powered tools. It features dynamic connection management, persistent configuration, and granular tools for database, table, and index operations.
An MCP (Model Context Protocol) server for managing multiple MySQL and MariaDB database connections. Connect to any number of databases by name, run queries, manage schemas, and dynamically add or remove connections — all from your AI-powered IDE or CLI tool.
local-dev, staging, prod-readonly)execute tool for anything else? placeholders to prevent SQL injection~/.mysql-multi-mcp/connections.json and persist across sessions| Tool | Description |
|---|---|
add-connection |
Add a new named database connection (persists to config file) |
remove-connection |
Remove a connection and close its pool |
list-connections |
List all configured connections (passwords are never shown) |
test-connection |
Test connectivity and show the server version |
| Tool | Description |
|---|---|
query |
Run a SELECT query, returns rows as JSON with field names. Supports params for safe ? placeholders and limit to control row count (default: 1000, set to 0 for unlimited) |
execute |
Run any SQL statement (INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, etc.). Returns affectedRows and insertId. This is the catch-all — if a dedicated tool doesn't exist, use execute |
| Tool | Description |
|---|---|
list-databases |
Show all databases on the server |
create-database |
Create a new database (with optional charset and collation) |
drop-database |
Drop a database |
| Tool | Description |
|---|---|
list-tables |
List all tables in a database |
describe-table |
Show column names, types, keys, and defaults for a table |
create-table |
Create a table (takes a full CREATE TABLE SQL statement) |
alter-table |
Alter a table (takes a full ALTER TABLE SQL statement) |
drop-table |
Drop a table |
| Tool | Description |
|---|---|
create-index |
Create an index (takes a full CREATE INDEX SQL statement) |
drop-index |
Drop an index from a table |
Every tool that operates on a database takes a connection parameter — the name you gave the connection when you added it. There is no implicit "active connection" state, so there's no risk of accidentally running a query against the wrong database.
git clone https://github.com/pchimbolo/mysql-multi-mcp.git
cd mysql-multi-mcp
npm install
npm run build
After building (or if using npx from a published package), configure your MCP client to run the server. Below are setup instructions for popular tools.
No config file needed. Run this command in your terminal:
claude mcp add mysql-multi -- node /absolute/path/to/mysql-multi-mcp/dist/index.js
Or add it to your project's .mcp.json:
{
"mcpServers": {
"mysql-multi": {
"command": "node",
"args": ["/absolute/path/to/mysql-multi-mcp/dist/index.js"]
}
}
}
Add to your User Settings (settings.json) or Workspace Settings (.vscode/settings.json):
{
"mcp": {
"servers": {
"mysql-multi": {
"command": "node",
"args": ["/absolute/path/to/mysql-multi-mcp/dist/index.js"]
}
}
}
}
Alternatively, create a .vscode/mcp.json file in your project root:
{
"servers": {
"mysql-multi": {
"command": "node",
"args": ["/absolute/path/to/mysql-multi-mcp/dist/index.js"]
}
}
}
Create or edit .cursor/mcp.json in your project root:
{
"mcpServers": {
"mysql-multi": {
"command": "node",
"args": ["/absolute/path/to/mysql-multi-mcp/dist/index.js"]
}
}
}
Add to your Windsurf MCP config (~/.windsurf/mcp.json or via Windsurf Settings > MCP):
{
"mcpServers": {
"mysql-multi": {
"command": "node",
"args": ["/absolute/path/to/mysql-multi-mcp/dist/index.js"]
}
}
}
Edit your Claude Desktop config file:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.json{
"mcpServers": {
"mysql-multi": {
"command": "node",
"args": ["/absolute/path/to/mysql-multi-mcp/dist/index.js"]
}
}
}
Add to your OpenCode configuration (opencode.json or similar):
{
"mcpServers": {
"mysql-multi": {
"command": "node",
"args": ["/absolute/path/to/mysql-multi-mcp/dist/index.js"]
}
}
}
Note: Replace
/absolute/path/to/mysql-multi-mcp/dist/index.jswith the actual absolute path to the builtdist/index.jsfile on your system. On Windows, use forward slashes (e.g.C:/Users/you/mysql-multi-mcp/dist/index.js).
Database connections are stored in ~/.mysql-multi-mcp/connections.json. This file is created automatically on first run.
You can manage connections in two ways:
Ask your AI assistant to add a connection:
"Add a MySQL connection called
local-devat localhost:3306 with userrootand passwordsecret, default databasemyapp"
The AI will call the add-connection tool, and the connection is immediately available and persisted.
{
"connections": {
"local-dev": {
"host": "localhost",
"port": 3306,
"user": "root",
"password": "secret",
"database": "myapp_dev"
},
"staging": {
"host": "staging-db.example.com",
"port": 3306,
"user": "readonly",
"password": "pass123",
"database": "myapp_staging"
}
}
}
Fields:
| Field | Required | Description |
|---|---|---|
host |
Yes | Database hostname or IP |
port |
Yes | Database port (typically 3306) |
user |
Yes | Database username |
password |
Yes | Database password |
database |
No | Default database. If omitted, you must specify database on table/index tools, or use fully qualified table names. |
Once configured, you can ask your AI assistant things like:
list-connectionstest-connectionlist-tablesdescribe-tablequeryexecuteaudit_log on staging" — calls create-tableusers.email on local-dev" — calls create-indexprod-readonly at prod-db.example.com" — calls add-connectionAll tools return structured JSON:
| Tool Type | Response Shape |
|---|---|
query |
{ "rows": [...], "rowCount": N, "fields": ["col1", "col2"], "truncated": false } |
execute |
{ "affectedRows": N, "insertId": N, "message": "..." } |
test-connection |
{ "success": true, "message": "Connected to local-dev (MySQL 8.0.32)" } |
list-connections |
{ "connections": { "name": { "host", "port", "user", "database" } } } |
| DDL tools | { "success": true, "message": "..." } |
charset and collation parameters in create-database are validated against a strict allowlist ([a-zA-Z0-9_]) to prevent SQL injection through unquoted DDL clauses.query and execute tools support params (a positional array for ? placeholders) for safe value binding.~/.mysql-multi-mcp/connections.json. The file is created with 0600 permissions on Unix (owner read/write only). On Windows, it inherits the user directory's permissions. You are responsible for securing this file.list-connections tool never exposes passwords. Error messages from MySQL are passed through as-is (they do not contain passwords).ssh -L). The architecture is designed so SSH tunnel support can be added later without breaking changes.mysql2's default connection behavior. Custom CA certificates or client certificates are not yet configurable.query tool fetches all rows from MySQL and truncates in memory. Very large result sets will still consume memory before truncation. For large tables, add a LIMIT clause in your SQL.BEGIN/COMMIT/ROLLBACK session management. Each query/execute call uses its own connection from the pool. You can still run transaction statements via execute, but they must be self-contained.HEX() or TO_BASE64() in your SQL for binary columns.# Watch mode (recompile on changes)
npm run dev
# Build once
npm run build
# Run the server directly (for testing with MCP inspector, etc.)
npm start
Apache-2.0
Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"mysql-multi-mcp": {
"command": "npx",
"args": []
}
}
}