MariaDB MCP Server

Local setup required. This server has to be cloned and prepared on your machine before you register it in Claude Code.
1

Set the server up locally

Run this once to clone and prepare the server before adding it to Claude Code.

Run in terminal
git clone https://github.com/MariaDB/mcp
cd mcp

Then follow the repository README for any remaining dependency or build steps before continuing.

2

Register it in Claude Code

After the local setup is done, run this command to point Claude Code at the built server.

Run in terminal
claude mcp add mariadb-mcp -- python "<FULL_PATH_TO_MCP>/dist/index.js"

Replace <FULL_PATH_TO_MCP>/dist/index.js with the actual folder you prepared in step 1.

README.md

Manage and query MariaDB databases with SQL and vector search capabilities.

MCP MariaDB Server

The MCP MariaDB Server provides a Model Context Protocol (MCP) interface for managing and querying MariaDB databases, supporting both standard SQL operations and advanced vector/embedding-based search. Designed for use with AI assistants, it enables seamless integration of AI-driven data workflows with relational and vector databases.


Overview

The MCP MariaDB Server exposes a set of tools for interacting with MariaDB databases and vector stores via a standardized protocol. It supports:

  • Listing databases and tables
  • Retrieving table schemas
  • Executing safe, read-only SQL queries
  • Creating and managing vector stores for embedding-based search
  • Integrating with embedding providers (currently OpenAI, Gemini, and HuggingFace) (optional)

Core Components

  • server.py: Main MCP server logic and tool definitions.
  • config.py: Loads configuration from environment and .env files.
  • embeddings.py: Handles embedding service integration (OpenAI).
  • tests/: Manual and automated test documentation and scripts.

Available Tools

Standard Database Tools

  • list_databases

    • Lists all accessible databases.
    • Parameters: None
  • list_tables

    • Lists all tables in a specified database.
    • Parameters: database_name (string, required)
  • get_table_schema

    • Retrieves schema for a table (columns, types, keys, etc.).
    • Parameters: database_name (string, required), table_name (string, required)
  • get_table_schema_with_relations

    • Retrieves schema with foreign key relations for a table.
    • Parameters: database_name (string, required), table_name (string, required)
  • execute_sql

    • Executes a read-only SQL query (SELECT, SHOW, DESCRIBE).
    • Parameters: sql_query (string, required), database_name (string, optional), parameters (list, optional)
    • Note: Enforces read-only mode if MCP_READ_ONLY is enabled.
  • create_database

    • Creates a new database if it doesn't exist.
    • Parameters: database_name (string, required)

Vector Store & Embedding Tools (optional)

Note: These tools are only available when EMBEDDING_PROVIDER is configured. If no embedding provider is set, these tools will be disabled.

  • create_vector_store

    • Creates a new vector store (table) for embeddings.
    • Parameters: database_name, vector_store_name, model_name (optional), distance_function (optional, default: cosine)
  • delete_vector_store

    • Deletes a vector store (table).
    • Parameters: database_name, vector_store_name
  • list_vector_stores

    • Lists all vector stores in a database.
    • Parameters: database_name
  • insert_docs_vector_store

    • Batch inserts documents (and optional metadata) into a vector store.
    • Parameters: database_name, vector_store_name, documents (list of strings), metadata (optional list of dicts)
  • search_vector_store

    • Performs semantic search for similar documents using embeddings.
    • Parameters: database_name, vector_store_name, user_query (string), k (optional, default: 7)

Embeddings & Vector Store

Overview

The MCP MariaDB Server provides optional embedding and vector store capabilities. These features can be enabled by configuring an embedding provider, or completely disabled if you only need standard database operations.

Supported Providers

  • OpenAI
  • Gemini
  • Open models from Huggingface

Configuration

  • EMBEDDING_PROVIDER: Set to openai, gemini, huggingface, or leave unset to disable
  • OPENAI_API_KEY: Required if using OpenAI embeddings
  • GEMINI_API_KEY: Required if using Gemini embeddings
  • HF_MODEL: Required if using HuggingFace embeddings (e.g., "intfloat/multilingual-e5-large-instruct" or "BAAI/bge-m3")

Model Selection

  • Default and allowed models are configurable in code (DEFAULT_OPENAI_MODEL, ALLOWED_OPENAI_MODELS)
  • Model can be selected per request or defaults to the configured model

Vector Store Schema

A vector store table has the following columns:

  • id: Auto-increment primary key
  • document: Text of the document
  • embedding: VECTOR type (indexed for similarity search)
  • metadata: JSON (optional metadata)

Configuration & Environment Variables

All configuration is via environment variables (typically set in a .env file):

| Variable | Description

Tools (11)

list_databasesLists all accessible databases.
list_tablesLists all tables in a specified database.
get_table_schemaRetrieves schema for a table including columns, types, and keys.
get_table_schema_with_relationsRetrieves schema with foreign key relations for a table.
execute_sqlExecutes a read-only SQL query.
create_databaseCreates a new database if it does not exist.
create_vector_storeCreates a new vector store table for embeddings.
delete_vector_storeDeletes a vector store table.
list_vector_storesLists all vector stores in a database.
insert_docs_vector_storeBatch inserts documents and metadata into a vector store.
search_vector_storePerforms semantic search for similar documents using embeddings.

Environment Variables

EMBEDDING_PROVIDERProvider for embeddings (openai, gemini, or huggingface)
OPENAI_API_KEYAPI key for OpenAI embeddings
GEMINI_API_KEYAPI key for Gemini embeddings
HF_MODELModel name for HuggingFace embeddings
MCP_READ_ONLYEnforces read-only mode for SQL queries

Configuration

claude_desktop_config.json
{"mcpServers": {"mariadb": {"command": "python", "args": ["path/to/server.py"], "env": {"DB_HOST": "localhost", "DB_USER": "root", "DB_PASSWORD": "password", "DB_NAME": "my_database"}}}}

Try it

List all the databases available on the server.
Show me the schema for the 'users' table in the 'production' database.
Execute a query to find all users who signed up in the last 30 days.
Search the 'knowledge_base' vector store for documents related to 'database security best practices'.
Create a new vector store named 'product_embeddings' in the 'catalog' database.

Frequently Asked Questions

What are the key features of MariaDB MCP Server?

Standard SQL query execution with read-only enforcement. Schema retrieval including foreign key relationship mapping. Vector store management for embedding-based semantic search. Integration with OpenAI, Gemini, and HuggingFace embedding providers. Database and table discovery tools.

What can I use MariaDB MCP Server for?

Enabling AI assistants to query relational data directly from MariaDB. Building RAG (Retrieval-Augmented Generation) pipelines using MariaDB as a vector store. Automating database schema documentation and exploration for developers. Performing semantic search across unstructured text stored in relational databases.

How do I install MariaDB MCP Server?

Install MariaDB MCP Server by running: python server.py

What MCP clients work with MariaDB MCP Server?

MariaDB MCP Server works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep MariaDB MCP Server docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare