Query a Postgres database from Claude
A Postgres MCP server gives your assistant a live connection to a database, so it can list tables, read column types, and run the queries it writes instead of guessing at your schema. That makes it practical to ask for a weekly revenue breakdown, debug a slow query with EXPLAIN, or draft a migration that matches the tables you actually have. Most servers accept a standard connection string, and several can be locked to read-only. Start with a read-only role on a replica before you point one at production, and check which tools can write.
Example prompts
Paste one into Claude, Cursor, or any MCP client once a matching server is installed.
List the tables in the public schema and describe how orders relate to customers.
How many users signed up each week over the last three months?
Run EXPLAIN ANALYZE on this query and tell me which index would speed it up.
Draft a migration that adds a nullable archived_at column to the projects table.
MCP servers for Postgres queries
The 12 strongest of 241 matching servers. Servers that name the topic directly come first.
- 65Trust score 65 of 100, Good
ohmyho.st
by amerged-org · TypeScript
Operate ohmyho.st hosting from your coding agent: deploy GitHub apps, Postgres, mail, domains.
Registry - 64Trust score 64 of 100, Good
codeDB Lens
by codedb-io · Go
Read-only health checks and data questions for SQL Server and PostgreSQL, with your saved profiles.
Registry
63Trust score 63 of 100, GoodMCP server for interacting with the Supabase platform
OfficialRegistryRemote- 62Trust score 62 of 100, Good
Hosted PostgreSQL MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
RegistryRemote - 57Trust score 57 of 100, Fair
mcp-ssh-manager
by bvisible · JavaScript
SSH for AI agents: commands, files, backups and health, with approval, a vault and an audit trail
Registry - 55Trust score 55 of 100, Fair
Deterministic security layer your AI can't be. 634 rules, 39 tools, CLI + doctor + host audit.
Registry - 55Trust score 55 of 100, Fair
Provision and connect third-party dev services (Supabase, Vercel, and more) from your coding agent.
Registry - 55Trust score 55 of 100, Fair
Finds authorization holes in Next.js + Supabase apps and live Supabase databases. No API key.
Registry - 55Trust score 55 of 100, Fair
Read-only diagnostics: Loki, Prometheus, PostgreSQL, Redis, BullMQ, Docker and GitHub.
Registry - 55Trust score 55 of 100, Fair
Postgres backend your coding agent builds over MCP; destructive actions wait for a person.
RegistryRemote - 55Trust score 55 of 100, Fair
Ekwo OS — open source accounting: ledger, invoices and VAT on your own Supabase or Postgres
by ekwo-ai
Double-entry books an agent keeps as the user: invoices, VAT returns, 174 country packs.
RegistryRemote
55Trust score 55 of 100, FairJam SQL Studio
Unknown author
Lets AI agents query SQL Server, PostgreSQL, MySQL, Oracle and SQLite via the Jam SQL Studio app.
Registry
How to set it up
- Pick a server. ohmyho.st is the strongest match. Check its tools and the API keys it needs on its page.
- Copy the config for your client. Open the install guide for Claude Desktop, Claude Code, Cursor, or VS Code, and paste the generated block into the client's config file. The client guides show where each config file lives.
- Restart and try a prompt. Restart the client so it loads the server, then paste one of the example prompts above.
Questions about Postgres queries
What is the best MCP server for Postgres queries?
ohmyho.st ranks first here with a trust score of 65/100, followed by codeDB Lens (64) and Supabase (63). Servers that name the topic directly come first, each group ordered by the public trust score, which nobody can pay for. See the methodology for how it is calculated.
How do I set up ohmyho.st in Claude or Cursor?
Open the install guide for Claude Desktop or Cursor, copy the generated config into the client's config file, add any API keys the server asks for, then restart the client. The client guides cover VS Code, Claude Code, Windsurf, and more.
Can I use a hosted server instead of installing one locally?
4 of the 12 servers listed here can connect remotely over HTTP, so there is nothing to run on your machine: Supabase, PostgreSQL MCP by InsightfulPipe, Backenly, and others. The rest run locally over stdio.
How many MCP servers can do this?
MCPpedia lists 241 published servers that match this use case. This page shows the 12 strongest matches; thin and duplicate listings are left out.