Provides tools for managing and querying MariaDB databases, including database and table operations, schema inspection, and read-only SQL query execution.
Integrates with OpenAI's embedding API to enable vector-based semantic search and document similarity operations within MariaDB vector stores.
Built as a Python-based MCP server that leverages Python libraries for database connectivity and embedding operations.
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.
Table of Contents
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 - .envfiles.
- 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 
 
- 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 | Required | Default | 
| 
 | MariaDB host address | Yes | 
 | 
| 
 | MariaDB port | No | 
 | 
| 
 | MariaDB username | Yes | |
| 
 | MariaDB password | Yes | |
| 
 | Default database (optional; can be set per query) | No | |
| 
 | Enforce read-only SQL mode ( 
 / 
 ) | No | 
 | 
| 
 | Max DB connection pool size | No | 
 | 
| 
 | Embedding provider ( 
 / 
 / 
 ) | No | 
 (Disabled) | 
| 
 | API key for OpenAI embeddings | Yes (if EMBEDDING_PROVIDER=openai) | |
| 
 | API key for Gemini embeddings | Yes (if EMBEDDING_PROVIDER=gemini) | |
| 
 | Open models from Huggingface | Yes (if EMBEDDING_PROVIDER=huggingface) | 
Example .env file
With Embedding Support (OpenAI):
Without Embedding Support:
Installation & Setup
Requirements
- Python 3.11 (see - .python-version)
- uv (dependency manager; install instructions) 
- MariaDB server (local or remote) 
Steps
- Clone the repository 
- Install (if not already): pip install uv
- Install dependencies uv pip compile pyproject.toml -o uv.lockuv pip sync uv.lock
- Create in the project root (see Configuration) 
- Run the server python server.py- Adjust entry point if needed (e.g., 
Usage Examples
Standard SQL Query
Create Vector Store
Insert Documents into Vector Store
Semantic Search
Integration - Claude desktop/Cursor/Windsurf/VSCode
or If already running MCP server
Logging
- Logs are written to - logs/mcp_server.logby default.
- Log messages include tool calls, configuration issues, embedding errors, and client requests. 
- Log level and output can be adjusted in the code (see - config.pyand logger setup).
Testing
- Tests are located in the - src/tests/directory.
- See - src/tests/README.mdfor an overview.
- Tests cover both standard SQL and vector/embedding tool operations. 
This server cannot be installed
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
Enables AI assistants to interact with MariaDB databases through SQL operations and vector-based semantic search. Supports standard database queries, schema inspection, and optional embedding-powered document storage and retrieval.