mcpField
P
PostgreSQL

PostgreSQL

Local
github.com/pyljainDeveloper Tools0Updated 86w ago

About PostgreSQL

A PostgreSQL MCP server for LLMs and database users to inspect schemas and run read-only SQL queries. It exposes table metadata alongside a query tool, with every query run in a read-only transaction.

Key features

  1. 01Read-only SQL queries
  2. 02Table schema resources
  3. 03Column names and data types
  4. 04Automatic schema discovery

Use cases

  1. 01Inspect PostgreSQL tables and columns
  2. 02Run read-only database queries

MCP support

Exposes a query tool for read-only SQL and table schema resources to MCP clients. Queries run inside read-only transactions.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

mcp.json · Universal config
{
"mcpServers": {
"mcp_server_template": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"build"
]
}
}
}
Run commanddocker run -i --rm build

Local servers need a runtime on your machine (e.g. Node.js 18+). Config file locations differ by client; see your client’s docs.

Packages
ocibuild

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project README

PostgreSQL

A Model Context Protocol server that provides read-only access to PostgreSQL databases. This server enables LLMs to inspect database schemas and execute read-only queries.

Components

Tools
  • query
    • Execute read-only SQL queries against the connected database
    • Input: sql (string): The SQL query to execute
    • All queries are executed within a READ ONLY transaction
Resources

The server provides schema information for each table in the database:

  • Table Schemas (postgres://<host>/<table>/schema)
    • JSON schema information for each table
    • Includes column names and data types
    • Automatically discovered from database metadata

Usage with Claude Desktop

To use this server with the Claude Desktop app, add the following configuration to the "mcpServers" section of your claude_desktop_config.json:

Docker
  • when running docker on macos, use host.docker.internal if the server is running on the host network (eg localhost)
  • username/password can be added to the postgresql url with postgresql://user:password@host:port/db-name
{
  "mcpServers": {
    "postgres": {
      "command": "docker",
      "args": [
        "run", 
        "-i", 
        "--rm", 
        "mcp/postgres", 
        "postgresql://host.docker.internal:5432/mydb"]
    }
  }
}
NPX
{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-postgres",
        "postgresql://localhost/mydb"
      ]
    }
  }
}

Replace /mydb with your database name.

Building

Docker:

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

License

This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.