• 正文
  • 相关推荐
申请入驻 产业图谱

通过 MCP PostgreSQL 安全访问数据

03/27 10:30
1274
加入交流群
扫码加入
获取工程师必备礼包
参与热点资讯讨论

项目简介

提供对 PostgreSQL 数据库的只读访问功能。该服务器允许大型语言模型(LLMs)检查数据库的模式结构,并执行只读查询操作。

核心功能

    • 提供对 PostgreSQL 数据库的只读访问• 允许 LLM(大语言模型)查看数据库架构和执行只读查询• 确保数据安全性(仅支持读操作)

配置使用方法

提供了两种配置方式:

Docker 方式

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

特别说明:

    • MacOS 上运行 Docker 时,如果服务器在主机网络上运行,使用 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


现已开发 MCP 100 专栏服务,欢迎来撩

 

相关推荐

登录即可解锁
  • 海量技术文章
  • 设计资源下载
  • 产业链客户资源
  • 写文章/发需求
立即登录