PostgresHow to serve PostgreSQL as a REST API and MCP server

Open PostgreSQL to apps and agents, permissioned per table.

Register it once as type postgres. Every table, view and materialized view is served as a PostgreSQL REST API and as MCP tools.

Every role, decided on the table. Every call, on the record. The rows stay in your Postgres; nothing is copied out of it.

Free licence: 50,000 requests a month, for any use, commercial included, no card. Need more? See pricing.

acme / people / postgres / acme / employee

Request

GET /minimal/api/rest/auto/v1/acme/people/postgres/acme/employee?fc=id,full_name,department_id&oy=id.as&ps=5&pg=0
Host: api.acme.example
LB-Access-Token: <your-access-token>

Response · 200

[
  { "id": 1, "full_name": "Rafael Delacroix", "department_id": 11 },
  { "id": 2, "full_name": "Rafael Müller", "department_id": 7 },
  { "id": 3, "full_name": "Rafael Novak", "department_id": 8 },
  { "id": 4, "full_name": "Kwame Haddad", "department_id": 6 },
  { "id": 5, "full_name": "Rafael Haddad", "department_id": 6 }
]

Four things that are specific to Postgres.

The name is postgres

postgres is the path segment, and the db_type you register the database with. The short code pg also works in the path and as the MCP type argument.

Writes are transactional

A multi-row insert lands in one transaction: send ten rows and either all ten insert or none do. A PUT or DELETE that matches many rows runs as one statement, atomic the same way. Schema statements are transactional on Postgres only.

Views are read like tables

A view or a materialized view is read through the same route; the join, if there is one, was built into the view when the database was set up. Acme’s schema lists v_employee_directory and mv_headcount_by_department beside its tables.

Defaults stay with the database

department.id fills itself from the database and is still not-null, so an insert sends "id": null to let the default run. Leaving the key out is refused as a missing required field.

Acme’s employee table, read and refused.

Acme’s Postgres database, in the project people. Both requests are lifted from the Book of Minimal and run as printed against a deployment.

acme / people / postgres / acme / employee

Request

DELETE /minimal/api/rest/auto/v1/acme/people/postgres/acme/employee?id=eq.5
Host: api.acme.example
LB-Access-Token: <token · roles hr-analyst · key_type -r-->

Response · 403

{
  "code": 403,
  "status": "Forbidden",
  "message": "insufficient permissions for this operation on this table, got [hr-analyst]"
}

The path reads organisation, project, database engine, database, table. fc picks columns, oy orders, ps and pg page. The refusal names the roles the caller held; a read-only token could not have deleted the row whatever its role. Vol. I, Chapter 5 is the full query language; Chapter 6 covers the three gates.

One table per call.

The Auto API reads and writes one table per call: no joins, no subqueries, no aggregate functions. A join belongs in a view, or in a Custom API definition. Sign-in comes from Zitadel in the Docker Compose setup, which can sign in your customers too, or from the gateway you already run; third-party services stay where they already are.

Also: MySQL and MariaDB · ClickHouse · All of Minimal Core · Pricing

Put it in front of a Postgres database.