mcpField
M
mariadb-mcp

mariadb-mcp

github.com/mariadbData & databases17157 installsUpdated 2w ago
Repository

About mariadb-mcp

An open-source MCP server maintained by the MariaDB Foundation, giving AI agents access to MariaDB schemas, read-only queries, and optional vector search. It is for developers who want agents to access database data without writing an integration themselves.

Key features

  1. 01List databases and tables
  2. 02Read table schemas and foreign key relations
  3. 03Run read-only SQL queries
  4. 04Create databases
  5. 05Optionally manage vector stores and semantic search

Use cases

  1. 01Let an AI agent inspect MariaDB schemas
  2. 02Query database contents through an agent
  3. 03Prototype RAG with stored documents
  4. 04Manage vector stores through an agent

MCP support

This MCP server exposes database browsing, read-only SQL, database creation, and optional vector search tools to MCP clients.

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/mariadb/skills --skill mariadb-mcp

After installing, type/mariadb-mcpin Claude Code to confirm it loaded.

Details

From the project README

MariaDB MCP Server

Last updated: 2026-05-25

The Model Context Protocol (MCP) lets AI agents connect to external tools and data sources. The MariaDB MCP Server gives agents direct, controlled access to a MariaDB database — reading schemas, running queries, and optionally performing vector/semantic search — without requiring the developer to write integration code.

The server is open source (MIT), maintained by the MariaDB Foundation at github.com/MariaDB/mcp.

Requires: Python 3.11+, uv package manager, MariaDB server.

What Agents Can Do

With the MariaDB MCP Server connected, an agent can:

  • List databases and tables
  • Read table schemas including foreign key relationships
  • Run read-only SQL queries (SELECT, SHOW, DESCRIBE)
  • Create databases
  • Perform semantic/vector search on stored documents (when embedding provider is configured)

Write operations (INSERT, UPDATE, DELETE) are disabled by default.

Installation

git clone https://github.com/MariaDB/mcp
cd mcp
cp .env.example .env
# Edit .env with your database credentials

Minimum .env configuration:

DB_HOST=127.0.0.1
DB_PORT=3306
DB_USER=myuser
DB_PASSWORD=mypassword
DB_NAME=mydatabase
MCP_READ_ONLY=true

Run the server:

uv run server.py

Connecting Claude Code, Cursor, or Windsurf

Use the official server from a local clone (see Installation). Point your MCP config at uv run server.py and the .env file with database credentials.

Claude Code (project-scoped .mcp.json at the repo root):

{
  "mcpServers": {
    "mariadb": {
      "command": "uv",
      "args": [
        "--directory",
        "/absolute/path/to/mcp",
        "run",
        "server.py"
      ],
      "envFile": "/absolute/path/to/mcp/.env"
    }
  }
}

Or add via CLI (replace paths):

claude mcp add mariadb -- uv --directory /absolute/path/to/mcp run server.py

Cursor / VS Code — same mcpServers block in MCP settings; use absolute paths.

SSE or HTTP — run uv run server.py --transport sse (or http) and connect to the URL; see MariaDB/mcp README — Integration.

Not official: PyPI package mcp-server-mariadb (uvx mcp-server-mariadb) is a third-party project, not maintained by the MariaDB Foundation. Prefer github.com/MariaDB/mcp unless you have a specific reason to use the PyPI package.

Available Tools

ToolWhat it does
list_databasesLists all databases the user can access
list_tablesLists tables in a database
get_table_schemaReturns column definitions and types
get_table_schema_with_relationsIncludes foreign key relationships
execute_sqlRuns a read-only SQL query
create_databaseCreates a new database

Vector & Semantic Search (Optional)

When an embedding provider is configured, additional tools are available for building RAG pipelines directly through the MCP interface:

ToolWhat it does
create_vector_storeCreates a vector store table
insert_docs_vector_storeEmbeds and stores documents
search_vector_storeSemantic similarity search
list_vector_storesLists available vector stores
delete_vector_storeRemoves a vector store

Configure an embedding provider in .env:

EMBEDDING_PROVIDER=openai   # or gemini or huggingface
OPENAI_API_KEY=sk-...

For building pure vector search applications, using MariaDB's native VECTOR type and VEC_DISTANCE_* functions directly is more efficient. The MCP vector tools are useful for quick prototyping and when AI agents need to manage the vector store themselves. See the mariadb-vector skill for native vector SQL.

Security: Read-Only Access

The MCP_READ_ONLY=true setting enforces read-only at the application level by filtering queries. For production or shared environments, also restrict at the database level:

CREATE USER 'mcp_agent'@'localhost' IDENTIFIED BY 'password';
GRANT SELECT, SHOW DATABASES ON *.* TO 'mcp_agent'@'localhost';
-- Do NOT grant INSERT, UPDATE, DELETE, DROP

Application-level read-only alone is not sufficient — database-level privileges are the reliable guarantee.

Key Gotchas

  • uv is required: the MCP server uses uv for dependency management, not pip directly. Install: pip install uv or brew install uv.
  • Read-only is not fully enforced in software: rely on database-level privileges, not just MCP_READ_ONLY=true.
  • Vector tools are disabled until EMBEDDING_PROVIDER is set in .env.
  • Connection pooling defaults to 10 connections — tune MCP_MAX_POOL_SIZE for concurrent agent use.
  • SSL/TLS: configure DB_SSL_CA, DB_SSL_CERT, DB_SSL_KEY in .env for remote or production databases.
  • Enterprise version: MariaDB also offers a MariaDB Enterprise MCP Server with additional access control and multi-agent features. See mariadb.com/products/mcp-server.

Sources

For topics not covered here, see the official MariaDB documentation at mariadb.com/docs.

Comments

Markdown supported