PostgreSQL MCP Server

数据库stdiov0.6.2
代码仓库

通过 Model Context Protocol 提供对 PostgreSQL 数据库的只读访问。AI 智能体可以检查数据库模式、执行 SELECT 查询并探索表结构。通过只读事务隔离防止意外修改数据。该服务器原属于参考服务器集合,现已归档并可在 servers-archived 中获取。

此描述由机器自动翻译,尚未经过人工审核。

连接

将此配置添加到 .claude/mcp.json

{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-postgres",
        "postgresql://localhost/mydb"
      ],
      "env": {
        "POSTGRES_CONNECTION_STRING": "<YOUR_POSTGRES_CONNECTION_STRING>"
      }
    }
  }
}

工具 (3)

query

Execute a read-only SQL query against the connected PostgreSQL database and return results.

{
  "type": "object",
  "required": [
    "sql"
  ],
  "properties": {
    "sql": {
      "type": "string",
      "description": "SQL query to execute (SELECT statements only)"
    }
  }
}

list_tables

List all tables in the connected PostgreSQL database with their schemas.

{
  "type": "object",
  "properties": {
    "schema": {
      "type": "string",
      "description": "Schema name to filter tables (defaults to public)"
    }
  }
}

describe_table

Get the column definitions, types, and constraints for a specific table.

{
  "type": "object",
  "required": [
    "table_name"
  ],
  "properties": {
    "schema": {
      "type": "string",
      "description": "Schema name (defaults to public)"
    },
    "table_name": {
      "type": "string",
      "description": "Name of the table to describe"
    }
  }
}

资源 (1)

postgres://{host}/{database}/schema

Access to the database schema information including tables, columns, and relationships.

提示词

此服务器未提供任何提示词。

服务器信息

作者
Anthropic (@modelcontextprotocol)
代码仓库
https://github.com/modelcontextprotocol/servers-archived
许可证
MIT
版本
0.6.2
星标
265
最后更新
2026年1月27日