io.github.ofershap/postgres

Official registry Data and databases

PostgreSQL MCP — query databases, inspect schemas, explain queries.

Install

Add this to your client's MCP configuration (Claude Desktop: claude_desktop_config.json; Cursor: .cursor/mcp.json; VS Code and others use the same "mcpServers" shape).

NPM package mcp-pg-server
Claude Code
claude mcp add postgres -- npx -y mcp-pg-server@1.0.0
JSON configuration (Claude Desktop, Cursor, VS Code)
{
    "mcpServers": {
        "postgres": {
            "command": "npx",
            "args": [
                "-y",
                "mcp-pg-server@1.0.0"
            ]
        }
    }
}

Documentation

From the project's README on GitHub, refreshed weekly. Links open on GitHub.

Contents
  1. mcp-server-postgres
  2. Why
  3. Tools
  4. Quick Start
  5. Example prompts
  6. Safety
  7. Development
  8. See also
  9. Author
  10. License

mcp-server-postgres

Query PostgreSQL, inspect schemas, and explain queries from your AI assistant. A daily-driver MCP for local and dev Postgres — same belt as docker and sqlite servers, not an enterprise DBA suite.

DATABASE_URL=postgres://user:pass@localhost:5432/mydb npx mcp-pg-server

Works with Claude Desktop, Cursor, VS Code Copilot, and any MCP client. Connects via DATABASE_URL or per-call connectionString.

Why

Postgres is the default for most new backends, local dev stacks, and agent workflows that need a real SQL database. You already run it in Docker or on localhost — this server lets your assistant query it, read schemas, and explain plans without leaving the IDE. Read-only by default so exploration stays safe; opt into writes when you need them.

Tools

ToolWhat it does
queryExecute SQL (SELECT, WITH, EXPLAIN, SHOW, ANALYZE). Returns a text table.
schemaTables in a schema (default public) with columns and approximate row counts
table_infoOne table: columns, types, null/default, PK, exact row count
explainEXPLAIN (FORMAT TEXT), optional ANALYZE
list_schemasList non-system schemas

Quick Start

Cursor

Add to .cursor/mcp.json:

{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": ["mcp-pg-server"],
      "env": {
        "DATABASE_URL": "postgres://user:pass@localhost:5432/mydb"
      }
    }
  }
}
Claude Desktop

Add to claude_desktop_config.json (macOS: ~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": ["mcp-pg-server"],
      "env": {
        "DATABASE_URL": "postgres://user:pass@localhost:5432/mydb"
      }
    }
  }
}
VS Code

Configure the MCP server in your VS Code settings to run npx mcp-pg-server with DATABASE_URL set.

Example prompts

  • "Show me the schema of the public tables"
  • "Query users: SELECT * FROM users LIMIT 10"
  • "Explain this join query"
  • "What schemas exist in this database?"
  • "How many rows are in the orders table?"

Safety

Read-only by default. The query tool accepts only SELECT, WITH, EXPLAIN, SHOW, and ANALYZE in readonly mode. Set readonly=false to enable INSERT, UPDATE, DELETE, and DDL.

Pass connectionString on any tool to override DATABASE_URL for a single call.

Development

npm install
npm run typecheck
npm run build
npm test
npm run format
npm run lint

See also

More MCP servers and developer tools on my portfolio.

Author

License

MIT © 2026 Ofer Shapira

Frequently asked questions

What is io.github.ofershap/postgres?

PostgreSQL MCP — query databases, inspect schemas, explain queries.

How do I install io.github.ofershap/postgres?

It runs on your machine. In Claude Code: claude mcp add postgres -- npx -y mcp-pg-server@1.0.0. For other clients, paste the JSON configuration from this page into their MCP settings.

Does io.github.ofershap/postgres need an API key?

Its registry entry lists no required key or secret. Some features may still need an account with the service it connects to.

Is io.github.ofershap/postgres open source?

Yes. Its code is on GitHub under the MIT license.

Who maintains io.github.ofershap/postgres?

It is published by ofershap. AI.tn lists it but does not maintain or endorse it.

From the official MCP Registry. Listing is not an endorsement: review a server's code and permissions before giving it access to your data.