← All recipes

MCP Recipe

Inspect a Postgres schema before writing SQL

Influzer starter recipe: connect the PostgreSQL MCP server, inspect schemas/tables first, then ask the agent for read-only SQL with an explanation — before any writes.

Data & Analytics
By Influzer Published 2026-10-11 Updated 2026-10-11 0 worked for me

MCP servers used

Compatible clients (author-reported, not verified by Influzer): Cursor, Claude Desktop, Claude Code

Prerequisites

  • A PostgreSQL database you can reach from your machine- Connection string available as a client secret / env var (never pasted into chat)- Prefer a read-only DB role for exploration

Required permissions

The official Postgres MCP runs SQL you allow. Use a read-only role when exploring. Connection strings belong in MCP config, not prompts.

Setup

1. Add Postgres MCP with a placeholder DSN

Install the PostgreSQL MCP via your client. Put the real connection string only in local config or an environment variable.

2. Example stdio config (placeholder DSN) · json
{  "mcpServers": {    "postgres": {      "command": "npx",      "args": [        "-y",        "@modelcontextprotocol/server-postgres",        "postgresql://READONLY_USER:YOUR_PASSWORD@127.0.0.1:5432/YOUR_DB"      ]    }  }}
3. Schema first, then SELECT-only SQL · markdown
Inspect the available schemas and list the main tables with key columns.Then propose a read-only SQL query to answer: “How many new users signed up each day for the last 14 days?”Do not run INSERT/UPDATE/DELETE/DROP. Explain the query before executing any SELECT.

Expected result

A schema overview and a proposed read-only query with an explanation of joins/filters — no destructive statements.

Sample output

Tables: users, orders, order_itemsSuggested query: count orders by day for the last 14 days…

Troubleshooting

  • Connection refused: check host/port/VPN and that the role can connect- Agent proposes DROP/UPDATE: stop and tighten the prompt to SELECT-only- Stdio server — not usable from ChatGPT’s remote-only MCP path

Report an issue