Skip to content
Scalekit Docs
Talk to an Engineer Dashboard

Connect AI agents to the Clickhouse MCP server

Vendor MCP
Open markdown

The Clickhouse MCP connector routes your AI agent's tool calls to Clickhouse's own MCP server through Scalekit. Each user signs in to Clickhouse once, and Scalekit stores and refreshes their tokens, so your agent never handles credentials. It comes with 17 tools.

Tools
17
What they doRead · write · destructive
17 · 0 · 017 read0 write0 destructive
Users sign in with
OAuth app
Scalekit's or your own

What you can do

  • Run SELECT queries: execute read-only SQL queries against any ClickHouse service and retrieve results directly in your agent
  • Explore schema: list databases, tables, and column types to understand your data model before writing queries
  • Manage services: list, inspect, and get full details for ClickHouse Cloud services (clusters) in an organization
  • Monitor backups: list service backups, get backup details, and retrieve the backup schedule and retention config
  • Inspect ClickPipes: list and retrieve data ingestion pipeline status and configuration
  • Track costs: get billing and usage cost data for an organization over a custom date range

Setup

  1. Install the SDK

    Terminal window
    npm install @scalekit-sdk/node dotenv
  2. Set your credentials

    Add your Scalekit credentials to your .env file. Find values in app.scalekit.com > Developers > API Credentials.

    .env
    SCALEKIT_ENVIRONMENT_URL=<your-environment-url>
    SCALEKIT_CLIENT_ID=<your-client-id>
    SCALEKIT_CLIENT_SECRET=<your-client-secret>
  3. Create the Clickhouse MCP connection

    In AgentKit > Connections, create a Clickhouse MCP connection. The name you give it is the connection_name your code passes. See Configure connections.

    Scalekit credentials are available for Clickhouse MCP server, so you don't need to register an OAuth app.

  4. Authorize a user and make your first call

    quickstart.mts
    import { ScalekitClient } from '@scalekit-sdk/node'
    import 'dotenv/config'
    import { createInterface } from 'node:readline/promises'
    const scalekit = new ScalekitClient(
    process.env.SCALEKIT_ENVIRONMENT_URL,
    process.env.SCALEKIT_CLIENT_ID,
    process.env.SCALEKIT_CLIENT_SECRET,
    )
    const actions = scalekit.actions
    const connector = 'clickhouse'
    const identifier = 'user_123'
    // Generate an authorization link for the user
    const { link } = await actions.getAuthorizationLink({ connectionName: connector, identifier })
    console.log('Authorize Clickhouse MCP:', link)
    const rl = createInterface({ input: process.stdin, output: process.stdout })
    await rl.question('Press Enter after authorizing...')
    rl.close()
    // Make your first call
    const result = await actions.executeTool({
    connector,
    identifier,
    toolName: 'clickhouse_get_organizations',
    toolInput: {},
    })
    console.log(result)
    Terminal window
    npx tsx quickstart.mts

    Each user signs in once. See Authorize a user for the full flow and statuses.

Tools

Pass the exact name to execute_tool
Try in PlaygroundRequest a tool
  • clickhouse_get_clickpipeGet configuration and status for a specific ClickPipe by ID.Read-only

    Get Clickpipe

    Get configuration and status for a specific ClickPipe by ID.

    Inputs

    clickPipeIdstringrequired
    ID of the requested ClickPipe
    organizationIdstringrequired
    ID of the organization that owns the service
    serviceIdstringrequired
    ID of the service that owns the ClickPipe
  • clickhouse_get_organization_costGet billing and usage cost data for an organization over a date range (max 31 days).Read-only

    Get Organization Cost

    Get billing and usage cost data for an organization over a date range (max 31 days). Returns a grand total and daily per-entity cost breakdown.

    Inputs

    organizationIdstringrequired
    The unique identifier of the organization
    from_datestring
    Start date for the report, e.g. 2024-12-19 (YYYY-MM-DD)
    to_datestring
    End date (inclusive) for the report, e.g. 2024-12-20 (YYYY-MM-DD). Cannot be more than 30 days after from_date.
  • clickhouse_get_organization_detailsGet details for a specific ClickHouse Cloud organization: name, tier, status, and settings.Read-only

    Get Organization Details

    Get details for a specific ClickHouse Cloud organization: name, tier, status, and settings. Use get_organizations to find the organizationId.

    Inputs

    organizationIdstringrequired
    ID of the organization to retrieve
  • clickhouse_get_organizationsList all ClickHouse Cloud organizations accessible with the current API key.Read-only

    Get Organizations

    List all ClickHouse Cloud organizations accessible with the current API key. Returns organization IDs and names. Use the returned organizationId with all other tools.

    Inputs

    This tool takes no inputs.

  • clickhouse_get_postgres_metricsReturns bucketed time-series metrics for a Postgres service over a time window (CPU, memory, disk, network, connections, cache hit ratio, throughput, transactions, and more).Read-only

    Get Postgres Metrics

    Returns bucketed time-series metrics for a Postgres service over a time window (CPU, memory, disk, network, connections, cache hit ratio, throughput, transactions, and more). Each metric has a key, name, unit, description, and one series per label dimension, where each series is a list of (timestamp, value) data points. Timestamps are Unix seconds at the bucket start. Provide fromDate and toDate to bound the window; omit bucketSizeSeconds to let the server pick a bucket granularity for the window. Use this to chart or analyze how a service behaved over time.

    Inputs

    fromDatestringrequired
    Inclusive start of the time window, as a UTC date-time with milliseconds, e.g. 2026-06-08T00:00:00.000Z
    organizationIdstringrequired
    The organization that owns the Postgres service
    serviceIdstringrequired
    The unique identifier of the Postgres service
    toDatestringrequired
    Exclusive end of the time window, as a UTC date-time with milliseconds, e.g. 2026-06-09T00:00:00.000Z
    bucketSizeSecondsinteger
    Bucket granularity in seconds; omit to let the server choose a bucket size for the window
  • clickhouse_get_postgres_slow_query_pattern_detailsReturns up to the 10 most recent individual executions for a single Postgres slow query pattern from the last 24 hours, plus aggregate metrics for the pattern when available.Read-only

    Get Postgres Slow Query Pattern Details

    Returns up to the 10 most recent individual executions for a single Postgres slow query pattern from the last 24 hours, plus aggregate metrics for the pattern when available. For exact drill-down from list_postgres_slow_query_patterns, pass queryId, dbName, dbUser, dbOperation, and app exactly as returned; pass app as an empty string when the selected pattern has no application_name. Omit app only when intentionally querying across all applications. Each execution includes duration, rows, buffer/temp/WAL/JIT/CPU counters, and the error message and SQLSTATE if it failed. Durations are in microseconds. The execution sample is capped at 10 rows, so when aggregate is present rely on its fields for totals.

    Inputs

    dbNamestringrequired
    Database the pattern ran in, as returned by list_postgres_slow_query_patterns
    dbOperationstringrequired
    Top-level SQL operation type of the pattern, as returned by list_postgres_slow_query_patterns
    dbUserstringrequired
    Database user that executed the pattern, as returned by list_postgres_slow_query_patterns
    organizationIdstringrequired
    The organization that owns the Postgres service
    queryIdstringrequired
    Stable identifier for the query pattern, as returned by list_postgres_slow_query_patterns
    serviceIdstringrequired
    The unique identifier of the Postgres service
    appstring
    Postgres application_name of the pattern, exactly as returned by list_postgres_slow_query_patterns. Pass an empty string for a pattern with no application_name; omit only to match all applications.
  • clickhouse_get_service_backup_configurationGet the backup schedule and retention configuration for a service.Read-only

    Get Service Backup Configuration

    Get the backup schedule and retention configuration for a service.

    Inputs

    organizationIdstringrequired
    ID of the organization that owns the service
    serviceIdstringrequired
    ID of the service
  • clickhouse_get_service_backup_detailsGet details for a specific backup: status, size, duration, and creation time.Read-only

    Get Service Backup Details

    Get details for a specific backup: status, size, duration, and creation time.

    Inputs

    backupIdstringrequired
    ID of the backup
    organizationIdstringrequired
    ID of the organization that owns the service
    serviceIdstringrequired
    ID of the service

Workflows

Get your service ID

Every ClickHouse tool requires a serviceId. Fetch it first by listing the services in your organization.

const orgs = await actions.executeTool({
toolName: 'clickhouse_get_organizations',
connector: 'clickhouse',
identifier: 'user_123',
toolInput: {},
});
const orgId = orgs.data?.result?.[0]?.id;
const services = await actions.executeTool({
toolName: 'clickhouse_get_services_list',
connector: 'clickhouse',
identifier: 'user_123',
toolInput: { organizationId: orgId },
});
const serviceId = services.data?.result?.[0]?.id;
console.log('Service ID:', serviceId);
Explore schema before querying

List databases and tables to understand the data model before writing queries.

// List databases
const dbs = await actions.executeTool({
toolName: 'clickhouse_list_databases',
connector: 'clickhouse',
identifier: 'user_123',
toolInput: { serviceId: '<your-service-id>' },
});
// List tables in a database
const tables = await actions.executeTool({
toolName: 'clickhouse_list_tables',
connector: 'clickhouse',
identifier: 'user_123',
toolInput: {
serviceId: '<your-service-id>',
database: 'default',
},
});
console.log(tables.data?.result);
Run a SELECT query

Execute read-only SQL against your ClickHouse service. Only SELECT statements are permitted.

const result = await actions.executeTool({
toolName: 'clickhouse_run_select_query',
connector: 'clickhouse',
identifier: 'user_123',
toolInput: {
serviceId: '<your-service-id>',
query: 'SELECT event, count() AS cnt FROM events GROUP BY event ORDER BY cnt DESC LIMIT 10',
timeoutSeconds: 30,
},
});
console.log(result.data?.result);
Check organization costs

Retrieve billing and usage data for a ClickHouse Cloud organization over a date range (max 31 days per request).

const costs = await actions.executeTool({
toolName: 'clickhouse_get_organization_cost',
connector: 'clickhouse',
identifier: 'user_123',
toolInput: {
organizationId: '<your-org-id>',
from_date: '2025-01-01',
to_date: '2025-01-31',
},
});
console.log(costs.data?.result);
List and inspect ClickPipes

ClickPipes are managed data ingestion pipelines. List all pipelines for a service and get detailed status for a specific one.

const pipes = await actions.executeTool({
toolName: 'clickhouse_list_clickpipes',
connector: 'clickhouse',
identifier: 'user_123',
toolInput: {
organizationId: '<your-org-id>',
serviceId: '<your-service-id>',
},
});
const pipeId = pipes.data?.result?.[0]?.id;
const pipe = await actions.executeTool({
toolName: 'clickhouse_get_clickpipe',
connector: 'clickhouse',
identifier: 'user_123',
toolInput: {
organizationId: '<your-org-id>',
serviceId: '<your-service-id>',
clickPipeId: pipeId,
},
});
console.log(pipe.data?.result);