Skip to content
CoffeeQL docs · v1.0.9
Documentation · v1.0.9

Learn CoffeeQL, step by step.

This guide assumes you have never used CoffeeQL. Follow the Start here pages in order and you will have run a real query against a real database in about fifteen minutes. The rest is reference: come back to it when you need it.

Windows · macOS · LinuxPostgreSQL · MySQL · MongoDB · RedisNode · Python · Dart · .NET
New here? Four steps, in this order
  1. Install the server: one command, or download it and double-click coffeeql-server.
  2. Start it: coffeeql-server dev. Studio opens in your browser by itself, already signed in.
  3. Connect a database in Studio (+ Connect) and run a query: Your first query.
  4. Optional: click Link account at the top of Studio to connect the server to code.coffeeql.dev. Then AI tools can use your databases through the dashboard, and every change they make shows up there (and, with a licence key, can be undone): The dashboard.
You do not need an account for steps 1 to 3, and you never need to log in before starting the server.

What is CoffeeQL?

CoffeeQL is a universal layer that keeps AI off your database and speaks every database. Your applications and AI agents talk to CoffeeQL, never to your databases: it holds the connections, records every change with the rows before and after, and can undo them with a licence key.

It is also one query language for several kinds of database. You write a query once; CoffeeQL works out which database it is for, turns it into that database's own language (SQL for PostgreSQL and MySQL, a find for MongoDB, commands for Redis) and runs it there.

It is made for the moment an application stops having one database. Orders in PostgreSQL, product documents in MongoDB, sessions in Redis: without CoffeeQL that means three drivers, three connection pools and three ways of writing a query. With it, it is one.

users[]
  .where(plan = "pro", balance > 2000)
  .give(name, email)
  .sort(balance, DESC)
  .cup(10)

Read it left to right: take the users table, keep the Pro users with more than 2,000 in their balance, give me their name and email, sort by balance from high to low, and give me at most ten.

What CoffeeQL is notIt does not replace Prisma, Drizzle or GraphQL, and it does not do migrations. If your whole app runs on one PostgreSQL database and your ORM makes you happy, keep your ORM. CoffeeQL is for coordinating several databases, and it works alongside those tools.

The three pieces

PieceWhat it isWhere it runs
coffeeql-serverThe engine. Holds your database connections, runs queries, keeps a journal of every change, with the rows before and after.Your computer or your server
An SDKThe library your code calls: npm install coffeeql, pip install coffeeql, and so on.Inside your application
The dashboardA website where you create API keys for AI agents and see what they changed.code.coffeeql.dev

You do not need all three. Which parts do I need? has a quick table.

Start here · 1

Words you'll see

A few words come up everywhere in these docs. Here is what each one means, in plain language.

WordMeaning
CollectionA structured table (users[]), an unstructured document collection (products{}), or a key-value entry (session:u42{}). The brackets classify data shape and structure, decoupled from the underlying storage engine.
QueryOne CoffeeQL statement, such as users[].give(name). One query text holds exactly one statement.
ChainThe methods after the collection, joined by dots: .where(…).give(…).cup(…).
AdapterA registered pairing of one collection with the connection string of the database it lives in. You register adapters on the server with /connect.
Connection stringThe address of a database with its username and password, like postgresql://user:pass@localhost:5432/shop.
TokenThe password of your CoffeeQL server. Every request sends it as Authorization: Bearer <token>.
CommitThe record the server keeps of one change: which rows, what they were before and after. A commit can be reverted.
Dry runAsking the server "what would this change?" without changing anything.
MCPThe protocol AI tools (Claude, Cursor, VS Code) use to call outside systems. CoffeeQL speaks it, so an AI agent can query your data.
StudioThe page your server shows at http://localhost:3080: type a query, press Run, see the rows.
Start here · 2

Install the server

The server is a single file called coffeeql-server. The installer finds out which system you are on, downloads the right build, checks its SHA-256 checksum against the published one, and puts it on your PATH. It needs no admin rights.

  1. Open PowerShellPress Win, type PowerShell, press Enter. You do not need "Run as administrator".
  2. Run the installer
    powershell
    irm https://coffeeql.dev/install.ps1 | iex
    It installs to %USERPROFILE%\.coffeeql\bin\coffeeql-server.exe and adds that folder to your user PATH.
  3. Close PowerShell and open a new windowA window that was already open does not see the new PATH.
  4. Check it worked
    powershell
    coffeeql-server --version
    You should see coffeeql-server 1.0.9.
Windows on ARM (Surface, Snapdragon laptops)There is no native ARM64 build yet. The installer gives you the x64 build, which Windows runs through its built-in emulation.

Installer options

Set these environment variables before running the installer to change what it does.

VariableDefaultWhat it does
COFFEEQL_VERSION1.0.9Install another version.
COFFEEQL_INSTALL_DIR~/.local/bin · %USERPROFILE%\.coffeeql\binWhere the file goes.
COFFEEQL_NO_MODIFY_PATH—Windows only: set to 1 to leave your PATH alone.
COFFEEQL_DOWNLOAD_BASEhttps://releases.coffeeql.devDownload from a mirror of your own.
bash
# example: install into /opt/coffeeql/bin
curl -fsSL https://coffeeql.dev/install.sh | COFFEEQL_INSTALL_DIR=/opt/coffeeql/bin sh

Download it yourself

Prefer not to pipe a script into your shell? Download the archive for your system, check it, and unpack it.

Every file has a matching .sha256 next to it (add .sha256 to the link). Check the download before you run it:

bash · macOS / Linux
shasum -a 256 -c coffeeql-server-v1.0.9-aarch64-apple-darwin.tar.gz.sha256
tar -xzf coffeeql-server-v1.0.9-aarch64-apple-darwin.tar.gz
mv coffeeql-server ~/.local/bin/
powershell · Windows
(Get-FileHash .\coffeeql-server-v1.0.9-x86_64-pc-windows-msvc.zip -Algorithm SHA256).Hash
Get-Content .\coffeeql-server-v1.0.9-x86_64-pc-windows-msvc.zip.sha256
# the two hashes must be the same (the case does not matter)
Windows: double-click worksUnzip the file (right-click → Extract All; do not run it from inside the zip) and double-click coffeeql-server.exe. It starts in development mode and opens Studio in your browser. Keep the black window open: closing it stops the server. If Windows shows "Windows protected your PC", click More info → Run anyway (the file is not code-signed yet; the one-line installer above avoids this warning).
macOS: "cannot be opened because the developer cannot be verified"The binaries are not signed by Apple yet. A file downloaded with a browser is quarantined; clear it once with xattr -d com.apple.quarantine ~/.local/bin/coffeeql-server. The installer does this for you.

Upgrade and uninstall

  • Upgrade: run the installer again. It replaces the file. On Windows, stop a running server first.
  • Uninstall on Windows: irm https://coffeeql.dev/uninstall.ps1 | iex. It stops the server, unlinks it from your account, deletes %USERPROFILE%\.coffeeql\bin, takes it off your PATH, and asks before deleting the server's saved token and link.
  • Uninstall on macOS / Linux: curl -fsSL https://coffeeql.dev/uninstall.sh | sh. It stops the server, unlinks it from your account, and deletes ~/.local/bin/coffeeql-server and ~/.coffeeql/state.
  • Uninstall on Docker: docker rm -f coffeeql, then docker volume rm coffeeql-state.
  • Where the server keeps its files: ~/.coffeeql/state (%USERPROFILE%\.coffeeql\state on Windows): the hash of its token, its account link and its licence proof. It works the same from any folder; COFFEEQL_STATE_DIR puts them somewhere else.
Start here · 3

Your first query

You will start the server, give it a database, and run a query — first in the browser, then from the command line. Allow ten minutes.

What you need

  • The server, installed as on the previous page.
  • A database with some data in it. No database? Step 2 starts a PostgreSQL for you with Docker.
  1. Start the server in development mode
    terminal
    coffeeql-server dev
    Leave this window open. The server listens on http://localhost:3080, opens Studio in your browser, and prints the same link: Open Studio: http://127.0.0.1:3080/#token=cql_tok_…. Every call needs a token, in dev too: the one in that link is made for this run and stops working when the server stops (see Access tokens).
  2. Get a database with a table in it If you already have one, skip ahead. Otherwise, in a second terminal:
    terminal
    docker run -d --name cql-pg -e POSTGRES_PASSWORD=coffee -p 5432:5432 postgres:16
    Wait five seconds for it to start, then create a table with three rows:
    terminal
    docker exec -i cql-pg psql -U postgres -c "create table users (id serial primary key, name text, email text, plan text, balance int); insert into users (name, email, plan, balance) values ('Ada', 'ada@example.com', 'pro', 5200), ('Grace', 'grace@example.com', 'free', 300), ('Linus', 'linus@example.com', 'pro', 2600);"
  3. Open CoffeeQL Studio It opened when the server started. If not (or you closed it), open the Open Studio link from the terminal (Ctrl-click it in most terminals). The link signs Studio in; the token then leaves the address bar. Opening http://localhost:3080 without the link asks for the token.
  4. Tell the server where users[] lives In Connected Databases, click + Connect. Fill in:
    Keyusers[]
    Database URIpostgresql://postgres:coffee@localhost:5432/postgres
    Click Connect. users[] appears in the list.
  5. Run your first query Type this into the query box and press Ctrl Enter (or ▶ Run Query):
    users[].where(plan = "pro").give(name, balance).sort(balance, DESC)
    You get two rows back: Ada (5200) and Linus (2600). That is CoffeeQL reading PostgreSQL — you never wrote SQL.
  6. Look at the plan Click 🔍 Explain Plan, then the Plan tab. You see how the query was split into steps and which database each step runs on.

The same thing from the command line

Studio is a front end for the server's HTTP API. Here are steps 4 and 5 without the browser. First put the token from the Studio link (the part after #token=) in COFFEEQL_TOKEN.

bash
export COFFEEQL_TOKEN=cql_tok_…   # from the Studio link

# register users[]
curl -s -X POST http://localhost:3080/connect \
  -H "Authorization: Bearer $COFFEEQL_TOKEN" \
  -H 'content-type: application/json' \
  -d '{"adapters": {"users[]": "postgresql://postgres:coffee@localhost:5432/postgres"}}'

# run a query
curl -s -X POST http://localhost:3080/query \
  -H "Authorization: Bearer $COFFEEQL_TOKEN" \
  -H 'content-type: application/json' \
  -d '{"cql": "users[].where(plan = \"pro\").give(name, balance)"}'

The answer looks like this:

json
{
  "success": true,
  "schema": ["name", "balance"],
  "rows": [["Ada", 5200], ["Linus", 2600]],
  "row_count": 2,
  "elapsed_ms": 4
}

schema names the columns; each entry of rows is one row, in that column order. The SDKs turn this into a list of objects for you.

Two things beginners trip on
  • Register every collection you query. users[] and orders[] are two registrations, even if both tables are in the same database. Only Redis has a shortcut (see why).
  • Registrations live in memory. When the server restarts, connect again. The SDKs do this for you every time your app starts.

Clean up

terminal
docker rm -f cql-pg

Stop the server with Ctrl C in its window.

Start here · 4

Which parts do I need?

I want to…ServerSDKDashboard
Query my databases from a Node, Python, Dart or .NET app✓✓—
Try queries by hand✓ (Studio)——
Check a query is valid, in CI or an editor—✓ (npm, offline)—
Let an AI agent on my own machine use my databases✓ (coffeeql-server mcp)——
Let a hosted AI agent use my databases, with keys I can revoke✓—✓
Every SDK goes through the serverNode, Python, Dart and .NET all send each query to a coffeeql-server, so the server's safe-write checks and undo apply to every language. (The Python 1.0.9 package also shipped direct database adapters that skipped those checks; they are removed in the next release — see Python.)
SDK

Node.js & TypeScript

terminal
npm install coffeeql

The package does two things: it talks to your coffeeql-server to run queries, and it parses and plans queries offline, in WebAssembly, with no server at all.

Connect and query

javascript
import { CoffeeQL } from 'coffeeql';

const db = new CoffeeQL({
  server: 'http://localhost:3080',     // your coffeeql-server
  token: process.env.COFFEEQL_TOKEN,   // with `dev`: the token from the Studio link
  adapters: {
    'users[]':    'postgresql://postgres:coffee@localhost:5432/shop',
    'orders[]':   'postgresql://postgres:coffee@localhost:5432/shop',
    'products{}': 'mongodb://localhost:27017/shop',
  },
  timeout: 10000,                      // ms, the default
});

await db.connect();                    // registers the adapters on the server

const rows = await db.query('users[].where(plan = "pro").give(name, email).cup(10)');
console.log(rows);            // [{ name: 'Ada', email: 'ada@example.com' }, …]
console.log(rows.rowCount);   // 2
console.log(rows.elapsedMs);  // 4
console.log(rows.schema);     // ['name', 'email']

await db.disconnect();

query() returns an array of plain objects that also carries rowCount, elapsedMs, schema and rawRows.

Writing

javascript
await db.pour('users[]', { name: 'Ada', plan: 'free' });          // insert
await db.refill('users[]', 'id = 1', { plan: 'pro' });            // update where id = 1
await db.spill('users[]', 'id = 1');                               // delete where id = 1

// or write the query yourself
await db.query('users[].where(id = 1).refill({ balance: balance + 500 })');

Check a query without running it

javascript
import { isValid, coffeeql, explainQuery, version } from 'coffeeql';

isValid('users[].give(name)');          // true
isValid('users.give(name)');            // false — a collection needs [] or {}
coffeeql('users[].cup(0)').error;       // the parser's message, with line and column
explainQuery('users[].where(age > 18).give(name)');   // the steps, offline
version();                              // '0.4.0'

These run entirely inside your process — in Node, Bun, Deno and the browser. Use them in tests, in CI, or to check an AI's query before you send it.

Errors

javascript
import { CoffeeQLError } from 'coffeeql';
try {
  await db.query('users[].where(id = 1).spill()');
} catch (err) {
  if (err instanceof CoffeeQLError) console.error(err.status, err.message);
}
Known gaps in 0.4.0
  • The TypeScript types do not list the token option yet. In TypeScript, set the COFFEEQL_TOKEN environment variable instead — the SDK reads it automatically.
  • query() cannot send confirm, dry_run or max_affected_rows yet. For those, call POST /query directly.
  • The offline isValid() wrongly rejects a string containing // or -- (a URL, say). The server accepts it; this is fixed in the next package release.
SDK

Python

terminal
pip install coffeeql
export COFFEEQL_ENDPOINT=http://localhost:3080   # your coffeeql-server
export CQL_TOKEN=cql_tok_...                      # a server token or agent key

The Python package is a client for coffeeql-server, like the Node, Dart and .NET packages. Connect your databases to the server (config file, Studio or POST /v1/databases); your Python code only holds the server address and a token, never a database password. Every query and write goes through the server, so its safe-write checks, row limits, dry run and undo and read-only agent keys apply. The package has no other dependencies.

python
import coffeeql

db = coffeeql.Client()   # or Client(endpoint=..., token=..., database="pg")

rows = db.query('users[].where(plan = $1).give(name, email).cup(10)', "pro")
for row in rows:
    print(row['name'], row['email'])

db.pour('users[]', {'name': 'Ada', 'plan': 'free'})
db.refill('users[]', 'id = $1', {'plan': 'pro'}, 1)
db.spill('users[]', 'id = $1', 99)

preview = db.refill('users[]', 'plan = $1', {'plan': 'team'}, 'pro', dry_run=True)
print(preview.would_change)

print(coffeeql.explain('users[].where(plan = "pro").give(name)').rendered)   # local, no network
python · async
from coffeeql import CoffeeQL

db = CoffeeQL()            # same options; every method is awaitable
await db.connect()         # checks the server answers
rows = await db.query('users[].where(plan = $1)', "pro")
  • query() returns a list of dicts. The list also carries what the server reported: row_count, commit_id, revertible, dry_run, would_change.
  • The helpers send every value as a bound parameter. Write filters with $1 or $name and pass the values separately.
  • A refill or spill without a filter is refused by the server unless you pass confirm=True.
  • database="pg" makes the helpers address @pg:users[]; in your own queries write @alias: yourself.
  • db.raw('users[]', 'SELECT …') goes through the server's /raw route, which must be enabled and refuses read-only agent keys.
  • Errors are exceptions: AuthenticationError (401), PermissionDeniedError (403), BadRequestError (400), NotFoundError, RateLimitError (retried), ServerError, and GatewayUnavailableError when the server cannot be reached.
Not released yet — and the 1.0.9 package is differentThis describes the next Python release. The coffeeql 1.0.9 package on PyPI still includes PostgresAdapter, MongoAdapter, MySQLAdapter and RedisAdapter, which connect to databases directly and skip every server protection: no write checks, no row limit, no dry run, no undo, no audit. Do not use them; use the server functions (coffeeql.query, pour, refill, spill) instead. In the next release those adapters raise an error with migration steps. Parameterized updates and deletes (where(id = $1)) also need a coffeeql-server build newer than 1.0.9.
SDK

Dart & Flutter

terminal
dart pub add coffeeql        # or: flutter pub add coffeeql
dart
import 'package:coffeeql/coffeeql.dart';

final db = CoffeeQL(
  server: 'http://localhost:3080',
  token: const String.fromEnvironment('COFFEEQL_TOKEN'),
  adapters: {
    'users[]': 'postgresql://postgres:coffee@localhost:5432/shop',
  },
  timeout: const Duration(seconds: 10),
);

Future<void> main() async {
  await db.connect();
  final rows = await db.query('users[].where(plan = "pro").give(name, email)');
  for (final row in rows) print(row['name']);

  await db.pour('users[]', {'name': 'Ada', 'plan': 'free'});
  await db.shot([
    'users[].where(id = 1).refill({ balance: balance - 500 })',
    'users[].where(id = 2).refill({ balance: balance + 500 })',
  ]);
  await db.disconnect();
}
  • query() returns a list of maps; queryResultSet() also gives you the schema and timing.
  • pour, refill(collection, filter, data), spill(collection, [filter]), shot([...]), explain(), ping() and getAdapters() are all there.
  • In a Flutter app, never ship your server token inside the app: anyone can read it. Call your own backend, and let the backend talk to CoffeeQL.
SDK

.NET (C#, F#, VB)

terminal
dotnet add package CoffeeQL

The .NET client builds queries with methods and sends them to the server's /rpc endpoint. It does not register databases itself, so connect them on the server first (Studio, curl, or another SDK).

c#
using CoffeeQL;
using System.Text.Json;

var client = new CoffeeClient("http://localhost:3080/rpc", Environment.GetEnvironmentVariable("COFFEEQL_TOKEN"));

// builds: users[].where(plan = "pro").give(name, email).cup(10)
var reply = await client.Give("users", "name", "email").Where("plan", "pro").Cup(10).ExecuteAsync();

// the rows are JSON text inside the JSON-RPC answer
var text = reply.GetProperty("result").GetProperty("content")[0].GetProperty("text").GetString();
using var result = JsonDocument.Parse(text!);
foreach (var row in result.RootElement.GetProperty("rows").EnumerateArray())
    Console.WriteLine(row[0]);

What each builder writes

Call .ToCoffeeQL() on any builder to see its query without running it. These are real outputs:

C#CoffeeQL
Give("users", "name").Where(new { plan = "pro", active = true })users[].where(plan = "pro", active = true).give(name)
Give("products{}", "name", "price").WhereRaw("price > 100")products{}.where(price > 100).give(name, price)
Pour("users", new { name = "Ada", age = 36 })users[].pour({"name": "Ada", "age": 36})
Refill("users", new { plan = "team" }).Where("id", 1)users[].where(id = 1).refill({"plan": "team"})
Spill("users").Where("id", 1)users[].where(id = 1).spill()
Give("orders", "city").Blend("city")orders[].blend(city).give(city)
Give("users", "name").Mix("orders", "users[].id = orders[].user_id")users[].mix(orders[] ON users[].id = orders[].user_id).give(name)

A plain table name becomes a table (users → users[]); write "products{}" for a document collection. client.ExecuteRawAsync("…") runs a query you wrote yourself, and ShotAsync builds a transaction.

SDK

Java & Spring Boot

The Java SDK is served from CoffeeQL's own Maven repository at https://releases.coffeeql.dev/maven, so add it next to Maven Central.

kotlin · Gradle
repositories {
    mavenCentral()
    maven("https://releases.coffeeql.dev/maven")
}

dependencies {
    implementation("dev.coffeeql:coffeeql-spring-boot-starter:1.0.9") // Spring Boot 3
    // without Spring: implementation("dev.coffeeql:coffeeql-core:1.0.9")
}
xml · Maven
<repositories>
    <repository>
        <id>coffeeql</id>
        <url>https://releases.coffeeql.dev/maven</url>
    </repository>
</repositories>

<dependency>
    <groupId>dev.coffeeql</groupId>
    <artifactId>coffeeql-spring-boot-starter</artifactId>
    <version>1.0.9</version>
</dependency>

coffeeql-core is a Java 17+ client with no dependencies (CoffeeQLClient). The Spring Boot 3 starter adds auto-configuration, a CoffeeQLTemplate bean and an Actuator health indicator. Configure it in application.yml:

yaml
coffeeql:
  url: http://localhost:3080
  token: ${COFFEEQL_TOKEN}
java
@Service
public class UserService {
    private final CoffeeQLTemplate coffeeql;

    public UserService(CoffeeQLTemplate coffeeql) {
        this.coffeeql = coffeeql;
    }

    public List<Map<String, Object>> proUsers() {
        return coffeeql.collection("users[]")
            .where("plan = $plan")
            .give("id", "name", "email")
            .cup(20)
            .param("plan", "pro")
            .run()
            .asMaps();
    }
}
SDK

Go

terminal
go get coffeeql.dev/go@v1.0.9

Go 1.21+ client with context support, bound parameters and a fluent query builder:

go
import coffeeql "coffeeql.dev/go"

client := coffeeql.New("http://localhost:3080", coffeeql.WithToken(os.Getenv("COFFEEQL_TOKEN")))
rows, err := client.Query(ctx, "users[].where(active = true).cup(10)")
SDK

Any language (HTTP)

Everything the SDKs do is two HTTP calls, so any language that can send JSON can use CoffeeQL:

  1. POST /connect with {"adapters": {"users[]": "postgresql://…"}} — once, when your app starts.
  2. POST /query with {"cql": "users[].give(name)"} — for every query.

Send Authorization: Bearer <token> with both (unless the server runs as dev). The HTTP API page lists every endpoint, and your server serves an interactive reference at http://localhost:3080/docs.

The language

Collections & Structural Shapes

Every query starts with a collection. Its brackets classify the data shape and structure of the table or collection — tabular rows, schema-free JSON documents, or key-value entries. The brackets do not restrict or select the database brand; any connected database engine can host structured tables ([]), JSON/document collections ({}), or key-value entries (ns:id{}).

You writeData ShapeStorage Engines Supported
users[]Structured (Tabular): Relational fixed columns and rowsPostgreSQL, Supabase, MySQL, MariaDB, or typed MongoDB collections (ClickHouse in preview)
products{}Unstructured (Documents): Schema-free JSON/BSON with nested dotted pathsMongoDB, Firebase Firestore, Elasticsearch, OpenSearch, or PostgreSQL jsonb / MySQL JSON tables
session:abc123{}Key-Value Entry: Specific namespaced keyRedis, key-value stores, or indexed KV tables
rate:limit:api{}Composite Key: Multiple colon-separated segmentsRedis or KV cache engines
session:{}Key-Value Namespace: All keys in the namespaceRedis or KV stores

Database Selection: Decoupled from Syntax

How does CoffeeQL know which database to query if brackets classify the data structure rather than the vendor? CoffeeQL decouples data structure from database connection routing:

  • Automatic Catalog Discovery: When you register databases, CoffeeQL introspects schemas and maps collections to the appropriate database connection automatically.
  • Explicit Database Aliases: Prefix any collection with @alias: to route directly to a specific connected database instance — for example, @supabase:users[], @mongo:events{}, or @cache:session:abc123{}.

A collection on its own is already a complete query — it reads everything:

users[]
@supabase:users[]
session:abc123{}

Rules

  • A collection always has [] or {}. A bare word like users is a field name, never a collection.
  • Names use letters, digits and _, and do not start with a digit.
  • A Redis key's parts are separated by :; each part is a name or a whole number. A part cannot contain a dot, so a key like login:192.168.1.1 cannot be written as a collection.
The language

Reading data

After the collection comes a chain of methods. Each one narrows or shapes the result.

MethodWhat it doesSQL cousin
.where(condition)Keep only the rows that matchWHERE
.give(fields)Pick which fields to returnSELECT a, b
.sort(field, DESC)Order the rows (ASC is the default)ORDER BY
.cup(n)Return at most n rows (n ≥ 1)LIMIT
users[].where(plan = "pro", active = true).give(name, email, balance).sort(balance, DESC).cup(50)

Long queries read better over several lines. Spaces and line breaks do not matter:

users[]
  .where(plan = "pro", active = true)
  .give(name, email, balance)
  .sort(balance, DESC)
  .cup(50)

.give()

users[].give(id, name)
users[].give(*)
products{}.where(price > 100).give(title, price)

* means every field. A nested field of a document is reached with a dot: specs.watts.

.sort() and .cup()

users[].where(active = true).sort(age)
users[].where(active = true).sort(age, ASC).cup(10)
users[].cup(5)

The order of the chain

Methods must come in a sensible order. This table says what may come directly after what:

MethodMay come right after
.mix()the collection, .where
.where()the collection, .mix
.blend()the collection, .where
.give()the collection, .where, .mix, .blend
.sort().where, .give
.cup()the collection, .where, .mix, .blend, .give, .sort — and nothing may follow it
.pour()the collection
.refill(), .spill()the collection, .where
.explain()anything — it ends the chain

A query has at most one .where. Put all conditions into it, separated by commas.

The language

Conditions

Conditions go inside .where(…).

Comparing

OperatorMeansExample
=equal toplan = "pro"
!=not equal tostatus != "banned"
> >=greater than (or equal)age >= 18
< <=less than (or equal)score < 100
users[].where(age >= 18, age <= 65, score > 1, score < 100, status != "banned")

AND, OR and brackets

  • A comma means AND: every condition must be true.
  • A bar | means OR: at least one must be true.
  • The comma binds tighter, just like × before + in arithmetic: a = 1, b = 2 | c = 3 means (a = 1 AND b = 2) OR c = 3.
  • Use brackets to group differently.
users[].where(plan = "pro" | plan = "team")
users[].where((plan = "pro" | plan = "team"), active = true)

NOT and EXISTS

users[].where(!active).give(name)
products{}.where(discount EXISTS)

!active is true when the boolean field active is false. discount EXISTS is true when a document has a discount field at all.

Nested and qualified fields

products{}.where(specs.color = "red")

A dot reaches into a document. When a query joins two collections, write a field with its collection to say which one you mean: users[].plan, events{}.created_at.

The language

Values

KindWrite it asNotes
Text"Ada" or 'Ada'Escapes: \" \' \\ \/ \n \r \t \b \f \uXXXX
Number42, -3, 1.5No exponent form: write 1500000, not 1.5e6
True / falsetrue, false
Nothingnull
List["hot", "milk"]Any values, nested as deep as you like
Object{ size: "M" }Keys can be names or strings: { "size": "M" }
A new iduuid()A fresh UUID
Right nownow()The current date and time
Todaytoday()The current date
Arithmeticbalance - 500Only inside .refill: + - * / on fields
A duration45s 30m 1h 7d 2w 3mo 1yOnly inside .last(). Here m is minutes
A distance500m 5km 10miOnly inside .near(). Here m is metres
products{}.pour({ title: "Latte", price: 4.5, stock: 12, discount: null, day: today(), tags: ["hot", "milk"], specs: { size: "M" }, offset: -3 })
The language

Writing data

MethodDoesFollows
.pour({ … })Inserts one recordthe collection
.refill({ … })Updates the matching records.where(…)
.spill()Deletes the matching records.where(…)

Insert with .pour()

users[].pour({ id: uuid(), name: "Ada", email: "ada@example.com", plan: "pro", active: true, joined_at: now() })

Update with .refill()

users[].where(email = "ada@example.com").refill({ plan: "team", balance: 5000.00 })

A new value can be worked out from the current one:

users[].where(id = "usr_001").refill({ balance: balance - 500 })

Delete with .spill()

users[].where(id = 1).spill()
users[].where(!active).spill()
Always put .where before .refill and .spillusers[].spill() is valid CoffeeQL and means delete every user. The server refuses it unless you explicitly send "confirm": true — see Safe writes & undo. This applies to every SDK, because they all go through the server.

One write per query

.pour never has a .where or .give before it, and a query inserts one record. To do several writes together, use a shot.

The language

Grouping & totals

.blend(field) groups the rows by a field, like SQL's GROUP BY. The totals go into .give, each named with as.

orders[].where(status = "completed").blend(city).give(city, COUNT() as orders, SUM(total) as revenue).sort(revenue, DESC)
FunctionGives
COUNT()how many rows are in the group
SUM(field)the total
AVG(field)the average
MIN(field) / MAX(field)the smallest / largest
orders[].blend(city).give(city, COUNT() as n, SUM(total) as s, AVG(total) as a, MAX(total) as hi, MIN(total) as lo)

Function names are written in capitals. The name after as is the column name you get back, and you can sort by it.

The language

Joining collections

.mix() joins a second collection to the first — within the same database or across different databases.

1. Same-database joins

When both collections are in one PostgreSQL or MySQL database that is connected as a whole (POST /v1/databases), CoffeeQL compiles the join into a native SQL INNER JOIN: filters, the join, projections and limits run in your database. These joins need no licence. Collections registered one at a time with POST /connect count as separate databases, so a join between them is a cross-database join, even if they live in the same database.

users[].mix(orders[] ON users[].id = orders[].user_id)
  .where(users[].status = "active", orders[].total > 100)
  .give(users[].name, orders[].id, orders[].total)
  .cup(50)

2. Composite Joins with Multi-Condition AND

Joins can match on multiple columns using AND:

users[].mix(orders[] ON users[].id = orders[].user_id AND users[].org_id = orders[].org_id)
  .give(users[].name, orders[].total)

3. Cross-Database Federated Joins

When joining across two different engines (for example, a PostgreSQL table with a MongoDB collection), CoffeeQL uses a high-performance bind-join: it queries the left side first and asks the right side only for the keys that can match, joining results in memory.

users[]
  .mix(events{} ON users[].id = events{}.user_id)
  .where(users[].plan = "pro", events{}.created_at.last(7d))
  .give(users[].name, users[].email, events{}.type)
  .sort(events{}.created_at, DESC)
  .cup(100)
Both collections must be registered. Same-database joins on a database connected as a whole need no licence. Cross-database joins need a licence key (paid plans are on a waitlist); without one the server answers 403.
The language

Geo, AI & time filters

Four special methods go on a field, inside .where. What each one can do depends on the database behind the collection.

.near(latitude, longitude, distance)

stores[].where(location.near(12.97, 77.59, 5km))
stores[].where(location.near(12.97, 77.59, 500m))

Rows whose point is within the distance. The distance needs a unit: m (metres), km, mi.

.like("text") and .threshold(n)

docs[].where(embed.like("coffee beans").threshold(0.85))
docs[].where(embed.like("coffee beans"))

Rows whose vector field is similar in meaning to the text. .threshold is how similar (0 to 1); without it, 0.80 is used.

1.0.9 .similar("text") and .vector_match("text") are other names for .like("text"), and take the same .threshold(n).

products{}.where(embed.similar("dark roast").threshold(0.85)).select(id, name)

.has(value)

orders[].where(items.has("latte"))

Rows whose list field contains the value.

.last(duration)

events{}.where(created_at.last(7d))
events{}.where(a.last(2w) | b.last(3mo) | c.last(1y) | d.last(45s))

Rows whose time field falls within the last stretch of time. Units: s seconds, m minutes, h hours, d days, w weeks, mo months, y years.

The language

Transactions (shot)

A shot runs several statements as one transaction: either all of them happen, or none do. Put one statement per line, or separate them with /.

shot {
  users[].where(id = "usr_001").refill({ balance: balance - 500 })
  users[].where(id = "usr_002").refill({ balance: balance + 500 })
  transactions{}.pour({ from: "usr_001", to: "usr_002", amount: 500, at: now() })
}
shot { users[].where(id = 1).refill({ a: 1 }) / users[].where(id = 2).refill({ a: 2 }) / logs{}.pour({ n: 1 }) }
All statements of a shot must run on one database. A shot that spans databases is refused, because no database can promise all-or-nothing across another one.
The language

Schemas: grind & menu

grind — define a collection

grind users[] (id UUID PRIMARY, name TEXT NOT NULL, email TEXT UNIQUE, age INT, balance FLOAT, active BOOL, joined DATETIME)
grind events{}
TypeHoldsAlso written
UUIDa unique id—
TEXTtextSTRING, text, string
INTa whole numberINTEGER, int, integer
FLOATa decimal numberfloat
BOOLtrue or falseBOOLEAN, bool, boolean
DATETIMEa date and timeTIMESTAMP, datetime, timestamp
GEOPOINTa point on the mapgeopoint
VECTORan embedding, for .like()vector

Column options: PRIMARY (the primary key), UNIQUE (no duplicates), NOT NULL (must have a value).

menu — see what is registered

menu()
menu(users[])
The language

explain()

Add .explain() to the end of any query to see its plan instead of running it. Nothing is read or changed — even for a write.

users[].where(plan = "pro").give(name, email).explain()
users[].where(id = 1).refill({ plan: "pro" }).explain()

The npm package can also plan a query with no server at all: explainQuery(cql).

The language

Comments

Three kinds of comment are ignored by the parser:

users[]                      // the users table
  .where(plan = "pro")       -- only Pro users
  /* newest first */
  .sort(joined_at, DESC)

A //, -- or /* */ inside a quoted string is part of the string, not a comment — so "https://coffeeql.dev" is stored whole. (The server does this correctly; the 0.4.0 npm offline checker and Python package do not yet — see the changelog.)

The language

Other spellings

These are accepted because older code uses them. Each means exactly the same as the standard form. Write the standard form in new code.

Also acceptedStandard form
===
&& or AND / and,
|| or OR / or|
; between the statements of a shota line break or /
onON
asc, descASC, DESC
.select(...) 1.0.9.give(...)
.limit(n) 1.0.9.cup(n)
.offset(n).skip(n)
.group_by(...) or .groupby(...) 1.0.9.blend(...)
.insert({...}) 1.0.9.pour({...})
.update({...}) 1.0.9.refill({...})
.delete() 1.0.9.spill()
.similar("…"), .vector_match("…") 1.0.9.like("…")

The SQL names follow the same rules as the CoffeeQL ones. .delete(), like .spill(), must come straight after the collection or its .where(), so a filter can never be dropped by accident.

users[].where(status = "active").select(id, name).limit(10)
users[].where(status == "active" AND age >= 18)

…is the same query as…

users[].where(status = "active", age >= 18)
The language

Reserved words

These words belong to the language, so they cannot be used as bare field names:

where give sort cup blend mix pour refill spill explain shot grind menu on as and or last like has near threshold now uuid today null true false and every type name: text string int integer float bool boolean datetime timestamp geopoint vector uuid (in any of their spellings).

The one people hit mostA column called text, last or timestamp. notes{}.where(text = "hi") fails with expected expression, found DataType(Text). If you can, name the column something else (body, last_seen, created_at).
The language

Common mistakes

Every query on this page is wrong on purpose, with the fix next to it. They come from CoffeeQL's own test suite, so these are the real mistakes people make.

WrongWhyRight
users.give(id)A collection needs [] or {}users[].give(id)
users[].mix(orders[], users[].id = orders[].user_id)The join condition follows ONusers[].mix(orders[] ON users[].id = orders[].user_id)
users[].mix(products{}).give(name)A join needs ON a = busers[].mix(products{} ON users[].id = products{}.user_id).give(name)
users[].give(id) orders[].give(id)One query is one statementtwo queries, or a shot { … } for writes
users[].give(id);No ; at the endusers[].give(id)
users[].cup(5).give(id).cup ends the chainusers[].give(id).cup(5)
users[].give(id).where(id = 1)Filter first, then pick fieldsusers[].where(id = 1).give(id)
users[].where(a = 1).where(b = 2)One .where per queryusers[].where(a = 1, b = 2)
users[].where(a = 1 b = 2)Conditions are joined by , or |users[].where(a = 1, b = 2)
users[].where(id = 1).give(id).spill()The filter would be lost: .spill goes right after .whereusers[].where(id = 1).spill()
users[].where(id = 1).pour({ a: 1 })An insert has no filterusers[].pour({ a: 1 })
users[].cup(0)The limit must be 1 or moreusers[].cup(1)
events{}.where(created_at.last(5km))km is a distance, not a timeevents{}.where(created_at.last(5d))
stores[].where(location.near(12.97, 77.59, 5)).near needs a unitstores[].where(location.near(12.97, 77.59, 5km))
events{}.where(last(7d)).last belongs to a fieldevents{}.where(created_at.last(7d))
users[].where(a = 1).sort(age, UP)The direction is ASC or DESCusers[].where(a = 1).sort(age, DESC)
users[].fetch(10)There is no .fetchusers[].cup(10)
SELECT * FROM usersThis is SQL, not CoffeeQLusers[].give(*)
When a query is wrong, the parser says where: "Spilled query at line 2, column 9". Check that spot first.
The language

Every keyword, A–Z

Every word and symbol CoffeeQL understands, in one place. Type to filter.

KeywordKindWhat it doesExample
[]collectionA table (PostgreSQL, MySQL)users[]
{}collectionDocuments (MongoDB), or a key (Redis) after :products{}
:collectionSeparates the parts of a Redis keysession:u42{}
.where()readKeep matching rows.where(age >= 18)
.give()readPick the fields to return.give(name, email)
*readEvery field (in .give); multiply (in .refill).give(*)
.sort()readOrder the rows.sort(balance, DESC)
ASC / DESCreadLow to high (default) / high to low.sort(age, ASC)
.cup()readAt most n rows; ends the chain.cup(10)
.blend()groupGroup rows by a field.blend(city)
COUNT()groupRows in the groupCOUNT() as n
SUM()groupTotal of a fieldSUM(total) as revenue
AVG()groupAverage of a fieldAVG(total) as avg
MIN() / MAX()groupSmallest / largest valueMAX(total) as hi
asgroupNames a total's columnCOUNT() as orders
.mix()joinJoin another collection, even from another database.mix(orders[] ON users[].id = orders[].user_id)
ONjoinStarts the join condition in .mixON a[].id = b{}.a_id
.pour()writeInsert one record.pour({ name: "Ada" })
.refill()writeUpdate matching records.refill({ plan: "pro" })
.spill()writeDelete matching records.where(id = 1).spill()
shot { }statementRun several statements as one transactionshot { … / … }
/statementSeparates the statements of a shot; divide (in .refill)shot { a / b }
grindschemaDefine a collection and its columnsgrind users[] (id UUID PRIMARY)
menu()schemaList what is registeredmenu(users[])
PRIMARYschemaThe primary-key columnid UUID PRIMARY
UNIQUEschemaNo two rows may share the valueemail TEXT UNIQUE
NOT NULLschemaThe column must have a valuename TEXT NOT NULL
UUID TEXT INT FLOAT BOOL DATETIME GEOPOINT VECTORtypeColumn types for grind (see aliases)age INT
.explain()statementShow the plan instead of running.give(name).explain()
= != > >= < <=conditionCompare two valuesage >= 18
,conditionANDa = 1, b = 2
|conditionORa = 1 | a = 2
( )conditionGroup conditions(a = 1 | a = 2), b = 3
!conditionNOT, on a true/false field!active
EXISTSconditionThe field is presentdiscount EXISTS
.near()filterWithin a distance of a pointlocation.near(12.97, 77.59, 5km)
.like()filterSimilar in meaning (vectors)embed.like("latte")
.threshold()filterHow similar, 0–1 (default 0.80).like("latte").threshold(0.9)
.has()filterA list field contains the valuetags.has("hot")
.last()filterWithin the last stretch of timecreated_at.last(7d)
s m h d w mo yunitSeconds, minutes, hours, days, weeks, months, years — in .last30m
m km miunitMetres, kilometres, miles — in .near500m
uuid()valueA new unique id{ id: uuid() }
now()valueThe current date and time{ at: now() }
today()valueThe current date{ day: today() }
true false nullvalueYes, no, nothingactive = true
+ -valueAdd, subtract (in .refill); - also for negative numbersbalance: balance + 500
// -- /* */commentIgnored by the parser-- a note
== && AND || OR ; on asc descaliasOther spellings — see the tablea == 1
The server

Running it

CommandWhat it does
coffeeql-server devStarts a server on 127.0.0.1:3080 and prints a Studio link with a token made for this run. Set COFFEEQL_TOKEN for one that stays the same.
coffeeql-serverStarts a server that requires a token. Use this anywhere else.
coffeeql-server initWrites a starter coffeeql-server.toml in the current folder (--force overwrites one).
coffeeql-server mcpRuns as an MCP server over stdin/stdout, for AI tools on your machine. See Connect an AI.
coffeeql-server --helpEvery option.
coffeeql-server --versionPrints the version.

When it starts, the server prints its address, whether a token is required, and — the first time — a newly generated token. Stop it with Ctrl C.

Run it in the background

To keep the server running after you close the terminal, start it in the background. It keeps the same state folder, so the link to code.coffeeql.dev and your databases come with it.

CommandWhat it does
coffeeql-server startStarts the server in the background on 127.0.0.1:3080 (--port for another) and returns. Running it again while it runs says so and changes nothing.
coffeeql-server statusWhether it runs, its address, its databases and the account it is linked to.
coffeeql-server openOpens Studio for the running server, already signed in.
coffeeql-server logsThe last 50 lines of its log (-n 200 for more). The log is ~/.coffeeql/state/server.log.
coffeeql-server stopStops it.
coffeeql-server autostart onStarts it every time you log in (off undoes it). Windows: a value under HKCU\…\Run. macOS: a LaunchAgent. Linux: a systemd user service.

On a server machine with no one logged in, use Docker (Docker) or your own service manager with the plain coffeeql-server command instead.

Besides the API, the server shows: Studio at /, an interactive API reference at /docs, and health checks at /health, /ping and /ready. These pages need no token; everything else does.

The server

Access tokens

A token is the password of your server. Anyone who has it can read and change every database the server is connected to, so treat it like one.

Getting a token

Option 1 — let the server make one. Start it without any token set. The first start prints a new one once:

server output
  ┌─ Your API token (shown once, only its hash is stored in ~/.coffeeql/state/.coffeeql_token_hash) ─
  │  cql_…
  └─ Send it as   Authorization: Bearer <token>   Set COFFEEQL_TOKEN to use your own instead.
Copy it right awayThe server keeps only a hash of the token and can never show it again. Lost it? Delete .coffeeql_token_hash in the state folder and restart for a new one.

Option 2 — choose your own. Any of these works:

terminal
coffeeql-server --token my-long-random-value
COFFEEQL_TOKEN=my-long-random-value coffeeql-server
# or, in coffeeql-server.toml:  tokens = ["my-long-random-value"]

Several tokens can be active at once (comma-separated), which lets you rotate: add the new one, update your apps, remove the old one.

Using a token

bash
curl -H "Authorization: Bearer my-long-random-value" http://localhost:3080/adapters

The token of dev

coffeeql-server dev makes a new token every time it starts and prints it inside the Studio link (http://127.0.0.1:3080/#token=…). Opening the link signs Studio in; the same token works for the API and the SDKs until the server stops. The token sits after #, so browsers never send it in a request line and it does not end up in logs. For a token that stays the same across restarts, set COFFEEQL_TOKEN: it is accepted next to the one in the link.

Running without a token

Only by asking for it: --insecure-no-auth (or COFFEEQL_INSECURE_NO_AUTH=1), and only when the server listens on 127.0.0.1, ::1 or localhost. On any other address the server refuses to start that way. Anyone on the machine can then use the API.

The server

Connecting databases

The server knows nothing about your databases until you register them. Each registration pairs one collection name with the connection string of the database it lives in.

json · POST /connect
{
  "adapters": {
    "users[]":    "postgresql://app:secret@db.internal:5432/shop",
    "orders[]":   "mysql://app:secret@mysql.internal:3306/shop",
    "products{}": "mongodb://db.internal:27017/shop",
    "session:{}": "redis://cache.internal:6379"
  }
}

How a query finds its database

  • A query on orders[] uses the registration named orders[]. Two tables in one database are still two registrations, with the same connection string.
  • For Redis, register the namespace once — session:{} — and every key in it (session:u42{}, session:abc{}…) works with key pattern matching and DBSIZE estimation.
  • ClickHouse, Elasticsearch / OpenSearch and Firestore (preview) are not accepted by POST /connect in 1.0.9. Connect them as a whole with POST /v1/databases.
  • The kind of database is taken automatically from the connection string's scheme.

Connection strings and support in 1.0.9

Database EngineStarts with / SchemesExampleStatus in 1.0.9
PostgreSQL & Supabasepostgresql://, postgres://, supabase://postgresql://user:pass@localhost:5432/shopSupported. supabase:// only works with POST /v1/databases.
MySQL & MariaDBmysql://, mysqls://, mariadb://, mariadbs://mysql://user:pass@localhost:3306/shopSupported
SQLitesqlite:// (file path or in-memory)sqlite:///var/data/app.dbComing soon: not in the 1.0.9 builds
ClickHouseclickhouse://, http://, https://clickhouse://default:pass@localhost:8123/defaultPreview: POST /v1/databases only; writes are not revertible; shot is not a transaction
MongoDBmongodb:// or mongodb+srv://mongodb://localhost:27017/shopSupported; transactions need a replica set
Redisredis://redis://localhost:6379Supported. rediss:// (TLS) is not in the 1.0.9 builds; most writes are not revertible
Elasticsearch & OpenSearchelasticsearch://, opensearch://, es://, ess://elasticsearch://localhost:9200/audit-logsPreview: POST /v1/databases only; some filters are not applied (known issue); not revertible
Firebase Firestorefirestore:// or firebase://firestore://my-firebase-projectPreview: POST /v1/databases only; add firestore.googleapis.com to allowed_connect_hosts; not yet verified end to end
Three things to know
  • MongoDB: put the database name in the path (…:27017/shop). Without it the server uses a test database.
  • Special characters in a password must be URL-encoded: @ → %40, : → %3A, / → %2F, # → %23.
  • Registrations are kept across restarts. A database connected in Studio or with POST /connect is saved in ~/.coffeeql/state/.coffeeql_connections.json (readable only by your account; it holds the connection string) and connected again when the server starts. Set COFFEEQL_REMEMBER_CONNECTIONS=0 to keep them in memory only.

Removing a database

In Studio, Remove on the database's card. With the API, POST /disconnect with {"key": "users[]"}. On code.coffeeql.dev, Databases → Connected on your servers → Remove (the server must be running). All three disconnect it and forget it, so it does not come back after a restart. A database saved on the dashboard is removed on the dashboard.

A remembered database the server cannot reach when it starts shows as not connected with the reason, in Studio and on the dashboard. The server tries again every minute.

Which hosts the server may reach

By default the server only opens connections to localhost and 127.0.0.1. This stops someone with a stolen token from pointing your server at your internal network. Name the hosts your databases are on:

terminal
coffeeql-server --allow-connect-host db.internal,cache.internal
# or  COFFEEQL_ALLOWED_CONNECT_HOSTS=db.internal,cache.internal
# or  allowed_connect_hosts = ["db.internal", "cache.internal"]  in the TOML file

How many

A server without a licence key accepts 3 registrations and 100 requests a minute. A fourth registration is refused with a clear error. A licence key lifts both limits.

The server

Configuration

Settings come from four places. A later one wins over an earlier one:

  1. built-in defaults
  2. the TOML file
  3. environment variables
  4. flags you type

The TOML file is coffeeql-server.toml in the folder you start the server from, or the file you name with --config. Make a starter one with coffeeql-server init.

toml · coffeeql-server.toml
port = 3080
host = "127.0.0.1"                 # 0.0.0.0 to listen on every network interface
log_level = "info"                 # trace, debug, info, warn, error
max_req_min = 100                  # requests per minute, per client
enable_raw = false                 # allow POST /raw (native commands)
cors_origins = ["http://localhost:3000", "https://code.coffeeql.dev"]
allowed_connect_hosts = ["localhost", "127.0.0.1"]
tokens = ["my-long-random-value"]  # or leave out, and one is generated
state_dir = "~/.coffeeql/state"   # where the token hash, account link and licence proof live
trusted_proxies = []               # your tunnel or load balancer, if there is one
# license_key = "cql_live_…"
# insecure_no_auth = false
SettingFlagEnvironmentDefault
port-p, --portCOFFEEQL_PORT, PORT3080
host-H, --hostCOFFEEQL_HOST, HOST127.0.0.1
tokens-t, --tokenCOFFEEQL_TOKEN, TOKENgenerated
license_key-l, --licenseCOFFEEQL_LICENSE_KEYnone (Free)
log_level--log-levelRUST_LOGinfo
allowed_connect_hosts--allow-connect-hostCOFFEEQL_ALLOWED_CONNECT_HOSTSlocalhost, 127.0.0.1
trusted_proxies--trusted-proxyCOFFEEQL_TRUSTED_PROXIESnone
state_dir--state-dirCOFFEEQL_STATE_DIR~/.coffeeql/state
insecure_no_auth--insecure-no-authCOFFEEQL_INSECURE_NO_AUTHfalse
enable_raw--enable-raw—false
config file-c, --config—./coffeeql-server.toml

Lists (tokens, hosts, proxies) are comma-separated in flags and environment variables. A broken config file stops the server with a message rather than quietly using defaults.

The server

Safe writes & undo

A single mistyped query can delete a table. The server has four guards against that, and a way to take a change back.

1. No filter, no write

An .refill or .spill without .where is refused. If you really mean every row, say so with "confirm": true.

2. At most 1,000 rows

One write may change at most 1,000 existing rows. Raise it for one request with "max_affected_rows": 5000, or lift it with "confirm": true.

3. Try it first: dry run

json · POST /query
{ "cql": "users[].where(active = false).spill()", "dry_run": true }

The answer says how many rows would change (would_change), shows a sample of them (steps), and lists anything that would block the real run (blocked). Nothing is changed.

4. Every change is a commit

A write that changes rows answers with a commit_id. The server logs each changed row as it was before, saved into a persistent on-disk commit journal (.coffeeql_journal.json in the state directory) so commits survive server restarts. Reverting needs a licence key: without one, /revert answers 403. Rows the server cannot identify exactly (most Redis writes, rows without an id, preview databases) are marked revertible: false.

bash
# see exactly what changed, field by field
curl -H "Authorization: Bearer $TOKEN" http://localhost:3080/diff/cmt_…

# put it back (needs a licence key)
curl -X POST -H "Authorization: Bearer $TOKEN" -H 'content-type: application/json' \
  -d '{"commit_id": "cmt_…"}' http://localhost:3080/revert

Reverting a shot reverts every collection it touched in reverse chronological order. The revert is itself recorded as an audit commit.

Conflict Isolation & PersistenceCommits are persisted to disk and survive server restarts. On inserts, target keys are verified beforehand: if an insert fails due to a conflict or error, pre-existing rows are never recorded as after-images and cannot be mistakenly deleted on revert.
The server

HTTP API

Every endpoint takes and returns JSON. Send Authorization: Bearer <token> except where it says public. The live, clickable version is at http://localhost:3080/docs.

EndpointDoes
POST /connectRegister collections: {"adapters": {"users[]": "postgresql://…"}} → {"success": true, "connected": ["users[]"]}
POST /disconnectDisconnect a collection and forget it: {"key": "users[]"} → {"success": true, "disconnected": "users[]"}. A collection added on code.coffeeql.dev is removed there.
GET /adaptersWhat is registered, with masked connection strings
POST /queryRun a query (below)
POST /explain{"cql": "…"} → the plan, without running it
POST /revert{"commit_id": "…"} → undo a change
GET /diff/:commit_idBefore and after of every changed row
GET /historyRecent changes, newest first
POST /rawA native command, when enable_raw is on
POST /rpcJSON-RPC 2.0 (MCP tools) — used by the .NET SDK and AI agents
GET /metricsPrometheus metrics
GET /health, /ping, /readypublic — is it up, is it ready
GET /, /docs, /openapi.jsonpublic — Studio, the API reference, its OpenAPI file

POST /query

json · request
{
  "cql": "users[].where(plan = \"pro\").give(name)",
  "timeout_ms": 5000,          // optional
  "dry_run": false,            // optional: only report what a write would change
  "confirm": false,            // optional: allow a write without .where, lift the row cap
  "max_affected_rows": 1000    // optional: raise the cap for this write
}
json · answer
{
  "success": true,
  "schema": ["name"],
  "rows": [["Ada"], ["Linus"]],
  "row_count": 2,
  "elapsed_ms": 3,
  "commit_id": "cmt_…",        // only when rows were changed
  "revertible": true           // only when rows were changed
}

Errors

An error has an HTTP status and a message:

json
{ "success": false, "error": "Free tier limit reached: maximum 3 adapters allowed. Upgrade at coffeeql.dev" }
StatusUsually means
400The query or the request body is wrong — read the message
401No token, or the wrong one
403Not allowed: a blocked host, a write without .where, a plan limit
404No such commit or endpoint
429Too many requests this minute — slow down
500The database answered with an error
The server

Docker

The published image runs the server as a non-root user, on x86_64 and arm64 — including Apple silicon and Intel Macs with Docker Desktop. docker pull picks the right one for your machine.

terminal
docker run -d --name coffeeql -p 3080:3080 \
  -e COFFEEQL_TOKEN=change-me \
  -e COFFEEQL_ALLOWED_CONNECT_HOSTS=host.docker.internal \
  -v coffeeql-state:/var/lib/coffeeql \
  khusshvii54/coffeeql:1.0.9

Then open http://localhost:3080. The image is on Docker Hub; :latest follows the newest release.

Build your own image

Rather build it yourself? This Dockerfile installs the published Linux build with the same installer (it checks the checksum too).

dockerfile · Dockerfile
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates curl \
 && rm -rf /var/lib/apt/lists/*
ARG COFFEEQL_VERSION=1.0.9
RUN curl -fsSL https://coffeeql.dev/install.sh | COFFEEQL_VERSION=$COFFEEQL_VERSION COFFEEQL_INSTALL_DIR=/usr/local/bin sh
RUN useradd -r -m -d /var/lib/coffeeql coffeeql
USER coffeeql
WORKDIR /var/lib/coffeeql
ENV COFFEEQL_HOST=0.0.0.0 COFFEEQL_PORT=3080 COFFEEQL_STATE_DIR=/var/lib/coffeeql
EXPOSE 3080
HEALTHCHECK CMD curl -fsS http://127.0.0.1:3080/health || exit 1
CMD ["coffeeql-server"]
terminal
docker build -t coffeeql-server .
docker run -d --name coffeeql -p 3080:3080 \
  -e COFFEEQL_TOKEN=change-me \
  -e COFFEEQL_ALLOWED_CONNECT_HOSTS=host.docker.internal \
  -v coffeeql-state:/var/lib/coffeeql \
  coffeeql-server
  • Inside a container the server must listen on 0.0.0.0, so a token is always required.
  • To reach a database on the computer running Docker, use the host host.docker.internal in your connection strings (on Linux, add --add-host=host.docker.internal:host-gateway).
  • Leave out COFFEEQL_TOKEN and the token is printed once in docker logs coffeeql. The volume keeps its hash across restarts.
The server

Where your data goes

What leaves your machine depends on how you run CoffeeQL. In every mode the server talks to your databases directly; the question is what else it talks to.

ModeReaches CoffeeQL's serversStays on your machine
Local, not linked (dev, serve, mcp over stdio, any SDK)Nothing. (Studio's page loads its fonts from Google Fonts.)Queries, results, connection strings, the journal.
Linked to code.coffeeql.devEvery 20 s: version, host name, database names and masked addresses (no passwords). Every write: its query, collection, action, time, revert state and undo queries, and — unless COFFEEQL_SYNC_ROWS=0 — up to 100 rows before and after plus the field-by-field diff. These synced rows can contain personal data.Connection strings of databases you connected on the server, read results of your own apps, the journal.
AI through the dashboard (claude.ai, ChatGPT, a remote tool)The AI's requests and the server's answers, including the rows it reads, pass through code.coffeeql.dev on their way between the AI and your server.Connection strings.
Database added on the dashboardIts connection string is stored on code.coffeeql.dev, encrypted (AES-256-GCM), and sent over HTTPS only to the linked server, which keeps it in memory.—
Python SDK 1.0.9 direct adaptersNothing — but they skip the server entirely, so none of its checks, limits or journal apply. Use the server functions.Everything, in your app.

Switches

SettingEffect
COFFEEQL_SYNC_ROWS=0Commits still reach the dashboard, but without rows or diffs.
COFFEEQL_REMOTE_AI=0No AI requests through the dashboard; AI tools need a local connection.
COFFEEQL_REMOTE_AI_READ_ONLY=1AI requests through the dashboard may only read (next server release).
COFFEEQL_REMOTE_REVERT=0The dashboard cannot ask the server to revert a commit.
COFFEEQL_REMEMBER_CONNECTIONS=0Connection strings are not saved on disk (see below); reconnect after each restart.
coffeeql-server logoutUnlinks the server: nothing more is sent.
How long the dashboard keeps synced commitsThere is no automatic expiry yet: commits synced to a project, with their rows, stay until you delete them or the project. Plan-based retention is planned. Turn off COFFEEQL_SYNC_ROWS if rows must not leave your machine.

Files the server keeps

In the state folder (~/.coffeeql/state by default, COFFEEQL_STATE_DIR to change). On Linux and macOS each file is readable by your account only; on Windows it inherits your profile folder's permissions.

FileHolds
.coffeeql_connections.jsonFull connection strings, passwords included, in plain text, for databases you connected by hand, so they come back after a restart. COFFEEQL_REMEMBER_CONNECTIONS=0 turns this off.
.coffeeql_journal.jsonEvery write with the rows before and after — whatever data those rows hold.
.coffeeql_link.jsonThe credential linking the server to your dashboard account. coffeeql-server logout removes it.
.coffeeql_studio_tokenThe Studio sign-in token. In 1.0.9 it is permanent; from the next release it is new on every start, deleted on stop and accepted only from this machine.
.coffeeql_token_hashA hash of the server's API token — not the token.

Treat the folder like a password file: keep it out of synced folders and shared backups, and delete it to forget everything.

The server

Putting it online

You probably don't need thisA linked server (0.4.5 and later) fetches AI requests from the dashboard itself, so it needs no public address. This page is for calling your server's API directly from other machines.

Without a link, the dashboard and hosted AI agents need to reach your server over public HTTPS. The dashboard refuses localhost, private addresses (10.x, 192.168.x, 172.16–31.x) and cloud metadata addresses, on purpose.

The easiest way to give a server on your own machine a public HTTPS address, without opening a port, is a Cloudflare Tunnel:

terminal
coffeeql-server --token my-long-random-value --trusted-proxy 127.0.0.1
cloudflared tunnel --url http://localhost:3080

cloudflared prints an https://…trycloudflare.com address; use a named tunnel for a permanent one. --trusted-proxy 127.0.0.1 tells the server that requests arriving through the tunnel carry the real visitor's address, so the rate limit counts each visitor separately.

Before you go live

  • A long, random token — not change-me.
  • allowed_connect_hosts set to exactly your database hosts.
  • A database user for CoffeeQL with only the rights it needs.
  • Backups of your databases. The undo journal survives restarts, but it is not a backup.
The server

Benchmark it yourself

What does CoffeeQL add on top of your database? coffeeql-server bench measures it on your machine, against your own databases, with your own queries. It only reads: a query that changes data is refused.

terminal · one database
coffeeql-server bench --db "users[]=postgresql://user:pass@localhost:5432/shop" \
  --query 'users[].where(id = 42)' \
  --native "users[]=SELECT * FROM users WHERE id = 42"
terminal · a join across two databases
coffeeql-server bench --db "users[]=postgresql://…" --db "products{}=mongodb://localhost:27017/shop" \
  --query 'users[].where(id = 42).mix(products{} ON users[].id = products{}.user_id)' \
  --native "users[]=SELECT * FROM users WHERE id = 42" \
  --native 'products{}=[{"$match": {"user_id": 42}}]'

Each query is run in five layers. The difference between two lines is what that layer costs:

LayerWhat runs
parse + planThe CoffeeQL engine alone, no database.
direct driverYour --native command, through the same driver and connection. The baseline: no CoffeeQL.
coffeeql engineThe CoffeeQL query, in process.
coffeeql serverWhat POST /query does, without HTTP: locks, checks, journal.
HTTP /queryA real request to the server on 127.0.0.1, with its token.

The layers that reach the database take turns within every round, so they see the same machine and the same database. You get p50, p95, p99, mean and queries per second; --json prints the same as JSON, -n sets the number of runs (default 1,000) and --warmup the unmeasured runs before them (default 100).

What we measured

On a Windows 11 laptop, with PostgreSQL 16 (10,000 users) and MongoDB 7 (5,000 products) in Docker on the same machine, server 0.4.6, 1,000 to 3,000 runs. p50, and the difference with the direct driver:

QueryDirect driverCoffeeQL engineCoffeeQL serverHTTP /query
Parse and plan only—1.5 µs——
One row by primary key (PostgreSQL)0.94 ms+32–38 µs+46–53 µs+155–162 µs
A user and their products, PostgreSQL + MongoDB2.99 ms (two queries, no join)+0.14 ms+0.18 ms+0.44 ms

The database dominates: here a round trip to Docker costs about 0.9 ms, and CoffeeQL adds a few percent. On your hardware the absolute numbers will differ, so run it next to your real database and compare the lines. A request from an AI app goes through the internet and the dashboard as well, which adds tenths of a second that no engine can remove: benchmark on your machine, not through an AI.

AI agents

Connect an AI (MCP)

CoffeeQL speaks MCP, the protocol AI tools use to call outside tools. Connect one and the AI can look at your databases, query them and change them — and every change it makes is recorded on your server (undo needs a licence key).

On your computerThrough the dashboard
ForAn AI tool on a computer that can reach your databasesclaude.ai, ChatGPT, the Gemini app, or an AI tool on another computer
You needThe server installedThe server installed and linked to your code.coffeeql.dev account. No public address.
Undo (cql_revert)Yes, on every planPaid plans only (not open yet) — undo on the server instead
CostFreeFree: one key, so one AI

Start on your own computer. Move to the dashboard when an AI somewhere else needs to reach your databases.

On your own computer

  1. Install the serverSee Install the server, and check it with coffeeql-server --version.
  2. Add CoffeeQL to your AI toolThe AI tool starts coffeeql-server mcp itself and talks to it over standard input and output — no port, no token.

    In Claude Desktop: Settings → Developer → Edit Config. Add this to claude_desktop_config.json, save, then quit and reopen Claude Desktop.

    json · claude_desktop_config.json
    {
      "mcpServers": {
        "coffeeql": {
          "command": "coffeeql-server",
          "args": ["mcp"]
        }
      }
    }
    "coffeeql-server" not found?An app that was already open, or one started from the Dock or the Start menu, may not see the PATH the installer set. Put the full path in command instead: C:\\Users\\you\\.coffeeql\\bin\\coffeeql-server.exe on Windows (backslashes doubled inside JSON), /Users/you/.local/bin/coffeeql-server on macOS.
  3. Connect your database outside the chatNever type a connection string into the AI: everything you write in a chat goes to your AI provider, password included. Instead, connect the database once on your own machine:
    • In Studio: run coffeeql-server dev, click + Connect and add the database. The next server release also connects it in coffeeql-server mcp automatically (same account, same state folder).
    • In the MCP entry (works on 1.0.9): add the connection to the entry's environment, which stays in a file on your computer:
      json
      "coffeeql": {
        "command": "coffeeql-server",
        "args": ["mcp"],
        "env": { "COFFEEQL_CONFIG": "{\"users[]\": \"postgresql://postgres:coffee@localhost:5432/shop\"}" }
      }
    Then ask: "Show me the 5 users with the highest balance." The AI calls cql_query. A free server takes three collections.
  4. Undo a changeAsk: "Show me what you changed, then undo it." The AI uses cql_history and cql_diff, then cql_revert.
A database on another computerFor safety the server only connects to localhost unless you allow a host. Add it to the MCP entry as an environment variable, for example in Claude Desktop or Cursor:
json
"coffeeql": {
  "command": "coffeeql-server",
  "args": ["mcp"],
  "env": { "COFFEEQL_ALLOWED_CONNECT_HOSTS": "db.example.com" }
}

What can the AI do?

  • On your computer (coffeeql-server mcp) the AI has the same rights as you: it can read, write, connect databases and undo. There is no key on this route — it is your own process. Use it only with an AI you would let change your data.
  • Read-only: to let an AI only look, run the server with an agent key (--agent-key or CQL_AGENT_KEY) and connect the AI over HTTP MCP at POST /rpc with that key. It can query, explain and inspect schemas; writes (pour/refill/spill and their SQL names, shot), grind, /raw, undo and connecting databases are refused with 403.
  • Through the dashboard an AI has full rights on your linked server by default. Start the server with COFFEEQL_REMOTE_AI_READ_ONLY=1 to make every dashboard AI read-only, or COFFEEQL_REMOTE_AI=0 to turn the dashboard route off.
  • An agent key covers the whole server: it can read every database, table, row and field the server can read. Limiting an agent to some databases or columns, and masking personal data, are CoffeeQL Guard features (Compliance and Enterprise plans), not available yet.
coffeeql-server 1.0.9: agent keys are not fully read-onlyIn 1.0.9 an agent key could still write through POST /v1/query, run grind and connect databases through /v1/databases. This is fixed in the next server release, which checks every route with one read-only policy, and COFFEEQL_REMOTE_AI_READ_ONLY arrives in that release too. Until you run it, do not rely on an agent key to keep an AI from changing data.

Through the dashboard

For an AI app in the cloud (claude.ai, ChatGPT, the Gemini app) or an AI tool on another computer. The AI connects to https://code.coffeeql.dev/api/mcp, and the dashboard hands each request to your linked server, which runs it next to your databases. Your server needs no public address: it fetches the requests itself.

  1. Link your serverStart it with coffeeql-server dev and click Link account at the top of Studio. See Link your server.
  2. Connect your AIPick it below. claude.ai, ChatGPT and the Gemini app need only the address and ask you to sign in; the other tools use a key. The dashboard's Connect an agent page shows these same steps, with your key filled in.
  3. Check itOn Connect an agent, under 3. Connections, the AI shows up with the time it last connected. Remove it there to cut it off.

Signs in, no key. Paste only the address; Claude opens a CoffeeQL page where you allow it for a project.

  1. In claude.ai or the Claude desktop app, open Settings → Connectors.
  2. Click Add custom connector. Name: CoffeeQL. Remote MCP server URL: https://code.coffeeql.dev/api/mcp
  3. Click Add, then Connect. A CoffeeQL page opens: sign in, choose the project and click Allow.
  4. In a chat, open the tools menu (+) and turn CoffeeQL on. It works in the Claude mobile app too.

On Team and Enterprise plans, an organization Owner may have to add the connector first.

The tools the AI gets

ToolDoes
cql_connectRegister a collection: key (such as users[]) and uri (its connection string). Avoid it: the connection string passes through the AI and its provider. Connect databases in Studio or the server config instead. Not available to read-only agent keys.
cql_queryRun a query. Writes are checked like any other: confirm, dry_run, max_affected_rows
cql_explainPlan a query without running it
cql_schema, cql_menuWhat is registered, and on which database
cql_verifyCheck that every registered database answers
cql_history, cql_journalRecent changes, newest first
cql_show, cql_diffOne commit, and what it changed field by field
cql_revertUndo a commit. Through the dashboard it needs a paid plan

When it does not work

You seeDo this
The AI tool says the server failed to startPut the full path to coffeeql-server in command (see the note above), and restart the AI tool.
Host '…' is not permitted by allowed_connect_hostsAdd the host to COFFEEQL_ALLOWED_CONNECT_HOSTS.
Free tier limit reached: maximum 3 adaptersA free server takes three collections. Restart the AI tool to begin with none.
The key is refused because another AI holds itDashboard → Connect an agent → 3. Connections → Reset.
Reverting a commit needs a paid planUndo on your server with POST /revert (see Safe writes & undo), or connect the AI on your own computer.
Dashboard

The dashboard

code.coffeeql.dev connects AI tools that run somewhere else to your server, and shows which AI holds which key. You do not need it to use CoffeeQL from your own code, or with an AI on your own computer.

Your database passwords stay on your serverAn AI's calls go through the dashboard to your server, and your server holds the connection strings. Your server fetches the calls itself, so it needs no public address, no open port and no tunnel.

Set it up

  1. Create an accountGo to code.coffeeql.dev/sign-up and enter your name, email and a password. You start on the Free plan.
  2. Create a projectOn Overview, press New project and give it a name, such as Payments service. A project is one server and the AI tools that use it.
  3. Link your server to the projectOn the machine with your databases, start the server (coffeeql-server dev) and click Link account at the top of Studio. A page on code.coffeeql.dev opens: choose the project and press Allow. On Connect an agent, step 1. Your CoffeeQL server then shows the server as Online. (Without Studio: run coffeeql-server login in a second terminal; see Link your server.)
  4. Connect your AIUnder 2. Choose your AI, pick your tool and follow the steps shown. claude.ai, ChatGPT and the Gemini app: copy the address, add it as a connector in the app, and allow it on the CoffeeQL page that opens (no key). Claude Code, Codex, Gemini CLI, Antigravity, Cursor, VS Code, Devin Desktop (Windsurf): press Create key and paste the text it shows, with the key filled in. Copy it now: a key starts with cql_sk_ and is not shown again. The same steps are in Connect an AI → Through the dashboard.
  5. See it connectUnder 3. Connections, the key changes from Waiting for first connection to the name of the AI that connected, with when it was last seen.

A linked server knows which account and project it belongs to, and takes its plan from your account. It shows up on Settings → Servers with its version, the databases it has connected (names only) and whether it is online. The server always calls the dashboard, never the other way round, so this works on a laptop without a public address.

  1. Start linkingEasiest: click Link account at the top of Studio. Or, in a second terminal on the server's machine:
    coffeeql-server login
    A browser opens at code.coffeeql.dev/link and Studio (or the terminal) shows a code such as BCDF-GHJK.
  2. Check the code and pick a projectSign in if asked. Make sure the page shows the same code as the terminal, choose the project, and press Allow.
  3. That's itA running server picks the link up within seconds, no restart. Studio shows the project and plan at the top, and coffeeql-server dev prints the account at start from now on.
Command or settingWhat it does
coffeeql-server whoamiShows the account, project and plan this server is linked to.
coffeeql-server logoutUnlinks the server. It keeps working, as Free.
COFFEEQL_LINK_KEYFor a server without a browser (Docker, a VPS): make a Server key on Settings → Servers and pass it, for example docker run -e COFFEEQL_LINK_KEY=cql_srv_… khusshvii54/coffeeql.
COFFEEQL_NO_BROWSER=1login prints the address instead of opening a browser (SSH sessions).
What a linked server sendsEvery 20 seconds: its version, host name and the collections it has connected, with their addresses masked (no user, password or query string). Its commits, as they happen (see below). Never a password or a connection string of its own. The plan it gets back is signed, so it cannot be changed on the way. If the dashboard cannot be reached, the last plan keeps working for 7 days. Unlink on Settings → Servers stops the link within a minute; the server then runs as Free.

Databases, in both directions

On Databases, Add database saves a database for a project: a name, its collections (users[] for a table, products{} for documents, session:{} for Redis keys) and its connection string. The server linked to that project connects it within about 15 seconds, and the page shows Connected or the exact reason it could not. Remove it there and the server disconnects it.

  • The connection string is stored encrypted (AES-256-GCM) and is sent only to the server that holds the project's link, over HTTPS. The browser never sees it again.
  • The server reaches the database, not the dashboard: write the address as the server sees it (localhost when both run on the same machine), and allow its host on the server (COFFEEQL_ALLOWED_CONNECT_HOSTS, localhost and 127.0.0.1 by default).
  • Databases you connect on the server itself (Studio, POST /connect) appear under Connected on your servers, by name, masked address and status. Remove there asks the server to disconnect it and forget it (servers 0.4.7 and later, while the server runs).

The pages

PageWhat it is for
OverviewYour projects, and the commits used this month. Create or delete a project here; deleting one deletes its keys and commits too.
Connect an agentRegister the server, make a key for each AI, copy its snippet, and see which AI holds each key. Reset lets another AI take a key; the bin icon revokes it at once.
A projectIts commits, with search. They arrive by themselves from the linked server; there is no way to type one in. A commit opens to show its query, the rows it changed and what undoes it; on a paid plan, Revert commit asks your server to undo it.
ProjectsEvery project with the databases its server has connected right now, its commits and its latest activity. Create or delete a project here.
DatabasesDatabases saved for a project, which its linked server connects, and those connected on your servers directly. See Databases, in both directions.
ServersYour linked servers: online or not, version, the databases they have connected. Server key links a server without a browser; Unlink removes one. See Link your server.
API keysAll your keys in one list, and keys for one project or for all of them — each lets one AI tool reach your server through the dashboard.
Plan & billingYour plan and its limits (see Plans & limits). Paid plans are not open yet; join the waitlist here.
Commits and undo
  • From server 0.4.4, a linked server sends every change it makes (by an AI or by your code) to its project's commit list within seconds: the query, the rows before and after (up to 100 of each) and what undoes it. To send the query only, without rows, start the server with COFFEEQL_SYNC_ROWS=0. A server that is not linked keeps its changes to itself: see them with cql_history and cql_diff, or GET /history.
  • Undo happens on your server, with cql_revert or POST /revert; the commit then shows as Reverted on the dashboard too. On a paid plan, the Revert button on a commit a linked server sent asks that server to undo it: the server takes the request within seconds, runs the same checked revert as POST /revert, and the page shows how it went. The dashboard never sends a query, only "revert this commit". Turn it off on a server with COFFEEQL_REMOTE_REVERT=0. A commit recorded by hand or with an API key has no server behind it, so its Revert button changes nothing and says so.
Dashboard

Plans & limits

The server and every SDK are free. Two separate things have limits:

The server, without a licence key

  • 3 registered collections
  • 100 requests a minute

The dashboard & control plane

FreeTinkererProTeamCompliance
Price$0$9 one-time$20 a month ($192 yearly)$79 a month flat$299 a month flat
API Keys1 API keyAnnounced soonAnnounced soonAnnounced soonAnnounced soon
Details1 project, active limitsAnnounced soonAnnounced soonAnnounced soonAnnounced soon
StatusAvailable nowComing soonComing soonComing soonComing soon

Paid plans will open soon. Exact details and limits will be announced at launch.

Help

Troubleshooting

You seeDo this
coffeeql-server: command not found / is not recognizedOpen a new terminal. Still there? The install folder is not on your PATH: see Install, step 3.
running without a token is only allowed on a loopback hostYou used --insecure-no-auth with --host 0.0.0.0. Remove it and use a token.
Studio asks for a tokenOpen the Open Studio link the terminal printed, not the bare address. After a restart the old link no longer works: use the new one.
401 UnauthorizedSend Authorization: Bearer <token>, with the exact token.
No adapters registered. Call POST /connect first.Register your collections — the server forgets them when it restarts.
No adapter for 'orders'Register orders[] too; each collection is its own registration.
Free tier limit reached: maximum 3 adaptersA server without a licence takes three registrations.
The server refuses your database hostAdd it with --allow-connect-host.
A write is refused without .whereAdd a .where, or send "confirm": true if you really mean every row.
Spilled query at line …, column …A syntax error at that spot. Compare with Common mistakes.
expected expression, found DataType(…)A field is named like a type (text, timestamp…). See Reserved words.
A Redis query returns nothingCheck the key is exactly right, and the namespace (session:{}) is registered.
MongoDB reads the wrong databasePut the database name in the connection string's path.
429 Too many requestsOver 100 requests a minute. Behind a tunnel, set --trusted-proxy so visitors are counted separately.
The installer says the checksum does not matchThe download was damaged or changed. Run it again; if it persists, tell us at hello@coffeeql.dev.
Windows: running scripts is disabledUse the one-line command exactly as shown (irm … | iex) — it does not run a script file, so the execution policy does not apply.
The dashboard can't reach your serverIt needs a public HTTPS address — see Putting it online. Try the address in a browser: Studio should open.
Help

FAQ

Is CoffeeQL a database?

No. It is a language and an engine that sits in front of the databases you already have. Your data stays in them; the server keeps its own journal of the writes it makes, on your machine.

Do my database passwords leave my machine?

No. Connection strings go to your coffeeql-server and stay there. The dashboard only ever holds your server's address and token, encrypted.

Does it replace SQL?

No. For PostgreSQL and MySQL, CoffeeQL writes parameterised SQL and hands it over. Need something CoffeeQL can't express? The server has /raw when you enable it, and the SDKs can call it (Python: raw()).

Can I join a table to a document collection?

Yes — that is what .mix() is for.

Why is the language full of coffee words?

Because a pour, a refill and a spill are easier to remember than INSERT, UPDATE and DELETE — and because it's called CoffeeQL. ☕

Where do I report a problem?

Email hello@coffeeql.dev with the query, the full error, your operating system and coffeeql-server --version.

Help

Changelog

Upcoming (not released yet)

  • FIX coffeeql-server: agent keys are read-only on every route. One policy now checks every request before it runs: an agent key can no longer write through /v1/query, run grind, use /raw, or connect, disconnect or refresh databases through /v1/databases. Queries are judged by what they parse to, so case, comments and SQL names make no difference. New: COFFEEQL_REMOTE_AI_READ_ONLY=1 makes AI tools connected through the dashboard read-only.
  • Python SDK goes through coffeeql-server. Client (sync) and CoffeeQL (async) send every query, write and raw() call to the server with your token, so its write checks, row limits, dry run, undo and read-only keys apply. The direct PostgresAdapter, MongoAdapter, MySQLAdapter and RedisAdapter and the [postgres]/[mongodb]/[mysql]/[redis]/[all] extras are removed; using them raises an error with migration steps. Helpers bind every value as a parameter; query() returns dicts with server metadata; errors are typed.
  • FIX coffeeql-server: parameterized updates and deletes. where(id = $1).refill(...) and .spill() with parameters were refused with "unbound parameter" because the undo snapshot was read before the parameters were bound.

coffeeql-server 1.0.9 November 2026

LATEST RELEASE Structural Shape Decoupling & Multi-Engine Universal Release. Brackets now classify collection/table data shapes (structured tabular rows, unstructured documents, and key-value namespaces) decoupled from specific database vendors, with synchronized v1.0.9 releases across all language SDKs.

  • Structural Shape Classification: Formally decoupled bracket roles from database engines. [] represents structured tabular rows with fixed schemas; {} represents unstructured / schema-free JSON documents; ns:id{} represents key-value namespaces and keys. Any storage engine can host structured, unstructured, or key-value data.
  • Engine Multi-Shape Adaptability: PostgreSQL and MySQL tables and JSONB columns can now be queried as unstructured document collections ({}), and MongoDB collections can be queried as structured tabular collections ([]).
  • Explicit Database Routing & Catalog Introspection: Use @alias:table[] or @alias:collection{} to target specific database instances explicitly (e.g., @supabase:users[], @mongo:events{}), alongside automatic multi-database catalog routing.
  • SQL keyword aliases: .select, .limit, .group_by (or .groupby), .insert, .update and .delete now work as other names for .give, .cup, .blend, .pour, .refill and .spill. .delete() keeps the same safety rule as .spill(): it must come straight after the collection or its .where(). See Other spellings.
  • .similar() vector search: field.similar("text") and field.vector_match("text") are other names for .like(), with the same optional .threshold(n) (default 0.80). On PostgreSQL it uses pgvector; elsewhere the rows are ranked in memory.
  • FIX Bracket shape is respected per collection. Before 1.0.9 the PostgreSQL and MySQL adapters always treated a collection as [] and MongoDB always as {}, whatever you wrote. The shape now comes from the brackets in the query (then from the catalog), so @pg:events{} and @mongo:users[] do what they say.
  • FIX MongoDB database name from the connection: the database chosen when connecting is used again in every build configuration. Previously, some builds ignored it and fell back to the name in the URI, or to test.
  • Universal SDK & Tooling Sync: Released v1.0.9 for all 7 SDK packages and extensions: TypeScript/Node (coffeeql), Python (coffeeql), Java & Spring Boot Starter (coffeeql-spring-boot-starter), Go (coffeeql.dev/go), .NET (CoffeeQL), Dart/Flutter (coffeeql), and VS Code extension (coffeeql-vscode). CORRECTION The VS Code extension was not published as 1.0.9; the Marketplace has 0.1.0. Java is on the CoffeeQL Maven repository (not Maven Central), and Go is coffeeql.dev/go.

coffeeql-server 1.0.0 (GA) November 2026

GA RELEASE Production General Availability for CoffeeQL. The governed control layer between AI agents, applications, and your database ecosystem is now complete across 8 engines, with full SQL pushdown and persistent safety rollback journals. CORRECTION In the published 1.0.x builds SQLite is not enabled, and ClickHouse, Elasticsearch / OpenSearch and Firestore are preview engines connected with POST /v1/databases; see Connecting databases.

  • 8-Engine Production Database Support: Full support for PostgreSQL (including Supabase), MySQL, MariaDB, SQLite, ClickHouse, MongoDB, Redis, Elasticsearch / OpenSearch, and Firebase Firestore. CORRECTION SQLite is not enabled in the published 1.0.x builds; ClickHouse, Elasticsearch / OpenSearch and Firestore are preview engines.
  • 100% Single-Database Join Pushdown (Free on all tiers): When joining collections in the same relational database (Postgres, MySQL, ClickHouse, SQLite), .mix() compiles directly into a native SQL INNER JOIN executed by your database engine with zero in-memory buffering and no federation license requirement. CORRECTION Without a licence key this holds only for a database connected as a whole with POST /v1/databases, and SQLite and ClickHouse joins are not available in the 1.0.x builds; see Joining collections.
  • Composite Multi-Condition Joins: .mix() now supports chaining multiple join predicates with AND (e.g., .mix(orders[] ON users[].id = orders[].user_id AND users[].org_id = orders[].tenant_id)).
  • Persistent On-Disk Commit Journal & Conflict Protection: Commits are logged to persistent state (.coffeeql_journal.json) surviving server restarts. Inserts pre-read target keys to guarantee that a failed insert or duplicate key conflict never marks pre-existing rows as revertible after-images (DEF-037).
  • Resilient Connection Lifecycle & Reconnect: Implemented lazy auto-reconnect handles (PgClientHandle) that recover seamlessly from database restarts, network drops, and idle connection closures while completely redacting credentials in diagnostic outputs.
  • Native Wire & Type Decoders: Added native decoders for PostgreSQL binary 1-D arrays, BYTEA hex strings; MySQL VARBINARY/BLOB, BIT, GEOMETRY; MariaDB JSON columns; Elasticsearch nested field paths; and Firestore bytes, reference, and geoPoint values.
  • Expanded SDK Ecosystem: Added official Java & Spring Boot Starter (coffeeql-spring-boot-starter) and Go client (coffeeql.dev/go) alongside Node.js/TypeScript, Python, Dart/Flutter, and .NET.
  • Zero-config discovery: every table and collection in a connected database is found automatically and can be queried without registering it. menu() lists what was found, and menu(missing[]) says plainly when a collection doesn't exist.
  • Write-aware query cache: repeated reads are served from cache, and a write clears the cache only for the table it changed. The cache can be turned off per query.
  • Parameters: $1, $name and ? placeholders, filled with .bind() / .bind_named(). A missing value is a clear error, and explain() works without binding.
  • Pagination: .skip(n) / .offset(n) before or after .cup(m), with .sort(), following SQL LIMIT … OFFSET rules. .count() works as a shorthand at the end of a chain.
  • More operators: IS NULL, IS NOT NULL, IN [...], NOT IN [...], BETWEEN, LIKE, NOT LIKE, lowercase not and <>.
  • Joins of three or more collections: chain .mix() as many times as you need.
  • FIX Query language fixes:
    • .sort() then .cup(n) without .give() returns the true top N. Before, the limit could be applied before the sort.
    • COUNT(*) and lowercase count / sum work, aliases are optional, totals work without .blend(), and a count on an empty table returns 0 instead of no row. Grouped columns keep their original type.
    • .near() accepts negative coordinates, and paths can be several levels deep (a.b.c, a.b.last(7d)).
    • .near() and .like().threshold() really filter and rank rows instead of returning everything.
    • JSON paths read real nested values, .has("latte") no longer matches "latte_macchiato", 10.0 = 10 is true, and .last() understands ISO-8601 dates.
    • .pour() evaluates uuid() (a fresh v4 UUID each call), now() and today() (the real date), and keeps the keys of nested objects.
    • @db routing (@analytics:users[] and @db("analytics") users[]) goes to the exact database, and the prefix is never sent to it as part of the table name.
    • grind really creates the collection through the database's adapter.
    • Syntax errors report the real line and column, and explain() shows joins cleanly.
  • Studio Workbench & Data Explorer Upgrades: Added query result cache toggles, manual refresh bypasses, JSON data export buttons, error state recovery, and sampled schema indicators.

coffeeql-server 0.4.7 September 2026

  • Runs in the background: coffeeql-server start, stop, status, logs, open, and autostart on to start it when you log in. See Run it in the background.
  • Databases survive a restart. A database connected in Studio or with POST /connect is connected again when the server starts. One that cannot be reached shows why, and is tried again every minute.
  • Remove a database anywhere: in Studio, with POST /disconnect, or on code.coffeeql.dev (Databases). The dashboard now shows each server database's status, and databases saved on the dashboard are no longer listed twice.
  • The uninstall scripts also turn off start-at-login and delete the new state files.

coffeeql-server 0.4.6 September 2026

NEW coffeeql-server bench: measure what CoffeeQL adds on top of your databases, one database or a join across several. See Benchmark it yourself.

NEW Joins across databases ask only for the rows that can match. CoffeeQL reads the left side first and asks the right side for its keys only (a bind join), instead of reading all of it. A user and their products across PostgreSQL and MongoDB went from 13.4 ms to 3.1 ms. When a database refuses that filter, CoffeeQL reads everything, as before: the rows never change.

NEW A simple read (a filter, a projection, a cup) waits for its database on the request's own task, without a detour through a blocking thread.

NEW AI requests reach a linked server in about a tenth of a second instead of one to five: the server keeps one request to the dashboard open (a long poll) and gets each AI request as it arrives.

code.coffeeql.dev September 2026

NEW claude.ai, ChatGPT and the Gemini app connect by signing in. Add https://code.coffeeql.dev/api/mcp as a custom connector, sign in, choose the project and click Allow: no key to copy. Works in Claude Desktop and the mobile apps too.

NEW Steps for Codex, Gemini CLI and Antigravity, next to Claude Code, Cursor, VS Code and Windsurf. The dashboard and these docs show the same steps for every tool: Connect an AI → Through the dashboard.

coffeeql-server 0.4.5 September 2026

NEW AI tools reach a linked server through the dashboard, with no public address. The server fetches the AI's requests itself, so Connect an agent no longer needs a server address, a token or a tunnel. COFFEEQL_REMOTE_AI=0 turns it off.

NEW Link account from Studio, with one click. A login in another terminal is picked up by a running server too, without a restart.

NEW dev opens Studio in your browser. Double-clicking coffeeql-server.exe starts it the same way, and an error keeps the window open so it can be read. A port already in use says so.

CHANGED The server keeps its files in ~/.coffeeql/state, not in the folder it was started from, which gave "Access is denied" in folders such as C:\Windows\System32. Files from an older version are copied over at the first start. New uninstaller for Windows.

coffeeql-server 0.4.4 September 2026

CHANGED dev needs a token too. It makes one for each run and prints an Open Studio link that signs Studio in. Set COFFEEQL_TOKEN for a token that stays the same; --insecure-no-auth still turns it off, on loopback only.

NEW Databases saved on the dashboard are connected by the linked server, within about 15 seconds, and the dashboard shows Connected or the reason it could not. Databases connected on the server appear on the dashboard too. See Databases, in both directions.

NEW The dashboard has a Projects page, and shows the databases a project really has instead of the labels picked when it was created.

FIX A masked database address no longer shows the query string (which can carry a password), and a key=value connection string is not shown at all. A linked server checks in every 20 seconds instead of every minute.

coffeeql-server 0.4.3 September 2026

NEW A linked server's changes show up on the dashboard. Every write it makes appears in its project's commit list within seconds, with the rows before and after and what undoes it. COFFEEQL_SYNC_ROWS=0 sends the query only.

NEW Revert from the dashboard. On a paid plan, the Revert button on such a commit asks your server to undo it, and shows the result. The server only ever receives "revert this commit", never a query; COFFEEQL_REMOTE_REVERT=0 turns it off.

coffeeql-server 0.4.2 September 2026

NEW Link your server to your code.coffeeql.dev account with coffeeql-server login (or COFFEEQL_LINK_KEY on a headless server). The server then knows its account, project and plan, and shows up on the dashboard's new Servers page. Also logout and whoami. See Link your server.

NEW CoffeeQL Studio has a light and a dark theme, the same as this site, and shows which project and plan the server runs under.

FIX Studio explains errors such as No adapter for 'users' in plain words and says what to do, and shows values from your database as text, never as markup.

coffeeql-server 0.4.1 September 2026

FIX Undo could revert the wrong change. Two writes made within a few microseconds of each other — the steps of one shot, or two clients at once — could be given the same commit id, and reverting one then undid the other. Every commit now gets an id of its own.

FIX CoffeeQL Studio no longer connects sample databases and runs a query by itself when it opens. It shows the databases you connected, and nothing else.

FIX A MongoDB connection string without a database now uses test, MongoDB's own default, instead of a test database from our development setup.

FIX Studio shows the port the server really listens on, and every place the server reports its version (--version, /health, Studio, MCP, OpenAPI) now reads it from one source.

FIX Windows installer: downloads with curl.exe first, so a slow connection no longer fails after two minutes.

NEW A Docker image on Docker Hub, khusshvii54/coffeeql, for x86_64 and arm64.

coffeeql-server 0.4.0 binaries September 2026

NEW Install the server with one command on Windows, macOS (Apple silicon and Intel) and Linux (x86_64 and arm64): install.sh and install.ps1 detect your system, check the SHA-256 of the download, and install without admin rights. Downloads and checksums are at releases.coffeeql.dev.

NEW The Linux builds carry their own OpenSSL, so they don't depend on the version your distribution ships.

FIX A //, -- or /* */ inside a quoted string was taken for a comment, which broke any query with a URL in it — and silently removed text between /* and */. Strings are now left whole. Fixed in the server; the npm offline checker and the Python package get it in their next release.

FIX Aggregates keep their as names; .give(*) works on Redis hashes; Redis keys with a suffix are found; nested MongoDB fields such as specs.watts can be read and filtered.

CHANGED --help now calls the program coffeeql-server, the name you type.

v0.4.0 September 2026

NEW One grammar for every SDK, pinned down by a shared test suite of 54 valid queries, 8 alternative spellings and 59 mistakes that every package must agree on.

NEW Undo: every write is journalled with its before-image; /diff shows what changed field by field, /revert puts it back, /history lists recent changes.

NEW Safe writes: updates and deletes without .where are refused unless confirmed, one write changes at most 1,000 rows, and dry_run reports what a write would do.

NEW MCP: coffeeql-server mcp for local AI tools and /rpc over HTTP, with eleven tools.

NEW Security: a token is required except on your own machine, only its hash is stored, databases can only be reached on hosts you allow, and requests are rate-limited per client.

NEW /metrics for Prometheus and /ready for orchestrators.

NEW Packages on npm, PyPI (Windows, Linux and macOS wheels), pub.dev and NuGet.

NEW The dashboard at code.coffeeql.dev: accounts, projects, API keys for AI agents, and a field-by-field view of every change.

v0.2.0 May 2026

NEW Real databases: PostgreSQL, MySQL, MongoDB and Redis adapters that run queries for real.

NEW Joins across databases: .mix() joins PostgreSQL with MongoDB, or two SQL databases, in memory; both sides are fetched at the same time.

NEW connect(), query() and disconnect() on the CoffeeQL class.

v0.1.0 May 2026

The first public release. ☕

Roadmap (Post-1.0)

  • Streaming result sets and cursor-based large export endpoints.
  • Kafka & webhook CDC connectors for real-time commit journal streaming.
  • Distributed query cache synchronization across multi-instance clusters.
  • Signed macOS binaries (Notarized) and Windows EV code signing.

Something wrong or missing on this page? Tell us at hello@coffeeql.dev.