
Postgres
io.github.ofershapPublished by GitHub account ofershapv1.0.0Updated Oct 24, 2026
PostgreSQL MCP — query databases, inspect schemas, explain queries.
Overview
A local MCP server that lets an AI assistant query a PostgreSQL database, inspect schemas and tables, and explain query plans.
- What you can do
- Run SQL queries (SELECT, WITH, EXPLAIN, SHOW, ANALYZE) and get results as a text table, with optional per-call connection string override and opt-in writes when readonly is disabled. List non-system schemas and the tables in a schema with columns and approximate row counts. Inspect a single table's columns, types, null/default flags, primary key and exact row count. Explain a query plan in text format, optionally with ANALYZE.
- When to use it
- Useful when you work with a local or development PostgreSQL database and want the assistant to explore schemas, run read-only queries and understand query plans without leaving the IDE or chat client.
- Requirements
- Runs locally via npx from the npm package mcp-pg-server, so Node.js is needed. A PostgreSQL connection is required, supplied through the DATABASE_URL environment variable or a per-call connectionString. Network access to the database host.
Installation
In SourceWeft
- Open Postgres in the dashboard and add it to a workspace.
- Enable the server for the chats that should use its tools.
Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.
Other MCP clients
Follow the launch instructions in the repository.
README
mcp-server-postgres
[npm version] [npm downloads] [CI] [TypeScript] [License: MIT]
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.
Works with Claude Desktop, Cursor, VS Code Copilot, and any MCP client. Connects via
DATABASE_URLor per-callconnectionString.
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
Quick Start
Cursor
Add to .cursor/mcp.json:
Claude Desktop
Add to claude_desktop_config.json (macOS: ~/Library/Application Support/Claude/claude_desktop_config.json):
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
See also
More MCP servers and developer tools on my portfolio.
Author
License
MIT © 2026 Ofer Shapira
Source: README.md at commit 6b813b6
Tools
0Version history
1- v1.0.0LatestSep 16, 2026
Score
50% of the applicable checks met
How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.
- Reached in the last 30 days25 pts
Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.
- Auth declared10 pts
Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.
- Tools listed15 pts
Answer tools/list without a credential, or ship a package that starts in a sandbox without one.
- DescriptionRequired15 pts
- Logo10 pts
- Documentation15 pts
- License10 pts