MariaDB MCP Server

by bretoreta

Integrations

  • Provides access to MariaDB databases, allowing users to list databases, explore table schemas, and execute read-only SQL queries with security features like query validation and resource limits.

  • Enables interaction with MySQL databases through capabilities to list available databases, browse tables, describe table structures, and run SQL queries with built-in security controls.

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

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

它允许您:

  • 列出可用的数据库
  • 列出数据库中的表
  • 描述表模式
  • 执行 SQL 查询

安全功能

  • 只读访问权限默认值:SELECT、SHOW、DESCRIBE 和 EXPLAIN
  • 查询验证:防止 SQL 注入并阻止任何数据修改尝试
  • 查询超时:防止长时间运行的查询消耗资源
  • 行限制:防止返回过多的数据

安装

选项 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" } }

执行查询

执行 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文件。

-
security - not tested
F
license - not found
-
quality - not tested

提供对 MariaDB/MySQL 数据库的安全只读访问,允许用户列出数据库、探索表模式并使用内置安全措施执行 SQL 查询。

  1. 安全功能
    1. 安装
      1. 选项 1:从源代码构建
      2. 2.配置环境变量
      3. 3. 添加到 MCP 设置
    2. 可用工具
      1. 列出数据库
      2. 列表表
      3. 描述表
      4. 执行查询
    3. 测试
      1. 故障排除
        1. 执照

          Related MCP Servers

          • A
            security
            A
            license
            A
            quality
            Enables interaction with a MySQL database via JSON commands, supporting read-only queries, test execution of write queries, and table information retrieval through Docker.
            Last updated -
            4
            5
            5
            JavaScript
            MIT License
          • -
            security
            A
            license
            -
            quality
            A Model Context Protocol server that provides read-only access to MySQL databases, enabling LLMs to inspect database schemas and execute read-only queries.
            Last updated -
            1,363
            350
            TypeScript
            MIT License
            • Linux
            • Apple
          • -
            security
            A
            license
            -
            quality
            A Model Context Protocol server that provides read-only access to MySQL databases, enabling LLMs to inspect database schemas and execute read-only queries.
            Last updated -
            1,363
            MIT License
          • -
            security
            A
            license
            -
            quality
            An MCP server implementation that enables Claude to execute read-only queries against MariaDB databases and explore database schemas through natural language.
            Last updated -
            5
            Python
            MIT License
            • Apple

          View all related MCP servers

          ID: 9tru29x6wk