该 MCP 服务器提供对 MariaDB / MySQL 数据库的访问。它允许你:
本 MCP 服务器可让你轻松访问 MariaDB / MySQL 数据库,执行各类常见的数据库操作。
# 克隆仓库
git clone https://github.com/bretoreta/mariadb-mcp-server.git
cd mariadb-mcp-server
# 安装依赖并构建
pnpm install
pnpm run build
服务器需要以下环境变量:
将以下配置添加到你的 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 设置的功能兼容性。
如果你遇到问题:
https://github.com/rjsalgado/mariadb-mcp-server
本项目采用 MIT 许可证 - 有关详细信息,请参阅 LICENSE 文件。