
Research
/Security News
Popular npm Packages in the keyv and Cacheable Namespaces Compromised in Active Supply Chain Attack
Popular npm packages keyv and cacheable compromised.
@valv/clickhouse
Advanced tools
ClickHouse adapter for valv — row-level security and access control for AI agents
ClickHouse adapter for valv — let an LLM run analytics over ClickHouse, scoped by policies you write in code. The model emits a structured query; valv validates it, injects your tenant/row filter, and compiles it to ClickHouse SQL.
npm i @valv/clickhouse @clickhouse/client
import { createClient } from "@clickhouse/client"
import { createValv } from "@valv/clickhouse"
const ch = createClient({ url: process.env.CLICKHOUSE_URL })
// Introspects the live database on construction — call once at startup.
const valv = await createValv(ch, { schema: "introspect", database: "analytics", defaultPolicy: "deny-all" })
valv.policy("events", (ctx) => ({
read: { tenant_id: ctx.tenant.id }, // every read is scoped to this tenant
fields: { deny: ["raw_payload"] }, // hide a column from the model
}))
const tools = await valv.tools.aisdk(ctx) // or .anthropic / .openai / .gemini / .neutral
See the root README for policies, the tool layer, and saved queries.
On top of the standard aggregates (count, sum, avg, min, max), this dialect adds ClickHouse-native functions the model can call:
| Function | Use |
|---|---|
quantileTiming(level)(col) | percentiles, e.g. p95 latency |
toDate / toStartOfHour / toStartOfDay | fixed-grain time buckets |
toStartOfInterval(col, n, unit) | arbitrary-grain time buckets |
uniq / uniqExact | distinct counts (DAU/MAU) |
countIf(pred) / sumIf(col, pred) | conditional aggregation |
Each is type-checked, and any literal a function compares against becomes a bound parameter — never string-concatenated.
schema: "introspect" queries system.columns to build the catalog (table → columns with native types, primary-key parts).schema: <SchemaMap> lets you declare the schema by hand — useful for per-tenant tables, or to add relations ClickHouse can't introspect. See examples/hand-schema.ClickHouse has no schema-level notion of "sensitive", so mark hidden columns in your policy (fields.deny), not the schema.
Every query runs with conservative ClickHouse settings — max_execution_time, max_result_rows/bytes, result_overflow_mode: throw — so a structurally-valid query can't run away on the server. Raise them per deployment if your analytics needs more headroom.
ClickHouse is insert-only here (UPDATE/DELETE are heavy async mutations, so they're not exposed). Allow inserts in policy and turn the tool on:
valv.policy("events", (ctx) => ({ create: { tenant_id: ctx.tenant.id } }))
const tools = await valv.tools.aisdk(ctx, { create: true })
await valv.create({ from: "events", values: { event: "click", latency: 12 } }, ctx)
Forced fields (tenant_id) are set server-side — the model can't choose, omit, or override them. See Writes in the root README.
No client wired up? createValvFromUrl(url, { database }) builds the client and introspects for you. This is also what the @valv/mcp CLI uses for ClickHouse.
MIT
FAQs
ClickHouse adapter for valv — row-level security and access control for AI agents
The npm package @valv/clickhouse receives a total of 45 weekly downloads. As such, @valv/clickhouse popularity was classified as not popular.
We found that @valv/clickhouse demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Popular npm packages keyv and cacheable compromised.

Security News
A misconfiguration gave three Anthropic models internet access, and one, believing it was in a simulation, shipped a credential-stealing package to PyPI.

Security News
/Company News
Socket has joined the new Composer and Packagist sponsorship program as a launch sponsor, supporting the team that keeps PHP's package ecosystem secure.