How to Configure Claude Code ClickHouse Sandbox
You set up a claude code clickhouse sandbox by creating a read-only database user. Then you link that user to the agent through a Model Context Protocol server. Teams often start by handing an agent a standard developer database string. When roles are too broad, the agent can change tables or read private fields. A dedicated sandbox user limits what the AI tool can touch. How a claude code clickhouse sandbox works Claude Code talks to outside databases in two main ways. It can use a Model Con
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 a claude code clickhouse sandbox by creating a read-only database user. Then you link that user to the agent through a Model Context Protocol server. Teams often start by handing an agent a standard developer database string. When roles are too broad, the agent can change tables or read private fields. A dedicated sandbox user limits what the AI tool can touch.
How a claude code clickhouse sandbox works
Claude Code talks to outside databases in two main ways. It can use a Model Context Protocol server or its built-in Bash tool. An MCP server gives the agent a structured way to query databases. Vendor docs tell teams to put a read-only database user in the string. That rule stops the queries from changing any stored records.
The agent can also run shell commands through its Bash tool. In Manual mode, the Bash tool asks for human approval before running commands. It only skips approval for basic local commands like listing files or checking git. Database CLI calls from the shell still require a human to say yes. Even with prompts, the database role itself must hold strict limits.
ClickHouse manages users, roles, row policies, settings profiles, and quotas through SQL statements. To turn on SQL access control, an admin sets a server storage directory. At least one admin account needs user management rights turned on. An admin can only grant rights that they already hold themselves. Creating a new sandbox account takes the create user privilege.
During setup, the admin sets the login method and allowed client hosts. The admin also assigns default roles and user settings for that account. For a tight sandbox, you can grant read rights on single columns. If a user only has rights on two columns, other queries fail. A full table query with an asterisk also fails and returns no data. It only works if the table holds just those granted columns. Starting in version 24.10, admins can also grant rights by table name prefixes.
What native roles solve and what they leave open
Native ClickHouse roles and column grants solve the first layer of risk. They decide who can log in and which tables or columns are visible. If the AI agent tries to drop a table, the database blocks it. If the agent queries a restricted column, the engine rejects the statement.
Claude Code Security + ClickHouse Access Management: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Yet native database grants leave an operational gap open during live work. Database roles check permissions at login and table level, not inside returned text. An allowed text column might still hold emails, phone numbers, or card numbers. Once a column is granted, the database sends every matching row in plain text.
Also, local MCP setups often store static database passwords in local files. If a developer machine has a plain password, any local process can read it. Finally, manual Bash prompts only show the command before it runs. They do not rewrite sensitive fields like national IDs in the query results. Teams need a way to inspect queries and mask results in flight.
Check ClickHouse queries and result columns on the wire
ClickHouse users and row policies decide who connects. They do not check each statement on the wire or redact sensitive string columns in query results. With hoop.dev, you run an open-source proxy, a sidecar for your ClickHouse, inline in ClickHouse's native TCP protocol. On every query an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.
Multi-statement queries and table mutations are split and checked by hoop.dev guardrails, which refuse banned actions with a native ClickHouse error or hold risky ones for approval. On returned rows, hoop.dev data masking rewrites String and FixedString columns in memory, and the audit trail logs each query and verdict. See the MIT-licensed source on GitHub.
Frequently asked questions
How does Claude Code run queries against ClickHouse?
The agent connects through a Model Context Protocol server or runs CLI tools via Bash. Vendor docs recommend using a read-only user in the MCP string to prevent changes.
Can ClickHouse restrict an AI agent to specific columns?
Yes, admins can grant read rights on named columns only. Queries asking for other columns or using an asterisk on wider tables will fail.
Why are read-only database grants not enough for AI agents?
Read-only grants block writes, but they still return raw data from allowed columns. They cannot mask emails, phone numbers, or card numbers inside query results.
Related guides
In this post