Skip to main content
Glama
MariaDB MCP Server

MariaDB MCP Server

by bretoreta

MariaDB / MySQL 数据库访问 MCP 服务器

该 MCP 服务器提供对 MariaDB / MySQL 数据库的访问。

它允许您:

  • 列出可用的数据库

  • 列出数据库中的表

  • 描述表模式

  • 执行 SQL 查询

安全功能

  • 只读访问权限默认值:SELECT、SHOW、DESCRIBE 和 EXPLAIN

  • 查询验证:防止 SQL 注入并阻止任何数据修改尝试

  • 查询超时:防止长时间运行的查询消耗资源

  • 行限制:防止返回过多的数据

Related MCP server: MySQL MCP Server

安装

选项 1:从源代码构建

# Clone the repository
git clone https://github.com/bretoreta/mariadb-mcp-server.git
cd mariadb-mcp-server

# Install dependencies and build
pnpm install
pnpm run build

2.配置环境变量

服务器需要以下环境变量:

  • MARIADB_HOST:数据库服务器主机名

  • MARIADB_PORT:数据库服务器端口(默认值:3306)

  • MARIADB_USER:数据库用户名

  • MARIADB_PASSWORD:数据库密码

  • MARIADB_DATABASE:默认数据库名称(可选)

  • MARIADB_ALLOW_INSERT:false

  • MARIADB_ALLOW_UPDATE:false

  • MARIADB_ALLOW_DELETE:false

  • MARIADB_TIMEOUT_MS:10000

  • MARIADB_ROW_LIMIT:1000

3. 添加到 MCP 设置

将以下配置添加到您的 MCP 设置文件:

如果你从源代码构建:

{
  "mcpServers": {
    "mariadb": {
      "command": "node",
      "args": ["/path/to/mariadb-mcp-server/dist/index.js"],
      "env": {
        "MARIADB_HOST": "your-host",
        "MARIADB_PORT": "3306",
        "MARIADB_USER": "your-user",
        "MARIADB_PASSWORD": "your-password",
        "MARIADB_DATABASE": "your-default-database",
        "MARIADB_ALLOW_INSERT": "false",
        "MARIADB_ALLOW_UPDATE": "false",
        "MARIADB_ALLOW_DELETE": "false",
        "MARIADB_TIMEOUT_MS": "10000",
        "MARIADB_ROW_LIMIT": "1000",
      },
      "disabled": false,
      "autoApprove": []
    }
  }
}

可用工具

列出数据库

列出 MariaDB / MySQL 服务器上所有可访问的数据库。参数:无

例子:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "sessionId": "session_id from /sse call",
    "name": "list_databases"
  }
}

列表表

列出指定数据库中的所有表。

参数:

  • database (可选):数据库名称(如果未指定则使用默认值)

例子:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "sessionId": "session_id from /sse call",
    "name": "list_tables",
    "database": "my_database_name"
  }
}

描述表

显示特定表的模式。

参数:

  • database (可选):数据库名称(如果未指定则使用默认值)

  • table (必填):表名

例子:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "sessionId": "session_id from /sse call",
    "name": "describe_table",
    "database": "my_database_name",
    "table": "my_table_name"
  }
}

执行查询

执行 SQL 查询。

参数:

  • query (必需):SQL 查询

  • database (可选):数据库名称(如果未指定则使用默认值)

例子:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "sessionId": "session_id from /sse call",
    "name": "execute_query",
    "query": "SELECT * FROM my_table LIMIT 10"
  }
}

测试

服务器会自动测试 MariaDB 以验证您的 MariaDB 设置的功能:

故障排除

如果您遇到问题:

  1. 检查服务器日志中的错误消息

  2. 验证您的 MariaDB 凭据和连接详细信息

  3. 确保您的 MariaDB 用户具有适当的权限

  4. 检查您的查询是否为只读且格式正确

灵感 https://github.com/rjsalgado/mariadb-mcp-server

执照

该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅LICENSE文件。

Available Tools

4 tools
describe_tableB

Show the schema for a specific table

Inputs: table (required), database.

execute_queryC

Execute a SQL query

Inputs: query (required), database.

list_databasesB

List all accessible databases on the MariaDB server

Inputs: no named parameters.

list_tablesC

List all tables in a specified database

Inputs: database.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 4 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose with no overlap: describe_table shows table schemas, execute_query runs SQL queries, list_databases enumerates databases, and list_tables lists tables within a database. The boundaries are well-defined, preventing agent misselection.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun pattern (describe_table, execute_query, list_databases, list_tables) with clear, descriptive verbs. There are no deviations in style or convention, making the set predictable and readable.

    Tool Count4/5

    Four tools is reasonable for a MariaDB server, covering core operations like listing databases/tables, describing schemas, and executing queries. It feels slightly thin as it lacks CRUD operations (e.g., create_table, insert_data), but it's well-scoped for basic database inspection and query execution.

    Completeness3/5

    The tools provide good coverage for database inspection and query execution, but there are notable gaps in CRUD operations (e.g., no create_table, update_data, or delete_table). Agents can work around this using execute_query, but the surface is incomplete for full database management workflows.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Enables interaction with MariaDB databases through secure read-only operations. Supports database exploration, schema inspection, and SQL query execution with comprehensive logging and connection pooling.
      5
      2
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables safe interaction with MySQL databases through SELECT queries, table structure inspection, and database schema exploration. Provides read-only access to query data and examine database metadata.
      1
      -
    • A
      license
      A
      quality
      D
      maintenance
      Enables read-only MySQL database access, allowing listing databases, tables, describing schemas, and executing SELECT/SHOW/DESCRIBE/EXPLAIN queries.
      7
      48 npm
      4
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Provides read-only MySQL query execution, database/table browsing, and table structure inspection with SQL safety validation.
      5
      9 npm
      MIT