Azure Database for PostgreSQL MCP Server 基于 Model Context Protocol (MCP),能让用户与 Azure Database for PostgreSQL 相连。此服务正处预览阶段,功能持续开发完善中。
# 创建虚拟环境
python -m venv azure_postgres_mcp
# 激活虚拟环境
source azure_postgres_mcp/bin/activate
# 安装依赖项
pip install -r requirements.txt
claude_desktop_config.json 文件。{
"mcp": {
"servers": {
"azure-postgresql-mcp": {
"command": "/Scripts/python" ,
"args": [
"<路径到 azure_postgresql_mcp.py 文件>"
],
"env": {
"PGHOST": "" ,
"PGUSER": "<用户名>",
"PGPASSWORD": "<密码>",
"PGDATABASE": "<数据库名称>"
}
}
}
}
}
MCP 并选择编辑 settings.json 文件。{
"mcp": {
"servers": {
"azure-postgresql-mcp": {
"command": "<路径到虚拟环境>/Scripts/python",
"args": [
"<路径到 azure_postgresql_mcp.py 文件>"
],
"env": {
"PGHOST": "" ,
"PGUSER": "<用户名>",
"PGPASSWORD": "<密码>",
"PGDATABASE": "<数据库名称>"
}
}
}
}
}
为了通过 Microsoft Entra 身份验证连接到 Azure Database for PostgreSQL MCP Server,请更新 claude_desktop_config.json 文件(Claude Desktop)和 settings.json 文件(Visual Studio Code)中的配置:
{
"azure-postgresql-mcp": {
"command": "<路径到虚拟环境>/Scripts/python",
"args": [
"<路径到 azure_postgresql_mcp.py 文件>"
],
"env": {
"PGHOST": "" ,
"PGUSER": "" ,
"AZURE_USE_AAD": "True",
"AZURE_SUBSCRIPTION_ID": "<您的 Azure 订阅 ID>",
"AZURE_RESOURCE_GROUP": "<包含 Azure Database for PostgreSQL 实例的资源组>"
}
}
}
Azure Database for PostgreSQL MCP Server 目前处于预览阶段。如果您有任何问题或建议,请参考 CONTRIBUTING.md 文件。
该项目根据 MIT 许可证授权。详细信息请查看 LICENSE 文件。