2026-11-26 15:39 UTC

n6kd offers policy-controlled SQL access to DuckDB catalogs for people and agents

state: seedheat: mediumuncertainty: mediumrelevance: highdatabase-agents sql-security production-datan6k-io

What is this?

n6kd is an open-source project from n6k-io that serves DuckDB catalogs to clients over the n6k protocol, with a separate Quack option. Its GitHub documentation describes SQL bootstrapping and configurable catalog and table policies: unlisted tables and operations are denied, and row predicates can restrict reads and writes. With OIDC, verified JWT claims can provide per-client policy context. The project also documents connecting an MCP agent, which receives the same limits as other clients, and combining BigQuery with local data. A Hacker News post on Nov. 9, 2026 pointed to the project; the supplied evidence is its documentation and a search result, not independent testing or adoption evidence.

Why it matters

This targets a practical obstacle to agentic data work: giving an AI agent useful SQL access without handing it unrestricted database credentials. Policy enforcement at the serving layer, including claim-based row filtering and write checks, could make it easier to expose production or multi-tenant data to agents and other clients. The documentation establishes the intended features, not their security effectiveness under attack or suitability for every production deployment.

Current assessment

Newly surfaced project: n6k-io’s n6kd, documented on GitHub and linked in a Hacker News post created Nov. 9, 2026. The repository says it serves DuckDB catalogs over WebSocket using the n6k protocol; users configure catalog/table policies for select, insert, update, and delete, with row predicates and optional update checks. OIDC mode verifies JWT signature, issuer, audience, and expiry, and makes supported scalar claims available to policy predicates as bound values. The docs include an MCP-agent example and a BigQuery-plus-local-data example; credentials for the BigQuery source remain server-side. These are project documentation claims, not independently validated results. Important boundary: without a permissions file, the default serves every loaded catalog read/write; the documentation therefore makes configuration material to safe use. Quack is a distinct, simpler shared-database/one-token mode without per-user JWT context. No supplied evidence establishes security audit results, production adoption, performance, or whether the policies cover all relevant threat models. Follow up on implementation and security testing before treating it as a proven production safeguard.

Measured heat

now 0 pts/hpeak 0 pts/hcomments 0/hpeers p10momentum: steady2 platformsage 425h
points/hour across evidence · reading as of 2026-11-27 02:23:58.509736+11:00 · deterministic, not a model opinion

How the heat travelled

11-08 23:24 (minted)⭐ origin echo-reconstructedThe GitHub repository is the origin: its README describes n6kd as serving DuckDB catalogs and says it lets “people and AI agents query all y
Sean Ross-Ross on github (echo) · attributed from hn.story.50418179 · published time unknown
—
11-08 22:35first on hacker news · published · lag ?N6k – Let users and agents run untrusted SQL on production databases
srossross
—
11-08 22:35amplified on hacker news 👑hn.story.50418179
srossross
peak 2 · 0 comments · 103% of case engagement
11-08 23:20our radar first saw it · lag ?discovery anchor: hn.story.50418179—
pace: p26 vs 1845 stories at the 336h mark (now 425h old) — ahead of adap-delegated-authority-protocol-draft (2.0x), behind abmaze-protein-fitness-agent-benchmark (0.7x)

Evidence (2) — ⭐ canonical anchor

sourceobjectauthorscorecomments
🟧 hnN6k – Let users and agents run untrusted SQL on production databases
Retrieved article excerpt

Open article · Retrieved 2026-11-08T23:21:39.288595+00:00

# n6kd

Serves DuckDB catalogs over the n6k protocol via WebSocket.

## Install

```
curl -fsSL https://n6k-io.github.io/n6kd/get.sh | sh
```

Installs the latest release, with its extensions, for Linux, or macOS on arm64.
`N6KD_VERSION` picks a release, `N6KD_HOME` where it is unpacked
(`~/.n6kd`) and `N6KD_BIN_DIR` where the `n6kd` symlink goes (`~/.local/bin`).

## Examples

- [Quickstart](https://github.com/n6k-io/n6kd/blob/main/examples/quickstart/README.md): run n6kd locally on NYC data and control which rows clients see and what they can write. No account needed.
- [Let an AI agent query it](https://github.com/n6k-io/n6kd/blob/main/examples/agent/README.md): point an MCP agent such as Claude Code at the quickstart server. It gets the same limits as any other client.
- [Give each client its own rows](https://github.com/n6k-io/n6kd/blob/main/examples/per-client/README.md): sign clients in with OIDC so each sees and edits only its own rows. Needs an OIDC issuer.
- [Combine BigQuery and local data](https://github.com/n6k-io/n6kd/blob/main/examples/multi-source/README.md): serve a BigQuery dataset next to local tables from one process and join across them. Cloud credentials stay on the server. Needs a Google Cloud project.

## Build

```
go build -o n6kd .
./n6kd install   # download the n6k DuckDB extensions
```

To run against local extension builds instead, point `N6K_EXTENSION_DIR` at
their `build/release/extension` directories as an OS path list (`:` on Unix,
`;` on Windows); each is searched
for `<name>/<name>.duckdb_extension`. `vcatbridge` comes from
`duckdb-virtual-catalog`, `n6k_client` and `n6k_server` from `duckdb-n6k-protocol`.
Tests skip when it is unset.

## Run

```
n6kd -f schema.sql --perms perms.yml
```

Boot SQL is run in the order given by `-f` (file), `-t` (template file) and `-c` (statement). Without
`--perms`, every catalog in the loaded database is served read/write, unbridged.

A `-t` file is a `-f` file rendered with Go
[`text/template`](https://pkg.go.dev/text/template) first, for values DuckDB
only accepts as literals, such as `ATTACH` strings. `{{ env "NAME" }}` inserts
an environment variable and fails the boot when it is unset:

```
ATTACH 'project=bigquery-public-data dataset=new_york_taxi_trips billing_project={{ env "BQ_BILLING_PROJECT" }}' AS taxi (TYPE bigquery);
```

With `--listen=<path>` (or `N6K_LISTEN=<path>`), n6kd listens on that Unix
socket instead of `--addr` and serves every client that connects, each in its
own session, in n6k stream framing. A stale socket file is replaced, one a live
server holds is refused, and the file is mode 0600 and removed on exit. The
dialing parent authenticates; the HELLO token is not checked, and `--api-key` /
`--oidc-*` are refused at startup.

### Flags

| Flag | Description |
| --- | --- |
| `-f, --file` | SQL file run at boot; repeatable |
| `-t, --template` | SQL file rendered with Go `text/template`, then run at boot; repeatable |
| `-c, --command` | SQL run at boot; repeatable |
| `--perms` | perms.yml naming the catalogs to serve bridged |
| `--addr` | listen address (default `:8080`, or `$PORT`) |
| `--listen` | Unix socket to listen on instead of `--addr` (`N6K_LISTEN`) |
| `--api-key` | token clients must present (`N6KD_API_KEY`) |
| `--oidc-issuer-url` | OIDC issuer whose JWTs clients must present (`N6KD_OIDC_ISSUER_URL`); not with `--api-key` |
| `--oidc-audience` | `aud` claim a client's JWT must carry (`N6KD_OIDC_AUDIENCE`); required with `--oidc-issuer-url` |
| `--oidc-client-id` | public client `n6kd auth login` signs users in with, advertised at `/.well-known/oauth-protected-resource` (`N6KD_OIDC_CLIENT_ID`) |
| `--load-dotenv[=path]` | load environment variables from `.env` (or `path`) first; variables already set win |
| `--allow-origin` | browser origins allowed to connect; repeatable, default any (`N6KD_ALLOW_ORIGIN`, comma-separated) |
| `--lockdown` / `--no-lockdown` | deny served connections filesystem and extension access |
| `--memory-limit` / `--threads` | locked in by `--lockdown`, per session database; default DuckDB's (`N6KD_MEMORY_LIMIT`, `N6KD_THREADS`) |
| `--boot-only` | run the boot SQL, then exit without serving |
| `--debug` | per-connection and per-catalog logging |
| `--pprof` | address to serve Go's `net/http/pprof` on, off by default (`N6KD_PPROF`) |
| `--json-logging` | JSON logs with Cloud Logging severity fields |

### Commands

- `n6kd install` — download the extensions into DuckDB's extension directory
- `n6kd selftest` — bridge a throwaway catalog end to end
- `n6kd quack` — serve over DuckDB's quack protocol instead; see below

## Quack

```
n6kd quack -f schema.sql --perms perms.yml --token super_secret
```

```
-- from any DuckDB client
INSTALL quack; LOAD quack;
CREATE SECRET (TYPE quack, TOKEN 'super_secret');
ATTACH 'quack:localhost:8080' AS app;
```

A different model from n6k: one database shared by every client and one token,
with no users and no JWT claims. With `--perms`, perms.yml must name exactly one
catalog, served bridged as the main database, since that is all a quack client's
`ATTACH` sees; policies get no `$name` context values. Without
`--perms`, the loaded database is served directly. Quack speaks plain HTTP, so
put TLS in a proxy.

Quack's `ATTACH` cannot run `UPDATE` or `DELETE`; send those through
`quack_query('quack:localhost:8080', '...')`.

Takes `-f`, `-c`, `--perms`, the lockdown flags and `--boot-only` as above, plus:

| Flag | Description |
| --- | --- |
| `--addr` | listen address (default `:8080`, or `$PORT`); a host other than `localhost` listens beyond this machine |
| `--token` | token every client presents, at least 4 characters (`N6KD_QUACK_TOKEN`); generated and logged when empty |

With `N6K_EXTENSION_DIR` set, the local `vcatbridge` build is installed into
DuckDB's extension directory first: the bridged main database loads it by name,
and the source must load that same copy. `quack` and `httpfs` load from there too
(`n6kd install` downloads them).

## perms.yml

```
catalogs:
  app:
    tables:
      main.users:
        primary_key: [id]
        select: true
        insert: true
        update: true
        delete: true

      main.audit_log:
        select: true

      main.orders:
        select: "status <> 'deleted'"
        insert: "amount > 0"
        update: { using: "status = 'open'", check: "amount > 0" }
        delete: "status = 'closed'"
```

Each catalog's value is a `vcatbridge` policy document, passed to
`vcatbridge_configure_policy` as written; `policy_version` defaults to `1`. See the
bridge's `docs/policy-v1.schema.json` for every setting (`schemas`, `functions`,
`foreign_keys`, ...). The bridge validates the document at boot and again each
time it bridges the catalog (per client, or once under quack), and an unlisted
verb is denied.

| Verb | Value |
| --- | --- |
| `select` | `true` or a `USING` predicate: rows a client can see |
| `insert` | `true` or a `WITH CHECK` predicate: rows a client can add |
| `update` | `true`, a predicate, or `{using, check}`: rows a client can change, and what they may become |
| `delete` | `true` or a `USING` predicate: rows a client can remove |

`update` and `delete` need a primary key. `primary_key` overrides it where the
bridge cannot discover one from the schema.

Each catalog is served under its own name:

```
ATTACH 'n6k://localhost:8080' AS eggs (TYPE n6k, CATALOG 'app');
SELECT * FROM eggs.main.users;
```

The alias is the client's to pick; `CATALOG` selects the served catalog. An
unlisted table does not exist for clients.

`memory`, `system`, and `temp` cannot be served — every DuckDB already has
them, so a served catalog cannot take those names. Boot SQL must `ATTACH` a
catalog of its own rather than relying on the default.

### JWT claims

With `--oidc-issuer-url`, a client passes its JWT as the ATTACH token:

```
ATTACH 'n6k://localhost:8080' AS app (TYPE n6k, TOKEN '<jwt>');
```

n6kd discovers the issuer's signing keys at boot and checks each token's
signature, `iss`, `aud`, and `exp`. A token that fails is refused as
`unauthorized`.

Every string, boolean, and number claim in the token is available to policy
predicates as `$name` — `$sub`, `$iss`, `$exp`, `$email`, and any custom
claim. Array and object claims are left out, and so is `aud` when it is a list.

```
catalogs:
  app:
    tables:
      main.orders:
        select: "owner = $sub"
        insert: "owner = $sub"
```

Values are bound as typed constants, never spliced into the SQL. A predicate
naming a claim the token does not carry refuses the connection.

## SQL functions

| Function | Description |
| --- | --- |
| `getenv(name)` | environment variable, NULL when unset; only available inside `-f` boot SQL and, with `--perms`, `n6kd_set_interval` bodies |
| `n6kd_log(message)` | echoes the message into the server log, prefixed `sql:` |
| `n6kd_set_interval(name, INTERVAL, sql)` | repeats `sql` against the source every interval; boot SQL only |

```
SELECT n6kd_set_interval('refresh', INTERVAL 5 MINUTE,
  'INSERT INTO audit_log SELECT max(id) + 1, ''tick'' FROM audit_log');
```

The body runs inline, before the call returns, so the boot statements after it
see its effect and a broken statement fails startup rather than the first tick.
It cannot register another interval, and the calling statement's own snapshot
predates it. Months and years are rejected; the interval must be positive.

## Docker

```
FROM srossross/n6kd
COPY schema.sql /app/schema.sql
COPY perms.yml  /app/perms.yml
CMD ["-f", "/app/schema.sql", "--perms", "/app/perms.yml"]
```
srossross20
🟧 echo.github ⭐The GitHub repository is the origin: its README describes n6kd as serving DuckDB catalogs and says it lets “people and AI agents query all ySean Ross-Ross——

Interpretation history

Decision trace