
Byted Bytehouse Data Asset Analyzer
- 2 installs
- 408 repo stars
- Updated August 3, 2026
- volcengine/agentkit-samples
Generate a ByteHouse data asset catalog and lineage analysis by fetching table schemas, statistics, and inter-table relationships via the ByteHouse MCP Server.
About
Builds a data asset catalog and lineage analysis for ByteHouse by extracting full schemas, engine distributions, and table relationships through the ByteHouse MCP Server. A developer uses it to inventory data assets and analyze lineage between tables.
- Full schema extraction with engine and comment metadata plus auto tags
- Lineage analysis identifying Distributed-to-Local table relationships
Byted Bytehouse Data Asset Analyzer by the numbers
- 2 all-time installs (skills.sh)
- Ranked #741 of 911 Databases skills by installs in the Skillselion catalog
- Data as of Aug 4, 2026 (Skillselion catalog sync)
npx skills add https://github.com/volcengine/agentkit-samples --skill byted-bytehouse-data-asset-analyzerAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 2 |
|---|---|
| repo stars | ★ 408 |
| Last updated | August 3, 2026 |
| Repository | volcengine/agentkit-samples ↗ |
What it does
Generate a ByteHouse data asset catalog and lineage analysis by fetching table schemas, statistics, and inter-table relationships via the ByteHouse MCP Server.
Files
ByteHouse 数据资产和血缘分析 Skill
🔵 ByteHouse 品牌标识
「ByteHouse」—— 火山引擎云原生数据仓库,极速、稳定、安全、易用
>
本Skill基于ByteHouse MCP Server,提供完整的数据资产盘点和血缘分析能力
---
描述
基于ByteHouse MCP Server,生成数据资产目录和血缘分析的技能。
当以下情况时使用此 Skill: (1) 需要获取数据库表结构和字段信息 (2) 需要生成数据资产目录 (3) 需要分析表之间的血缘关系 (4) 用户提到"数据资产"、"血缘分析"、"表结构"、"字段分析"
前置条件
- Python 3.8+
- uv (已安装在
/root/.local/bin/uv) - ByteHouse MCP Server Skill - 本skill依赖
bytehouse-mcpskill提供的ByteHouse访问能力
依赖关系
本skill依赖 bytehouse-mcp skill,使用其提供的MCP Server访问ByteHouse。
确保 bytehouse-mcp skill已正确配置并可以正常使用。
📁 文件说明
- SKILL.md - 本文件,技能主文档
- data_asset_analyzer.py - 数据资产和血缘分析主程序
- README.md - 快速入门指南
配置信息
ByteHouse连接配置
本skill复用 bytehouse-mcp skill的配置。请确保已在 bytehouse-mcp skill中配置好:
export BYTEHOUSE_HOST="<ByteHouse-host>"
export BYTEHOUSE_PORT="<ByteHouse-port>"
export BYTEHOUSE_USER="<ByteHouse-user>"
export BYTEHOUSE_PASSWORD="<ByteHouse-password>"
export BYTEHOUSE_SECURE="true"
export BYTEHOUSE_VERIFY="true"🎯 功能特性
1. 完整Schema获取
- 获取指定数据库的所有表
- 获取每张表的所有字段
- 提取表引擎、注释等元数据
- 解析CREATE TABLE语句
2. 数据资产目录生成
- 表统计(总表数、总列数)
- 引擎分布统计
- 自动标签生成
- 表资产详情
3. 血缘分析
- 表关系识别(Distributed → Local)
- 列相似性分析
- 关系可视化
🚀 快速开始
方法1: 运行数据资产和血缘分析
cd /root/.openclaw/workspace/skills/data-asset-analyzer
# 先设置环境变量(复用bytehouse-mcp的配置)
export BYTEHOUSE_HOST="<ByteHouse-host>"
export BYTEHOUSE_PORT="<ByteHouse-port>"
export BYTEHOUSE_USER="<ByteHouse-user>"
export BYTEHOUSE_PASSWORD="<ByteHouse-password>"
export BYTEHOUSE_SECURE="true"
export BYTEHOUSE_VERIFY="true"
# 运行分析工具
uv run data_asset_analyzer.py分析内容包括:
- 数据库完整schema(所有表和字段)
- 数据资产目录(表统计、引擎分布、自动标签)
- 血缘分析(表关系、列相似性)
输出文件(保存在 `output/` 目录): 1. `schema_{database}_{timestamp}.json` - 完整的数据库schema 2. `catalog_{database}_{timestamp}.json` - 数据资产目录 3. `lineage_{database}_{timestamp}.json` - 血缘分析报告
💻 程序化使用
使用分析器模块
#!/usr/bin/env python3
# /// script
# dependencies = [
# "mcp>=1.0.0",
# ]
# ///
import asyncio
import sys
import os
# 添加bytehouse-mcp skill的路径
BYTEHOUSE_MCP_PATH = os.path.join(
os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
"bytehouse-mcp"
)
sys.path.insert(0, BYTEHOUSE_MCP_PATH)
from data_asset_analyzer import DataAssetAnalyzer
async def main():
analyzer = DataAssetAnalyzer()
await analyzer.connect()
# 分析数据库
result = await analyzer.analyze_database("default")
# result 包含:
# - schema: 完整的数据库schema
# - catalog: 数据资产目录
# - lineage: 血缘分析
# - files: 生成的文件路径
asyncio.run(main())📊 输出文件说明
1. Schema文件 (schema_*.json)
包含数据库的完整结构:
{
"database": "default",
"analyzed_at": "2026-03-12T19:50:00",
"tables": [
{
"name": "conversation_feedback",
"comment": "",
"engine": "Distributed",
"columns": [
{
"name": "session_id",
"type": "String",
"comment": ""
}
],
"create_table_query": "CREATE TABLE ..."
}
]
}2. 数据资产目录 (catalog_*.json)
包含数据资产的统计信息:
{
"database": "default",
"generated_at": "2026-03-12T19:50:00",
"summary": {
"total_tables": 8,
"total_columns": 45,
"engines": {
"Distributed": 4,
"HaMergeTree": 3,
"MergeTree": 1
}
},
"tables": [
{
"name": "conversation_feedback",
"comment": "",
"engine": "Distributed",
"column_count": 10,
"columns": [...],
"tags": ["distributed", "user-feedback"]
}
]
}3. 血缘分析 (lineage_*.json)
包含表关系和列相似性:
{
"database": "default",
"generated_at": "2026-03-12T19:50:00",
"table_relationships": [
{
"source_table": "conversation_feedback",
"relationships": [
{
"type": "distributed_to_local",
"target_table": "conversation_feedback_local",
"description": "Distributed表指向Local表"
}
]
}
],
"column_similarities": [
{
"column_name": "session_id",
"column_type": "String",
"found_in_tables": [
"conversation_feedback",
"conversation_feedback_local"
]
}
]
}🏷️ 自动标签生成
分析器会根据表名和引擎自动生成标签:
| 标签 | 说明 |
|---|---|
merge-tree | 使用MergeTree引擎 |
distributed | 使用Distributed引擎 |
high-availability | 使用HaMergeTree或HaUniqueMergeTree |
log-table | 表名包含"log" |
user-feedback | 表名包含"feedback" |
local-table | 表名以"_local"结尾 |
test-table | 表名包含"test" |
📚 更多信息
详细使用说明请参考 bytehouse-mcp skill
--- 最后更新: 2026-03-12
# Copyright (c) 2025 Beijing Volcano Engine Technology Co., Ltd. and/or its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.ByteHouse 数据资产和血缘分析 Skill
🔵 ByteHouse 品牌标识
「ByteHouse」—— 火山引擎云原生数据仓库,极速、稳定、安全、易用
>
本Skill基于ByteHouse MCP Server,提供完整的数据资产盘点和血缘分析能力
---
📁 文件说明
- SKILL.md - 技能主文档,包含详细使用说明
- data_asset_analyzer.py - 数据资产和血缘分析主程序
- README.md - 本文件,快速入门指南
🎯 功能特性
1. 完整Schema获取
- 获取指定数据库的所有表
- 获取每张表的所有字段
- 提取表引擎、注释等元数据
- 解析CREATE TABLE语句
2. 数据资产目录生成
- 表统计(总表数、总列数)
- 引擎分布统计
- 自动标签生成
- 表资产详情
3. 血缘分析
- 表关系识别(Distributed → Local)
- 列相似性分析
- 关系可视化
🚀 快速开始
前置条件
本skill依赖 bytehouse-mcp skill,确保已正确配置:
cd /root/.openclaw/workspace/skills/bytehouse-mcp
# 确认bytehouse-mcp可以正常工作
uv run test_mcp_server.py方法1: 运行数据资产和血缘分析
cd /root/.openclaw/workspace/skills/bytehouse-data-asset-analyzer
# 先设置环境变量(复用bytehouse-mcp的配置)
export BYTEHOUSE_HOST="<ByteHouse-host>"
export BYTEHOUSE_PORT="<ByteHouse-port>"
export BYTEHOUSE_USER="<ByteHouse-user>"
export BYTEHOUSE_PASSWORD="<ByteHouse-password>"
export BYTEHOUSE_SECURE="true"
export BYTEHOUSE_VERIFY="true"
# 运行分析工具
uv run data_asset_analyzer.py输出文件(保存在 `output/` 目录): 1. `schema_{database}_{timestamp}.json` - 完整的数据库schema 2. `catalog_{database}_{timestamp}.json` - 数据资产目录 3. `lineage_{database}_{timestamp}.json` - 血缘分析报告
📊 输出文件说明
1. Schema文件
包含数据库的完整结构,所有表和字段信息。
2. 数据资产目录
包含数据资产的统计信息、引擎分布、自动标签等。
3. 血缘分析
包含表关系识别和列相似性分析。
🏷️ 自动标签生成
分析器会根据表名和引擎自动生成标签:
merge-tree- 使用MergeTree引擎distributed- 使用Distributed引擎high-availability- 使用HaMergeTreelog-table- 表名包含"log"user-feedback- 表名包含"feedback"local-table- 表名以"_local"结尾test-table- 表名包含"test"
📚 更多信息
详细使用说明请参考 SKILL.md
ByteHouse访问配置请参考 bytehouse-mcp skill
--- 最后更新: 2026-03-12
#!/usr/bin/env python3
# Copyright (c) 2025 Beijing Volcano Engine Technology Co., Ltd. and/or its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
数据资产和血缘分析工具
获取数据库表结构,生成数据资产目录和血缘分析
"""
# /// script
# dependencies = [
# "mcp>=1.0.0",
# ]
# ///
import asyncio
import os
import json
from datetime import datetime
from typing import Dict, List, Any
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
def _extract_engine(create_query: str) -> str:
"""从CREATE TABLE语句中提取引擎"""
if "ENGINE = " in create_query:
parts = create_query.split("ENGINE = ")
if len(parts) > 1:
engine_part = parts[1].split("\n")[0].split("(")[0].strip()
return engine_part
return "Unknown"
def _generate_tags(table: Dict[str, Any]) -> List[str]:
"""为表生成标签"""
tags = []
# 引擎标签
engine = table.get("engine", "")
if "MergeTree" in engine:
tags.append("merge-tree")
if "Distributed" in engine:
tags.append("distributed")
if "HaMergeTree" in engine or "HaUniqueMergeTree" in engine:
tags.append("high-availability")
# 表名标签
table_name = table.get("name", "").lower()
if "log" in table_name:
tags.append("log-table")
if "feedback" in table_name:
tags.append("user-feedback")
if "local" in table_name:
tags.append("local-table")
if "test" in table_name:
tags.append("test-table")
return tags
async def analyze_database(database: str, output_dir: str = None):
"""分析数据库并生成报告"""
if output_dir is None:
output_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "output")
os.makedirs(output_dir, exist_ok=True)
# 从环境变量获取配置
env = os.environ.copy()
# MCP Server参数
server_params = StdioServerParameters(
command='/root/.local/bin/uvx',
args=[
'--from',
'git+https://github.com/volcengine/mcp-server@main#subdirectory=server/mcp_server_bytehouse',
'mcp_bytehouse',
'-t',
'stdio'
],
env=env
)
print(f"📊 正在分析数据库: {database}")
print("-" * 80)
async with stdio_client(server_params) as (read, write):
async with ClientSession(read, write) as session:
await session.initialize()
print("✅ 连接成功!")
# 1. 列出所有表
print(f"\n1️⃣ 列出所有表...")
result = await session.call_tool("list_tables", {"database": database})
tables = []
for content in result.content:
if content.type == 'text':
try:
table_data = json.loads(content.text)
if isinstance(table_data, dict):
tables.append(table_data)
elif isinstance(table_data, list):
tables.extend(table_data)
except:
pass
print(f" 找到 {len(tables)} 张表")
# 2. 解析表结构
print(f"\n2️⃣ 解析表结构...")
schema = {
"database": database,
"analyzed_at": datetime.now().isoformat(),
"tables": []
}
for i, table in enumerate(tables, 1):
table_name = table.get("name", "unknown")
print(f" [{i}/{len(tables)}] 处理表: {table_name}")
table_info = {
"name": table_name,
"comment": table.get("comment", ""),
"engine": _extract_engine(table.get("create_table_query", "")),
"columns": [],
"create_table_query": table.get("create_table_query", "")
}
# 解析列信息
columns = table.get("columns", [])
for col in columns:
column_info = {
"name": col.get("name", ""),
"type": col.get("type", ""),
"comment": col.get("comment", ""),
"default_type": col.get("default_type", ""),
"default_expression": col.get("default_expression", ""),
"codec_expression": col.get("codec_expression", ""),
"ttl_expression": col.get("ttl_expression", "")
}
table_info["columns"].append(column_info)
schema["tables"].append(table_info)
# 3. 生成数据资产目录
print(f"\n3️⃣ 生成数据资产目录...")
catalog = {
"database": database,
"generated_at": datetime.now().isoformat(),
"summary": {
"total_tables": len(schema["tables"]),
"total_columns": sum(len(t["columns"]) for t in schema["tables"]),
"engines": {}
},
"tables": []
}
# 统计引擎分布
for table in schema["tables"]:
engine = table["engine"]
catalog["summary"]["engines"][engine] = catalog["summary"]["engines"].get(engine, 0) + 1
# 生成表资产信息
for table in schema["tables"]:
table_asset = {
"name": table["name"],
"comment": table["comment"],
"engine": table["engine"],
"column_count": len(table["columns"]),
"columns": [
{
"name": c["name"],
"type": c["type"],
"comment": c["comment"]
}
for c in table["columns"]
],
"tags": _generate_tags(table)
}
catalog["tables"].append(table_asset)
# 4. 生成血缘分析
print(f"\n4️⃣ 生成血缘分析...")
lineage = {
"database": database,
"generated_at": datetime.now().isoformat(),
"table_relationships": [],
"column_similarities": []
}
# 分析表关系(基于表名模式)
tables_list = schema["tables"]
table_map = {t["name"]: t for t in tables_list}
for table in tables_list:
table_name = table["name"]
# 查找相关表(基于命名模式)
related_tables = []
# Distributed表 -> Local表
if "Distributed" in table["engine"]:
local_name = table_name.replace("_local", "")
if local_name in table_map:
related_tables.append({
"type": "distributed_to_local",
"target_table": local_name,
"description": "Distributed表指向Local表"
})
# Local表 -> Distributed表
if table_name.endswith("_local"):
distributed_name = table_name.replace("_local", "")
if distributed_name in table_map:
related_tables.append({
"type": "local_to_distributed",
"target_table": distributed_name,
"description": "Local表被Distributed表引用"
})
if related_tables:
lineage["table_relationships"].append({
"source_table": table_name,
"relationships": related_tables
})
# 分析列相似性
column_map = {}
for table in tables_list:
for col in table["columns"]:
col_name = col["name"]
col_type = col["type"]
key = f"{col_name}:{col_type}"
if key not in column_map:
column_map[key] = []
column_map[key].append(table["name"])
for key, table_list in column_map.items():
if len(table_list) > 1:
col_name, col_type = key.split(":", 1)
lineage["column_similarities"].append({
"column_name": col_name,
"column_type": col_type,
"found_in_tables": table_list
})
# 5. 保存文件
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
schema_file = os.path.join(output_dir, f"schema_{database}_{timestamp}.json")
catalog_file = os.path.join(output_dir, f"catalog_{database}_{timestamp}.json")
lineage_file = os.path.join(output_dir, f"lineage_{database}_{timestamp}.json")
with open(schema_file, "w", encoding="utf-8") as f:
json.dump(schema, f, ensure_ascii=False, indent=2)
with open(catalog_file, "w", encoding="utf-8") as f:
json.dump(catalog, f, ensure_ascii=False, indent=2)
with open(lineage_file, "w", encoding="utf-8") as f:
json.dump(lineage, f, ensure_ascii=False, indent=2)
# 6. 打印摘要
print("\n" + "=" * 80)
print("📊 数据资产和血缘分析摘要")
print("=" * 80)
print(f"\n📁 数据库: {catalog['database']}")
print(f"📋 总表数: {catalog['summary']['total_tables']}")
print(f"📝 总列数: {catalog['summary']['total_columns']}")
print(f"\n🔧 引擎分布:")
for engine, count in catalog["summary"]["engines"].items():
print(f" - {engine}: {count} 张表")
print(f"\n🔗 表关系: {len(lineage['table_relationships'])} 组")
print(f"📊 相似列: {len(lineage['column_similarities'])} 组")
print(f"\n🏷️ 表标签示例:")
tag_count = {}
for table in catalog["tables"]:
for tag in table["tags"]:
tag_count[tag] = tag_count.get(tag, 0) + 1
for tag, count in sorted(tag_count.items(), key=lambda x: x[1], reverse=True):
print(f" - {tag}: {count} 张表")
print(f"\n📁 输出文件已保存到: {output_dir}")
print(f" - Schema: {os.path.basename(schema_file)}")
print(f" - 数据资产目录: {os.path.basename(catalog_file)}")
print(f" - 血缘分析: {os.path.basename(lineage_file)}")
return {
"schema": schema,
"catalog": catalog,
"lineage": lineage,
"files": {
"schema": schema_file,
"catalog": catalog_file,
"lineage": lineage_file
}
}
async def main():
"""主函数"""
print("=" * 80)
print("ByteHouse 数据资产和血缘分析工具")
print("=" * 80)
print()
print("⚠️ 请确保已设置以下环境变量:")
print(" - BYTEHOUSE_HOST")
print(" - BYTEHOUSE_PORT")
print(" - BYTEHOUSE_USER")
print(" - BYTEHOUSE_PASSWORD")
print()
# 要分析的数据库
database = "default"
try:
result = await analyze_database(database)
print("\n✅ 分析完成!")
except Exception as e:
print(f"\n❌ 分析失败: {e}")
import traceback
traceback.print_exc()
if __name__ == "__main__":
asyncio.run(main())