Get the FREE Ultimate OpenClaw Setup Guide →

mariadb

MCP Server for MariaDB

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio bretoreta-mariadb-mcp-server node /path/to/mariadb-mcp-server/dist/index.js \
  --env MARIADB_HOST="your-host" \
  --env MARIADB_PORT="3306" \
  --env MARIADB_USER="your-user" \
  --env MARIADB_DATABASE="your-default-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 read-only access to a MariaDB or MySQL database. It exposes tools to list databases, list tables within a database, describe table schemas, and execute SQL queries in a controlled, read-only fashion. The server enforces query validation, a timeout to prevent long-running operations, and a row limit to avoid returning excessive data. Clients interact with the server via the available tools (list_databases, list_tables, describe_table, execute_query) using JSON-RPC style requests as shown in the examples. By default, only SELECT, SHOW, DESCRIBE, and EXPLAIN statements are allowed, with insert/update/delete disallowed unless explicitly configured otherwise.

How to install

Prerequisites:

  • Node.js installed on the host (version compatible with the server)
  • Git installed
  • Access to a running MariaDB/MySQL instance

Install from source:

  1. Clone the repository git clone https://github.com/bretoreta/mariadb-mcp-server.git cd mariadb-mcp-server

  2. Install dependencies and build pnpm install pnpm run build

  3. Prepare environment variables (example values shown below). Create a runtime environment or a .env file with these values: MARIADB_HOST=your-host MARIADB_PORT=3306 MARIADB_USER=your-user MARIADB_PASSWORD=your-password MARIADB_DATABASE=your-default-database MARIADB_ALLOW_INSERT=false MARIADB_ALLOW_UPDATE=false MARIADB_ALLOW_DELETE=false MARIADB_TIMEOUT_MS=10000 MARIADB_ROW_LIMIT=1000

  4. Add to MCP settings (example configuration): { "mcpServers": { "mariadb": { "command": "node", "args": ["/path/to/mariadb-mcp-server/dist/index.js"], "env": { "MARIADB_HOST": "your-host", "MARIADB_PORT": "3306", "MARIADB_USER": "your-user", "MARIADB_PASSWORD": "your-password", "MARIADB_DATABASE": "your-default-database", "MARIADB_ALLOW_INSERT": "false", "MARIADB_ALLOW_UPDATE": "false", "MARIADB_ALLOW_DELETE": "false", "MARIADB_TIMEOUT_MS": "10000", "MARIADB_ROW_LIMIT": "1000" }, "disabled": false, "autoApprove": [] } } }

Additional notes

Tips and caveats:

  • The server is configured for read-only access by default; attempting to run INSERT, UPDATE, or DELETE queries will be blocked unless you explicitly adjust the environment variables.
  • Ensure your MariaDB user has the necessary network access and privileges to list databases, show tables, and describe schemas.
  • If you encounter timeouts, consider increasing MARIADB_TIMEOUT_MS or adjusting MARIADB_ROW_LIMIT to suit your data size.
  • Use the execute_query tool with carefully constructed SELECT statements to fetch only the needed data and avoid excessive payloads.
  • When deploying in production, consider securing the MCP endpoint and rotating credentials regularly.

Related MCP Servers

Sponsor this space

Reach thousands of developers