home / mcp / mariadb / mysql database access mcp server
MCP Server for MariaDB
Configuration
View docs{
"mcpServers": {
"bretoreta-mariadb-mcp-server": {
"command": "node",
"args": [
"/path/to/mariadb-mcp-server/dist/index.js"
],
"env": {
"MARIADB_HOST": "your-host",
"MARIADB_PORT": "3306",
"MARIADB_USER": "your-user",
"MARIADB_DATABASE": "your-default-database",
"MARIADB_PASSWORD": "your-password",
"MARIADB_ROW_LIMIT": "1000",
"MARIADB_TIMEOUT_MS": "10000",
"MARIADB_ALLOW_DELETE": "false",
"MARIADB_ALLOW_INSERT": "false",
"MARIADB_ALLOW_UPDATE": "false"
}
}
}
}This MCP server gives you read-only access to MariaDB and MySQL databases, enabling you to list databases and tables, inspect table schemas, and run safe queries with built-in protections against modification attempts.
Connect to the MariaDB / MySQL MCP server using your MCP client. You can perform the following actions: list available databases, list tables in a database, describe a table’s schema, and execute read-only SQL queries. The server enforces read-only access by default and validates queries to prevent SQL injection and unintended data modifications. If you need to review result sizes or prevent long-running work, you can rely on the row limit and query timeout protections.
Prerequisites: install Node.js (LTS version) and a package manager. This server uses a standard Node runtime and is built from source.
# Clone the MCP server repository
git clone https://github.com/bretoreta/mariadb-mcp-server.git
cd mariadb-mcp-server
# Install dependencies and build
pnpm install
pnpm run buildPrepare the required environment variables to connect to your MariaDB / MySQL instance. Provide these values in the environment when starting the MCP server.
{
"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": []
}
}
}Read-only access is the default, allowing only SELECT, SHOW, DESCRIBE, and EXPLAIN operations. Queries undergo validation to help prevent SQL injection and any data modification attempts are blocked. A query timeout prevents long-running queries from consuming resources, and a row limit controls the amount of data returned in a single response.
When you configure access, ensure your user has the appropriate permissions for the intended read-only operations. Use the provided environment variables to connect to the database, and respect the default database when none is specified in a request.
Lists all accessible databases on the MariaDB / MySQL server.
Lists all tables in a specified database, using the default database if none is provided.
Shows the schema for a specific table, including column types and constraints.
Executes a SQL query with optional database context, returning results for read-only statements.