Connect

Programmatic usage

Start the hypequery MCP server from a Node process.

Use createMCPServer when you want to start the MCP server from your own Node process instead of using the CLI.

import { createMCPServer } from '@hypequery/mcp';
import { createDatasetClient } from '@hypequery/datasets';
import { createQueryBuilder } from '@hypequery/clickhouse';
import { datasets } from './datasets/index.js';

const db = createQueryBuilder({
  url: process.env.CLICKHOUSE_URL!,
  username: process.env.CLICKHOUSE_USERNAME!,
  password: process.env.CLICKHOUSE_PASSWORD!,
  database: process.env.CLICKHOUSE_DATABASE!,
});

const analytics = createDatasetClient({ queryBuilder: db });

const server = await createMCPServer({
  datasets,
  analytics,
  name: 'analytics-mcp',
  version: '1.0.0',
});

// The server is now running over stdio.

createMCPServer returns the server instance after calling start(). The stdio transport is intended for MCP clients that launch and manage the process.

Tenant-scoped servers

If registered datasets have tenantKey, pass a trusted tenantId when creating the MCP server.

const server = await createMCPServer({
  datasets,
  analytics,
  tenantId: 'tenant_123',
});

The server forwards that value as dataset runtime tenant context for query_dataset and query_metric.

Stop the server

If your application owns the lifecycle, call stop().

await server.stop();

Config shape

The programmatic API accepts the same core inputs as the CLI config, plus optional server metadata and tenant scope.

type MCPServerConfig = {
  datasets: Record<string, Record<string, unknown>>;
  analytics: DatasetClient;
  name?: string;
  version?: string;
  tenantId?: string;
  includeSql?: boolean;
};

Set includeSql: true only in trusted debugging contexts. Query tools redact generated SQL by default.

On this page

Get early access to hypequery cloud.

Cloud hosts the same model you run in your backend, with a managed API and MCP server, versions, and rollback. We're letting teams in a few at a time. Join the waitlist and we'll reach out when your project can go live.

How do you want to build your analytics layer? (Optional)
What features do you most need? (Optional)

Pick as many as you like.

Only your email is required. All other questions are optional.