This MariaDB MCP server implementation allows you to retrieve data from MariaDB databases and execute read-only queries through Claude's Model Context Protocol. It exposes schema lists and provides a query tool to interact with your database.
When installing the MariaDB connector, you might encounter this error:
OSError: mariadb_config not found.
This error typically indicates that MariaDB Connector/C, a dependency which
must be preinstalled, is not found.
To resolve this issue:
Install the MariaDB connector with Homebrew:
brew install mariadb-connector-c
Add the connector to your PATH:
echo 'export PATH="/opt/homebrew/opt/mariadb-connector-c/bin:$PATH"' >> ~/.bashrc
Set the required environment variable:
export MARIADB_CONFIG=$(brew --prefix mariadb-connector-c)/bin/mariadb_config
Install the MariaDB package:
uv add mariadb
The configuration file for Claude Desktop is located at:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
Add the following to your Claude Desktop configuration file:
{
"mcpServers": {
"mcp_server_mariadb": {
"command": "/PATH/TO/uvx"
"args": [
"mcp-server-mariadb",
"--host",
"${DB_HOST}",
"--port",
"${DB_PORT}",
"--user",
"${DB_USER}",
"--password",
"${DB_PASSWORD}",
"--database",
"${DB_NAME}"
]
}
}
}
Note: Replace /PATH/TO/uvx
with the full path to your uvx executable, and update the database connection parameters with your actual values.
For development or unpublished servers, use this configuration:
{
"mcpServers": {
"mcp_server_mariadb": {
"command": "/PATH/TO/uv",
"args": [
"--directory",
"/YOUR/SOURCE/PATH/mcp-server-mariadb/src/mcp_server_mariadb",
"run",
"server.py"
],
"env": {
"MARIADB_HOST": "127.0.0.1",
"MARIADB_USER": "USER",
"MARIADB_PASSWORD": "PASSWORD",
"MARIADB_DATABASE": "DATABASE",
"MARIADB_PORT": "3306"
}
}
}
}
Note: Replace the placeholder paths and database credentials with your actual values.
The MCP server provides two main capabilities:
query_database
toolAfter configuring the server in Claude Desktop, you can ask Claude to interact with your MariaDB database by running queries and retrieving schema information.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.