mcp服务器mariadb
从mariadb检索数据的MCP服务器实现
特性
资源
显示数据库中的架构列表
工具
- 查询数据库
- 对MariDB执行只读操作
依赖
安装mariadb
- 苹果电脑
- 当安装mariadb时, 可能会在下面引发操作系统错误。 您可以通过安装mariadb-connector-c来解决这个问题。
OSError: mariadb_config not found.
This error typically indicates that MariaDB Connector/C, a dependency which
must be preinstalled, is not found.
If MariaDB Connector/C is not installed, see installation instructions
If MariaDB Connector/C is installed, either set the environment variable
MARIADB_CONFIG or edit the configuration file 'site.cfg' to set the
'mariadb_config' option to the file location of the mariadb_config utility.
- 执行
brew install mariadb-connector-c - 执行
echo 'export PATH="/opt/homebrew/opt/mariadb-connector-c/bin:$PATH"' >> ~/.bashrc - 设置环境变量
export MARIADB_CONFIG=$(brew --prefix mariadb-connector-c)/bin/mariadb_config - 执行
uv add mariadb再一次。
使用Claude Desktop
配置文件
Claude Desktop配置文件的路径:
- MacOS:
~/Library/Application Support/Claude/claude_desktop_config.json - 视窗:
%APPDATA%\Claude\claude_desktop_config.json
Add this configuration to enable published servers
{
"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}"
]
}
}
}
备注:将这些占位符替换为实际路径:
/PATH/TO/uvx:uvx可执行文件的完整路径
Add this configuration to enable development/unpublished servers
{
"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"
}
}
}
}备注:将这些占位符替换为实际路径:
/PATH/TO/uv:UV可执行文件的完整路径/YOUR/SOURCE/PATH/mcp-server-mariadb/src/mcp_server_mariadb:服务器源代码的路径
许可证
此mcp服务器根据MIT许可证获得许可。请查看存储库中的LICENSE文件。

