How to Configure Amazon Q ClickHouse MCP Server
You set up an amazon q clickhouse mcp server by adding the server to your agent settings. Then you give it a read-only database user account. Teams often test this setup with a broad admin account to move fast. Broad roles let the AI tool read every table or drop live data by mistake. A safer setup uses strict database roles and clear access rules from day one. How the amazon q clickhouse mcp server setup works Amazon Q uses the Model Context Protocol to talk to outside data tools. The protoc
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 an amazon q clickhouse mcp server by adding the server to your agent settings. Then you give it a read-only database user account. Teams often test this setup with a broad admin account to move fast. Broad roles let the AI tool read every table or drop live data by mistake. A safer setup uses strict database roles and clear access rules from day one.
How the amazon q clickhouse mcp server setup works
Amazon Q uses the Model Context Protocol to talk to outside data tools. The protocol lets the coding agent ask the database server for table lists and query results. When you ask a question, the agent picks a tool from the local server. The local server then logs in to ClickHouse with the database user you set up.
ClickHouse manages users, roles, row policies, settings profiles, and quotas through SQL commands. To turn on SQL access control, an admin sets up a local storage folder on the server. At least one database user also needs user management rights turned on. Once that is ready, you can create a new user account just for the AI agent.
When you create this user, you set the login method and the allowed host addresses. You also assign a default role and user settings for that account. A database user can only give out rights that they already hold themselves. For an AI tool, you should grant read rights on specific columns instead of whole tables. If you grant read rights on two columns, the user can only query those two columns. If the agent tries to select all columns with a star, the database blocks the query. The database only allows a star query if the table holds just those granted columns. You can also grant read rights across a group of tables that share a name prefix.
What native database roles solve and what they miss
Native ClickHouse roles and column grants solve the first part of the security puzzle. They decide who can log in and which tables or columns that user can read. Host checks also make sure the login comes from a trusted machine. Quotas and settings profiles help stop a single bad query from using all the server memory.
Still, static database roles leave a big gap during live agent runs. The database only sees the shared user account that the local server uses to log in. It does not know which human engineer typed the prompt in Amazon Q. If five developers share the same setup, every query looks the same in the database log.
Column grants also struggle when a Permitted column holds sensitive text mixed with normal data. A support log column might include customer emails, phone numbers, card numbers, or national IDs. If the agent needs to read that column, native grants return the raw text in full. The database cannot rewrite matched fields in results on the fly for the AI tool.
ClickHouse Access Management + Kubernetes API Server Access: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Finally, local server setups store database keys in plain text files on developer laptops. If a laptop gets lost, those keys can leak. Static grants also cannot pause a risky query and ask a team lead for approval first. Native controls check the login at the door, but they do not watch each query in flight.
Steps to harden your database role for AI tools
Start by creating a dedicated role in ClickHouse that only holds read rights on safe columns. Never give the AI user account the right to create users or change table rules. Lock the user account to the specific host address where the local server runs. Set strict query quotas so a loop in the agent cannot overload your cluster.
Next, review every table that you expose to the coding agent. Remove columns that store raw user secrets, phone numbers, or card numbers from the grant list. If the agent must read a table with sensitive fields, create a clean view first. Grant the agent read rights on the clean view instead of the base table. Check your database query logs each week to see what SQL the agent writes.
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. It reads ClickHouse's native TCP protocol before queries run while ClickHouse stays in charge of login and grants.
Multi-statement queries and table mutations are split and checked by hoop.dev guardrails. Banned actions are refused with a native ClickHouse error. On returned rows, hoop.dev data masking rewrites String and FixedString columns that match your rules. The audit trail logs each query, table, and verdict. See the MIT-licensed source on GitHub.
Frequently asked questions
Why does ClickHouse block select star queries for my AI agent?
When you grant read rights on specific columns only, ClickHouse blocks select star queries by default. The agent must name the allowed columns in its SQL query, or the table must hold only those columns.
Can I restrict which hosts the MCP server logs in from?
Yes, when you create the user in ClickHouse, you can set the allowed host addresses. The database will reject any login attempt that comes from a different machine.
How do I stop an AI agent from reading sensitive columns in ClickHouse?
Use column-level select grants so the database user can only read safe columns on each table. For deeper control over emails or card numbers inside text fields, add data masking to rewrite matched fields in results.
Related guides
In this post