Clickhouse

Live

BEARER TOKEN

DATA WAREHOUSE

Analytics

Every event stream, analytics table, and OLAP query your team runs lives in ClickHouse. ClickHouse MCP gives your agent authenticated access to your data warehouse scoped to the user who authorized it.

  • Acts as the user: Access and write actions stay tied to the Clickhouse account that authorized the agent.
  • Credentials stay vaulted: AES-256, resolved at request time, never in LLM context.
  • Scoped before every call: User permissions enforced. 90-day audit trail.
Clickhouse
agent · Acme Q3
Run
Query our events table for the top 10 event types by volume in the last 24 hours.
S
ch_query_run
0.3s
Analytics agent
Query ran in 0.3s, scanned 2.1B rows. Top events: page_view (840M), api_call (312M), session_start (280M), feature_used (195M), export_triggered (42M) and 5 more.
Sources: events table, last 24 hours
clickhousemcp
1 query
18:29
Message Claude...

Tools your analytics agent reaches for on Clickhouse, scoped per user.

CALL ANY TOOL
Run SQL queries, list databases and tables, inspect schemas, and retrieve query execution logs.
ch_query_run
Run query
Execute a ClickHouse SQL query and return results.
Parameters
Name
Type
Required
Description
query
string
Required
ClickHouse SQL query
database
string
Optional
Target database name
max_rows
integer
Optional
Max rows to return
ch_databases_list
List databases
ch_tables_list
List tables
ch_table_schema
Get table schema
ch_query_log
Get query log
Build your Agent
Drop the toolkit in, point it at the user, and your analytics agent can use Clickhouse from the first run.
import { ScalekitClient } from "@scalekit-sdk/node";
import { DynamicStructuredTool } from "@langchain/core/tools";
import { createReactAgent } from "@langchain/langgraph/prebuilt";
import { z } from "zod";

const sk = new ScalekitClient(envUrl, clientId, clientSecret);

const { tools } = await sk.tools.listScopedTools("user_123", {
filter: { connectionNames: ["clickhouse"], toolNames: ["ch_query_run", "ch_databases_list", "ch_tables_list"] },
pageSize: 100,
});

const lcTools = tools.map((t) => new DynamicStructuredTool({
name: t.tool.definition.name,
description: t.tool.definition.description,
schema: z.object({}).passthrough(),
func: async (args) => {
const { data } = await sk.tools.executeTool({
toolName: t.tool.definition.name,
identifier: "user_123",
params: args,
});
return JSON.stringify(data);
},
}));

const agent = createReactAgent({ llm, tools: lcTools });
import { ScalekitClient } from "@scalekit-sdk/node";
import OpenAI from "openai";

const sk = new ScalekitClient(envUrl, clientId, clientSecret);
const openai = new OpenAI();

const { tools } = await sk.tools.listScopedTools("user_123", {
filter: { connectionNames: ["clickhouse"], toolNames: ["ch_query_run", "ch_databases_list", "ch_tables_list"] },
pageSize: 100,
});

const llmTools = tools.map((t) => ({
type: "function",
function: {
name: t.tool.definition.name,
description: t.tool.definition.description,
parameters: t.tool.definition.input_schema,
},
}));

const resp = await openai.responses.create({
model: "gpt-4o", input: prompt, tools: llmTools,
});
import { ScalekitClient } from "@scalekit-sdk/node";
import Anthropic from "@anthropic-ai/sdk";

const sk = new ScalekitClient(envUrl, clientId, clientSecret);
const anthropic = new Anthropic();

const { tools } = await sk.tools.listScopedTools("user_123", {
filter: { connectionNames: ["clickhouse"], toolNames: ["ch_query_run", "ch_databases_list", "ch_tables_list"] },
pageSize: 100,
});

const llmTools = tools.map((t) => ({
name: t.tool.definition.name,
description: t.tool.definition.description,
input_schema: t.tool.definition.input_schema,
}));

const msg = await anthropic.messages.create({
model: "claude-sonnet-4-6", max_tokens: 1024,
tools: llmTools,
messages: [{ role: "user", content: prompt }],
});
import { Agent } from "@google/adk/agents";
import {
MCPToolset, StreamableHTTPConnectionParams,
} from "@google/adk/tools/mcp";

const toolset = new MCPToolset({
connectionParams: new StreamableHTTPConnectionParams({
url: "https://mcp.scalekit.com/clickhouse",
headers: { Authorization: `Bearer ${userScopedToken}` },
}),
});

const agent = new Agent({
name: "agent", model: "gemini-2.0-flash",
tools: await toolset.getTools(),
});
Try these prompts
Paste any prompt into your agent to start using Clickhouse.
Schema & discovery
Copy the prompt
Copied
List all databases.
Copy the prompt
Copied
Show tables in [database].
Copy the prompt
Copied
Get schema for [database.table].
Copy the prompt
Copied
How many rows are in [table]?
Query & analysis
Copy the prompt
Copied
Run: SELECT event_type, count() FROM events GROUP BY event_type.
Copy the prompt
Copied
Daily active users last 30 days.
Copy the prompt
Copied
Top 10 customers by API call volume.
Copy the prompt
Copied
P99 latency by endpoint last week.
Monitoring & ops
Copy the prompt
Copied
Recent slow queries over 5 seconds.
Copy the prompt
Copied
Query log for user [username] today.
Copy the prompt
Copied
Which tables have the most reads?
Copy the prompt
Copied
Storage size by database.
SEE HOW AUTH WORKS
Users authorize Clickhouse once. Their credentials stay vaulted, every call is checked, and every action is logged.
1
Authorize
Your user connects
Clickhouse
once. We tie it to their identity and the meetings they approved — no shared bot account, no org-wide access
Who:
user ‘A’
when:
Once per user
access:
Limited to user
2
Store
Their
Clickhouse
token lives in a vault scoped to them. User A's meetings are never reachable by an agent acting for user B, even on the same connection
vault:
encrypted
scope:
per-user
tokens:
auto-refreshed
3
Resolve
When your agent calls a
Clickhouse
tool, we fetch the right token server-side. It never touches your agent, never appears in the LLM context, never shows up in your logs
speed:
~40ms
check:
before every call
seen by:
nobody
4
Audit
Every
Clickhouse
tool call is logged — who triggered it, which meeting was fetched, what came back. 90 days of history, tied to the user who authorized it
history:
90 days
export:
SIEM-ready
logged:
every call
Test other agents
Same per-user auth pattern across other analytics agents and MCP connectors. Working code, live demos, fork what fits.
GTM
HubSpot to Slack updates agent
Watch HubSpot deal stage changes and post structured updates to the right Slack channel. Reps stop checking the CRM all day.
ENGINEERING
Engineering standup agent
Aggregate GitHub and GitLab activity, link to Jira, and post a daily standup digest to Slack. No async updates.
Why Scalekit
Secure your agent's access. Connectors ship in minutes
Other connector libraries treat auth as a demo afterthought. Scalekit starts with user identity, scope enforcement, and audit.
01.
Shared tokens break per-user analytics
A shared token looks fine in a demo. In production every call looks like a service account. Scalekit resolves the real user credential so attribution, audit, and scope stay accurate.
// shared token
 audit → bot_service_account
 user_filter → broken

 // scalekit
 audit → user_abc
 scope → enforced ✓
02.
Authentication is not authorization
03.
Multi-tenancy is architectural
04.
Clickhouse today. Others tomorrow.
“Our agents act across Salesforce, Gong, Google Drive, and more, on behalf of every customer. Scalekit behind the scenes meant we can keep adding tools without ever rebuilding how credentials or tool calling work.”
Venu Madhav Kattagoni
Head of Engineering / Von
FAQs
Frequently Asked Questions
Does the agent access Clickhouse as the user or as a shared key?
As the user. Each workspace member authorizes once and Scalekit resolves their credential at request time. Audit logs attribute every action to that user, not a shared service account.
Where is the Clickhouse bearer token stored?
In Scalekit's managed AES-256 token vault, namespaced per tenant. Refresh is automatic. Revocation is a single dashboard action. Tokens never appear in prompts, logs, or LLM context.
Can I limit what the agent is allowed to do in Clickhouse?
Yes. Pass a tool name filter to listScopedTools so the analytics agent only sees the subset you authorize. Pre-API-call scope checks block out-of-policy actions before the request reaches Clickhouse.
What happens when a user revokes Clickhouse access?
The connection is invalidated on the next tool call. Subsequent requests for that user fail closed with a clear error. Other users in the tenant remain unaffected. The event is logged for audit.
Does the agent inherit ClickHouse user roles and row-level access policies?
Yes. Queries run under the authorizing user's ClickHouse credentials. Role-based access, row-level policies, and database-level grants all apply. The agent cannot read what the user cannot.
Start in your coding agent
Up and running in one command
Install the Scalekit skill in your editor of choice. Connector, auth, tools, prompt, all wired up
Claude Code REPL
/plugin marketplace add scalekit-inc/claude-code-authstack
/plugin install agentkit@scalekit-auth-stack
Cursor Code REPL
# ~/.cursor/mcp.json
{
""mcpServers"": {
""clickhouse"": {
""url"": ""https://mcp.scalekit.com/clickhouse"",
""headers"": { ""Authorization"": ""Bearer $SCALEKIT_TOKEN"" }
}
}
}
Codex Code REPL
# ~/.codex/config.toml
[mcp_servers.clickhouse]
url = ""https://mcp.scalekit.com/clickhouse""
auth_env = ""SCALEKIT_TOKEN""
Copilot Code REPL
# .vscode/mcp.json
{
""servers"": {
""clickhouse"": {
""url"": ""https://mcp.scalekit.com/clickhouse"",
""type"": ""http""
}
}
}