Analyticbase

io.github.CloudCorpRecords由 GitHub 帳號 CloudCorpRecords 發布v0.1.0更新於 Nov 7, 2026

Query ClickHouse over HTTP: list databases and tables, run SELECT.

已驗證STDIO僅桌面資料庫資料與分析

概覽

AI 產生的概覽

唯讀的 ClickHouse MCP 伺服器,讓助理透過 HTTP 介面列出資料庫與資料表,並執行受保護的 SELECT 查詢。

可以做什麼
  • 列出 ClickHouse 伺服器上的資料庫
  • 列出某個資料庫中的資料表,包含引擎、註解、列數與欄數,可用 LIKE 模式篩選
  • 執行單一唯讀的 SELECT 或 WITH 查詢,以欄名為鍵的 JSON 物件回傳結果列
  • 連線失敗或資料庫錯誤時以工具錯誤回報,而不是捏造資料列
適用情境
適合需要讓助理檢視或回答 ClickHouse 資料問題、但不應具備修改能力的場合,例如了解資料表結構或進行臨時唯讀分析。
執行需求
以 stdio 本機程序執行,可透過 npx 或 Docker 映像啟動。需要可連線的 ClickHouse HTTP 端點,以 CLICKHOUSE_URL 或 CLICKHOUSE_HOST 與 CLICKHOUSE_PORT 設定,並提供 CLICKHOUSE_USER 與 CLICKHOUSE_PASSWORD。清單未宣告驗證資訊;即使後端無法連線,伺服器仍可啟動並列出工具。
安裝前請注意
憑證會以 URL 參數送往 ClickHouse HTTP 介面,建議使用 TLS 與最小權限帳號。唯讀保護以關鍵字比對實作,可能拒絕含 update、drop 等字的正常查詢;它只是過濾,不能取代資料庫端權限控管。對大型資料表查詢可能耗費大量資源。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Analyticbase,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

analyticbase

analyticbase lets an agent — or you, at a terminal — look inside a ClickHouse database and ask it questions, without ever being able to change it. It lists the databases on a server, lists the tables in one database along with each table's engine, comment, row count and column count, and runs single read-only SELECT queries. Everything travels over ClickHouse's plain HTTP interface, so there is no client library bundled and no native port to tunnel.

When ClickHouse is not there, analyticbase says so. The MCP server starts and lists its tools with no server behind it at all; only an actual operation makes a request, and a refused connection or a server error comes back as an error carrying the server's own text — never as invented rows.

Install

bash
npx @reneturcios/analyticbase list-databases

Or run the container image:

bash
docker run -i ghcr.io/cloudcorprecords/analyticbase

The container defaults to the MCP server (see below). Pass CLI arguments to use it as a CLI instead.

CLI

bash
# Which databases does this server hold?analyticbase list-databases
# What tables live in one database? (name filters are LIKE patterns)analyticbase list-tables analyticsanalyticbase list-tables analytics --like "events_%" --not-like "%_tmp"
# Run one read-only query; rows print as JSONanalyticbase query "SELECT count() AS n FROM analytics.events"
# Start the MCP serveranalyticbase mcp
analyticbase --version

Exit codes: 0 on success, 1 when the query, the guard, or the connection fails (the error says which), 2 for usage errors.

The endpoint is configured through the environment:

VariableMeaningDefault
CLICKHOUSE_URLWhole base URL of the HTTP interface; overrides host and port—
CLICKHOUSE_HOSTHostname, or a full http(s):// URLlocalhost
CLICKHOUSE_PORTHTTP interface port8123
CLICKHOUSE_USERUsernamedefault
CLICKHOUSE_PASSWORDPassword(empty)

How the queries work

Each operation POSTs its SQL to the HTTP interface as the request body, with the credentials as URL parameters — the interface's own convention. The listing operations append FORMAT JSONEachRow and parse one JSON object per line; list_tables reads system.tables and counts each table's columns with a subquery over system.columns, applying the like / not_like filters as LIKE / NOT LIKE clauses with safely escaped literals. Select queries append FORMAT JSON and return the response's data array.

The read-only guard

run_select_query (and the CLI query command) accepts a query only if all of these hold:

  • After leading whitespace and comments are stripped, its first keyword is SELECT or WITH.
  • It is a single statement: a semicolon followed by anything other than whitespace ends the conversation.
  • None of INSERT, UPDATE, DELETE, DROP, ALTER, CREATE, TRUNCATE, GRANT, REVOKE, OPTIMIZE, RENAME, DETACH, or ATTACH appears as a whole word outside a string literal. Single-quoted literals are blanked out before scanning, so SELECT 'drop table t' is a fine query; a column literally named update is not — the guard would rather refuse an odd name than be talked around.

The listing operations build their SQL internally from validated, escaped pieces, so they need no guard.

MCP server

One bin serves both faces. The mcp subcommand starts a stdio MCP server:

bash
npx -y @reneturcios/analyticbase mcp

MCP client configuration:

json
{  "mcpServers": {    "analyticbase": {      "command": "npx",      "args": ["-y", "@reneturcios/analyticbase", "mcp"],      "env": { "CLICKHOUSE_HOST": "localhost", "CLICKHOUSE_PORT": "8123" }    }  }}

Tools

ToolInputWhat it returns
list_databases(none)One object per database, from system.databases.
list_tablesdatabase (string, required), like / not_like (strings, optional)One object per table in that database: its schema (database), name, engine, comment, row count, and column count.
run_select_queryquery (string, required) — one read-only SQL statementThe result rows as a JSON array of objects keyed by column name. Guard violations, a missing server, and database errors all come back as tool errors — never as made-up rows.

Development

bash
npm installnpm run build   # tsc -> dist/npm test        # node test runner over test/*.test.ts, no network, no live ClickHousenpm run dev     # run the CLI from source via tsx

All HTTP goes through an injectable fetch function, which is what the test suite drives: config resolution, the guard, SQL construction, both response-format parsers, and all three operations are covered against a fake fetch.

License

MIT — see LICENSE.

來源:README.md,提交 4f03e0f

工具

3

list_databases

List available ClickHouse databases

無需輸入參數。

list_tables

List available ClickHouse tables in a database, including schema, comment, row count, and column count.

輸入參數likedatabase必填not_like

run_select_query

Run a SELECT query in a ClickHouse database

輸入參數query必填

版本歷史

1
  1. v0.1.0最新Oct 31, 2026

評分

已滿足適用檢查項的 90%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分
  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具必需15 分
  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分