Postgres is probably already running somewhere in your stack. Claude Code is Anthropic's AI coding CLI that lives in your terminal. Sequel's MCP server connects the two so you can ask questions about your Postgres data directly from the command line. No context switching, no SQL, no opening a DB client.
This guide walks you through the full setup in four steps.
What You'll Accomplish
By the end of this guide, you'll be able to open a terminal, run Claude Code, and ask questions like:
- "How many users signed up last week?"
- "Which products have had more than 100 orders in the past 30 days?"
- "Show me the top 5 customers by lifetime value."
Claude Code will use Sequel's MCP server to translate those questions into SQL, run them against your PostgreSQL database, and return the results. All without leaving your terminal.
Prerequisites
- A Sequel account: Sign up free at sequel.sh
- A running PostgreSQL database: local or cloud-hosted (RDS, Supabase, Neon, Railway, etc.)
- Claude Code installed: run
npm install -g @anthropic-ai/claude-codeif you haven't already
Step 1: Connect Your PostgreSQL Database to Sequel
Sign in to sequel.sh and click Data Sources in the left sidebar.

Click New Connection. On the "Choose a connector" page, select PostgreSQL.

Fill in two fields:
- Connection Name: a memorable label, e.g.
Production DB - Connection String: your full PostgreSQL connection string:
postgresql://username:password@host:5432/database_name

Click Connect. Sequel will verify your credentials and save the connection.
Tip: For safety, create a read-only PostgreSQL user before connecting:
CREATE USER sequel_reader WITH PASSWORD 'a_strong_password'; GRANT CONNECT ON DATABASE myapp TO sequel_reader; GRANT USAGE ON SCHEMA public TO sequel_reader; GRANT SELECT ON ALL TABLES IN SCHEMA public TO sequel_reader;Then use
postgresql://sequel_reader:a_strong_password@host:5432/myappas your connection string.
Step 2: Get Your Sequel API Key
Click Settings in the left sidebar, then select API Keys from the settings navigation.

Click New key, give it a name like claude-code, and copy the generated key. It starts with sql_. Keep it secure and treat it like a password.
Step 3: Configure Claude Code to Use Sequel MCP
In your terminal, run:
claude mcp add sequel \
--transport http \
https://api.sequel.sh/mcp \
--header "Authorization: Bearer sql_your_api_key"
Replace sql_your_api_key with the key you copied in Step 2.
Verify it was registered:
claude mcp list
You should see sequel listed as a configured MCP server.
Step 4: Query Your PostgreSQL Database
Start a Claude Code session and try a few natural language queries:
How many rows are in the users table?
Show me orders placed in the last 7 days, grouped by day.
Which user has the highest total spend?
Claude Code will call the Sequel MCP server, which queries your PostgreSQL database and returns the results directly in your terminal.
What You Can Do Now
- Debug data issues: ask "Are there any orders with a null customer_id?" or "Find duplicate email addresses in the users table."
- Explore unfamiliar schemas: ask "What tables exist?" or "What does the events table look like?" without opening a SQL client.
- Generate quick reports: ask "Summarize revenue by product category for the past quarter."
- Write better queries: describe what you want, get working SQL back, then adapt it for production.
- Audit changes: ask "Which records were updated in the last 24 hours?"

