How to Configure AutoGen ClickHouse MCP Server

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up an autogen clickhouse mcp server by pairing your agent with a restricted database user. First, register the server tool in your agent framework and pass scoped login keys. Many teams start by giving the agent an admin database profile to test queries fast. That broad role lets the agent read sensitive columns or drop production tables by mistake. How an autogen clickhouse mcp server uses database roles The Model Context Protocol links your multi-agent app to your analytics database

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 autogen clickhouse mcp server by pairing your agent with a restricted database user. First, register the server tool in your agent framework and pass scoped login keys. Many teams start by giving the agent an admin database profile to test queries fast. That broad role lets the agent read sensitive columns or drop production tables by mistake.

How an autogen clickhouse mcp server uses database roles

The Model Context Protocol links your multi-agent app to your analytics database. When an agent needs data, it sends a request to the server tool. The server translates that request into a query and runs it against ClickHouse. Your database only sees the user profile tied to that server session.

ClickHouse manages users, roles, row policies, settings profiles, and quotas through SQL. To turn on SQL access control, you set a storage folder path on the server. You also need at least one admin account with user management rights turned on. That admin can create a dedicated user for your agent and set its login method. You can also limit which hosts the agent user can log in from. Note that a database user can only grant rights that they already hold.

To keep the agent safe, you can grant read rights on specific columns only. If an agent only has rights to two columns, it can query just those two. Queries asking for other columns will fail right away. A wildcard query for all columns also fails unless the table holds only permitted columns. Since version 24.10, you can also grant read rights using a table name prefix.

What native database roles solve and what they miss

Native ClickHouse users and column grants solve the basic problem of who can log in. They stop an agent from reading restricted tables or running write commands when set to read-only. Static column rules also block access to whole fields that the agent never needs.

Still, static roles do not check what happens inside permitted queries during a live run. An agent often needs to read a text column or customer table to answer support tickets. That allowed column might hold emails, phone numbers, card numbers, or national IDs. Because the database user has read rights on that column, ClickHouse sends the raw text back. The language model then ingests those sensitive values into its prompt context.

ClickHouse Access Management + Kubernetes API Server Access: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Shared service accounts also make auditing hard for security teams. Every agent in the group uses the same database user to run queries. Your database logs show the shared server account, not which agent task triggered the read. Also, storing raw database keys in agent config files creates a leak risk on host machines. Static setup decides who logs in, not what individual statements do in flight.

Scoping agent queries before they hit the database

Running autonomous agents in production takes more than a static database role. Teams need a way to inspect each query before it runs. They also need to rewrite matched fields like emails or card numbers in query results. Adding human approval steps for risky commands keeps agents from causing outages. This layer of control lets agents query analytical data while keeping private records safe.

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 do wildcard queries fail for my restricted ClickHouse agent user?

ClickHouse blocks wildcard queries when a user only has column-level read grants on part of a table. The agent must name the allowed columns in its query, or the database returns no data.

How do I turn on SQL role management in ClickHouse for my agents?

You must configure the access control storage path on the server and enable access management for your admin user. After that, you can create users, roles, and quotas using standard SQL statements.

Can ClickHouse column grants hide sensitive fields inside a single text column?

No, native column grants are all-or-nothing for each column. If an agent has read rights on a column, it receives all text inside it unless data masking rewrites matched fields in the results.

The query runs. The emails stay hidden.