• 正文
  • 相關推薦
申請入駐 產業(yè)圖譜

通過 MCP PostgreSQL 安全訪問數(shù)據(jù)

03/27 10:30
518
加入交流群
掃碼加入
獲取工程師必備禮包
參與熱點資訊討論

項目簡介

提供對 PostgreSQL 數(shù)據(jù)庫的只讀訪問功能。該服務器允許大型語言模型(LLMs)檢查數(shù)據(jù)庫的模式結構,并執(zhí)行只讀查詢操作。

核心功能

    ? 提供對 PostgreSQL 數(shù)據(jù)庫的只讀訪問? 允許 LLM(大語言模型)查看數(shù)據(jù)庫架構和執(zhí)行只讀查詢? 確保數(shù)據(jù)安全性(僅支持讀操作)

配置使用方法

提供了兩種配置方式:

Docker 方式

{
? "mcpServers": {
? ? "postgres": {
? ? ? "command": "docker",
? ? ? "args": [
? ? ? ? "run",?
? ? ? ? "-i",?
? ? ? ? "--rm",?
? ? ? ? "mcp/postgres",?
? ? ? ? "postgresql://host.docker.internal:5432/mydb"
? ? ? ]
? ? }
? }
}

特別說明:

    ? MacOS 上運行 Docker 時,如果服務器在主機網(wǎng)絡上運行,使用 host.docker.internal? 可以在 PostgreSQL URL 中添加用戶名和密碼:postgresql://user:password@host:port/db-name

NPX 方式

{
? "mcpServers": {
? ? "postgres": {
? ? ? "command": "npx",
? ? ? "args": [
? ? ? ? "-y",
? ? ? ? "@modelcontextprotocol/server-postgres",
? ? ? ? "postgresql://localhost/mydb"
? ? ? ]
? ? }
? }
}

構建說明

提供了 Docker 構建命令:

docker build -t mcp/postgres -f src/postgres/Dockerfile .

相關鏈接

    ? MCP PostgreSQL: https://github.com/modelcontextprotocol/servers/tree/main/src/postgres

#MCP #PostgreSQL #NPX #Docker #SQL


現(xiàn)已開發(fā) MCP 100 專欄服務,歡迎來撩

 

相關推薦