Get the FREE Ultimate OpenClaw Setup Guide →

mariadb

An MCP server that provides access to MariaDB ou MySQL databases.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio rjsalgado-mariadb-mcp-server npx mariadb-mcp-server \
  --env MARIADB_HOST="your-host" \
  --env MARIADB_PORT="3306" \
  --env MARIADB_USER="your-user" \
  --env MARIADB_DATABASE="your-database" \
  --env MARIADB_PASSWORD="your-password" \
  --env MARIADB_ROW_LIMIT="1000" \
  --env MARIADB_TIMEOUT_MS="10000" \
  --env MARIADB_ALLOW_DELETE="false" \
  --env MARIADB_ALLOW_INSERT="false" \
  --env MARIADB_ALLOW_UPDATE="false"

How to use

This MCP server provides controlled access to MariaDB and MySQL databases. It exposes tools that let you discover databases and tables, inspect table schemas, and run read-only SQL queries against the configured database server. Specifically, you can list databases with list_databases, view tables with list_tables, inspect a table's schema with describe_table, and execute safe read-only queries via execute_query. The server enforces security features such as read-only access by default, query validation to prevent injections, query timeouts to avoid long-running operations, and a row limit to cap data returned. To use it, configure the MCP settings to point to the mariadb-mcp-server, provide the appropriate connection details as environment variables, and invoke the available MCP tools as structured JSON payloads. The tools respond with results from the underlying MariaDB/MySQL instance, subject to the configured permissions and constraints.

How to install

Prerequisites:

  • Node.js and npm installed on the host
  • Access to a MariaDB/MySQL server

Option 1: Install from NPM (Recommended)

  1. Install globally
npm install -g mariadb-mcp-server
  1. Start the MCP server (example using npx as configured in MCP settings):
# In MCP settings, you would reference:
# command: "npx"
# args: ["mariadb-mcp-server"]

Option 2: Build from Source

  1. Clone the repository
git clone https://github.com/rjsalgado/mariadb-mcp-server.git
cd mariadb-mcp-server
  1. Install dependencies and build
npm install
npm run build

Configure environment variables (required):

  • MARIADB_HOST: Database server hostname
  • MARIADB_PORT: Database server port (default 3306)
  • MARIADB_USER: Database username
  • MARIADB_PASSWORD: Database password
  • MARIADB_DATABASE: Default database name (optional)
  • MARIADB_ALLOW_INSERT: false
  • MARIADB_ALLOW_UPDATE: false
  • MARIADB_ALLOW_DELETE: false
  • MARIADB_TIMEOUT_MS: 10000
  • MARIADB_ROW_LIMIT: 1000

Add to MCP settings (example provided in README):

{
  "mcpServers": {
    "mariadb": {
      "command": "npx",
      "args": ["mariadb-mcp-server"],
      "env": {
        "MARIADB_HOST": "your-host",
        "MARIADB_PORT": "3306",
        "MARIADB_USER": "your-user",
        "MARIADB_PASSWORD": "your-password",
        "MARIADB_DATABASE": "your-database",
        "MARIADB_ALLOW_INSERT": "false",
        "MARIADB_ALLOW_UPDATE": "false",
        "MARIADB_ALLOW_DELETE": "false",
        "MARIADB_TIMEOUT_MS": "10000",
        "MARIADB_ROW_LIMIT": "1000"
      },
      "disabled": false,
      "autoApprove": []
    }
  }
}

Note: If you build from source, replace the command/args and point to the built index.js as in the README.

Additional notes

Tips:

  • Ensure the MariaDB user has only read permissions if you want strict read-only access.
  • The MCP server defaults to SELECT, SHOW, DESCRIBE, and EXPLAIN commands; SQL statements that modify data should be avoided or blocked by the server configuration.
  • If you encounter connection issues, verify network access to MARIADB_HOST and that MARIADB_PORT is reachable.
  • Use MARIADB_TIMEOUT_MS to tune query timeouts for your environment, and MARIADB_ROW_LIMIT to prevent large data transfers.
  • For troubleshooting, check MCP logs for authentication, connection, and query validation messages.

Related MCP Servers

Sponsor this space

Reach thousands of developers