How to Configure Vercel AI SDK ClickHouse Approval

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up vercel ai sdk clickhouse approval by adding human checks to database tools. You also lock down the database user with strict SQL access rules. Many teams wire AI models right into their analytics tables using one shared login. When that login has broad rights, a bad prompt can scan or drop production data. Building a safe flow takes both app checks and strict database roles. How to set up vercel ai sdk clickhouse approval in your app The AI toolkit lets a model call functions that

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You set up vercel ai sdk clickhouse approval by adding human checks to database tools. You also lock down the database user with strict SQL access rules. Many teams wire AI models right into their analytics tables using one shared login. When that login has broad rights, a bad prompt can scan or drop production data. Building a safe flow takes both app checks and strict database roles.

How to set up vercel ai sdk clickhouse approval in your app

The AI toolkit lets a model call functions that you write in your app. To add an approval step, you split the database tool into two parts. First, the model creates a query plan and asks to run it. Your app stops the run and saves the request as pending. Next, the app sends this pending request to a human reviewer.

A team member reads the query text in your internal UI or chat app. They check that the query touches the right tables and uses safe filters. Once the reviewer clicks approve, your backend runs the SQL statement against the database. The app then passes the result back to the model to finish the reply.

Alongside app checks, you must lock down the database account used by the tool. ClickHouse manages users, roles, row policies, settings profiles, and quotas through SQL. To turn on SQL access control, you set a storage folder on the server. You also need at least one admin user with access management rights turned on.

That admin can create a restricted user for your AI app. In ClickHouse, a user can only grant the rights that they have themselves. When you create the user, you set the login method and allowed client hosts. You also attach default roles and user settings to limit what the account can do.

You can grant read access on single columns instead of full tables. The user can then query only those specific columns. If the AI tries a full wildcard read, the database refuses the query. It returns no data unless the table holds only the granted columns. You can also grant read rights across tables that share a name prefix.

Approval Chains & Escalation + ClickHouse Access Management: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What native setup solves and what keeps the session active

Native roles and app checks stop many bad queries before they hit your cluster. Column grants keep the AI user away from secret columns in your tables. Human checks in the app stop obvious mistakes when the model writes bad logic. Host limits also stop outsiders from using the AI login from unknown servers.

Yet this native setup leaves a big gap during live runs. Database roles decide who logs in, not what each query does in flight. Once a human approves a tool call, the app uses a static database key. If a builder codes a new tool and skips the review code, queries run unchecked.

Native column grants also require hard work to keep up to date. Every time your schema changes, someone must update the SQL grants by hand. If an approved column holds emails, phone numbers, card numbers, or national IDs, raw values return. Data masking rewrites matched fields in results so raw text stays out of model prompts. App code alone cannot tie each SQL statement to the human who approved it.

Check ClickHouse queries and results before execution

Access control in ClickHouse is essential setup. Setup alone does not check single queries for risk or rewrite sensitive strings in returned rows. By design, hoop.dev sits beside the server as a sidecar for your ClickHouse and parses every statement before execution.

First, hoop.dev guardrails block disallowed deletes, drops, and alter mutations. Then hoop.dev data masking rewrites sensitive string columns in responses and logs each decision per resource. Read the docs and source on GitHub.

Frequently asked questions

Can ClickHouse pause a single SQL query for human approval by itself?

No, the database checks user grants right away and runs or blocks the query. You must build the pause and review step outside the database engine.

What happens if an AI tool runs a wildcard query with column grants?

ClickHouse blocks the wildcard query and returns no data at all. It only works if the user has read rights on every column in that table by default.

How do you limit which servers the AI app can log in from?

When you create the database user, you set the allowed host rules. The server will reject any login attempts that come from other network hosts.

The query runs. The emails stay hidden.