DataHub 扩展
Watch the demo
本教程介绍如何将 DataHub MCP 服务器 添加为 goose 扩展,以便在整个数据生态中进行 AI 驱动的数据发现、血缘探索和元数据查询。
- goose Desktop
- goose CLI
命令
uvx mcp-server-datahub@latest
环境变量
DATAHUB_GMS_URL: <your-datahub-url>
DATAHUB_GMS_TOKEN: <your-datahub-token>
什么是 DataHub?
DataHub 是一个开源元数据平台,为你的数据生态提供统一视图,编目数据集、仪表盘、管道等,并附带丰富的元数据,包括所有权、血缘、使用统计和数据质量信息。
DataHub MCP 服务器让 AI 代理能够:
- 使用带有热度、质量和血缘等信任信号的自然语言搜索,找到可信的数据
- 探索数据血缘,在表级和列级理解上游和下游依赖
- 通过词汇表、域、数据产品和组织元数据理解业务上下文
- 借助文档、血缘和常见查询模式生成 SQL 查询
了解更多:DataHub MCP 服务器指南 | GitHub 仓库
前提条件
使用 DataHub MCP 服务器之前,请确保你有:
- 已安装 Python 3.10+ 和 uv 包管理器
- 一个 DataHub 实例:DataHub Cloud 或自托管 DataHub
- 来自你的 DataHub 实例的 个人访问令牌
配置
运行此命令需要在系统上安装 uv,因为它使用 uvx。
- goose Desktop
- goose CLI
- Launch the installer
- Click
Yesto confirm the installation - Get your DataHub Personal Access Token and paste it in
- Click
Add Extension - Click the button in the top-left to open the sidebar
- Navigate to the chat
- Run the
configurecommand:
goose configure
- Choose to add a
Command-line Extension.
┌ goose-configure
│
◇ What would you like to configure?
│ Add Extension
│
◆ What type of extension would you like to add?
│ ○ Built-in Extension
│ ● Command-line Extension (Run a local command or script)
│ ○ Remote Extension (Streamable HTTP)
└
- Give your extension a name.
┌ goose-configure
│
◇ What would you like to configure?
│ Add Extension
│
◇ What type of extension would you like to add?
│ Command-line Extension
│
◆ What would you like to call this extension?
│ DataHub
└
- Enter the command to run when this extension is used.
┌ goose-configure
│
◇ What would you like to configure?
│ Add Extension
│
◇ What type of extension would you like to add?
│ Command-line Extension
│
◇ What would you like to call this extension?
│ DataHub
│
◆ What command should be run?
│ uvx mcp-server-datahub@latest
└
- Enter the number of seconds goose should wait for actions to complete before timing out. Default is
300seconds.
┌ goose-configure
│
◇ What would you like to configure?
│ Add Extension
│
◇ What type of extension would you like to add?
│ Command-line Extension
│
◇ What would you like to call this extension?
│ DataHub
│
◇ What command should be run?
│ uvx mcp-server-datahub@latest
│
◆ Please set the timeout for this tool (in secs):
│ 300
└
- Enter a description for this extension.
┌ goose-configure
│
◇ What would you like to configure?
│ Add Extension
│
◇ What type of extension would you like to add?
│ Command-line Extension
│
◇ What would you like to call this extension?
│ DataHub
│
◇ What command should be run?
│ uvx mcp-server-datahub@latest
│
◇ Please set the timeout for this tool (in secs):
│ 300
│
◆ Enter a description for this extension:
│ 数据发现与元数据平台集成
└
- Add environment variables for this extension.
┌ goose-configure
│
◇ What would you like to configure?
│ Add Extension
│
◇ What type of extension would you like to add?
│ Command-line Extension
│
◇ What would you like to call this extension?
│ DataHub
│
◇ What command should be run?
│ uvx mcp-server-datahub@latest
│
◇ Please set the timeout for this tool (in secs):
│ 300
│
◇ Enter a description for this extension:
│ 数据发现与元数据平台集成
│
◆ Would you like to add environment variables?
│ Yes
│
◇ Environment variable name:
│ DATAHUB_GMS_URL
│
◇ Environment variable value:
│ https://your-instance.acryl.io
│
◇ Add another environment variable?
│ Yes
│
◇ Environment variable name:
│ DATAHUB_GMS_TOKEN
│
◇ Environment variable value:
│ ▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪
│
◇ Add another environment variable?
│ No
│
└ Added DataHub extension
使用示例
找到可信的数据
用自然语言描述你的需要,找出与项目相关的数据集。
goose 提示词
找出分析团队拥有的、与客户交易相关的所有数据集
goose 输出
DataHub 扩展会搜索你的数据目录,并返回相关数据集及其元数据,包括:
- 数据集名称和描述
- 列名、类型、描述和标签
- 所有者
- 标签、属性和词汇表术语
- 使用统计
- 数据质量状态
探索数据血缘
我想从 customer_orders 表中删除 “timestamp_seconds” 列。什么会坏掉?
goose 提示词
给我看 customer_orders 表的上游血缘
goose 输出
扩展会遍历血缘图,并展示任何会受删除该列影响的:
- 源表和数据集
- 转换管道
- ETL 作业和工作流
- 下游列
生成 SQL 查询
我如何计算去年在美国产生的订单数量?
goose 提示词
针对 customer_orders 数据集最常运行的查询有哪些?
goose 输出
扩展会检索 SQL 查询历史,展示:
- 频繁执行的查询
- 常见的连接模式
- 过滤条件
- 聚合模式
此外还有列名、类型、描述和任何标签。这将使代理能够生成高质量 SQL 来回答问题。
理解数据质量与新鲜度
在使用数据集之前,判断它是否可信。
goose 提示词
customer_orders 表是否新鲜,并且没有数据质量问题?
goose 输出
扩展会获取:
- 最新的数据质量断言和测试结果
- 新鲜度 / 过期指标
- Schema 变更历史
- SLA 或 SLO 元数据
- 所有者提供的健康状态
从而使代理能够警告用户,或确认数据的可信度。
能力
DataHub MCP 服务器提供以下工具:
search
使用结构化关键词搜索(/q 语法)搜索 DataHub,支持布尔逻辑、过滤器、分页,以及按使用指标可选排序。
get_lineage
检索任意实体(数据集、列、仪表盘等)的上游或下游血缘,支持过滤、血缘内查询、分页和跳数控制。
get_dataset_queries
获取引用某个数据集或列的真实 SQL 查询(手工编写或系统生成),以理解使用模式、连接、过滤和聚合行为。
get_entities
按 URN 获取一个或多个实体的详细元数据;支持批量检索,以便高效检查搜索结果。
list_schema_fields
列出数据集的 schema 字段,支持关键词过滤和分页。当搜索结果截断了字段,或在探索大型 schema 时很有用。
get_lineage_paths_between
检索两个资产或列之间的确切血缘路径,包括中间转换和 SQL 查询信息。
资源
故障排除
连接问题
如果连接 DataHub 时遇到问题:
-
核实
DATAHUB_GMS_URL是否正确:- DataHub Cloud:
https://your-tenant.acryl.io - 本地实例:
http://localhost:8080 - 本地部署:
https://datahub.your-company.com
- DataHub Cloud:
-
确认个人访问令牌有效,并且具有适当权限
-
检查网络连通性和防火墙规则
安装问题
如果找不到 uvx:
- 确保已安装
uv:curl -LsSf https://astral.sh/uv/install.sh | sh - 重启终端,或 source 你的 shell 配置
- 验证安装:
which uvx