pREST v2.0.0 and v2.1.0 — PostgreSQL REST API with Multi-Database and MCP

pREST v2.0.0 lets one deployment front several Postgres clusters, picked by the first URL path segment. v2.1.0 adds a read-only MCP endpoint at /_mcp. Agents query Postgres through pREST’s existing auth and ACL, with no separate MCP process.

pREST is the open-source PostgreSQL REST API for Go teams, and v2.0.0 is its first stable v2 release. Below is what shipped and how to set it up. See v2.0.0 and v2.1.0.

pREST v2 series: Architecture (rc6) → This post (v2.0.0 / v2.1.0 GA) → MCP tutorial → AI plugins

Table of Contents

What v2 gives you

pREST is an open-source Go tool that turns PostgreSQL into a REST API. It exposes tables and custom SQL scripts over HTTP with low-code CRUD, authentication and access control. It’s a lightweight option for teams that want a Postgres-backed API without writing every handler by hand. It targets Go backends, existing Postgres applications, and teams moving from ad-hoc REST layers to config.

v2 is worth the upgrade if you run one of these:

  • Multi-tenant SaaS, routing each tenant to a registered database alias with per-tenant ACL.
  • Multi-cluster operations, with one pREST deployment fronting Postgres clusters on different hosts.
  • Agent-safe database access. The v2.1.0 MCP endpoint exposes read-only, permission-aware queries to Cursor, Claude or custom agents.
  • A team on rc6 that wants GA without a second architectural rewrite.

What shipped in v2.0.0 and v2.1.0

Version 2 is a major overhaul of pREST’s internals. It came in three milestones:

  1. The release candidates (rc6) brought hexagonal architecture, Adapter port decomposition and dependency-injected controllers. The prior architecture post covers them in depth.
  2. v2.0.0 GA added production hardening: a multi-database registry, PrestConf and connection management, and configuration resilience.
  3. v2.1.0 added agent integration: read-only MCP over HTTP on the same server.

If you followed the rc6 cycle, v2.0.0 and v2.1.0 build on that foundation. They’re incremental, with no second rewrite. Three merged PRs ship between v2.0.0-rc6 and v2.0.0.

Multi-database registry (PR #973)

This is the headline feature of v2.0.0. pREST can route requests to multiple Postgres clusters through a database registry:

  • The first URL path segment selects a registered database alias (e.g. GET /tenant-a/public/users).
  • Each alias can point to a different host, port and credentials.
  • access.tables entries can scope rules per alias and schema.
  • GET /_ready pings the default database and every registered alias.

It closes issues #943 to #946.

PrestConf and connection management (PR #972)

  • Config-driven adapter startup with clearer errors for non-Postgres adapters.
  • Connection pooling with singleflight deduplication.
  • A logsafe package that redacts database credentials in error logs.
  • Per-adapter statement caching and context-aware health checks.
  • Less reliance on global runtime state.

Configuration resilience (PR #974)

  • Malformed or missing config files fall back to safe defaults instead of blocking startup.
  • JWT misconfiguration disables auth with warning logs (non-fatal).
  • Invalid structured config keys warn and default to zero values.

What carried over from rc6

Everything from the release candidate line remains in v2.0.0 and v2.1.0:

  • Hexagonal architecture, Adapter port split, DI controllers (#968)
  • JWT auth bypass fix (#960)
  • OR clause support (#958)
  • GoReleaser Docker images (#953), Go 1.26, split unit/integration CI
  • Structured logging via slog (#950)

See the architecture post for the Adapter decomposition and request-flow details.

Step 1: pick a routing mode

pREST uses the first URL path segment as the database selector for CRUD, catalog and script routes. What that segment means depends on whether a registry is configured.

Mode When {database} in URL Connection target
Legacy multi-DB No registry configured Postgres database name Same host; dbname = path segment
Registry multi-cluster [[databases]] or env registry set Registered alias Per-profile host, port, credentials

Example routes:

GET /tenant-a/public/users
GET /tenant-a/public
GET /_ready

Step 2: register one alias per tenant

A common pattern is one alias per tenant (tenant-a, tenant-b), each pointing at an isolated Postgres database or schema. URL routing stays consistent: /{alias}/{schema}/{table}.

Registry configuration supports TOML for local development. In production, use indexed environment pairs:

DATABASE_ALIAS_1=tenant-a
DATABASE_URL_1=postgres://user:pass@cluster-a.example.com:5432/app_a?sslmode=require

Full configuration examples are in the pREST README.

Step 3: scope permissions per alias

access.tables enforces per-tenant read and write rules. Each rule can name the alias it applies to:

[[access.tables]]
database = "tenant-a"
schema = "public"
name = "users"
permissions = ["read"]

Step 4: budget pools and check readiness

Pools are keyed by connection URI, so aliases sharing the same URI share a pool. Plan the connection budget per cluster as replicas × aliases × pg.maxopenconn.

Point Kubernetes readiness probes at /_ready. It confirms every alias is reachable before the pod accepts traffic.

Step 5: add MCP with v2.1.0

v2.1.0 adds a read-only MCP-compatible endpoint at /_mcp (PR #977, closes #959). It runs on the same server that serves catalog, CRUD and script routes.

Model Context Protocol (MCP) is the open standard agents use to discover and call tools. pREST implements it as HTTP JSON-RPC on the existing server, with no separate MCP daemon and no extra port. The MCP surface inherits pREST’s deployment model, database routing, identifier validation and access control. When auth is enabled, /_mcp requires authentication like other protected routes.

  • Supported JSON-RPC methods: initialize, tools/list, tools/call.
  • Catalog discovery tools: prest.list_databases, prest.list_schemas, prest.list_tables.
  • Schema-aware selects, one per table.

The pREST MCP server tutorial has the step-by-step setup. It covers a Docker quick start, a curl walkthrough, and Cursor and Claude Desktop configuration. For the official prest-mcp adapter and Cursor/OpenClaw plugins, see AI plugins.

How to upgrade

From v1.x, expect breaking changes. v2 has a new module path (github.com/prest/prest/v2), config shape updates and bcrypt as the default password encryption. Test in staging before production.

From rc6, the upgrade is incremental. Add multi-database registry config if you need multi-cluster routing. Move to v2.1.0 when you want MCP.

Pull the images with Docker:

docker pull prest/prest:v2.0.0
docker pull prest/prest:v2.1.0

v2.1.0 is tagged on GitHub, and formal release assets may follow, so pin the tag. Open issues or discussions on prest/prest for migration questions.

Both pREST and PostgREST expose PostgreSQL over REST. PostgREST is Haskell-based and schema-driven. pREST is Go-native, with config-driven routes and custom SQL scripts. In v2 it also has a database registry and a built-in MCP endpoint. Choose on language ecosystem and deployment model. Also weigh whether you need multi-cluster aliases or agent-facing read tools.

If you’re weighing pREST against PostgREST, I wrote up the trade-offs in pREST vs PostgREST. The pREST v2 guide lists every release and which one to run.

FAQ

What is pREST?

pREST is an open-source Go tool that turns PostgreSQL into a REST API. It provides low-code CRUD over tables, custom SQL scripts, authentication and access control. It’s aimed at Go teams building on existing or new Postgres databases.

How is pREST v2 different from v1?

v2 brings hexagonal architecture with dependency-injected controllers, a multi-database registry and hardened PrestConf connection management. It adds configuration resilience and, in v2.1.0, a read-only MCP endpoint. v2 also bumps the Go module path to github.com/prest/prest/v2 and changes several config defaults.

What is multi-database support in pREST?

It lets pREST route HTTP requests to different Postgres clusters using registered aliases. The first URL path segment selects the alias. Permissions, connection pools and health checks are alias-aware, and you configure aliases via TOML or environment variables.

What is the MCP endpoint in v2.1.0?

v2.1.0 exposes a read-only MCP-compatible HTTP endpoint at /_mcp. It supports the JSON-RPC methods initialize, tools/list and tools/call for catalog discovery and schema-aware table reads. Auth and ACL from the REST API apply to MCP requests.

Is pREST an alternative to PostgREST?

Both are PostgreSQL REST API layers. PostgREST is Haskell-based and auto-generates routes from your schema. pREST is Go-native, supports custom SQL scripts and multi-cluster registry routing, and adds a built-in MCP endpoint in v2.1.0. The right choice depends on your stack and operational needs.

Should I upgrade from v1 or rc6?

From v1.x, plan for breaking changes and test in staging. From rc6, the upgrade is incremental: v2.0.0 for multi-DB and production hardening, v2.1.0 for MCP. Pin Docker tags or binaries to the exact version you validate.

Also from Insurgency Labs

pREST MCP and DeliveryCompass both follow a read-only, permission-aware model. pREST serves Postgres queries through /_mcp. DeliveryCompass gives engineering managers GitHub PR delivery metrics through a read-only dashboard. See the DeliveryCompass overview. It’s free during Early Access and isn’t a Jira replacement.