How to Configure Vercel AI SDK ClickHouse MCP Server
To set up a vercel ai sdk clickhouse mcp server, link your model client to an MCP process. Then give that process a limited database user role with strict read rules. Many teams start by passing a shared admin database key to the server. That broad role lets an AI agent read any table or run heavy queries. A safe setup pairs your app code with strict database access rules. How a vercel ai sdk clickhouse mcp server works The Vercel AI SDK runs inside your app and talks to your model. The model
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 a vercel ai sdk clickhouse mcp server, link your model client to an MCP process. Then give that process a limited database user role with strict read rules. Many teams start by passing a shared admin database key to the server. That broad role lets an AI agent read any table or run heavy queries. A safe setup pairs your app code with strict database access rules.
How a vercel ai sdk clickhouse mcp server works
The Vercel AI SDK runs inside your app and talks to your model. The model decides when it needs data from your analytical tables. It sends a tool call to the ClickHouse MCP server process. That server turns the tool call into a database query and runs it. The database sends rows back to the server, which feeds the model.
To keep this flow safe, you must lock down the database user. ClickHouse manages users, roles, row policies, settings profiles, and quotas with SQL commands. First, turn on SQL access control by setting a server storage path. You also need an admin account with access management turned on. That admin can then create a dedicated user for your MCP server.
When you create the user, you set how it logs in. You can also limit which hosts the user can log in from. Assign default roles and per-user settings at the same time. Remember that a database user can only grant rights that they already hold.
Locking down tables and columns for AI queries
AI agents often try to read whole tables when answering a prompt. You can stop this by granting read rights on specific columns only. When you grant select rights on two columns, the user can read only those. Any query that asks for a third column will fail right away.
Wildcard queries that ask for all columns will also fail and return nothing. They only work if the table holds just the allowed columns. Since version 24.10, you can also grant select rights using a table name prefix. A trailing asterisk lets you grant rights across matching tables in one step. This helps when your analytical app reads from many daily or monthly tables.
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 solve and what they miss
Native database roles and column grants solve the initial login problem well. They decide which user account can log in and which columns are off limits. They also block wildcards on wide tables and limit where logins come from. Every team building an AI app should set up these native rules first.
Still, static database roles do not inspect individual queries in flight. Once an allowed column is read, the database returns the raw text as stored. If an allowed column holds emails, phone numbers, card numbers, or national IDs, the model receives them. Static grants also cannot ask a human to approve a sudden, weird query. Also, a single shared MCP user hides which end user triggered a specific query. Teams need runtime controls to mask sensitive fields in results and track real users.
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 runs beside the server as a sidecar for your ClickHouse and checks native TCP queries with no change to your drivers.
With hoop.dev ClickHouse support, guardrails refuse banned queries before they run, and data masking rewrites matched string columns in results. The audit trail logs which entity types were masked and how many without storing raw values. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.
Frequently asked questions
Why do wildcard queries fail for my ClickHouse MCP user?
If you grant select rights on specific columns only, ClickHouse blocks wildcard select queries. The query returns no data unless the table contains only those exact granted columns.
How do I turn on SQL role management in ClickHouse?
You must set a storage directory path for access control on the server. You also need at least one user account with access management enabled.
Can a ClickHouse user grant table access to another AI service account?
A user in ClickHouse can only grant permissions that they already hold themselves. Creating a new user also requires the dedicated create user privilege.
Related guides
In this post