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
MariaDB MCP (Model Context Protocol) server implementation
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
DB_HOST
MariaDB host address
Yes
localhost
DB_PORT
MariaDB port
No
3306
DB_USER
MariaDB username
Yes
DB_PASSWORD
MariaDB password
Yes
DB_NAME
Default database (optional; can be set per query)
No
DB_CHARSET
Character set for database connection (e.g., cp1251)
No
MariaDB default
DB_SSL
Enable SSL/TLS for database connection (true/false)
No
false
DB_SSL_CA
Path to CA certificate file for SSL verification
No
DB_SSL_CERT
Path to client certificate file for SSL authentication
No
DB_SSL_KEY
Path to client private key file for SSL authentication
No
DB_SSL_VERIFY_CERT
Verify server certificate (true/false)
No
true
DB_SSL_VERIFY_IDENTITY
Verify server hostname identity (true/false)
No
false
MCP_READ_ONLY
Enforce read-only SQL mode (true/false)
No
true
MCP_BLOCK_SENSITIVE_SHOW
Block sensitive SHOW commands (PROCESSLIST, GRANTS, VARIABLES, MASTER/REPLICA STATUS, BINARY LOGS, etc.) that can leak cross-connection query text, credentials/privileges, or replication topology. Set independently of MCP_READ_ONLY (true/false)
No
true
MCP_MAX_POOL_SIZE
Max DB connection pool size
No
10
EMBEDDING_PROVIDER
Embedding provider (openai/gemini/huggingface)
No
None(Disabled)
OPENAI_API_KEY
API key for OpenAI embeddings
Yes (if EMBEDDING_PROVIDER=openai)
GEMINI_API_KEY
API key for Gemini embeddings
Yes (if EMBEDDING_PROVIDER=gemini)
HF_MODEL
Open models from Huggingface
Yes (if EMBEDDING_PROVIDER=huggingface)
ALLOWED_ORIGINS
Comma-separated list of allowed origins
No
Long list of allowed origins corresponding to local use of the server
ALLOWED_HOSTS
Comma-separated list of allowed hosts
No
localhost,127.0.0.1
Note that if using 'http' or 'sse' as the transport, configuring authentication is important for security if you allow connections outside of localhost. Because different organizations use different authentication methods, the server does not provide a default authentication method. You will need to configure your own authentication method. Thankfully FastMCP provides a simple way to do this starting with version 2.12.1. See the FastMCP documentation for more information. We have provided an example configuration below.
All SSL certificate paths support ~ for home directory expansion
DB_SSL_CA is used to verify the server's certificate
DB_SSL_CERT and DB_SSL_KEY are used for client certificate authentication (mutual TLS)
Set DB_SSL_VERIFY_CERT=false only for testing with self-signed certificates
Set DB_SSL_VERIFY_IDENTITY=true to enable strict hostname verification
Example Authentication Configuration:
This configuration uses external web authentication via GitHub or Google. If you have internal JWT authentication (desired for organizations who manage their own services), you can use the JWT provider instead.
⚠️ The only way to guarantee 100% read-only access with absolute certainty is to configure the MariaDB user with appropriate privileges. The READ_ONLY flag is a best effort attempt to prevent write operations, but it is based upon a whitelist of allowed queries and against a truly adversarial user it is not a substitute for proper database user privileges.
For production use, you should create a dedicated database user with minimal privileges. This is also recommended to show the LLM only the data it may need to perform its task even outside of read-only mode.
{
"tool": "search_vector_store",
"parameters": {
"database_name": "test_db",
"vector_store_name": "my_vectors",
"user_query": "What is the capital of France?",
"k": 5
}
}
Integration - Claude desktop/Cursor/Windsurf/VSCode