How to Configure Semantic Kernel ClickHouse Permissions

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up semantic kernel clickhouse permissions by creating a restricted database user with SQL roles. Your AI app then uses that account to run only approved read queries. Teams often start by giving their AI plugin a broad database account. This approach gets prototypes running fast during early tests. Still, a wide role lets an agent read private tables or change data. If a prompt goes wrong, the model might drop records or read secrets. Tight database rules stop these bad queries before t

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 semantic kernel clickhouse permissions by creating a restricted database user with SQL roles. Your AI app then uses that account to run only approved read queries.

Teams often start by giving their AI plugin a broad database account. This approach gets prototypes running fast during early tests. Still, a wide role lets an agent read private tables or change data. If a prompt goes wrong, the model might drop records or read secrets. Tight database rules stop these bad queries before they run.

How semantic kernel clickhouse permissions work in practice

Semantic Kernel connects to external data through custom plugins or database skills. When the model needs facts, the app sends a query to ClickHouse. ClickHouse does not know that an AI agent sent the request. The database only checks the user account attached to that login session.

ClickHouse manages users, roles, row rules, settings profiles, and quotas through SQL. To turn on SQL access control, an admin sets a storage directory path. At least one admin account also needs access management rights turned on. That admin can then create a dedicated user for the AI app. A user can only grant rights that they already hold themselves.

When creating the agent user, you can set the login method and allowed hosts. You can also assign default roles and specific settings profiles to that user. Instead of granting full table reads, you should grant read rights on exact columns. The user can then query only those approved columns. If the agent runs a query for all columns, the database refuses it. That query returns no data unless the table holds only those granted columns.

Starting in version 24.10, a trailing star grants rights by table name prefix. This helps when your AI app reads from many similar log tables.

How to scope roles and row rules for AI agents

Good setup splits duties between human admins and machine plugins. Start by building a role just for your Semantic Kernel skill. Grant that role read access only to the specific columns the agent needs. Then assign that role as the default for the AI database user.

ClickHouse Access Management + AI Agent Permissions: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

You can also add row rules and quotas to the agent role. Row rules filter which rows the AI user can read during a query. Quotas limit how much compute and query time the agent can use. This stops a bad loop in your app from overloading the cluster.

What native database roles solve and what keeps the session active

Native database roles and column grants solve the core problem of broad access. They decide which account can log in and which columns it can read. If an AI plugin tries to read a blocked column, ClickHouse stops it. Quotas also keep runaway agent loops from eating up server resources.

Still, static grants leave a few daily gaps open for engineering teams. First, the AI app still holds a database key to log in. Second, all users of that app share the same database identity in logs. You cannot tell which human prompt triggered a specific SQL query. Third, a column might hold mixed text with emails, phone numbers, or card numbers. Native column grants either allow the whole column or block it all. They do not rewrite sensitive fields inside a text result in flight.

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 a select all query fail for my Semantic Kernel plugin?

ClickHouse blocks wildcard queries when a user only has column-level read grants. The query works only if the table contains solely those granted columns. Update your plugin prompt to ask for specific column names instead.

Can I limit which hosts the Semantic Kernel app logs in from?

Yes, the user creation command in ClickHouse lets you restrict allowed client hosts. This ensures the AI user account only logs in from your app servers.

How do I stop an AI agent from running heavy queries?

You can attach settings profiles and quotas to the ClickHouse user or role. These rules limit resource use and block changes over a set time window.

The query runs. The emails stay hidden.