How to Configure Haystack ClickHouse MCP Server
You set up a haystack clickhouse mcp server by linking an AI tool node to a restricted database account. This setup lets your AI pipeline run read queries against your tables. Most teams start by sharing a single database user across all AI pipelines. That broad account often holds full read rights on every table. When an AI model writes its own SQL, broad roles create real risk. A bad prompt can pull private rows or overload the cluster. How to set up a haystack clickhouse mcp server Your fi
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 haystack clickhouse mcp server by linking an AI tool node to a restricted database account. This setup lets your AI pipeline run read queries against your tables. Most teams start by sharing a single database user across all AI pipelines. That broad account often holds full read rights on every table. When an AI model writes its own SQL, broad roles create real risk. A bad prompt can pull private rows or overload the cluster.
How to set up a haystack clickhouse mcp server
Your first step happens inside the database. ClickHouse manages users, roles, row rules, settings profiles, and quotas through SQL. To turn on SQL access control, you must set a storage path on the server. You also need at least one admin user with access management turned on. That admin can only hand out rights that they already hold themselves.
Next, the admin creates a dedicated user for the MCP server. Creating a user requires the create user privilege in the database. The creation statement sets the login method and limits which hosts can log in. It also assigns default roles and per-user settings for that account. Your MCP server then uses these login details to talk to the database.
Inside Haystack, you add a tool component that talks to the MCP server. When a user asks a question, the pipeline sends the prompt to the model. The model decides to call the MCP tool and writes a SQL query. The MCP server runs that query as the database user you created. The results then flow back into the Haystack pipeline to build the final answer.
How column grants work for AI queries
Database admins can lock down what the MCP user reads by using column grants. You can grant read rights on specific columns in a table instead of the whole table. The MCP user can then query only those approved columns. If the model asks for another column, the database blocks the query.
Column grants also change how wildcard queries work. If the AI runs a select all query, the database refuses the request. It returns no data at all unless the table only has the granted columns. Admins can also use a trailing asterisk to grant rights by table name prefix. This helps when your AI needs to read many tables that share a common name.
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 database roles leave open
Static database roles and column grants solve the basic login problem. They decide which host can log in and which columns are off limits. Yet they do not inspect what individual queries do in flight. Every request from the Haystack pipeline uses the exact same database user. Your database logs show the shared MCP account, not the human who asked the question.
Column grants also work on an all-or-nothing basis. Sometimes an AI workflow needs to read a text column that holds mixed data. That column might include emails, phone numbers, card numbers, or national IDs. Native grants cannot rewrite matched fields in results while letting the rest of the text through. If a model gets tricked into dumping rows, static roles will not stop the query.
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 beside the server as a sidecar for your ClickHouse and parses every statement before execution.
First, hoop.dev guardrails block disallowed deletes, drops, and alter mutations. Then hoop.dev data masking rewrites sensitive string columns in responses and logs each decision per resource. Read the docs and source on GitHub.
Frequently asked questions
Why did my select all query fail through the MCP server?
When a database user only has grants on specific columns, select all queries fail. The database refuses the query unless the table contains only the granted columns. Update your prompt rules so the model lists the exact column names it needs.
How do I limit which hosts can run the MCP server?
When you create the database user with SQL, you can set allowed client hosts. This rule blocks any login attempt that comes from an unknown IP or host. Only your approved app server can log in with those keys.
Can a database user grant new table rights to the AI account?
A user in ClickHouse can only grant rights that they already hold themselves. They also need access management turned on for their own account. Without both, any attempt to expand the MCP user role will fail.
Related guides
In this post