M

MCP Clickzetta 服务器

@yunqiqiliang/mcp-clickzetta-server
0 Stars 361 次浏览 yunqiqiliang 更新于 2026-08-23

一种模型上下文协议服务器, enables 数据库与Clickzetta的交互,使用户能够运行SQL查询、管理表并维护数据洞见的动态更新备忘录。 (注:原文中的“enables”可能为表述上的小疏忽,完整理解应为“enabling”。)

MCP 服务配置

复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用

{
  "mcpServers": {
    "clickzetta-mcp-server": {
      "args": [
        "--directory",
        "/Users/******/Documents/GitHub/mcp-clickzetta-server",
        "run",
        "mcp_clickzetta_server"
      ],
      "command": "/Users/******/anaconda3/bin/uv"
    }
  }
}

该服务需要配置环境变量:allow_write、exclude_tools、instance、log_dir、log_level、password、schema、service、user、vcluster、workspace

服务介绍

Clickzetta MCP 服务器

smithery 徽章 PyPI - 版本

概述

这是一个模型上下文协议 (MCP) 服务器实现,提供了与 Clickzetta Lakehouse 的数据库交互功能。该服务器能够使用工具运行 SQL 查询,并与作为资源呈现的数据洞察备忘录进行交互。

image.gif

组件

资源

服务器暴露了一个动态资源:

  • memo://insights: 一个持续更新的数据洞察备忘录,它在分析过程中聚合发现的洞察
    • 通过 append-insight 工具自动更新,当有新的洞察被发现时

工具

服务器提供了六个核心工具:

查询工具

  • read_query

    • 执行 SELECT 查询以从数据库中读取数据
    • 输入:
      • query (字符串): 要执行的 SELECT SQL 查询
    • 返回: 作为对象数组的查询结果
  • write_query (需要 --allow-write 标志)

    • 执行 INSERT, UPDATE 或 DELETE 查询
    • 输入:
      • query (字符串): SQL 修改查询
    • 返回: { affected_rows: number }
  • create_table (需要 --allow-write 标志)

    • 在数据库中创建新表
    • 输入:
      • query (字符串): CREATE TABLE SQL 语句
    • 返回: 表创建确认

模式工具

  • list_tables

    • 获取数据库中所有表的列表
    • 不需要输入
    • 返回: 表名数组
  • describe-table

    • 查看特定表的列信息
    • 输入:
      • table_name (字符串): 要描述的表名(可以是完全限定名)
    • 返回: 包含名称和类型的列定义数组

分析工具

  • append_insight
    • 向备忘录资源添加新的数据洞察
    • 输入:
      • insight (字符串): 从分析中发现的数据洞察
    • 返回: 洞察添加确认
    • 触发 memo://insights 资源的更新

与 Claude Desktop 一起使用

安装为本地 MCP 服务器(这种方法已在 MacOS 上测试并验证)

克隆此仓库:

git clone https://github.com/yunqiqiliang/mcp-clickzetta-server.git
cd mcp-clickzetta-server

安装包:

uv pip install -e .

配置凭据

基于 .env.example 创建一个 .env 文件,填写您的 Clickzetta Lakehouse 凭据:

CLICKZETTA_USERNAME = ""
CLICKZETTA_PASSWORD = ""
CLICKZETTA_SERVICE = "api.clickzetta.com"
CLICKZETTA_INSTANCE = ""
CLICKZETTA_WORKSPACE = ""
CLICKZETTA_SCHEMA = ""
CLICKZETTA_VCLUSTER = ""
使用
使用 uv 运行

安装完包后,您可以直接运行以下命令来启动服务器:

uv run mcp_clickzetta_server

如果您是第一次运行服务器,可以运行以下命令来加速包的安装:

UV_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple/ uv run mcp_clickzetta_server

这将启动基于 stdio 的 MCP 服务器,它可以连接到 Claude Desktop 或任何支持 stdio 通信的 MCP 客户端。

您应该会看到类似的输出:


uv run mcp_clickzetta_server

2025-03-25 10:11:20,799 - mcp_clickzetta_server - INFO - Starting Clickzetta MCP Server
2025-03-25 10:11:20,799 - mcp_clickzetta_server - INFO - Allow write operations: False
2025-03-25 10:11:20,799 - mcp_clickzetta_server - INFO - Prefetch table descriptions: True
2025-03-25 10:11:20,799 - mcp_clickzetta_server - INFO - Excluded tools: []
2025-03-25 10:11:20,799 - mcp_clickzetta_server - INFO - Prefetching table descriptions
2025-03-25 10:11:21,726 - clickzetta.zettapark.session - INFO - Zettapark Session information: 
"version" : 0.1.3,
"python.version" : 3.12.2,
"python.connector.version" : 0.8.89.0,
"python.connector.session.id" : dd46bd27-920d-4760-94a6-6f994d31e63e,
"os.name" : Darwin

2025-03-25 10:11:21,728 - clickzetta.connector.v0.client - INFO - clickzetta connector submitting job,  id:2025032510112172821098301
2025-03-25 10:11:23,059 - clickzetta.connector.v0.client - INFO - clickzetta connector submitting job,  id:2025032510112305897947697
2025-03-25 10:11:23,728 - mcp_clickzetta_server - INFO - Allowed tools: ['read_query', 'append_insight']
2025-03-25 10:11:23,732 - mcp_clickzetta_server - INFO - Server running with stdio transport
Claude Desktop 集成
  • 在 Claude Desktop 中,进入设置 → MCP 服务器
  • 添加一个新的服务器,并提供您的 uv 可执行文件的完整路径:
{
   "mcpServers": {
      "clickzetta-mcp-server" : {
         "command": "/Users/******/anaconda3/bin/uv",
         "args": [
            "--directory",
            "/Users/******/Documents/GitHub/mcp-clickzetta-server",
            "run",
            "mcp_clickzetta_server"
         ]
      }
   }
}
  • 您可以通过在终端中运行 which uv 来找到您的 uv 路径
  • 保存服务器配置

image.png

示例查询

当与 Claude 一起使用时,您可以提出如下问题:

  • "你能列出我 Clickzetta 账户中的所有模式吗?"
  • "列出 PUBLIC 模式下的所有视图"
  • "描述 SALES 模式下 CUSTOMER_ANALYTICS 视图的结构"
  • "显示 FINANCE 模式下 REVENUE_BY_REGION 视图的一些样本数据"
  • "运行此 SQL 查询:SELECT customer_id, SUM(order_total) as total_spend FROM SALES.ORDERS GROUP BY customer_id ORDER BY total_spend DESC LIMIT 10"
  • "查询 MARKETING 数据库以按转化率找出表现最好的前 5 名活动"
  • "帮我从Clickzetta中读取数据,分析下在public这个schema下github_users表里每个公司的用户数。请用中文返回结果,并对结果进行数据可视化展现"
  • "帮我从Clickzetta中读取数据,分析下在public这个schema下github_event_issuesevent表里有多少条记录?"
示例结果
  • '帮我从Clickzetta数据源中读取数据,先分析基于public这个schema下github_users表里的数据可以做哪些分析?包括指标、统计、趋势、以及各种经典的用户分析模型比如用户价值分析、用户生命周期分析、用户segment等,然后根据这些分析内容生成一个分析报告的dashboard'

image.gif

  • "帮我从Clickzetta中读取数据,分析下在public这个schema下github_users表里每个公司的用户数。请用中文返回结果,并对结果进行数据可视化展现" 的结果:

image.png

  • "帮我从Clickzetta中读取数据,分析下在public这个schema下github_users表里每个位置 的用户数。请用中文返回结果,并对结果进行数据可视化展现" 的结果:

image.png

安全考虑

该服务器:

  • 强制只读操作(仅允许 SELECT 语句)
  • 自动添加 LIMIT 子句以防止大量结果集
  • 使用服务帐户身份验证以确保安全连接
  • 验证输入以防止 SQL 注入
  • ⚠️ 重要提示:请确保您的 .env 文件的安全性,切勿将其提交到版本控制。.gitignore 文件已配置为排除它。

通过 Smithery 安装(这种方式待测试和验证)

要通过 Smithery 自动安装适用于 Claude Desktop 的 Clickzetta 服务器:

npx -y @smithery/cli@latest install @yunqiqiliang/mcp-clickzetta-server --client claude --key ******

通过 UVX 安装(这种方式待测试和验证)

# Add the server to your claude_desktop_config.json
"mcpServers": {
  "clickzetta_pip": {
      "command": "uvx",
      "args": [
          "mcp_clickzetta_server",
          "--service",
          "the_service",
          "--instance",
          "the_instance",
          "--vcluster",
          "the_vcluster",
          "--workspace",
          "the_workspace",
           "--schema",
          "the_schema",
          "--user",
          "the_user",
          "--password",
          "their_password",
          # Optionally: "--allow_write" (but not recommended)
          # Optionally: "--log_dir", "/absolute/path/to/logs"
          # Optionally: "--log_level", "DEBUG"/"INFO"/"WARNING"/"ERROR"/"CRITICAL"
          # Optionally: "--exclude_tools", "{tool name}", ["{other tool name}"]
      ]
  }
}

相关 MCP 服务