by MariaDB
Provides a Model Context Protocol interface for managing MariaDB databases and performing embedding‑based vector search, enabling AI‑driven data workflows with both relational and semantic queries.
MCP MariaDB Server exposes a set of standardized tools that let you list databases and tables, retrieve schemas, execute read‑only SQL, and, when an embedding provider is configured, create and query vector stores for semantic search. It is designed for integration with AI assistants and other automation pipelines that need seamless access to relational data and embeddings.
uv and run:
uv lock
uv sync
.env file with the required connection parameters (e.g., DB_HOST, DB_USER, DB_PASSWORD) and optional embedding settings (EMBEDDING_PROVIDER, OPENAI_API_KEY, etc.).uv run server.py
Alternative transports:
uv run server.py --transport sse --host 127.0.0.1 --port 9001
uv run server.py --transport http --host 127.0.0.1 --port 9001 --path /mcp
{ "tool": "execute_sql", "parameters": { "database_name": "test", "sql_query": "SELECT * FROM users" } }
MCP_READ_ONLY flag prevents data‑modifying statements..env: all connection, pooling, and embedding settings are environment‑driven.logs/mcp_server.log for debugging and audit.Do I need an embedding provider to run the server?
No. The server works for pure SQL operations; vector‑store tools are disabled when EMBEDDING_PROVIDER is unset.
Can I execute INSERT/UPDATE statements?
Only if MCP_READ_ONLY is set to false. By default it is true to protect data.
Which distance functions are supported for vector search?
The default is cosine, but you can specify any function supported by MariaDB’s VECTOR type (e.g., euclidean).
How are credentials protected?
All secrets are loaded from environment variables or a .env file; avoid committing this file to version control.
Is authentication built‑in? The core server does not provide authentication; you can plug in FastMCP authentication providers as described in the README.
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.
The MCP MariaDB Server exposes a set of tools for interacting with MariaDB databases and vector stores via a standardized protocol. It supports:
.env files.list_databases
list_tables
database_name (string, required)get_table_schema
database_name (string, required), table_name (string, required)get_table_schema_with_relations
database_name (string, required), table_name (string, required)execute_sql
SELECT, SHOW, DESCRIBE).sql_query (string, required), database_name (string, optional), parameters (list, optional)MCP_READ_ONLY is enabled.create_database
database_name (string, required)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
database_name, vector_store_name, model_name (optional), distance_function (optional, default: cosine)delete_vector_store
database_name, vector_store_namelist_vector_stores
database_nameinsert_docs_vector_store
database_name, vector_store_name, documents (list of strings), metadata (optional list of dicts)search_vector_store
database_name, vector_store_name, user_query (string), k (optional, default: 7)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.
EMBEDDING_PROVIDER: Set to openai, gemini, huggingface, or leave unset to disableOPENAI_API_KEY: Required if using OpenAI embeddingsGEMINI_API_KEY: Required if using Gemini embeddingsHF_MODEL: Required if using HuggingFace embeddings (e.g., "intfloat/multilingual-e5-large-instruct" or "BAAI/bge-m3")DEFAULT_OPENAI_MODEL, ALLOWED_OPENAI_MODELS)A vector store table has the following columns:
id: Auto-increment primary keydocument: Text of the documentembedding: VECTOR type (indexed for similarity search)metadata: JSON (optional metadata)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 |
MCP_READ_ONLY |
Enforce read-only SQL mode (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.
.env fileWith Embedding Support (OpenAI):
DB_HOST=localhost
DB_USER=your_db_user
DB_PASSWORD=your_db_password
DB_PORT=3306
DB_NAME=your_default_database
MCP_READ_ONLY=true
MCP_MAX_POOL_SIZE=10
EMBEDDING_PROVIDER=openai
OPENAI_API_KEY=sk-...
GEMINI_API_KEY=AI...
HF_MODEL="BAAI/bge-m3"
Without Embedding Support:
DB_HOST=localhost
DB_USER=your_db_user
DB_PASSWORD=your_db_password
DB_PORT=3306
DB_NAME=your_default_database
MCP_READ_ONLY=true
MCP_MAX_POOL_SIZE=10
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.
# GitHub OAuth
export FASTMCP_SERVER_AUTH=fastmcp.server.auth.providers.github.GitHubProvider
export FASTMCP_SERVER_AUTH_GITHUB_CLIENT_ID="Ov23li..."
export FASTMCP_SERVER_AUTH_GITHUB_CLIENT_SECRET="github_pat_..."
# Google OAuth
export FASTMCP_SERVER_AUTH=fastmcp.server.auth.providers.google.GoogleProvider
export FASTMCP_SERVER_AUTH_GOOGLE_CLIENT_ID="123456.apps.googleusercontent.com"
export FASTMCP_SERVER_AUTH_GOOGLE_CLIENT_SECRET="GOCSPX-..."
.python-version)Clone the repository
Install uv (if not already):
pip install uv
Install dependencies
uv lock
uv sync
Create .env in the project root (see Configuration)
Run the server
Standard Input/Output (default):
uv run server.py
SSE Transport:
uv run server.py --transport sse --host 127.0.0.1 --port 9001
HTTP Transport (streamable HTTP):
uv run server.py --transport http --host 127.0.0.1 --port 9001 --path /mcp
{
"tool": "execute_sql",
"parameters": {
"database_name": "test_db",
"sql_query": "SELECT * FROM users WHERE id = %s",
"parameters": [123]
}
}
{
"tool": "create_vector_store",
"parameters": {
"database_name": "test_db",
"vector_store_name": "my_vectors",
"model_name": "text-embedding-3-small",
"distance_function": "cosine"
}
}
{
"tool": "insert_docs_vector_store",
"parameters": {
"database_name": "test_db",
"vector_store_name": "my_vectors",
"documents": ["Sample text 1", "Sample text 2"],
"metadata": [{"source": "doc1"}, {"source": "doc2"}]
}
}
{
"tool": "search_vector_store",
"parameters": {
"database_name": "test_db",
"vector_store_name": "my_vectors",
"user_query": "What is the capital of France?",
"k": 5
}
}
{
"mcpServers": {
"MariaDB_Server": {
"command": "uv",
"args": [
"--directory",
"path/to/mariadb-mcp-server/",
"run",
"server.py"
],
"envFile": "path/to/mcp-server-mariadb-vector/.env"
}
}
}
{
"servers": {
"mariadb-mcp-server": {
"url": "http://{host}:9001/sse",
"type": "sse"
}
}
}
{
"servers": {
"mariadb-mcp-server": {
"url": "http://{host}:9001/mcp",
"type": "streamable-http"
}
}
}
logs/mcp_server.log by default.config.py and logger setup).src/tests/ directory.src/tests/README.md for an overview.Please log in to share your review and rating for this MCP.
Explore related MCPs that share similar capabilities and solve comparable challenges
by googleapis
An MCP server that streamlines database tool development by handling connection pooling, authentication, observability, and secure access, allowing agents to interact with databases via natural language.
by bytebase
Provides a universal gateway that lets MCP‑compatible clients explore and query MySQL, PostgreSQL, SQL Server, MariaDB, and SQLite databases through a single standardized interface.
by designcomputer
Enables secure interaction with MySQL databases via the Model Context Protocol, allowing AI applications to list tables, read contents, and execute queries safely.
by benborla
Provides read‑only access to MySQL databases for large language models, allowing schema inspection and safe execution of SQL queries.
by neo4j-contrib
Enables natural‑language interaction with Neo4j databases, allowing large language models to query, modify, and manage graph data through multiple transport modes.
by mongodb-js
Provides a Model Context Protocol server that enables interaction with MongoDB databases and MongoDB Atlas clusters through a unified API.
by ClickHouse
Enables AI assistants to run read‑only ClickHouse queries, list databases and tables, and execute embedded chDB queries through an MCP interface.
by neondatabase
Interact with Neon Postgres databases using natural language commands through the Model Context Protocol, enabling conversational database creation, migration, and query execution.
by motherduckdb
Enables SQL analytics on DuckDB and MotherDuck databases via a Model Context Protocol server, allowing AI assistants and IDEs to query data directly.