Agent prompts · six steps

Let your agent set it up for you.

Using an AI coding agent like Claude Code, Cursor, Codex or Gemini CLI? Paste the first prompt and it installs NexQL, saves your connection, wires your app and checks it works. Each step below shows a real run in Claude Code: what you said, what the agent ran and what came back. The one thing it never touches is your password: you type that once, in your own terminal.

Step 01 of 06 · Paste one prompt
01Get started

Paste one prompt

you paste

Set up NexQL MCP (https://github.com/NexQL-OSS/mcp), a Postgres MCP server, for me. Follow these steps in order and don't improvise extra ones. …

Your agent

Then your agent does

  1. 1runs node --versionv26.12.1
  2. 2asks for host, port, database, user, SSL and your appnot the password

Node v26.12.1 is installed, so we can continue. Next I need your connection details (not the password): host, port (5432 if you're not sure), database name, user, whether it needs SSL (hosted databases usually do), and which app you're using me in.

to paste
1 prompt
passwords in chat
0
PASTE INTO YOUR AGENT
Set up NexQL MCP (https://github.com/NexQL-OSS/mcp), a Postgres MCP server, for me. Follow these steps in order and don't improvise extra ones.

Never ask me for my database password, and never put one in a command, a file or this chat. If I paste one by accident, don't use it, and tell me to change it.

1. Run `node --version`. If Node.js isn't installed, tell me to install it from nodejs.org and stop.
2. Ask me for my database's host, port (5432 if I don't know), database name and user, whether it needs SSL (hosted databases usually do), and which app I'm using you in. Not the password.
3. Write out this command filled in with my details, and ask me to run it in my own terminal window, not yours:
   npx -y nexql-mcp@latest profile add mydb --host <host> --port <port> --dbname <database> --user <user> --access-mode read
   If it needs SSL, add --sslmode require to the end.
   It asks me for the password without showing it, tests the connection and saves the password in my OS keyring. It needs a real terminal, so it can't work in yours. Wait until I tell you it printed "✓ Profile 'mydb' saved".
4. Run `npx -y nexql-mcp@latest --profile mydb init <client> --apply`, with <client> set to my app (claude-code, claude-desktop, cursor, vscode-copilot, windsurf, zed, antigravity, gemini-cli, codex, copilot-cli, cline, lm-studio, kiro, kimi or qwen). It prints a diff of the app's MCP config, then "✓ wrote <app> (<path>)", plus a backup path if the file already existed. Show me the diff, and the backup path if there is one.
5. Run `npx -y nexql-mcp@latest --profile mydb doctor` and tell me what it reports.
6. Tell me how to restart or reload my app so it picks up NexQL.

Covers every step on this page. The steps after this one show the rest of the same session, each with its own prompt if you'd rather go one at a time.

WHAT YOUR AGENT RAN
$ node --version
v26.12.1
OR DO IT ALL IN YOUR BROWSER
npx -y nexql-mcp@latest setup

Opens a page on your computer where you add the connection, type the password and pick your apps. No agent needed.

02Connect

Save your connection

you reply

Host localhost, port 5432, database ecommerce_core, user app_reader. No SSL, it's a local Docker database. I'm using you in Claude Code, in this project folder.

Your agent

Then your agent does

  1. 1fills in the profile add command, but doesn't run it
  2. 2you run it in your own terminal and type the passwordhidden
  3. 3it tests the connection and saves the profile84ms

Thanks. It's local with no SSL, so it doesn't need --sslmode. Please run this in your own terminal window, not mine. It asks for your password without showing it, tests the connection, and saves the password in your OS keyring. Let me know when it prints "✓ Profile 'mydb' saved".

passwords in chat
0
access mode
read
PASTE INTO YOUR AGENT
Help me save my database connection for NexQL MCP. Never ask me for my database password, and never put one in a command, a file or this chat. If I paste one by accident, don't use it, and tell me to change it.

Ask me for the host, port, database name and user, and whether it needs SSL. Then write out this command filled in with my details for me to run in my own terminal window:

npx -y nexql-mcp@latest profile add mydb --host <host> --port <port> --dbname <database> --user <user> --access-mode read

If it needs SSL, add --sslmode require to the end.

Don't run it yourself: it asks for the password without showing it, and that only works in a real terminal. Wait for me to tell you it printed "✓ Profile 'mydb' saved". If it says the connection failed, help me check the host, port, user and SSL setting, not the password.
IN YOUR OWN TERMINAL
$ npx -y nexql-mcp@latest profile add mydb --host localhost --port 5432 --dbname ecommerce_core --user app_reader --access-mode read
password for 'mydb' (hidden; leave empty if none):
✓ Connection verified: PostgreSQL 17.11 (Debian 17.11-1.pgdg13+2) on x86_64-pc-linux-gnu (latency: 84ms)
✓ Profile 'mydb' saved to ~/.config/nexql-mcp/config.toml

Nothing shows while you type the password. The agent only hears back that it printed the saved line.

OR RUN IT YOURSELF
npx -y nexql-mcp@latest profile add mydb --host <host> --port <port> --dbname <database> --user <user> --access-mode read

Replace the <placeholders>. If the database needs SSL, add --sslmode require.

03Wire up

Add NexQL to your app

you reply

OK, that worked: ✓ Profile 'mydb' saved to ~/.config/nexql-mcp/config.toml

Your agent

Then your agent does

  1. 1runs init claude-code --apply✓ wrote
  2. 2shows you the diff it printednew file, no backup

The profile is saved and the connection test passed, so I've wired NexQL into Claude Code. This project had no .mcp.json before, so there's no backup. The entry starts NexQL through npx and names the profile only. No connection string or password.

app mcp config
1 file
secrets in it
0
PASTE INTO YOUR AGENT
Wire NexQL MCP into the app you're running in. Run:

npx -y nexql-mcp@latest --profile mydb init <client> --apply

with <client> set to my app (claude-code, claude-desktop, cursor, vscode-copilot, windsurf, zed, antigravity, gemini-cli, codex, copilot-cli, cline, lm-studio, kiro, kimi or qwen). Ask me if you're not sure which. Use the profile name we saved, if it isn't "mydb".

It merges NexQL into the app's existing MCP config, prints a diff of the change, then "✓ wrote <app> (<path>)", plus a backup path if the file already existed. Show me the diff, and the backup path if there is one.

Then tell me how to restart or reload the app so it loads NexQL.
WHAT YOUR AGENT RAN
$ npx -y nexql-mcp@latest --profile mydb init claude-code --apply
--- /dev/null
+++ ~/shop/.mcp.json
@@ -0,0 +1,13 @@
+{
+  "mcpServers": {
+    "nexql-mcp": {
+      "args": [
+        "-y",
+        "nexql-mcp@latest",
+        "--profile",
+        "mydb"
+      ],
+      "command": "npx"
+    }
+  }
+}
\ No newline at end of file
✓ wrote Claude Code (~/shop/.mcp.json)

init merges NexQL into your app's existing MCP config and keeps the other servers, hiding their secrets in the diff. Run through npx, the entry starts npx; with NexQL installed, it starts that copy. If the file already existed, it also prints where it backed up the old one.

OR PICK APPS IN THE BROWSER
npx -y nexql-mcp@latest setup

Clients tab: tick your apps, check the diff, Apply. VS Code uses a servers block, and Windsurf and Antigravity have their own file paths; init and setup pick the right one for each app.

04Check

Prove it works

you reply

Yes, continue.

Your agent

Then your agent does

  1. 1runs doctor against your profile0.5s
  2. 2reads the report back to youdoctor: ok
  3. 3you quit with /exit, run claude again and approve nexql-mcp/mcp

Doctor passed. It reaches PostgreSQL 17.11 with the mydb profile, and every session is read-only with a 30s statement timeout. It warns that you're connected as a superuser: NexQL still keeps the session read-only, but a dedicated read-only role is safer, and it printed the SQL for one. There's no local schema index yet; the server builds one the first time it starts. Claude Code reads .mcp.json only at startup, so quit with /exit, run claude again in this folder, approve nexql-mcp, then check /mcp.

doctor
ok
every session
read-only
columns masked
11
PASTE INTO YOUR AGENT
Check that NexQL MCP works. Run this, using the profile name we saved:

npx -y nexql-mcp@latest --profile mydb doctor

Paste the full output here. If a check fails, tell me what it reported and how to fix it, and don't ask database questions until everything passes. A "no local index" warning is fine: the server builds the index the first time it starts. If it says "password authentication failed", ask me to run `npx -y nexql-mcp@latest profile set-password mydb` in my own terminal. Never ask me for my database password, and never put one in a command, a file or this chat. If I paste one by accident, don't use it, and tell me to change it.
WHAT YOUR AGENT RAN
$ npx -y nexql-mcp@latest --profile mydb doctor
resolved source=Profile profile=Some("mydb")
connected: PostgreSQL 17.11 (Debian 17.11-1.pgdg13+2) on x86_64-pc-linux-gnu
WARNING: connected as a superuser. A prompt-injected query can read server files (pg_read_file) and control the database server. Create role `nexql_readonly` (GRANT pg_read_all_data) and reconnect as that role. Copy-paste SQL: `nexql-mcp profile readonly-role`.
-- Least-privilege login for nexql-mcp (PostgreSQL 14+).
-- Replace the password, then point the profile at this role instead of a superuser.
CREATE ROLE nexql_readonly WITH LOGIN PASSWORD 'replace-with-a-secret';
GRANT pg_read_all_data TO nexql_readonly;
access_mode=Read superuser=WARNING
session default_transaction_read_only=on statement_timeout=30s
grants: can SELECT information_schema.tables
masking: personal data on; 11 column(s) masked in results: billing.v_unpaid_invoices.customer_email, customers.addresses.street_address, …
warning: pg_stat_statements extension not installed (slow_queries / index tools degraded)
warning: no local index for conn=mydb db=ecommerce_core under ~/.local/share/nexql-mcp — run `nexql-mcp index build`
doctor: ok

This database logs in as a superuser, so doctor warns and prints SQL for a safer read-only role. It also lists the personal-data columns it masks in results.

OR RUN IN YOUR OWN TERMINAL
npx -y nexql-mcp@latest --profile mydb doctor
05Use it

Ask your first question

You ask

NexQL shows as connected. Start with orient and give me an overview of the database.

Your agent

Then your agent does

  1. 1the server starts and builds its schema index29ms
  2. orientone call: foreign-key joins, then a digest of tables, views and functions474 lines

ecommerce_core is an e-commerce schema split into six areas: customers, catalog, orders, billing, inventory and core/audit. Orient found 26 foreign-key joins: orders link to customers, invoices link to orders, and transactions link to invoices and payment methods. It found no enum-like columns. There are also ready-made views, like billing.v_unpaid_invoices and inventory.v_low_stock_alerts. What would you like to know?

schema overview
1 call
joins found
26
PASTE INTO YOUR AGENT
NexQL MCP should now be connected to my Postgres database. Use its MCP tools for this, not raw SQL through a shell or a database driver you write yourself:

1. orient: call this first. One call gives you the foreign-key joins and a digest of the tables, views and functions.
2. search_schema: only if orient didn't already surface what I'm asking about.
3. get_join_path: only if the join I need isn't already in orient's overview.

After orient, ask me what I actually want to know before running any queries. Don't invent a question to demo the tools.

If I want another database connected later, call add_database with its host, port, database and user. It opens a page on my computer where I type the password myself.

The agent uses NexQL's MCP tools, not a raw SQL connection, so it finds tables before writing queries.

SERVER LOG ON FIRST START
index: no schema index for mydb/ecommerce_core — building automatically
index build: Started
…
index build: Finished { build_ms: 29 }
index built: conn=mydb db=ecommerce_core tables=24 views=6 functions=135 enums=0 shards=9 … (29ms, 11 queries)
WHAT ORIENT RETURNED (FIRST LINES)
[context connectionId=mydb database=ecommerce_core accessMode=read]
{
  "database": "ecommerce_core",
  "enums": {},
  "joins": [
    {
      "declared": true,
      "detection": "declared_fk",
      "disabled": false,
      "edge": "billing.invoices.order_id -> orders.orders.id",
      "via": "invoices_order_id_fkey"
    },
    {
      "declared": true,
      "detection": "declared_fk",
      "disabled": false,
      "edge": "billing.invoices.customer_id -> customers.users.id",
      "via": "invoices_customer_id_fkey"
    },
…

The rest: 26 joins, then a digest of 24 tables, 4 views, 2 materialized views and 10 functions, and a note: "Showing 40 of 165 objects — pass `focus` to narrow the digest."

06Keep it

Make it stick

You ask

How do I make sure my agent always uses NexQL for database work, not just this once?

Your agent

Then your agent does

  1. 1you paste the rule into your agent's rules file
  2. 2agent adopts it as a standing instruction
  3. 3every future database question goes through NexQL

One paste works everywhere. Claude Code reads CLAUDE.md, Cursor reads .cursor/rules, and most other agents accept the same block as an AGENTS.md or project instructions file.

works in any agent
1 paste
passwords in chat
0
PASTE INTO YOUR AGENT RULES FILE
Whenever you need to read, search, or modify data in this project's Postgres database, use the nexql-mcp MCP tools. Do not open a raw psql/DB-driver connection or hand-write a connection string.

- Call `orient` first on any database you haven't explored yet in this session. One call gives you the foreign-key joins and a digest of tables, views and functions instead of guessing.
- Use `search_schema` / `describe_object` before writing SQL. Never assume a table or column exists.
- Prefer `run_select` for reads; it enforces read-only, row limits and masking of personal data.
- For writes use `execute_sql` / `edit_row`; for schema changes use `apply_ddl`. Both run inside a transaction and support `dry_run: true` to preview first.
- If a statement is flagged CRITICAL risk (e.g. DROP TABLE, TRUNCATE), stop and get my explicit confirmation. Never pass `confirm_destructive: true` on your own judgment.
- nexql-mcp is read-only by default. Check `get_current_context` before assuming you can write.
- Never ask me for a database password, or put one in a command, a file or the chat. To connect another database, call `add_database`; I'll type the password on the page it opens.

Claude Code → CLAUDE.md; Cursor → .cursor/rules; many agents → AGENTS.md. Same block everywhere.

Tools in this walkthrough

Each one is explained in the docs: what it does, how it works and what it needs.

Guided tourSet it up yourself in five minutesPick your app, install, connect a database, ask.See a sessionWatch NexQL answer a real questionA sales drop, traced to one slow request and fixed.DocsHow every tool and guardrail worksAll 55 tools, access modes, masking and more.