How to Configure Claude Code ClickHouse Credentials

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up claude code clickhouse credentials by making a read-only database user. Then you pass those login details to an MCP server or shell tool. Many teams start by reusing an admin database account for their coding agent. That shortcut gives the AI agent way too much power over live tables. A bad prompt or a simple mistake can change or wipe out rows. Setting up strict user rules on the database side stops those accidents early. How to set up claude code clickhouse credentials with SQL ro

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 credentials by making a read-only database user. Then you pass those login details to an MCP server or shell tool. Many teams start by reusing an admin database account for their coding agent. That shortcut gives the AI agent way too much power over live tables. A bad prompt or a simple mistake can change or wipe out rows. Setting up strict user rules on the database side stops those accidents early.

How to set up claude code clickhouse credentials with SQL roles

ClickHouse lets you manage users, roles, row policies, settings profiles, and quotas with SQL. To turn on SQL access control, the server needs a storage folder path. You also need at least one admin user with access management turned on. That admin user must also have named collection control set to one. Once that is ready, an admin with user creation rights makes the account. A user can only grant the database rights that they already hold themselves.

When you create the user, you set the login method and allowed hosts. You can also assign default roles and specific user settings at creation time. For an AI coding agent, vendor docs advise using a read-only database user. This step ensures the queries the agent runs cannot modify your stored data. You can lock down read rights even further with column-level select grants. When you grant select on specific columns, the user can only query them.

If the agent runs a query on another column, the database refuses it. A wildcard select query also fails unless the table only has granted columns. Since version 24.10, a trailing asterisk lets you grant rights by table prefix. Once the database user is ready, you connect the coding agent to it. Claude Code reaches external tools and databases through the Model Context Protocol. It can also run local database client commands through its built-in Bash tool.

What native database roles solve and what they leave open

In manual mode, the Bash tool asks for human approval before running commands. Only a small built-in set of read-only shell commands run without a prompt. Using MCP servers or the Bash tool with a read-only user helps safety. Native ClickHouse roles decide who can log in and which columns they read. They stop an AI agent from dropping tables or changing rows by mistake. Column grants also block the agent from reading columns you did not permit.

Still, static database credentials still leave big operational gaps for engineering teams. First, you have to store the database password on the developer machine. Anyone or any process reading the local config file can take that password. Second, static column grants are an all-or-nothing rule for the whole table. If an agent needs to query a customer table, it reads raw values. Native grants do not rewrite emails, phone numbers, or card numbers in results.

Claude Code Security + Ephemeral Credentials: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Third, database roles only check permissions when a session starts or runs queries. They do not give you one central audit log across different agent sessions. You cannot pause a single risky query in flight for a quick check. When an agent runs wild with heavy queries, revoking static keys takes work. You must rotate the secret on the server and update every developer machine.

Why local agent config files create secret sprawl

Every developer who uses an AI coding agent needs a local setup file. That file holds the connection string for the MCP server or shell script. Soon, dozens of laptops hold plaintext database passwords that rarely get rotated. If a laptop is lost, you must change the database user password fast. That change breaks the setup for every other engineer on the same team. Teams need a way to run agent queries without handing out raw secrets.

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 connect to a ClickHouse database?

Claude Code reaches databases through Model Context Protocol servers or its Bash tool. You give the MCP server a connection string, or run CLI queries after approval.

How do I limit which ClickHouse columns the agent can query?

You can grant select rights on specific columns to the agent database user. The database will block wildcard queries and queries that touch any ungranted columns.

Why should I avoid giving default database users to coding agents?

Default or admin users often have rights to alter tables and read everything. Using a read-only user with limited column grants keeps the agent from changing data.

The query runs. The emails stay hidden.