For the complete documentation index, see llms.txt. This page is also available as Markdown.

Tutorials

Connect an AI agent (Cursor, VS Code / Copilot, Claude Desktop, or any stdio MCP client) to PostgreSQL using pREST: a REST API from PostgreSQL plus a read-only PostgreSQL MCP server on the same process.

This tutorial is local-first. You will:

  1. Run pREST against Postgres

  2. Prefer a read-only database role

  3. Install the prest-mcp adapter

  4. Wire an AI client to MCP tools

Requires pREST v2.1.0+.


Architecture

AI client (Cursor / VS Code / Claude / …)
        ↓ stdio
   prest-mcp
        ↓ HTTP POST /_mcp
   prestd
        ↓
   PostgreSQL (read-only role recommended)

The adapter only bridges transports. Schema discovery and queries are implemented in pREST β€” see MCP Overview.


1. Run PostgreSQL and pREST

Start Postgres locally (Docker, Homebrew, or your existing instance). Then install and run pREST β€” pick a channel from Distribution or Get pREST.

Example with Homebrew for the server:

Configure connection settings (Configuring pREST) and start prestd. Confirm the REST API and MCP discovery:

You should see "name": "prest" and a tools array.


2. Use a read-only role

Create a least-privilege role with CONNECT, USAGE, and SELECT only β€” full SQL: Read-only PostgreSQL for AI. Point pREST’s Postgres credentials at that role for AI-facing instances.


3. Install the MCP adapter

On macOS:

Or:

Details: Install pREST MCP Adapter Β· Homebrew tutorial.

Quick check:

(Leave it running only if you are testing manually; MCP clients spawn it themselves.)


4. Connect your AI client

Cursor

Create .cursor/mcp.json:

Full guide: Use with Cursor. Optional rules/skills: pREST for Cursor plugin.

VS Code / GitHub Copilot

Create .vscode/mcp.json with a servers entry ("type": "stdio", command prest-mcp, env PREST_MCP_URL). Use Copilot Agent mode to verify. Guide: Use with VS Code and Copilot.

Claude Desktop

Edit claude_desktop_config.json with the same command / env pattern (prefer an absolute path on macOS). Guide: Use with Claude Desktop.

OpenClaw

Configure MCP with prest-mcp and PREST_MCP_URL (see plugin examples/mcp-readonly/openclaw-mcp.example.json). Plugin guide: pREST for OpenClaw.

Other tools

Cline, Continue, Windsurf, and generic stdio clients: Other AI tools.

Registry package name: io.github.prest/prest.


5. Try it

Ask the agent:

  • β€œList databases available through pREST.”

  • β€œDescribe public.users.”

  • β€œSelect 5 rows from public.users.”

Expected tools include prest.list_databases, prest.describe_table, and prest.select.*. Limits and auth: MCP over HTTP.


Troubleshooting

Symptom
Fix

No /_mcp response

Upgrade to pREST v2.1.0+; confirm host/port

Adapter exits on start

Set PREST_MCP_URL

Client cannot spawn binary

Absolute path to prest-mcp; brew install prest/tap/prest-mcp

Empty tools

Grants / permissions; restart pREST after schema changes

Auth errors

Set PREST_MCP_TOKEN when JWT auth is enabled


Next steps

Last updated