ClickHouseHow to serve ClickHouse as a REST API and MCP server

Serve ClickHouse as REST and MCP, with the history you choose.

Register it once as type clickhouse. Every table is served as REST routes and as MCP tools, merged by default and raw on request.

Every role, decided on the table. Every call, on the record. The rows stay in your ClickHouse; 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 / clickhouse / acme / employee

Request

GET /minimal/api/rest/auto/v1/acme/people/clickhouse/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 ClickHouse.

The name is clickhouse

clickhouse is the path segment, and the db_type you register the database with. The short code ch also works in the path and as the MCP type argument. A project can address Postgres and ClickHouse together; Acme’s people project does.

Merged by default, raw on request

A table whose table engine merges rows in the background (replacing, summing, collapsing, coalescing) reads in its fully merged form. uf=false reads every stored row, superseded ones included. On a non-merging table it does nothing; on a write it is refused with 400.

No transactions

ClickHouse has no transaction concept. A multi-row insert, and a PUT or DELETE that matches many rows, get no all-or-none guarantee, and a Custom API definition’s steps do not roll back as they do on every other database.

Schema runs can stop partway

A multi-statement schema run can leave some statements applied and later ones failed, so read each statement’s status in the run record. TRUNCATE, RENAME or DETACH combined with DATABASE is refused on ClickHouse only.

Change one word. Get the same answer.

The Book’s worked Acme database runs on Postgres. Move the same table to ClickHouse and the call changes in one place: postgres becomes clickhouse. The request, the role checks and the response stay the same, so moving a database is a configuration change, not a rewrite of the code that calls it.

acme / people / clickhouse / acme / employee

Request

DELETE /minimal/api/rest/auto/v1/acme/people/clickhouse/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]"
}

Acme’s employee table, as printed for Postgres in the Book of Minimal; only the database engine segment differs. Add uf=false to a read to get every stored row instead of the merged view. Vol. I, Chapter 5 is the full query language.

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: Postgres · MySQL and MariaDB · All of Minimal Core · Pricing

Put it in front of a ClickHouse database.