mysql-multi-mcp
Provides tools for managing MariaDB database connections, including executing SQL queries, managing schemas, and performing table and index operations.
Provides tools for managing MySQL database connections, including executing SQL queries, managing schemas, and performing table and index operations.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mysql-multi-mcpList all tables in my local-dev database"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mysql-multi-mcp
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.
Features
Multiple named connections — Connect to several MySQL/MariaDB databases simultaneously, each identified by a user-defined name (e.g.
local-dev,staging,prod-readonly)Dynamic connection management — Add, remove, test, and list connections at runtime without restarting the server
Full SQL support — Run any SQL statement: SELECT, INSERT, UPDATE, DELETE, TRUNCATE, and all DDL operations
16 granular tools — Dedicated tools for common operations (list tables, describe columns, create indexes, etc.) plus a catch-all
executetool for anything elseParameterized queries — Safe value binding via
?placeholders to prevent SQL injectionClient-side row limiting — SELECT queries return a maximum of 1000 rows by default (configurable per query, never modifies your SQL)
Persistent configuration — Connection details saved to
~/.mysql-multi-mcp/connections.jsonand persist across sessionsLazy connection pooling — Pools created on first use, cached for session lifetime, gracefully closed on shutdown
Works everywhere — Compatible with any MCP client: VS Code, Cursor, Windsurf, Claude Code, Claude Desktop, OpenCode, and more
Available Tools
Connection Management
Tool | Description |
| Add a new named database connection (persists to config file) |
| Remove a connection and close its pool |
| List all configured connections (passwords are never shown) |
| Test connectivity and show the server version |
SQL Operations
Tool | Description |
| Run a SELECT query, returns rows as JSON with field names. Supports |
| Run any SQL statement (INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, etc.). Returns |
Database Operations
Tool | Description |
| Show all databases on the server |
| Create a new database (with optional charset and collation) |
| Drop a database |
Table Operations
Tool | Description |
| List all tables in a database |
| Show column names, types, keys, and defaults for a table |
| Create a table (takes a full |
| Alter a table (takes a full |
| Drop a table |
Index Operations
Tool | Description |
| Create an index (takes a full |
| 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.
Installation
Prerequisites
Node.js 18 or later
npm
Access to one or more MySQL or MariaDB databases
From Source
git clone https://github.com/pchimbolo/mysql-multi-mcp.git
cd mysql-multi-mcp
npm install
npm run buildSetup by IDE / CLI Tool
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.jsOr 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:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%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).
Configuration
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:
1. Via MCP Tools (Recommended)
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.
2. Edit the Config File Directly
{
"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 |
| Yes | Database hostname or IP |
| Yes | Database port (typically 3306) |
| Yes | Database username |
| Yes | Database password |
| No | Default database. If omitted, you must specify |
Usage Examples
Once configured, you can ask your AI assistant things like:
"List all connections" — calls
list-connections"Test the staging connection" — calls
test-connection"Show me all tables in the local-dev database" — calls
list-tables"Describe the users table on staging" — calls
describe-table"Select the first 10 rows from orders on local-dev" — calls
query"Insert a new user into local-dev" — calls
execute"Create a new table called
audit_logon staging" — callscreate-table"Add an index on
users.emailon local-dev" — callscreate-index"Add a new connection called
prod-readonlyat prod-db.example.com" — callsadd-connection
Output Format
All tools return structured JSON:
Tool Type | Response Shape |
|
|
|
|
|
|
|
|
DDL tools |
|
Security Considerations
Identifier escaping: All user-supplied database, table, and index names are escaped using MySQL's backtick-doubling method before interpolation into SQL. This prevents identifier injection attacks where a crafted name could break out of the quoting context.
Charset/collation validation: The
charsetandcollationparameters increate-databaseare validated against a strict allowlist ([a-zA-Z0-9_]) to prevent SQL injection through unquoted DDL clauses.Parameterized queries: The
queryandexecutetools supportparams(a positional array for?placeholders) for safe value binding.Passwords in config: Stored in plaintext in
~/.mysql-multi-mcp/connections.json. The file is created with0600permissions on Unix (owner read/write only). On Windows, it inherits the user directory's permissions. You are responsible for securing this file.Passwords in output: The
list-connectionstool never exposes passwords. Error messages from MySQL are passed through as-is (they do not contain passwords).No SQL restrictions: This server is intentionally permissive — it's a power tool for developers. Any SQL statement that the connected database user has privileges to run can be executed. Security is delegated to MySQL's own permission system. Use read-only database users for connections where write access isn't needed.
Limitations / Potential Improvements
No SSH tunnel support — Only direct TCP connections are supported. If your database is behind a firewall, you'll need to set up an SSH tunnel externally (e.g. via
ssh -L). The architecture is designed so SSH tunnel support can be added later without breaking changes.No TLS/SSL configuration — The server uses
mysql2's default connection behavior. Custom CA certificates or client certificates are not yet configurable.Passwords stored in plaintext — There is no built-in secret management, encryption, or environment variable expansion. Protect the config file with filesystem permissions.
Config file concurrency — If multiple MCP server instances (e.g. one in VS Code and one in Claude Code) modify connections simultaneously, the last writer wins. This is fine for single-user use.
Connection pool size is fixed — Each connection uses a pool of 5 connections. This is not currently configurable per connection.
Row limit is client-side — The
querytool fetches all rows from MySQL and truncates in memory. Very large result sets will still consume memory before truncation. For large tables, add aLIMITclause in your SQL.No transaction support — There is no
BEGIN/COMMIT/ROLLBACKsession management. Each query/execute call uses its own connection from the pool. You can still run transaction statements viaexecute, but they must be self-contained.BLOB columns — Binary data in query results is returned as Buffer objects serialized to JSON, which may not be useful. Consider using
HEX()orTO_BASE64()in your SQL for binary columns.
Development
# Watch mode (recompile on changes)
npm run dev
# Build once
npm run build
# Run the server directly (for testing with MCP inspector, etc.)
npm startLicense
Apache-2.0
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/pchimbolo/mysql-multi-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server