MariaDB MCP server

Bridges Claude with MariaDB databases for read-only SQL query execution, enabling data exploration through formatted table results while enforcing safety restrictions on permitted operations.
Back to servers
Provider
HeejunShin
Release date
Feb 19, 2025
Language
Python
Package
Stats
1.6K downloads
10 stars

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.

Installation

Install MariaDB Dependencies

On macOS

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:

  1. Install the MariaDB connector with Homebrew:

    brew install mariadb-connector-c
    
  2. Add the connector to your PATH:

    echo 'export PATH="/opt/homebrew/opt/mariadb-connector-c/bin:$PATH"' >> ~/.bashrc
    
  3. Set the required environment variable:

    export MARIADB_CONFIG=$(brew --prefix mariadb-connector-c)/bin/mariadb_config
    
  4. Install the MariaDB package:

    uv add mariadb
    

Configuration with Claude Desktop

Setting Up the Config File

The configuration file for Claude Desktop is located at:

  • MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json

Configuration for Published Servers

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.

Configuration for Development Servers

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.

Usage

Available Features

The MCP server provides two main capabilities:

  • Resources: Access to schema lists in your MariaDB database
  • Tools: Execute read-only queries against your MariaDB database using the query_database tool

After configuring the server in Claude Desktop, you can ask Claude to interact with your MariaDB database by running queries and retrieving schema information.

How to add this MCP server to Cursor

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.

Adding an MCP server to Cursor globally

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"
            ]
        }
    }
}

Adding an MCP server to a project

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.

How to use the MCP server

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.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later