chore: import upstream snapshot with attribution
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled

This commit is contained in:
wehub-resource-sync
2026-07-13 13:20:55 +08:00
commit d25d482dc2
13754 changed files with 4996608 additions and 0 deletions
+100
View File
@@ -0,0 +1,100 @@
import type { ClickHouseCountResponse, ClickHouseCountRowsParams } from '@/tools/clickhouse/types'
import type { ToolConfig } from '@/tools/types'
export const countRowsTool: ToolConfig<ClickHouseCountRowsParams, ClickHouseCountResponse> = {
id: 'clickhouse_count_rows',
name: 'ClickHouse Count Rows',
description: 'Count rows in a ClickHouse table, optionally filtered',
version: '1.0.0',
params: {
host: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse server hostname (e.g., your-instance.clickhouse.cloud)',
},
port: {
type: 'number',
required: true,
visibility: 'user-only',
description: 'ClickHouse HTTP interface port (8443 for HTTPS, 8123 for HTTP)',
},
database: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Database name to connect to',
},
username: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse username',
},
password: {
type: 'string',
required: false,
visibility: 'user-only',
description: 'ClickHouse password',
},
secure: {
type: 'boolean',
required: false,
visibility: 'user-only',
description: 'Use a secure HTTPS connection (default: true)',
},
table: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Table name to count rows in',
},
where: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Optional WHERE clause condition without the WHERE keyword',
},
},
request: {
url: '/api/tools/clickhouse/count-rows',
method: 'POST',
headers: () => ({
'Content-Type': 'application/json',
}),
body: (params) => ({
host: params.host,
port: Number(params.port),
database: params.database,
username: params.username,
password: params.password,
secure: params.secure,
table: params.table,
where: params.where,
}),
},
transformResponse: async (response: Response) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'ClickHouse count rows failed')
}
return {
success: true,
output: {
message: data.message || 'Row count retrieved',
count: data.count ?? 0,
},
error: undefined,
}
},
outputs: {
message: { type: 'string', description: 'Operation status message' },
count: { type: 'number', description: 'Number of rows' },
},
}
@@ -0,0 +1,97 @@
import type {
ClickHouseCreateDatabaseParams,
ClickHouseMessageResponse,
} from '@/tools/clickhouse/types'
import type { ToolConfig } from '@/tools/types'
export const createDatabaseTool: ToolConfig<
ClickHouseCreateDatabaseParams,
ClickHouseMessageResponse
> = {
id: 'clickhouse_create_database',
name: 'ClickHouse Create Database',
description: 'Create a new database on a ClickHouse server',
version: '1.0.0',
params: {
host: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse server hostname (e.g., your-instance.clickhouse.cloud)',
},
port: {
type: 'number',
required: true,
visibility: 'user-only',
description: 'ClickHouse HTTP interface port (8443 for HTTPS, 8123 for HTTP)',
},
database: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Database name to connect to',
},
username: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse username',
},
password: {
type: 'string',
required: false,
visibility: 'user-only',
description: 'ClickHouse password',
},
secure: {
type: 'boolean',
required: false,
visibility: 'user-only',
description: 'Use a secure HTTPS connection (default: true)',
},
name: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Name of the database to create',
},
},
request: {
url: '/api/tools/clickhouse/create-database',
method: 'POST',
headers: () => ({
'Content-Type': 'application/json',
}),
body: (params) => ({
host: params.host,
port: Number(params.port),
database: params.database,
username: params.username,
password: params.password,
secure: params.secure,
name: params.name,
}),
},
transformResponse: async (response: Response) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'ClickHouse create database failed')
}
return {
success: true,
output: {
message: data.message || 'Database created',
},
error: undefined,
}
},
outputs: {
message: { type: 'string', description: 'Operation status message' },
},
}
+123
View File
@@ -0,0 +1,123 @@
import type {
ClickHouseCreateTableParams,
ClickHouseMessageResponse,
} from '@/tools/clickhouse/types'
import type { ToolConfig } from '@/tools/types'
export const createTableTool: ToolConfig<ClickHouseCreateTableParams, ClickHouseMessageResponse> = {
id: 'clickhouse_create_table',
name: 'ClickHouse Create Table',
description: 'Create a new MergeTree-family table in ClickHouse',
version: '1.0.0',
params: {
host: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse server hostname (e.g., your-instance.clickhouse.cloud)',
},
port: {
type: 'number',
required: true,
visibility: 'user-only',
description: 'ClickHouse HTTP interface port (8443 for HTTPS, 8123 for HTTP)',
},
database: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Database name to connect to',
},
username: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse username',
},
password: {
type: 'string',
required: false,
visibility: 'user-only',
description: 'ClickHouse password',
},
secure: {
type: 'boolean',
required: false,
visibility: 'user-only',
description: 'Use a secure HTTPS connection (default: true)',
},
table: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Name of the table to create',
},
columns: {
type: 'json',
required: true,
visibility: 'user-or-llm',
description:
'Array of column definitions, each an object with name and type, e.g. [{"name":"id","type":"UInt64"},{"name":"ts","type":"DateTime"}]',
},
engine: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Table engine (default MergeTree)',
},
orderBy: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'ORDER BY expression, e.g. "id" or "(id, ts)"',
},
partitionBy: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Optional PARTITION BY expression, e.g. toYYYYMM(ts)',
},
},
request: {
url: '/api/tools/clickhouse/create-table',
method: 'POST',
headers: () => ({
'Content-Type': 'application/json',
}),
body: (params) => ({
host: params.host,
port: Number(params.port),
database: params.database,
username: params.username,
password: params.password,
secure: params.secure,
table: params.table,
columns: params.columns,
engine: params.engine,
orderBy: params.orderBy,
partitionBy: params.partitionBy,
}),
},
transformResponse: async (response: Response) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'ClickHouse create table failed')
}
return {
success: true,
output: {
message: data.message || 'Table created',
},
error: undefined,
}
},
outputs: {
message: { type: 'string', description: 'Operation status message' },
},
}
+102
View File
@@ -0,0 +1,102 @@
import type { ClickHouseDeleteParams, ClickHouseDeleteResponse } from '@/tools/clickhouse/types'
import type { ToolConfig } from '@/tools/types'
export const deleteTool: ToolConfig<ClickHouseDeleteParams, ClickHouseDeleteResponse> = {
id: 'clickhouse_delete',
name: 'ClickHouse Delete',
description: 'Delete rows from a ClickHouse table via an ALTER TABLE ... DELETE mutation',
version: '1.0.0',
params: {
host: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse server hostname (e.g., your-instance.clickhouse.cloud)',
},
port: {
type: 'number',
required: true,
visibility: 'user-only',
description: 'ClickHouse HTTP interface port (8443 for HTTPS, 8123 for HTTP)',
},
database: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Database name to connect to',
},
username: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse username',
},
password: {
type: 'string',
required: false,
visibility: 'user-only',
description: 'ClickHouse password',
},
secure: {
type: 'boolean',
required: false,
visibility: 'user-only',
description: 'Use a secure HTTPS connection (default: true)',
},
table: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Table name to delete data from',
},
where: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'WHERE clause condition (without the WHERE keyword)',
},
},
request: {
url: '/api/tools/clickhouse/delete',
method: 'POST',
headers: () => ({
'Content-Type': 'application/json',
}),
body: (params) => ({
host: params.host,
port: Number(params.port),
database: params.database,
username: params.username,
password: params.password,
secure: params.secure,
table: params.table,
where: params.where,
}),
},
transformResponse: async (response: Response) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'ClickHouse delete failed')
}
return {
success: true,
output: {
message: data.message || 'Delete mutation submitted successfully',
rows: data.rows || [],
rowCount: data.rowCount || 0,
},
error: undefined,
}
},
outputs: {
message: { type: 'string', description: 'Operation status message' },
rows: { type: 'array', description: 'Deleted rows (empty for ClickHouse mutations)' },
rowCount: { type: 'number', description: 'Number of rows affected by the mutation' },
},
}
@@ -0,0 +1,99 @@
import type {
ClickHouseDescribeTableParams,
ClickHouseRowsResponse,
} from '@/tools/clickhouse/types'
import type { ToolConfig } from '@/tools/types'
export const describeTableTool: ToolConfig<ClickHouseDescribeTableParams, ClickHouseRowsResponse> =
{
id: 'clickhouse_describe_table',
name: 'ClickHouse Describe Table',
description: 'Describe the columns of a ClickHouse table',
version: '1.0.0',
params: {
host: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse server hostname (e.g., your-instance.clickhouse.cloud)',
},
port: {
type: 'number',
required: true,
visibility: 'user-only',
description: 'ClickHouse HTTP interface port (8443 for HTTPS, 8123 for HTTP)',
},
database: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Database name to connect to',
},
username: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse username',
},
password: {
type: 'string',
required: false,
visibility: 'user-only',
description: 'ClickHouse password',
},
secure: {
type: 'boolean',
required: false,
visibility: 'user-only',
description: 'Use a secure HTTPS connection (default: true)',
},
table: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Table name to describe',
},
},
request: {
url: '/api/tools/clickhouse/describe-table',
method: 'POST',
headers: () => ({
'Content-Type': 'application/json',
}),
body: (params) => ({
host: params.host,
port: Number(params.port),
database: params.database,
username: params.username,
password: params.password,
secure: params.secure,
table: params.table,
}),
},
transformResponse: async (response: Response) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'ClickHouse describe table failed')
}
return {
success: true,
output: {
message: data.message || 'Table described',
rows: data.rows || [],
rowCount: data.rowCount || 0,
},
error: undefined,
}
},
outputs: {
message: { type: 'string', description: 'Operation status message' },
rows: { type: 'array', description: 'Array of rows returned from the query' },
rowCount: { type: 'number', description: 'Number of rows returned' },
},
}
@@ -0,0 +1,95 @@
import type {
ClickHouseDropDatabaseParams,
ClickHouseMessageResponse,
} from '@/tools/clickhouse/types'
import type { ToolConfig } from '@/tools/types'
export const dropDatabaseTool: ToolConfig<ClickHouseDropDatabaseParams, ClickHouseMessageResponse> =
{
id: 'clickhouse_drop_database',
name: 'ClickHouse Drop Database',
description: 'Drop a database from a ClickHouse server',
version: '1.0.0',
params: {
host: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse server hostname (e.g., your-instance.clickhouse.cloud)',
},
port: {
type: 'number',
required: true,
visibility: 'user-only',
description: 'ClickHouse HTTP interface port (8443 for HTTPS, 8123 for HTTP)',
},
database: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Database name to connect to',
},
username: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse username',
},
password: {
type: 'string',
required: false,
visibility: 'user-only',
description: 'ClickHouse password',
},
secure: {
type: 'boolean',
required: false,
visibility: 'user-only',
description: 'Use a secure HTTPS connection (default: true)',
},
name: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Name of the database to drop',
},
},
request: {
url: '/api/tools/clickhouse/drop-database',
method: 'POST',
headers: () => ({
'Content-Type': 'application/json',
}),
body: (params) => ({
host: params.host,
port: Number(params.port),
database: params.database,
username: params.username,
password: params.password,
secure: params.secure,
name: params.name,
}),
},
transformResponse: async (response: Response) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'ClickHouse drop database failed')
}
return {
success: true,
output: {
message: data.message || 'Database dropped',
},
error: undefined,
}
},
outputs: {
message: { type: 'string', description: 'Operation status message' },
},
}
+104
View File
@@ -0,0 +1,104 @@
import type {
ClickHouseDropPartitionParams,
ClickHouseMessageResponse,
} from '@/tools/clickhouse/types'
import type { ToolConfig } from '@/tools/types'
export const dropPartitionTool: ToolConfig<
ClickHouseDropPartitionParams,
ClickHouseMessageResponse
> = {
id: 'clickhouse_drop_partition',
name: 'ClickHouse Drop Partition',
description: 'Drop a partition from a ClickHouse table',
version: '1.0.0',
params: {
host: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse server hostname (e.g., your-instance.clickhouse.cloud)',
},
port: {
type: 'number',
required: true,
visibility: 'user-only',
description: 'ClickHouse HTTP interface port (8443 for HTTPS, 8123 for HTTP)',
},
database: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Database name to connect to',
},
username: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse username',
},
password: {
type: 'string',
required: false,
visibility: 'user-only',
description: 'ClickHouse password',
},
secure: {
type: 'boolean',
required: false,
visibility: 'user-only',
description: 'Use a secure HTTPS connection (default: true)',
},
table: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Table name',
},
partition: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: "Partition expression, e.g. '2024-01' or 202401",
},
},
request: {
url: '/api/tools/clickhouse/drop-partition',
method: 'POST',
headers: () => ({
'Content-Type': 'application/json',
}),
body: (params) => ({
host: params.host,
port: Number(params.port),
database: params.database,
username: params.username,
password: params.password,
secure: params.secure,
table: params.table,
partition: params.partition,
}),
},
transformResponse: async (response: Response) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'ClickHouse drop partition failed')
}
return {
success: true,
output: {
message: data.message || 'Partition dropped',
},
error: undefined,
}
},
outputs: {
message: { type: 'string', description: 'Operation status message' },
},
}
+91
View File
@@ -0,0 +1,91 @@
import type { ClickHouseDropTableParams, ClickHouseMessageResponse } from '@/tools/clickhouse/types'
import type { ToolConfig } from '@/tools/types'
export const dropTableTool: ToolConfig<ClickHouseDropTableParams, ClickHouseMessageResponse> = {
id: 'clickhouse_drop_table',
name: 'ClickHouse Drop Table',
description: 'Drop a table from a ClickHouse database',
version: '1.0.0',
params: {
host: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse server hostname (e.g., your-instance.clickhouse.cloud)',
},
port: {
type: 'number',
required: true,
visibility: 'user-only',
description: 'ClickHouse HTTP interface port (8443 for HTTPS, 8123 for HTTP)',
},
database: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Database name to connect to',
},
username: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse username',
},
password: {
type: 'string',
required: false,
visibility: 'user-only',
description: 'ClickHouse password',
},
secure: {
type: 'boolean',
required: false,
visibility: 'user-only',
description: 'Use a secure HTTPS connection (default: true)',
},
table: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Table name to drop',
},
},
request: {
url: '/api/tools/clickhouse/drop-table',
method: 'POST',
headers: () => ({
'Content-Type': 'application/json',
}),
body: (params) => ({
host: params.host,
port: Number(params.port),
database: params.database,
username: params.username,
password: params.password,
secure: params.secure,
table: params.table,
}),
},
transformResponse: async (response: Response) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'ClickHouse drop table failed')
}
return {
success: true,
output: {
message: data.message || 'Table dropped',
},
error: undefined,
}
},
outputs: {
message: { type: 'string', description: 'Operation status message' },
},
}
+95
View File
@@ -0,0 +1,95 @@
import type { ClickHouseExecuteParams, ClickHouseExecuteResponse } from '@/tools/clickhouse/types'
import type { ToolConfig } from '@/tools/types'
export const executeTool: ToolConfig<ClickHouseExecuteParams, ClickHouseExecuteResponse> = {
id: 'clickhouse_execute',
name: 'ClickHouse Execute',
description: 'Execute raw SQL (DDL, mutations, or queries) on a ClickHouse database',
version: '1.0.0',
params: {
host: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse server hostname (e.g., your-instance.clickhouse.cloud)',
},
port: {
type: 'number',
required: true,
visibility: 'user-only',
description: 'ClickHouse HTTP interface port (8443 for HTTPS, 8123 for HTTP)',
},
database: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Database name to connect to',
},
username: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse username',
},
password: {
type: 'string',
required: false,
visibility: 'user-only',
description: 'ClickHouse password',
},
secure: {
type: 'boolean',
required: false,
visibility: 'user-only',
description: 'Use a secure HTTPS connection (default: true)',
},
query: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Raw SQL statement to execute',
},
},
request: {
url: '/api/tools/clickhouse/execute',
method: 'POST',
headers: () => ({
'Content-Type': 'application/json',
}),
body: (params) => ({
host: params.host,
port: Number(params.port),
database: params.database,
username: params.username,
password: params.password,
secure: params.secure,
query: params.query,
}),
},
transformResponse: async (response: Response) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'ClickHouse execute failed')
}
return {
success: true,
output: {
message: data.message || 'Statement executed successfully',
rows: data.rows || [],
rowCount: data.rowCount || 0,
},
error: undefined,
}
},
outputs: {
message: { type: 'string', description: 'Operation status message' },
rows: { type: 'array', description: 'Array of rows returned from the statement' },
rowCount: { type: 'number', description: 'Number of rows returned or affected' },
},
}
+53
View File
@@ -0,0 +1,53 @@
import { countRowsTool } from './count-rows'
import { createDatabaseTool } from './create-database'
import { createTableTool } from './create-table'
import { deleteTool } from './delete'
import { describeTableTool } from './describe-table'
import { dropDatabaseTool } from './drop-database'
import { dropPartitionTool } from './drop-partition'
import { dropTableTool } from './drop-table'
import { executeTool } from './execute'
import { insertTool } from './insert'
import { insertRowsTool } from './insert-rows'
import { introspectTool } from './introspect'
import { killQueryTool } from './kill-query'
import { listClustersTool } from './list-clusters'
import { listDatabasesTool } from './list-databases'
import { listMutationsTool } from './list-mutations'
import { listPartitionsTool } from './list-partitions'
import { listRunningQueriesTool } from './list-running-queries'
import { listTablesTool } from './list-tables'
import { optimizeTableTool } from './optimize-table'
import { queryTool } from './query'
import { renameTableTool } from './rename-table'
import { showCreateTableTool } from './show-create-table'
import { tableStatsTool } from './table-stats'
import { truncateTableTool } from './truncate-table'
import { updateTool } from './update'
export const clickhouseQueryTool = queryTool
export const clickhouseExecuteTool = executeTool
export const clickhouseInsertTool = insertTool
export const clickhouseInsertRowsTool = insertRowsTool
export const clickhouseUpdateTool = updateTool
export const clickhouseDeleteTool = deleteTool
export const clickhouseIntrospectTool = introspectTool
export const clickhouseListDatabasesTool = listDatabasesTool
export const clickhouseListTablesTool = listTablesTool
export const clickhouseDescribeTableTool = describeTableTool
export const clickhouseShowCreateTableTool = showCreateTableTool
export const clickhouseCountRowsTool = countRowsTool
export const clickhouseListPartitionsTool = listPartitionsTool
export const clickhouseListMutationsTool = listMutationsTool
export const clickhouseListRunningQueriesTool = listRunningQueriesTool
export const clickhouseTableStatsTool = tableStatsTool
export const clickhouseListClustersTool = listClustersTool
export const clickhouseCreateDatabaseTool = createDatabaseTool
export const clickhouseDropDatabaseTool = dropDatabaseTool
export const clickhouseCreateTableTool = createTableTool
export const clickhouseDropTableTool = dropTableTool
export const clickhouseTruncateTableTool = truncateTableTool
export const clickhouseRenameTableTool = renameTableTool
export const clickhouseOptimizeTableTool = optimizeTableTool
export const clickhouseDropPartitionTool = dropPartitionTool
export const clickhouseKillQueryTool = killQueryTool
+102
View File
@@ -0,0 +1,102 @@
import type { ClickHouseInsertRowsParams, ClickHouseRowsResponse } from '@/tools/clickhouse/types'
import type { ToolConfig } from '@/tools/types'
export const insertRowsTool: ToolConfig<ClickHouseInsertRowsParams, ClickHouseRowsResponse> = {
id: 'clickhouse_insert_rows',
name: 'ClickHouse Insert Rows',
description: 'Insert multiple rows into a ClickHouse table',
version: '1.0.0',
params: {
host: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse server hostname (e.g., your-instance.clickhouse.cloud)',
},
port: {
type: 'number',
required: true,
visibility: 'user-only',
description: 'ClickHouse HTTP interface port (8443 for HTTPS, 8123 for HTTP)',
},
database: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Database name to connect to',
},
username: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse username',
},
password: {
type: 'string',
required: false,
visibility: 'user-only',
description: 'ClickHouse password',
},
secure: {
type: 'boolean',
required: false,
visibility: 'user-only',
description: 'Use a secure HTTPS connection (default: true)',
},
table: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Table to insert into',
},
rows: {
type: 'json',
required: true,
visibility: 'user-or-llm',
description: 'Array of row objects to insert, e.g. [{"id":1,"name":"a"},{"id":2,"name":"b"}]',
},
},
request: {
url: '/api/tools/clickhouse/insert-rows',
method: 'POST',
headers: () => ({
'Content-Type': 'application/json',
}),
body: (params) => ({
host: params.host,
port: Number(params.port),
database: params.database,
username: params.username,
password: params.password,
secure: params.secure,
table: params.table,
rows: params.rows,
}),
},
transformResponse: async (response: Response) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'ClickHouse insert rows failed')
}
return {
success: true,
output: {
message: data.message || 'Rows inserted',
rows: data.rows || [],
rowCount: data.rowCount || 0,
},
error: undefined,
}
},
outputs: {
message: { type: 'string', description: 'Operation status message' },
rows: { type: 'array', description: 'Inserted rows (empty for ClickHouse inserts)' },
rowCount: { type: 'number', description: 'Number of rows inserted' },
},
}
+102
View File
@@ -0,0 +1,102 @@
import type { ClickHouseInsertParams, ClickHouseInsertResponse } from '@/tools/clickhouse/types'
import type { ToolConfig } from '@/tools/types'
export const insertTool: ToolConfig<ClickHouseInsertParams, ClickHouseInsertResponse> = {
id: 'clickhouse_insert',
name: 'ClickHouse Insert',
description: 'Insert a row into a ClickHouse table',
version: '1.0.0',
params: {
host: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse server hostname (e.g., your-instance.clickhouse.cloud)',
},
port: {
type: 'number',
required: true,
visibility: 'user-only',
description: 'ClickHouse HTTP interface port (8443 for HTTPS, 8123 for HTTP)',
},
database: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Database name to connect to',
},
username: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse username',
},
password: {
type: 'string',
required: false,
visibility: 'user-only',
description: 'ClickHouse password',
},
secure: {
type: 'boolean',
required: false,
visibility: 'user-only',
description: 'Use a secure HTTPS connection (default: true)',
},
table: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Table name to insert data into',
},
data: {
type: 'object',
required: true,
visibility: 'user-or-llm',
description: 'Data object to insert (key-value pairs mapping column names to values)',
},
},
request: {
url: '/api/tools/clickhouse/insert',
method: 'POST',
headers: () => ({
'Content-Type': 'application/json',
}),
body: (params) => ({
host: params.host,
port: Number(params.port),
database: params.database,
username: params.username,
password: params.password,
secure: params.secure,
table: params.table,
data: params.data,
}),
},
transformResponse: async (response: Response) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'ClickHouse insert failed')
}
return {
success: true,
output: {
message: data.message || 'Data inserted successfully',
rows: data.rows || [],
rowCount: data.rowCount || 0,
},
error: undefined,
}
},
outputs: {
message: { type: 'string', description: 'Operation status message' },
rows: { type: 'array', description: 'Inserted rows (empty for ClickHouse inserts)' },
rowCount: { type: 'number', description: 'Number of rows inserted' },
},
}
+99
View File
@@ -0,0 +1,99 @@
import {
CLICKHOUSE_TABLE_OUTPUT_PROPERTIES,
type ClickHouseIntrospectParams,
type ClickHouseIntrospectResponse,
} from '@/tools/clickhouse/types'
import type { ToolConfig } from '@/tools/types'
export const introspectTool: ToolConfig<ClickHouseIntrospectParams, ClickHouseIntrospectResponse> =
{
id: 'clickhouse_introspect',
name: 'ClickHouse Introspect',
description:
'Introspect a ClickHouse database to retrieve table structures, columns, and engines',
version: '1.0.0',
params: {
host: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse server hostname (e.g., your-instance.clickhouse.cloud)',
},
port: {
type: 'number',
required: true,
visibility: 'user-only',
description: 'ClickHouse HTTP interface port (8443 for HTTPS, 8123 for HTTP)',
},
database: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Database name to introspect',
},
username: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse username',
},
password: {
type: 'string',
required: false,
visibility: 'user-only',
description: 'ClickHouse password',
},
secure: {
type: 'boolean',
required: false,
visibility: 'user-only',
description: 'Use a secure HTTPS connection (default: true)',
},
},
request: {
url: '/api/tools/clickhouse/introspect',
method: 'POST',
headers: () => ({
'Content-Type': 'application/json',
}),
body: (params) => ({
host: params.host,
port: Number(params.port),
database: params.database,
username: params.username,
password: params.password,
secure: params.secure,
}),
},
transformResponse: async (response: Response) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'ClickHouse introspection failed')
}
return {
success: true,
output: {
message: data.message || 'Schema introspection completed successfully',
tables: data.tables || [],
},
error: undefined,
}
},
outputs: {
message: { type: 'string', description: 'Operation status message' },
tables: {
type: 'array',
description: 'Array of table schemas with columns and engines',
items: {
type: 'object',
properties: CLICKHOUSE_TABLE_OUTPUT_PROPERTIES,
},
},
},
}
+95
View File
@@ -0,0 +1,95 @@
import type { ClickHouseKillQueryParams, ClickHouseRowsResponse } from '@/tools/clickhouse/types'
import type { ToolConfig } from '@/tools/types'
export const killQueryTool: ToolConfig<ClickHouseKillQueryParams, ClickHouseRowsResponse> = {
id: 'clickhouse_kill_query',
name: 'ClickHouse Kill Query',
description: 'Kill a running query by its query ID',
version: '1.0.0',
params: {
host: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse server hostname (e.g., your-instance.clickhouse.cloud)',
},
port: {
type: 'number',
required: true,
visibility: 'user-only',
description: 'ClickHouse HTTP interface port (8443 for HTTPS, 8123 for HTTP)',
},
database: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Database name to connect to',
},
username: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse username',
},
password: {
type: 'string',
required: false,
visibility: 'user-only',
description: 'ClickHouse password',
},
secure: {
type: 'boolean',
required: false,
visibility: 'user-only',
description: 'Use a secure HTTPS connection (default: true)',
},
queryId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The query_id of the running query to kill',
},
},
request: {
url: '/api/tools/clickhouse/kill-query',
method: 'POST',
headers: () => ({
'Content-Type': 'application/json',
}),
body: (params) => ({
host: params.host,
port: Number(params.port),
database: params.database,
username: params.username,
password: params.password,
secure: params.secure,
queryId: params.queryId,
}),
},
transformResponse: async (response: Response) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'ClickHouse kill query failed')
}
return {
success: true,
output: {
message: data.message || 'Kill command executed',
rows: data.rows || [],
rowCount: data.rowCount || 0,
},
error: undefined,
}
},
outputs: {
message: { type: 'string', description: 'Operation status message' },
rows: { type: 'array', description: 'Kill status rows' },
rowCount: { type: 'number', description: 'Number of rows returned' },
},
}
@@ -0,0 +1,88 @@
import type { ClickHouseListClustersParams, ClickHouseRowsResponse } from '@/tools/clickhouse/types'
import type { ToolConfig } from '@/tools/types'
export const listClustersTool: ToolConfig<ClickHouseListClustersParams, ClickHouseRowsResponse> = {
id: 'clickhouse_list_clusters',
name: 'ClickHouse List Clusters',
description: 'List configured clusters, shards, and replicas',
version: '1.0.0',
params: {
host: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse server hostname (e.g., your-instance.clickhouse.cloud)',
},
port: {
type: 'number',
required: true,
visibility: 'user-only',
description: 'ClickHouse HTTP interface port (8443 for HTTPS, 8123 for HTTP)',
},
database: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Database name to connect to',
},
username: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse username',
},
password: {
type: 'string',
required: false,
visibility: 'user-only',
description: 'ClickHouse password',
},
secure: {
type: 'boolean',
required: false,
visibility: 'user-only',
description: 'Use a secure HTTPS connection (default: true)',
},
},
request: {
url: '/api/tools/clickhouse/list-clusters',
method: 'POST',
headers: () => ({
'Content-Type': 'application/json',
}),
body: (params) => ({
host: params.host,
port: Number(params.port),
database: params.database,
username: params.username,
password: params.password,
secure: params.secure,
}),
},
transformResponse: async (response: Response) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'ClickHouse list clusters failed')
}
return {
success: true,
output: {
message: data.message || 'Clusters retrieved',
rows: data.rows || [],
rowCount: data.rowCount || 0,
},
error: undefined,
}
},
outputs: {
message: { type: 'string', description: 'Operation status message' },
rows: { type: 'array', description: 'Array of cluster node rows' },
rowCount: { type: 'number', description: 'Number of rows returned' },
},
}
@@ -0,0 +1,92 @@
import type {
ClickHouseListDatabasesParams,
ClickHouseRowsResponse,
} from '@/tools/clickhouse/types'
import type { ToolConfig } from '@/tools/types'
export const listDatabasesTool: ToolConfig<ClickHouseListDatabasesParams, ClickHouseRowsResponse> =
{
id: 'clickhouse_list_databases',
name: 'ClickHouse List Databases',
description: 'List all databases on a ClickHouse server',
version: '1.0.0',
params: {
host: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse server hostname (e.g., your-instance.clickhouse.cloud)',
},
port: {
type: 'number',
required: true,
visibility: 'user-only',
description: 'ClickHouse HTTP interface port (8443 for HTTPS, 8123 for HTTP)',
},
database: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Database name to connect to',
},
username: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse username',
},
password: {
type: 'string',
required: false,
visibility: 'user-only',
description: 'ClickHouse password',
},
secure: {
type: 'boolean',
required: false,
visibility: 'user-only',
description: 'Use a secure HTTPS connection (default: true)',
},
},
request: {
url: '/api/tools/clickhouse/list-databases',
method: 'POST',
headers: () => ({
'Content-Type': 'application/json',
}),
body: (params) => ({
host: params.host,
port: Number(params.port),
database: params.database,
username: params.username,
password: params.password,
secure: params.secure,
}),
},
transformResponse: async (response: Response) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'ClickHouse list databases failed')
}
return {
success: true,
output: {
message: data.message || 'Databases retrieved',
rows: data.rows || [],
rowCount: data.rowCount || 0,
},
error: undefined,
}
},
outputs: {
message: { type: 'string', description: 'Operation status message' },
rows: { type: 'array', description: 'List of databases with engine and comment' },
rowCount: { type: 'number', description: 'Number of rows returned' },
},
}
+106
View File
@@ -0,0 +1,106 @@
import type {
ClickHouseListMutationsParams,
ClickHouseRowsResponse,
} from '@/tools/clickhouse/types'
import type { ToolConfig } from '@/tools/types'
export const listMutationsTool: ToolConfig<ClickHouseListMutationsParams, ClickHouseRowsResponse> =
{
id: 'clickhouse_list_mutations',
name: 'ClickHouse List Mutations',
description: 'List mutations (async ALTER UPDATE/DELETE) for the connected database',
version: '1.0.0',
params: {
host: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse server hostname (e.g., your-instance.clickhouse.cloud)',
},
port: {
type: 'number',
required: true,
visibility: 'user-only',
description: 'ClickHouse HTTP interface port (8443 for HTTPS, 8123 for HTTP)',
},
database: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Database name to connect to',
},
username: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse username',
},
password: {
type: 'string',
required: false,
visibility: 'user-only',
description: 'ClickHouse password',
},
secure: {
type: 'boolean',
required: false,
visibility: 'user-only',
description: 'Use a secure HTTPS connection (default: true)',
},
table: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Optional table name to filter mutations',
},
onlyRunning: {
type: 'boolean',
required: false,
visibility: 'user-or-llm',
description: 'Only show mutations that are still running',
},
},
request: {
url: '/api/tools/clickhouse/list-mutations',
method: 'POST',
headers: () => ({
'Content-Type': 'application/json',
}),
body: (params) => ({
host: params.host,
port: Number(params.port),
database: params.database,
username: params.username,
password: params.password,
secure: params.secure,
table: params.table,
onlyRunning: params.onlyRunning,
}),
},
transformResponse: async (response: Response) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'ClickHouse list mutations failed')
}
return {
success: true,
output: {
message: data.message || 'Mutations retrieved',
rows: data.rows || [],
rowCount: data.rowCount || 0,
},
error: undefined,
}
},
outputs: {
message: { type: 'string', description: 'Operation status message' },
rows: { type: 'array', description: 'Array of mutation rows' },
rowCount: { type: 'number', description: 'Number of rows returned' },
},
}
@@ -0,0 +1,101 @@
import type {
ClickHouseListPartitionsParams,
ClickHouseRowsResponse,
} from '@/tools/clickhouse/types'
import type { ToolConfig } from '@/tools/types'
export const listPartitionsTool: ToolConfig<
ClickHouseListPartitionsParams,
ClickHouseRowsResponse
> = {
id: 'clickhouse_list_partitions',
name: 'ClickHouse List Partitions',
description: 'List active partitions for a ClickHouse table',
version: '1.0.0',
params: {
host: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse server hostname (e.g., your-instance.clickhouse.cloud)',
},
port: {
type: 'number',
required: true,
visibility: 'user-only',
description: 'ClickHouse HTTP interface port (8443 for HTTPS, 8123 for HTTP)',
},
database: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Database name to connect to',
},
username: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse username',
},
password: {
type: 'string',
required: false,
visibility: 'user-only',
description: 'ClickHouse password',
},
secure: {
type: 'boolean',
required: false,
visibility: 'user-only',
description: 'Use a secure HTTPS connection (default: true)',
},
table: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Table name to inspect partitions for',
},
},
request: {
url: '/api/tools/clickhouse/list-partitions',
method: 'POST',
headers: () => ({
'Content-Type': 'application/json',
}),
body: (params) => ({
host: params.host,
port: Number(params.port),
database: params.database,
username: params.username,
password: params.password,
secure: params.secure,
table: params.table,
}),
},
transformResponse: async (response: Response) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'ClickHouse list partitions failed')
}
return {
success: true,
output: {
message: data.message || 'Partitions retrieved',
rows: data.rows || [],
rowCount: data.rowCount || 0,
},
error: undefined,
}
},
outputs: {
message: { type: 'string', description: 'Operation status message' },
rows: { type: 'array', description: 'Array of rows returned from the query' },
rowCount: { type: 'number', description: 'Number of rows returned' },
},
}
@@ -0,0 +1,94 @@
import type {
ClickHouseListRunningQueriesParams,
ClickHouseRowsResponse,
} from '@/tools/clickhouse/types'
import type { ToolConfig } from '@/tools/types'
export const listRunningQueriesTool: ToolConfig<
ClickHouseListRunningQueriesParams,
ClickHouseRowsResponse
> = {
id: 'clickhouse_list_running_queries',
name: 'ClickHouse List Running Queries',
description: 'List currently running queries on a ClickHouse server',
version: '1.0.0',
params: {
host: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse server hostname (e.g., your-instance.clickhouse.cloud)',
},
port: {
type: 'number',
required: true,
visibility: 'user-only',
description: 'ClickHouse HTTP interface port (8443 for HTTPS, 8123 for HTTP)',
},
database: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Database name to connect to',
},
username: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse username',
},
password: {
type: 'string',
required: false,
visibility: 'user-only',
description: 'ClickHouse password',
},
secure: {
type: 'boolean',
required: false,
visibility: 'user-only',
description: 'Use a secure HTTPS connection (default: true)',
},
},
request: {
url: '/api/tools/clickhouse/list-running-queries',
method: 'POST',
headers: () => ({
'Content-Type': 'application/json',
}),
body: (params) => ({
host: params.host,
port: Number(params.port),
database: params.database,
username: params.username,
password: params.password,
secure: params.secure,
}),
},
transformResponse: async (response: Response) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'ClickHouse list running queries failed')
}
return {
success: true,
output: {
message: data.message || 'Running queries retrieved',
rows: data.rows || [],
rowCount: data.rowCount || 0,
},
error: undefined,
}
},
outputs: {
message: { type: 'string', description: 'Operation status message' },
rows: { type: 'array', description: 'Array of rows returned from the query' },
rowCount: { type: 'number', description: 'Number of rows returned' },
},
}
+88
View File
@@ -0,0 +1,88 @@
import type { ClickHouseListTablesParams, ClickHouseRowsResponse } from '@/tools/clickhouse/types'
import type { ToolConfig } from '@/tools/types'
export const listTablesTool: ToolConfig<ClickHouseListTablesParams, ClickHouseRowsResponse> = {
id: 'clickhouse_list_tables',
name: 'ClickHouse List Tables',
description: 'List tables in the connected ClickHouse database',
version: '1.0.0',
params: {
host: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse server hostname (e.g., your-instance.clickhouse.cloud)',
},
port: {
type: 'number',
required: true,
visibility: 'user-only',
description: 'ClickHouse HTTP interface port (8443 for HTTPS, 8123 for HTTP)',
},
database: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Database name to connect to',
},
username: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse username',
},
password: {
type: 'string',
required: false,
visibility: 'user-only',
description: 'ClickHouse password',
},
secure: {
type: 'boolean',
required: false,
visibility: 'user-only',
description: 'Use a secure HTTPS connection (default: true)',
},
},
request: {
url: '/api/tools/clickhouse/list-tables',
method: 'POST',
headers: () => ({
'Content-Type': 'application/json',
}),
body: (params) => ({
host: params.host,
port: Number(params.port),
database: params.database,
username: params.username,
password: params.password,
secure: params.secure,
}),
},
transformResponse: async (response: Response) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'ClickHouse list tables failed')
}
return {
success: true,
output: {
message: data.message || 'Tables retrieved',
rows: data.rows || [],
rowCount: data.rowCount || 0,
},
error: undefined,
}
},
outputs: {
message: { type: 'string', description: 'Operation status message' },
rows: { type: 'array', description: 'Array of rows returned from the query' },
rowCount: { type: 'number', description: 'Number of rows returned' },
},
}
+104
View File
@@ -0,0 +1,104 @@
import type {
ClickHouseMessageResponse,
ClickHouseOptimizeTableParams,
} from '@/tools/clickhouse/types'
import type { ToolConfig } from '@/tools/types'
export const optimizeTableTool: ToolConfig<
ClickHouseOptimizeTableParams,
ClickHouseMessageResponse
> = {
id: 'clickhouse_optimize_table',
name: 'ClickHouse Optimize Table',
description: 'Trigger a merge of table parts via OPTIMIZE TABLE',
version: '1.0.0',
params: {
host: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse server hostname (e.g., your-instance.clickhouse.cloud)',
},
port: {
type: 'number',
required: true,
visibility: 'user-only',
description: 'ClickHouse HTTP interface port (8443 for HTTPS, 8123 for HTTP)',
},
database: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Database name to connect to',
},
username: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse username',
},
password: {
type: 'string',
required: false,
visibility: 'user-only',
description: 'ClickHouse password',
},
secure: {
type: 'boolean',
required: false,
visibility: 'user-only',
description: 'Use a secure HTTPS connection (default: true)',
},
table: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Table to optimize',
},
final: {
type: 'boolean',
required: false,
visibility: 'user-or-llm',
description: 'Force a merge to a single part using FINAL',
},
},
request: {
url: '/api/tools/clickhouse/optimize-table',
method: 'POST',
headers: () => ({
'Content-Type': 'application/json',
}),
body: (params) => ({
host: params.host,
port: Number(params.port),
database: params.database,
username: params.username,
password: params.password,
secure: params.secure,
table: params.table,
final: params.final,
}),
},
transformResponse: async (response: Response) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'ClickHouse optimize table failed')
}
return {
success: true,
output: {
message: data.message || 'Optimize submitted',
},
error: undefined,
}
},
outputs: {
message: { type: 'string', description: 'Operation status message' },
},
}
+95
View File
@@ -0,0 +1,95 @@
import type { ClickHouseQueryParams, ClickHouseQueryResponse } from '@/tools/clickhouse/types'
import type { ToolConfig } from '@/tools/types'
export const queryTool: ToolConfig<ClickHouseQueryParams, ClickHouseQueryResponse> = {
id: 'clickhouse_query',
name: 'ClickHouse Query',
description: 'Execute a SELECT query on a ClickHouse database',
version: '1.0.0',
params: {
host: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse server hostname (e.g., your-instance.clickhouse.cloud)',
},
port: {
type: 'number',
required: true,
visibility: 'user-only',
description: 'ClickHouse HTTP interface port (8443 for HTTPS, 8123 for HTTP)',
},
database: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Database name to connect to',
},
username: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse username',
},
password: {
type: 'string',
required: false,
visibility: 'user-only',
description: 'ClickHouse password',
},
secure: {
type: 'boolean',
required: false,
visibility: 'user-only',
description: 'Use a secure HTTPS connection (default: true)',
},
query: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'SQL SELECT query to execute',
},
},
request: {
url: '/api/tools/clickhouse/query',
method: 'POST',
headers: () => ({
'Content-Type': 'application/json',
}),
body: (params) => ({
host: params.host,
port: Number(params.port),
database: params.database,
username: params.username,
password: params.password,
secure: params.secure,
query: params.query,
}),
},
transformResponse: async (response: Response) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'ClickHouse query failed')
}
return {
success: true,
output: {
message: data.message || 'Query executed successfully',
rows: data.rows || [],
rowCount: data.rowCount || 0,
},
error: undefined,
}
},
outputs: {
message: { type: 'string', description: 'Operation status message' },
rows: { type: 'array', description: 'Array of rows returned from the query' },
rowCount: { type: 'number', description: 'Number of rows returned' },
},
}
+101
View File
@@ -0,0 +1,101 @@
import type {
ClickHouseMessageResponse,
ClickHouseRenameTableParams,
} from '@/tools/clickhouse/types'
import type { ToolConfig } from '@/tools/types'
export const renameTableTool: ToolConfig<ClickHouseRenameTableParams, ClickHouseMessageResponse> = {
id: 'clickhouse_rename_table',
name: 'ClickHouse Rename Table',
description: 'Rename a ClickHouse table',
version: '1.0.0',
params: {
host: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse server hostname (e.g., your-instance.clickhouse.cloud)',
},
port: {
type: 'number',
required: true,
visibility: 'user-only',
description: 'ClickHouse HTTP interface port (8443 for HTTPS, 8123 for HTTP)',
},
database: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Database name to connect to',
},
username: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse username',
},
password: {
type: 'string',
required: false,
visibility: 'user-only',
description: 'ClickHouse password',
},
secure: {
type: 'boolean',
required: false,
visibility: 'user-only',
description: 'Use a secure HTTPS connection (default: true)',
},
table: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Current table name',
},
newTable: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'New table name',
},
},
request: {
url: '/api/tools/clickhouse/rename-table',
method: 'POST',
headers: () => ({
'Content-Type': 'application/json',
}),
body: (params) => ({
host: params.host,
port: Number(params.port),
database: params.database,
username: params.username,
password: params.password,
secure: params.secure,
table: params.table,
newTable: params.newTable,
}),
},
transformResponse: async (response: Response) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'ClickHouse rename table failed')
}
return {
success: true,
output: {
message: data.message || 'Table renamed',
},
error: undefined,
}
},
outputs: {
message: { type: 'string', description: 'Operation status message' },
},
}
@@ -0,0 +1,99 @@
import type {
ClickHouseDdlResponse,
ClickHouseShowCreateTableParams,
} from '@/tools/clickhouse/types'
import type { ToolConfig } from '@/tools/types'
export const showCreateTableTool: ToolConfig<
ClickHouseShowCreateTableParams,
ClickHouseDdlResponse
> = {
id: 'clickhouse_show_create_table',
name: 'ClickHouse Show Create Table',
description: 'Get the CREATE TABLE statement (DDL) for a ClickHouse table',
version: '1.0.0',
params: {
host: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse server hostname (e.g., your-instance.clickhouse.cloud)',
},
port: {
type: 'number',
required: true,
visibility: 'user-only',
description: 'ClickHouse HTTP interface port (8443 for HTTPS, 8123 for HTTP)',
},
database: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Database name to connect to',
},
username: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse username',
},
password: {
type: 'string',
required: false,
visibility: 'user-only',
description: 'ClickHouse password',
},
secure: {
type: 'boolean',
required: false,
visibility: 'user-only',
description: 'Use a secure HTTPS connection (default: true)',
},
table: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Table name to get the CREATE statement for',
},
},
request: {
url: '/api/tools/clickhouse/show-create-table',
method: 'POST',
headers: () => ({
'Content-Type': 'application/json',
}),
body: (params) => ({
host: params.host,
port: Number(params.port),
database: params.database,
username: params.username,
password: params.password,
secure: params.secure,
table: params.table,
}),
},
transformResponse: async (response: Response) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'ClickHouse show create table failed')
}
return {
success: true,
output: {
message: data.message || 'CREATE statement retrieved',
ddl: data.ddl ?? '',
},
error: undefined,
}
},
outputs: {
message: { type: 'string', description: 'Operation status message' },
ddl: { type: 'string', description: 'The CREATE TABLE statement' },
},
}
+95
View File
@@ -0,0 +1,95 @@
import type { ClickHouseRowsResponse, ClickHouseTableStatsParams } from '@/tools/clickhouse/types'
import type { ToolConfig } from '@/tools/types'
export const tableStatsTool: ToolConfig<ClickHouseTableStatsParams, ClickHouseRowsResponse> = {
id: 'clickhouse_table_stats',
name: 'ClickHouse Table Stats',
description: 'Get row counts and on-disk size for tables in the connected database',
version: '1.0.0',
params: {
host: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse server hostname (e.g., your-instance.clickhouse.cloud)',
},
port: {
type: 'number',
required: true,
visibility: 'user-only',
description: 'ClickHouse HTTP interface port (8443 for HTTPS, 8123 for HTTP)',
},
database: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Database name to connect to',
},
username: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse username',
},
password: {
type: 'string',
required: false,
visibility: 'user-only',
description: 'ClickHouse password',
},
secure: {
type: 'boolean',
required: false,
visibility: 'user-only',
description: 'Use a secure HTTPS connection (default: true)',
},
table: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Optional table name to get stats for',
},
},
request: {
url: '/api/tools/clickhouse/table-stats',
method: 'POST',
headers: () => ({
'Content-Type': 'application/json',
}),
body: (params) => ({
host: params.host,
port: Number(params.port),
database: params.database,
username: params.username,
password: params.password,
secure: params.secure,
table: params.table,
}),
},
transformResponse: async (response: Response) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'ClickHouse table stats failed')
}
return {
success: true,
output: {
message: data.message || 'Table stats retrieved',
rows: data.rows || [],
rowCount: data.rowCount || 0,
},
error: undefined,
}
},
outputs: {
message: { type: 'string', description: 'Operation status message' },
rows: { type: 'array', description: 'Array of table stats rows' },
rowCount: { type: 'number', description: 'Number of rows returned' },
},
}
@@ -0,0 +1,97 @@
import type {
ClickHouseMessageResponse,
ClickHouseTruncateTableParams,
} from '@/tools/clickhouse/types'
import type { ToolConfig } from '@/tools/types'
export const truncateTableTool: ToolConfig<
ClickHouseTruncateTableParams,
ClickHouseMessageResponse
> = {
id: 'clickhouse_truncate_table',
name: 'ClickHouse Truncate Table',
description: 'Remove all rows from a ClickHouse table',
version: '1.0.0',
params: {
host: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse server hostname (e.g., your-instance.clickhouse.cloud)',
},
port: {
type: 'number',
required: true,
visibility: 'user-only',
description: 'ClickHouse HTTP interface port (8443 for HTTPS, 8123 for HTTP)',
},
database: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Database name to connect to',
},
username: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse username',
},
password: {
type: 'string',
required: false,
visibility: 'user-only',
description: 'ClickHouse password',
},
secure: {
type: 'boolean',
required: false,
visibility: 'user-only',
description: 'Use a secure HTTPS connection (default: true)',
},
table: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Table name to truncate',
},
},
request: {
url: '/api/tools/clickhouse/truncate-table',
method: 'POST',
headers: () => ({
'Content-Type': 'application/json',
}),
body: (params) => ({
host: params.host,
port: Number(params.port),
database: params.database,
username: params.username,
password: params.password,
secure: params.secure,
table: params.table,
}),
},
transformResponse: async (response: Response) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'ClickHouse truncate table failed')
}
return {
success: true,
output: {
message: data.message || 'Table truncated',
},
error: undefined,
}
},
outputs: {
message: { type: 'string', description: 'Operation status message' },
},
}
+213
View File
@@ -0,0 +1,213 @@
import type { OutputProperty, ToolResponse } from '@/tools/types'
/**
* Output property definitions for ClickHouse introspection and query responses.
* @see https://clickhouse.com/docs/sql-reference/statements/system
*/
/**
* Output definition for table column objects from introspection.
* @see https://clickhouse.com/docs/operations/system-tables/columns
*/
export const CLICKHOUSE_COLUMN_OUTPUT_PROPERTIES = {
name: { type: 'string', description: 'Column name' },
type: { type: 'string', description: 'ClickHouse data type (e.g., UInt32, String, DateTime)' },
defaultKind: {
type: 'string',
description: 'Kind of default expression (DEFAULT, MATERIALIZED, ALIAS)',
optional: true,
},
defaultExpression: {
type: 'string',
description: 'Default value expression for the column',
optional: true,
},
isInPrimaryKey: { type: 'boolean', description: 'Whether the column is part of the primary key' },
isInSortingKey: { type: 'boolean', description: 'Whether the column is part of the sorting key' },
} as const satisfies Record<string, OutputProperty>
/**
* Output definition for table schema objects from introspection.
* @see https://clickhouse.com/docs/operations/system-tables/tables
*/
export const CLICKHOUSE_TABLE_OUTPUT_PROPERTIES = {
name: { type: 'string', description: 'Table name' },
database: { type: 'string', description: 'Database the table belongs to' },
engine: { type: 'string', description: 'Table engine (e.g., MergeTree, Log)' },
totalRows: {
type: 'number',
description: 'Approximate total number of rows in the table',
optional: true,
},
columns: {
type: 'array',
description: 'Table columns',
items: {
type: 'object',
properties: CLICKHOUSE_COLUMN_OUTPUT_PROPERTIES,
},
},
} as const satisfies Record<string, OutputProperty>
export interface ClickHouseConnectionConfig {
host: string
port: number
database: string
username: string
password: string
secure: boolean
}
export interface ClickHouseQueryParams extends ClickHouseConnectionConfig {
query: string
}
export interface ClickHouseExecuteParams extends ClickHouseConnectionConfig {
query: string
}
export interface ClickHouseInsertParams extends ClickHouseConnectionConfig {
table: string
data: Record<string, unknown>
}
export interface ClickHouseUpdateParams extends ClickHouseConnectionConfig {
table: string
data: Record<string, unknown>
where: string
}
export interface ClickHouseDeleteParams extends ClickHouseConnectionConfig {
table: string
where: string
}
export interface ClickHouseIntrospectParams extends ClickHouseConnectionConfig {}
export interface ClickHouseRowsResponse extends ToolResponse {
output: {
message: string
rows: unknown[]
rowCount: number
}
error?: string
}
export interface ClickHouseMessageResponse extends ToolResponse {
output: {
message: string
}
error?: string
}
export interface ClickHouseCountResponse extends ToolResponse {
output: {
message: string
count: number
}
error?: string
}
export interface ClickHouseDdlResponse extends ToolResponse {
output: {
message: string
ddl: string
}
error?: string
}
export interface ClickHouseListDatabasesParams extends ClickHouseConnectionConfig {}
export interface ClickHouseListTablesParams extends ClickHouseConnectionConfig {}
export interface ClickHouseDescribeTableParams extends ClickHouseConnectionConfig {
table: string
}
export interface ClickHouseShowCreateTableParams extends ClickHouseConnectionConfig {
table: string
}
export interface ClickHouseCountRowsParams extends ClickHouseConnectionConfig {
table: string
where?: string
}
export interface ClickHouseListPartitionsParams extends ClickHouseConnectionConfig {
table: string
}
export interface ClickHouseListMutationsParams extends ClickHouseConnectionConfig {
table?: string
onlyRunning?: boolean
}
export interface ClickHouseListRunningQueriesParams extends ClickHouseConnectionConfig {}
export interface ClickHouseTableStatsParams extends ClickHouseConnectionConfig {
table?: string
}
export interface ClickHouseListClustersParams extends ClickHouseConnectionConfig {}
export interface ClickHouseCreateDatabaseParams extends ClickHouseConnectionConfig {
name: string
}
export interface ClickHouseDropDatabaseParams extends ClickHouseConnectionConfig {
name: string
}
export interface ClickHouseCreateTableParams extends ClickHouseConnectionConfig {
table: string
columns: Array<{ name: string; type: string }>
engine: string
orderBy: string
partitionBy?: string
}
export interface ClickHouseDropTableParams extends ClickHouseConnectionConfig {
table: string
}
export interface ClickHouseTruncateTableParams extends ClickHouseConnectionConfig {
table: string
}
export interface ClickHouseRenameTableParams extends ClickHouseConnectionConfig {
table: string
newTable: string
}
export interface ClickHouseOptimizeTableParams extends ClickHouseConnectionConfig {
table: string
final?: boolean
}
export interface ClickHouseDropPartitionParams extends ClickHouseConnectionConfig {
table: string
partition: string
}
export interface ClickHouseKillQueryParams extends ClickHouseConnectionConfig {
queryId: string
}
export interface ClickHouseInsertRowsParams extends ClickHouseConnectionConfig {
table: string
rows: Array<Record<string, unknown>>
}
export interface ClickHouseQueryResponse extends ClickHouseRowsResponse {}
export interface ClickHouseExecuteResponse extends ClickHouseRowsResponse {}
export interface ClickHouseInsertResponse extends ClickHouseRowsResponse {}
export interface ClickHouseUpdateResponse extends ClickHouseRowsResponse {}
export interface ClickHouseDeleteResponse extends ClickHouseRowsResponse {}
interface ClickHouseTableColumn {
name: string
type: string
defaultKind?: string
defaultExpression?: string
isInPrimaryKey: boolean
isInSortingKey: boolean
}
interface ClickHouseTableSchema {
name: string
database: string
engine: string
totalRows?: number
columns: ClickHouseTableColumn[]
}
export interface ClickHouseIntrospectResponse extends ToolResponse {
output: {
message: string
tables: ClickHouseTableSchema[]
}
error?: string
}
export interface ClickHouseResponse extends ClickHouseRowsResponse {}
+109
View File
@@ -0,0 +1,109 @@
import type { ClickHouseUpdateParams, ClickHouseUpdateResponse } from '@/tools/clickhouse/types'
import type { ToolConfig } from '@/tools/types'
export const updateTool: ToolConfig<ClickHouseUpdateParams, ClickHouseUpdateResponse> = {
id: 'clickhouse_update',
name: 'ClickHouse Update',
description: 'Update rows in a ClickHouse table via an ALTER TABLE ... UPDATE mutation',
version: '1.0.0',
params: {
host: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse server hostname (e.g., your-instance.clickhouse.cloud)',
},
port: {
type: 'number',
required: true,
visibility: 'user-only',
description: 'ClickHouse HTTP interface port (8443 for HTTPS, 8123 for HTTP)',
},
database: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Database name to connect to',
},
username: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'ClickHouse username',
},
password: {
type: 'string',
required: false,
visibility: 'user-only',
description: 'ClickHouse password',
},
secure: {
type: 'boolean',
required: false,
visibility: 'user-only',
description: 'Use a secure HTTPS connection (default: true)',
},
table: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Table name to update data in',
},
data: {
type: 'object',
required: true,
visibility: 'user-or-llm',
description: 'Data object with fields to update (key-value pairs)',
},
where: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'WHERE clause condition (without the WHERE keyword)',
},
},
request: {
url: '/api/tools/clickhouse/update',
method: 'POST',
headers: () => ({
'Content-Type': 'application/json',
}),
body: (params) => ({
host: params.host,
port: Number(params.port),
database: params.database,
username: params.username,
password: params.password,
secure: params.secure,
table: params.table,
data: params.data,
where: params.where,
}),
},
transformResponse: async (response: Response) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'ClickHouse update failed')
}
return {
success: true,
output: {
message: data.message || 'Update mutation submitted successfully',
rows: data.rows || [],
rowCount: data.rowCount || 0,
},
error: undefined,
}
},
outputs: {
message: { type: 'string', description: 'Operation status message' },
rows: { type: 'array', description: 'Updated rows (empty for ClickHouse mutations)' },
rowCount: { type: 'number', description: 'Number of rows written by the mutation' },
},
}