Postgresdb Mcp — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited Postgresdb Mcp (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
A Model Context Protocol (MCP) server that gives any MCP-compatible AI assistant direct access to PostgreSQL databases across multiple environments.
.env fileALLOW_WRITES=false), or enabled with mandatory "WRITE" confirmation (ALLOW_WRITES=true) for any statement that is not clearly read-onlySCHEMA (comma-separated)$1, $2 … placeholdersgit clone https://github.com/yourusername/postgresdb-mcp.git
cd postgresdb-mcp
npm install
npm run buildCopy the example env file and fill in your credentials:
cp .env.dist .env.env is gitignored so your credentials stay local and are never committed.
Edit .env with your database credentials. Environments are auto-discovered: any POSTGRES_{ENV}_HOST variable defines a new environment. The order in the file is preserved.
# Local
POSTGRES_LOCAL_HOST=localhost
POSTGRES_LOCAL_DATABASE=mydb
POSTGRES_LOCAL_USER=postgres
POSTGRES_LOCAL_PASSWORD=postgres
POSTGRES_LOCAL_ALLOW_WRITES=false
# Staging
POSTGRES_STG_HOST=your-env-host
POSTGRES_STG_DATABASE=stg_mydb
POSTGRES_STG_USER=stg_user
POSTGRES_STG_PASSWORD=your-stg-password
POSTGRES_STG_SSL=true
POSTGRES_STG_ALLOW_WRITES=false
# Production
POSTGRES_PROD_HOST=your-env-host
POSTGRES_PROD_DATABASE=prod_mydb
POSTGRES_PROD_USER=prod_user
POSTGRES_PROD_PASSWORD=your-prod-password
POSTGRES_PROD_SSL=true
POSTGRES_PROD_ALLOW_WRITES=falseAvailable variables per environment (prefix: POSTGRES_{ENV}_):
| Variable | Required | Default | Description |
|---|---|---|---|
HOST | yes | - | PostgreSQL host |
PORT | no | 5432 | PostgreSQL port |
DATABASE | yes | - | Database name |
USER | yes | - | Database user |
PASSWORD | yes | - | Database password |
SCHEMA | no | _all schemas_ | Schema allowlist (comma-separated). Example: public or public,users. When set, tools are scoped and queries are restricted to these schemas. |
SSL | no | false | Enable SSL (true/false) |
SSL_REJECT_UNAUTHORIZED | no | true | Verify SSL certificate. Default true — only set to false if your DB uses a self-signed cert and you have no other option. Never disable in production. |
ALLOW_WRITES | no | false | true: writes allowed, confirm_write="WRITE" required to execute. false: writes completely blocked, no confirmation shown. |
This server works with any MCP-compatible client. Below are examples for common ones.
Add to ~/.config/Claude/claude_desktop_config.json (macOS: ~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"postgresdb": {
"command": "node",
"args": [
"/absolute/path/to/postgresdb-mcp/dist/index.js",
"--env",
"/absolute/path/to/.env"
]
}
}
}Restart Claude Desktop after editing.
claude mcp add postgresdb -- node /absolute/path/to/dist/index.js --env /absolute/path/to/.envStart the server manually, it communicates over stdio:
node /absolute/path/to/postgresdb-mcp/dist/index.js --env /absolute/path/to/.envIf --env is omitted, the server looks for a .env file in the current working directory.
Refer to your client's documentation for how to register an MCP server using stdio transport.
queryExecute a SQL query on a target environment. Returns environment, database, queryType, duration, rowCount, rows, and fields.
Run: SELECT COUNT(*) FROM users.orders WHERE status = 'pending' on stgWrite operations are subject to the environment's write protection mode (see Write protection). To confirm a write on an environment with ALLOW_WRITES=true, pass confirm_write="WRITE".
list-tablesList all tables in a schema.
List all tables in the public schema on localdescribe-tableGet the full structure of a table (columns, types, nullability, defaults).
Describe the users table in the public schema on stglist-schemasList all user-defined schemas in a database.
What schemas are available on prod?list-environmentsList all configured environments (no credentials exposed).
What environments are configured?Every environment has one of two write modes, controlled by POSTGRES_{ENV}_ALLOW_WRITES:
| Mode | Config | Behaviour |
|---|---|---|
| Blocked (default) | ALLOW_WRITES=false or not set | Writes (UPDATE, DELETE, INSERT, DROP…) are immediately rejected. No confirmation prompt is shown. |
| Allowed with confirmation | ALLOW_WRITES=true | Writes are allowed, but the AI must explicitly pass confirm_write="WRITE" (exact string, case-sensitive) to execute. |
The guard inspects SQL in a fail-closed way:
PREPARE ...; EXECUTE ...) are detectedSELECT, WITH, VALUES, SHOW, TABLE, EXPLAIN) are treated as write-sensitive and require confirm_write="WRITE" when writes are enabledconfirm_write!="WRITE", queries run inside BEGIN READ ONLY, so accidental writes from side-effect functions are blocked at PostgreSQL levelBy default, if POSTGRES_{ENV}_SCHEMA is not set, the MCP can access all schemas the DB user is allowed to access.
Set POSTGRES_{ENV}_SCHEMA to scope access per environment:
POSTGRES_STG_SCHEMA=publicPOSTGRES_PROD_SCHEMA=public,usersWhen schema scope is configured:
list-tables / describe-table reject schemas outside the allowlistlist-schemas only returns allowed schemasquery blocks explicit references to non-allowed schemasquery executes with SET LOCAL search_path on allowed schema(s) for additional isolationFor strongest isolation, keep using dedicated PostgreSQL users with least-privilege grants per schema.
Recommendation: set ALLOW_WRITES=true on environments where you need to write from the AI (preprod, prod) — every write will require a deliberate "WRITE" confirmation. Leave it unset on read-only environments (replicas, analytics DBs).
npm run build # compile TypeScript
npm run watch # watch modeRequirements: Node.js >= 18
MIT
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.