SequelPG v0.4.0: an MCP server for Claude, Cursor and other AI assistants
AI coding assistants write better SQL when they can see your schema, and answer better questions when they can look at the data. Usually that means pasting \d output into a chat, or handing the assistant a connection string with a password in it. SequelPG 0.4.0 offers a third way: it is now a Model Context Protocol (MCP) server. Claude Code, Claude Desktop, Cursor, VS Code and other MCP clients can browse schemas and run read-only queries on the connections you choose, using the connections you already saved — SSH tunnels and SSL settings included — without ever seeing a password.
Setup takes a few minutes; the step-by-step guide is at AI Assistants (MCP). This post is about what it does and how it keeps your database safe.
Off until you turn it on, one connection at a time
Nothing is shared by default. Three switches open it up:
- Settings → MCP → Enable MCP server. The same tab has Add buttons for Claude Code, Claude Desktop and Cursor, and copies the JSON config for any other client.
- MCP Access on each connection, in a new AI Assistants section of the connection form: Off, Read-only, or Read-only, allow superuser. Connections set to Off don’t exist as far as an assistant is concerned.
- An approval prompt the first time each client calls a tool. Allowed clients are listed in Settings, each with a Revoke button.
These settings live in your Keychain rather than in the app’s preferences, so another program running as you can’t quietly switch them on with defaults write.
Eight tools
The assistant gets list_connections, list_databases, list_schemas, list_objects, describe_table (columns, indexes, constraints with foreign keys, triggers, row estimate), get_ddl (the CREATE statement for tables, views, functions, types and more), run_query and explain_query. That’s enough for “which tables reference orders?”, “write a migration that adds this column”, or “why is this query slow?”.
How the assistant reaches the app
MCP clients start local servers as a process and talk to them over standard input and output. The process they start is SequelPG itself, with --mcp-stdio. In that mode it opens no window and touches no database: it forwards messages over a Unix socket in ~/Library/Application Support/SequelPG to the running app, and opens SequelPG in the background first if it’s closed.
All the real work stays in the app, which already has your connections, SSH tunnels and Keychain access. The socket is readable only by your macOS user, and the app checks that the process on the other end is its own executable. There is no network port. MCP queries run on their own database sessions, so an assistant never interrupts or changes a query in your windows.
What “read-only” means here
Every run_query and explain_query call goes through three layers:
- An allowlist. Exactly one statement, starting with
SELECT,WITH,VALUES,TABLE,SHOWorEXPLAIN. The check reads past comments and whitespace the way PostgreSQL’s lexer does — including a--comment that ends at a carriage return, which could otherwise hide aCOPY … TO PROGRAMbehind an innocent-lookingSELECT. - A read-only transaction. The statement runs inside
BEGIN READ ONLYwith a 30-secondSET LOCAL statement_timeout, and is always rolled back. A data-modifying CTE or a function that writes fails with “cannot execute … in a read-only transaction”. Advisory locks are released afterwards, and a cancelled query closes its connection instead of returning it to the pool. - A role check. A read-only transaction doesn’t limit a superuser: functions can still end other sessions and read or write files on the server. So when it connects, SequelPG refuses superusers and members of
pg_execute_server_program,pg_write_server_filesandpg_read_server_files, with a message that tells the assistant (and you) to use a role with onlySELECT.
For a local development database where postgres is the only role, MCP Access has a third choice, Read-only, allow superuser. It skips only the role check, and the form shows a warning while it’s selected.
Results are capped at 1000 rows (200 by default) and about 100,000 characters, and the assistant is told when rows were left out. Remember that whatever it reads goes to its model provider; the guide shows how to create a role that sees only the schemas you want it to.
Smaller fixes
- The SQL editor ends a
--comment at a carriage return, as PostgreSQL does, so scripts with CR line endings split into statements correctly.
Concretely, v0.4.0 means
- An MCP server for Claude Code, Claude Desktop, Cursor, VS Code and other clients, off by default
- One-click setup for Claude Code, Claude Desktop and Cursor, and a copyable JSON config for the rest
- Per-connection MCP Access: Off, Read-only, or Read-only, allow superuser
- An approval prompt for each new client, with Revoke in Settings
- Eight tools: connections, databases, schemas, objects, table details, DDL, read-only queries and EXPLAIN
- Queries limited to one allowlisted statement in a rolled-back read-only transaction, with a 30-second timeout
- Passwords stay in your Keychain; no network port is opened
Grab v0.4.0 from the latest release, then follow the setup guide.