How to Configure n8n ClickHouse MCP Server
To set up an n8n clickhouse mcp server, attach the server to an AI Agent node. Then log in to the database with a read-only ClickHouse user role. Teams often use a shared admin user during initial tests. That shortcut gives the chat model broad rights over every table. If a prompt goes wrong, the agent can read private rows or drop data. How the n8n clickhouse mcp server workflow runs In n8n, the AI Agent node joins a chat model with one or more tool sub-nodes. The agent reads the user prompt
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.
To set up an n8n clickhouse mcp server, attach the server to an AI Agent node. Then log in to the database with a read-only ClickHouse user role. Teams often use a shared admin user during initial tests. That shortcut gives the chat model broad rights over every table. If a prompt goes wrong, the agent can read private rows or drop data.
How the n8n clickhouse mcp server workflow runs
In n8n, the AI Agent node joins a chat model with one or more tool sub-nodes. The agent reads the user prompt and picks which tool to call for the task. From n8n 1.82.0 onward, every AI Agent node runs as a Tools Agent. Node version 1 and the old agent type setting were removed in n8n 3.0. N8n also includes a registry of MCP servers Alongside workflow, code, and HTTP tools.
When you attach the ClickHouse tool, the agent turns plain questions into SQL queries. The MCP server sends those queries to ClickHouse using one database user account. ClickHouse manages users, roles, row policies, settings profiles, and quotas through SQL access control. To use SQL-driven access control, the server needs a storage path set up. It also needs an admin user with access management turned on. When you create the agent user, you set its login method and allowed host. You also assign default roles and per-user settings. Keep in mind that a user can only grant rights they already hold.
How to scope ClickHouse permissions for agent tools
Instead of giving full table access, grant SELECT rights on specific columns only. When a user has column grants, queries can only read those exact named columns. If the agent tries to select an ungranted column, ClickHouse blocks the query. A wildcard select also fails and returns no data unless every column is granted. Since version 24.10, you can also use a trailing asterisk to grant by table prefix.
Column grants and roles control which tables and columns the agent user can read. Still, static database grants only check who logs in at the start. They do not inspect what each generated SQL statement does in flight. Every user of the n8n workflow shares that single MCP server database account. If a column holds emails, phone numbers, or card numbers, the query returns them raw. The database cannot pause a risky query for a human check on its own. It also cannot rewrite sensitive fields like national IDs in query results before the model reads them.
ClickHouse Access Management + Kubernetes API Server Access: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Why runtime query checks matter for AI agents
AI agents write new SQL on the fly based on user chat input. Even with read-only roles, a bad query can pull millions of rows at once. That heavy load can slow down the database for the rest of your team. Also, database logs only show the shared MCP user name, not who triggered the run. Teams need a way to link each query back to a specific workflow task. They also need field masking that rewrites matched PII in results before the agent replies.
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
How does an n8n AI Agent pick the ClickHouse MCP tool?
You attach the MCP tool as a sub-node under the main AI Agent node. The chat model reads the prompt and decides when to call that tool.
Why does a wildcard SELECT query fail for a restricted ClickHouse user?
When you grant SELECT on specific columns only, ClickHouse blocks wildcard queries by default. The query only works if the user has grants for every column in that table by default.
Can ClickHouse column grants hide emails or card numbers inside allowed columns?
No, column grants are all or nothing for each column you allow. To rewrite emails, phone numbers, or card numbers in results, you need runtime data masking.
Related guides
In this post