How to Configure Codex ClickHouse MCP Server

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up a codex clickhouse mcp server by linking your AI agent to a read-only database user. Next, you register the server process in your local agent tool settings. Many teams start by giving the agent a broad admin account for quick testing. That choice exposes live tables to bad queries and accidental writes during a coding session. How a codex clickhouse mcp server works AI coding agents use the Model Context Protocol to reach outside tools and databases. The agent sends a tool request

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 codex clickhouse mcp server by linking your AI agent to a read-only database user. Next, you register the server process in your local agent tool settings. Many teams start by giving the agent a broad admin account for quick testing. That choice exposes live tables to bad queries and accidental writes during a coding session.

How a codex clickhouse mcp server works

AI coding agents use the Model Context Protocol to reach outside tools and databases. The agent sends a tool request to the local server process over standard input or network ports. The server translates that prompt request into a database query and runs it against ClickHouse. Then it returns the result rows back to the coding agent so the model can read them.

To keep this link safe, you must set up SQL-driven access control inside ClickHouse first. This feature stores users, roles, row policies, settings profiles, and quotas on disk. You need a storage directory and an admin account with access management turned on. Once active, you create a dedicated user for your agent with a strong login method.

ClickHouse lets a user grant only the permissions that they already hold themselves. You can restrict the new agent user by host so it only logs in from trusted machines. You can also attach default roles and settings profiles to cap memory or query time. This stops a runaway agent loop from taking down your analytics cluster.

Setting up column grants and read-only roles

Vendor guides for AI agents advise using a read-only database user in your connection string. That way, the queries the agent runs cannot change or delete live data. In ClickHouse, you can go further and grant read access on specific columns only. If you grant select on two columns, the agent can query only those two fields.

If the agent tries to query an unapproved column, ClickHouse refuses the query right away. A wildcard select query on the whole table also fails and returns no data at all. It only works if the table holds just the columns you granted to that user. Since version 24.10, you can also grant select rights across tables that share a name prefix.

ClickHouse Access Management + Kubernetes API Server Access: 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 database roles and column grants solve the first half of the agent security problem. They decide who can log in and which tables or columns the account can read. If an AI agent hallucinates a drop table statement, the database rejects it at once. Host checks and quotas also keep basic resource use within safe bounds.

Still, static roles leave a big operational gap during live coding sessions. The database user password still sits in a plain local file on the developer laptop. Any local script or untrusted server plugin can read that secret and log in directly. Also, a column grant cannot inspect the actual values inside an approved text column.

An approved column might still hold raw emails, phone numbers, card numbers, or national IDs. When the agent runs a query, those raw values flow straight into the model prompt. Static database permissions cannot rewrite matched fields in results on the fly. They also cannot pause a risky query to ask a human for approval in flight.

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 inline in the protocol beside the server as a sidecar for your ClickHouse. On every query an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human approval.

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

Frequently asked questions

Should I give my AI agent my own ClickHouse login?

No, you should never share your personal admin account with an AI coding agent. Create a dedicated read-only user with narrow column grants and strict query quotas instead.

Why does a wildcard select fail for my restricted agent user?

ClickHouse blocks wildcard select queries when a user only has grants on specific columns. Tell your agent to name the exact allowed columns in every select query it writes.

How do I stop sensitive fields from reaching the AI model?

Start by leaving sensitive columns out of your SQL select grants whenever you can. For text columns that mix safe data with emails or card numbers, use data masking to rewrite matched fields in results.

The query runs. The emails stay hidden.