How to Configure Claude Code ClickHouse Approval

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up claude code clickhouse approval by combining manual agent prompts with strict database roles. First, require manual checks in the coding agent and assign a read-only database user. Many engineering teams start by giving their coding agent a broad database login. That shortcut helps during early tests, but it puts live tables at risk. When an agent holds broad rights, one bad query can alter or drop production records. How native claude code clickhouse approval works Claude Code tal

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 claude code clickhouse approval by combining manual agent prompts with strict database roles. First, require manual checks in the coding agent and assign a read-only database user. Many engineering teams start by giving their coding agent a broad database login. That shortcut helps during early tests, but it puts live tables at risk. When an agent holds broad rights, one bad query can alter or drop production records.

How native claude code clickhouse approval works

Claude Code talks to outside systems and databases in two main ways. It can use Model Context Protocol servers, or it can run shell commands through its Bash tool. When you use the Bash tool in Manual mode, the agent asks for your permission first. Only a small built-in list of safe read commands can run without a prompt. Every database client call through the shell waits for a human to approve it.

For Model Context Protocol servers, vendor docs advise using a read-only database user in the login string. That way, the queries the agent runs cannot change your stored data. You build this read-only user inside ClickHouse using SQL access control. To turn on SQL access control, the server needs a storage directory for access entities. You also need an admin account with access management turned on.

In ClickHouse, an admin can only grant rights that they already hold themselves. When you create a new user for the agent, you define its login method and allowed hosts. You also attach default roles, settings profiles, row policies, and resource quotas to that user. To tighten read rules, you can grant select rights on specific columns only. If a table has ten columns and you grant two, the agent can only query those two. A wildcard query across the whole table will fail and return no data at all. Since version 24.10, you can also use a trailing asterisk to grant rights by table name prefix.

Where local prompts and static roles fall short

Native agent prompts and static database roles solve the first layer of risk. They decide which account can log in and whether a local shell command starts. Still, this setup leaves a large gap during daily work with live data. Manual prompts in the coding tool happen on the developer machine, not at the database level. Developers get tired of reading long SQL text in terminal prompts and start clicking approve out of habit.

When you connect through a Model Context Protocol server, the server holds a static login string. Once that connection is active, the database only checks the static role of that user. It cannot ask a team lead in Slack or Teams to review a risky query in flight. Static column grants also take heavy work to keep up to date as schemas change. If you forget to revoke a column grant on a new table, raw emails or card numbers stay exposed.

Claude Code Security + Approval Chains & Escalation: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Why runtime query checks matter for coding agents

Database roles are binary: a user either has select rights on a column or gets blocked. Sometimes an agent needs to query a customer table to debug a bug, without needing raw personal fields. If you block the whole column, the agent fails because its query breaks. If you allow the column, raw phone numbers and national IDs flow straight into the model context. Teams need a way to rewrite matched fields in results while letting safe queries run.

Audit trails are another headache when every developer runs an agent with a shared read-only login. The database log shows the shared service user, not the person who approved the prompt. Linking each SQL statement back to an individual identity and approval event is vital for security reviews. Separating login credentials from developer machines also stops secret leaks if an agent reads local config files.

Add runtime guardrails and masking beside ClickHouse

Database grants and network rules control who can reach ClickHouse. Even so, an allowed client or agent can send an alter mutation that deletes rows or read raw personal data. In practice, hoop.dev sits inline in the native TCP protocol beside the server as a sidecar for your ClickHouse. For every production query an agent or human sends, hoop.dev decides whether to pass, mask, block, or escalate it for review.

With hoop.dev ClickHouse support, guardrails refuse banned queries before they run or hold risky calls for approval, and data masking rewrites matched string columns in results in memory. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.

Frequently asked questions

How does Claude Code run queries against a ClickHouse database?

Claude Code reaches databases through Model Context Protocol servers or by running CLI tools with its Bash tool. In Manual mode, the Bash tool pauses for user approval before running non-listed shell commands.

Can ClickHouse restrict an AI agent to specific columns?

Yes, ClickHouse lets you grant select rights on named columns for a user or role. Queries that ask for other columns or use a wildcard across ungranted columns are refused and return no data.

Why is a read-only database user not enough for AI coding agents?

A read-only user stops data changes, but it still lets the agent read sensitive columns and run heavy queries. It also lacks per-query team approvals and cannot rewrite emails or card numbers in query results.

The query runs. The emails stay hidden.