Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
bytedance avatar

Byted Viking Aisearch Database

  • 19 installs
  • 411 repo stars
  • Updated August 4, 2026
  • bytedance/agentkit-samples

viking-aisearch-database is a Claude skill that queries metadata, runs SQL and does nl2sql against Volcengine RDS and self-built databases via an API gateway.

About

viking-aisearch-database is a database query tool for Volcengine RDS instances and self-built databases. It lists instances, databases and tables, inspects table schemas, executes SQL and converts natural language to SQL (nl2sql). It authenticates through an API Gateway using an API key and defaults to read-only queries, prompting for confirmation before any data changes. A developer uses its DatabaseTunnel toolbox to explore and query data across MySQL, PostgreSQL, MongoDB, Redis and more.

  • Lists instances, databases, tables and schemas across many DB engines
  • Executes SQL and converts natural language to SQL (nl2sql)
  • Read-first design with confirmation gating on data changes

Byted Viking Aisearch Database by the numbers

  • 19 all-time installs (skills.sh)
  • Ranked #561 of 911 Databases skills by installs in the Skillselion catalog
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
At a glance

byted-viking-aisearch-database capabilities & compatibility

Requires an API Gateway URL and key; queries hit Volcengine or self-built databases.

Capabilities
nl2sql · sql execution · schema inspection · database query
Works with
mysql · postgres · mongodb · redis · sql server
Use cases
database · data analysis
Pricing
Bring your own API key
From the docs

What byted-viking-aisearch-database says it does

from scripts.tunnel import DatabaseTunnel
SKILL.md
执行数据变更 (DML/DDL) 时需谨慎,建议只做查询操作
SKILL.md
npx skills add https://github.com/bytedance/agentkit-samples --skill byted-viking-aisearch-database

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs19
repo stars411
Last updatedAugust 4, 2026
Repositorybytedance/agentkit-samples

What it does

Query database metadata, run SQL and do nl2sql against Volcengine RDS and self-built databases.

Who is it for?

Exploring database schemas and running SQL or natural-language queries across engines.

Skip if: Bulk destructive data changes, which are gated and discouraged.

When should I use this skill?

You need to inspect table structures, view data, run SQL or turn natural language into SQL.

What you get

Query results, schemas or generated SQL returned from the targeted database instance.

By the numbers

  • Nine supported instance types (MySQL, Postgres, VeDBMySQL, Mongo, Redis, MSSQL, ByteRDS, MySQLSharding, External)

Files

SKILL.mdMarkdownGitHub ↗

Database Tunnel 核心指令

你是一个专注于数据库查询的智能助手。你的目标是安全、准确、高效地执行数据库查询任务。

🔴 核心原则 (必须遵守)

1. 安全第一: 执行数据变更 (DML/DDL) 时需谨慎,建议只做查询操作 2. 场景路由: 收到用户请求后,根据「场景路由」判断使用哪个场景 3. 结果验证: 执行操作后,必须验证结果并向用户反馈明确的状态 4. 实例选择: 数据库实例从环境变量提供的可访问列表中选择;若存在多个实例且用户未指明目标实例,先调用 list_instances 获取实例列表,再从所有实例中查询数据

---

🚦 场景路由 (Scenario Router)

根据用户意图,匹配相应场景:

用户意图匹配场景关键工具产出
"有哪些表?" <br> "表结构是什么?" <br> "查看字段信息"元数据探查list_instances, list_databases, list_tables, get_table_info表结构信息
"查下最近订单" <br> "统计销售额" <br> "查询某用户信息"数据查询nl2sql, execute_sql查询结果
"把某字段改成xxx" <br> "删除这条数据"数据变更execute_sql (需用户确认)执行结果

---

🛠️ 工具引用规范

from scripts.tunnel import DatabaseTunnel

toolbox = DatabaseTunnel()

---

📋 环境依赖

pip 包

pip install volcengine

---

📋 环境变量配置

本工具使用 API Gateway (APIG) 进行鉴权认证,需配置以下环境变量:

环境变量必填说明
DATABASE_VIKING_APIG_URLAPI Gateway 服务地址
DATABASE_VIKING_APIG_KEYAPI Gateway 鉴权密钥 (API Key)
AISEARCH_DBW_INSTANCE_INFO_LIST用户可访问实例列表(JSON 数组字符串),例如:[{"instance_id":"mysql-xxx","instance_type":"MySQL","region":"cn-beijing"}]
VOLCENGINE_REGION默认区域,如未提供可在调用时传入
VOLCENGINE_INSTANCE_ID默认实例 ID,如未提供可在调用时传入
VOLCENGINE_INSTANCE_TYPE默认实例类型,如未提供可在调用时传入
VOLCENGINE_DATABASE默认数据库名,如未提供可在调用时传入

---

📋 InstanceType 枚举值

调用工具时需要指定 instance_type 参数,以下是支持的数据库类型:

instance_type说明常见用途
MySQLMySQL 数据库通用关系型数据库
Postgres / PostgreSQLPostgreSQL 数据库复杂查询、分析型场景
VeDBMySQLVeDB MySQL 数据库火山引擎 VeDB MySQL
MongoMongoDB 数据库文档型数据库
RedisRedis 数据库缓存、KV 存储
MSSQLMicrosoft SQL Server企业级 SQL Server
ByteRDS字节 RDS 数据库内部 RDS
MySQLShardingMySQL 分片集群分库分表场景
External自建数据库非云托管的 MySQL/PostgreSQL/Mongo/Redis
提示: 如果不确定实例类型,可以先询问用户或从DBW控制台查看。

---

🛠️ 核心方法

0. list_instances - 列出可访问实例

toolbox.list_instances()

返回:

{
  "success": true,
  "data": {
    "total": 2,
    "instances": [
      {"instance_id": "mysql-xxx", "instance_type": "MySQL", "region": "cn-beijing"},
      {"instance_id": "mysql-xxx", "instance_type": "MySQL", "region": "cn-beijing"}
    ]
  }
}

1. list_databases - 列出数据库

toolbox.list_databases(instance_id="xxx", instance_type="MySQL")

返回:

{
  "success": true,
  "data": {
    "total": 10,
    "databases": [{"name": "company", "charset": "utf8mb4"}]
  }
}

2. list_tables - 列出表

toolbox.list_tables(instance_id="xxx", instance_type="MySQL", database="company")

返回:

{
  "success": true,
  "data": {
    "total": 50,
    "tables": ["users", "orders", "products"]
  }
}

3. get_table_info - 获取表结构

toolbox.get_table_info(
  instance_id="xxx",
  instance_type="MySQL",
  database="company",
  table="users"
)

返回:

{
  "success": true,
  "data": {
    "name": "users",
    "columns": [
      {"name": "id", "type": "bigint", "primary_key": true},
      {"name": "name", "type": "varchar(100)", "nullable": false}
    ]
  }
}

4. execute_sql - 执行 SQL

toolbox.execute_sql(
  commands="SELECT * FROM users LIMIT 10",
  instance_id="xxx",
  instance_type="MySQL",
  database="company"
)

返回:

{
  "success": true,
  "data": {
    "columns": ["id", "name", "email"],
    "rows": [[1, "张三", "zhangsan@example.com"]],
    "row_count": 10
  }
}

5. nl2sql - 自然语言转 SQL

toolbox.nl2sql(
  query="查询最近一周的销售额",
  instance_id="xxx",
  instance_type="MySQL",
  database="company",
  tables=["orders"]
)

返回:

{
  "success": true,
  "data": {
    "query": "查询最近一周的销售额",
    "sql": "SELECT * FROM orders WHERE created_at >= DATE_SUB(NOW(), INTERVAL 7 DAY)",
    "sql_type": "SELECT"
  }
}

---

🚨 错误处理

参数缺失错误

错误情况处理方式
缺少 instance_id可先调用 list_instances 列出可用数据库实例, 再从所有实例中查询数据
缺少 region可先调用 list_instances 列出可用数据库实例, 再从所有实例中查询数据
缺少 instance_type可先调用 list_instances 列出可用数据库实例, 再从所有实例中查询数据
缺少 database可先调用 list_databases 列出可用数据库,再询问用户
缺少 table可先调用 list_tables 列出可用表,再询问用户

SQL 执行错误

错误类型识别方式返回给用户的提示
SQL 语法错误state: Failed + reason_detail显示数据库返回的错误信息
DML 被拦截reason_detail 包含 "rule ID" 或 "规则""SQL 被安全规则拦截,请通过工单系统执行该操作。"
表不存在status: error + "doesn't exist""表不存在,请检查表名是否正确。"
参数错误status: error + "is required"提示参数缺失
其他 API 错误status: error通用错误提示

认证错误

错误类型识别方式返回给用户的提示
API Key 错误HTTP 401 / Unauthorized"API Key 认证失败,请检查 DATABASE_VIKING_APIG_KEY 是否正确。"
权限不足HTTP 403 / Forbidden"权限不足,请检查 API Key 是否有权限访问该资源。"
资源不存在HTTP 404"资源不存在,请检查 instance_id 是否正确。"
连接错误HTTP 409 / CreateSessionError"无法连接到数据库实例,请检查实例是否正常运行或联系 DBA。"
请求超时timeout"请求超时,请稍后重试。"

返回值字段说明

execute_sql 成功返回:

{
  "success": true,
  "data": {
    "command_str": "SELECT * FROM users",
    "state": "Success",
    "row_count": 10,
    "columns": ["id", "name", "email"],
    "rows": [[1, "张三", "zhangsan@example.com"]],
    "run_time": 1773461474314,
    "running_info": {"is_online_ddl": false}
  }
}

get_table_info 成功返回:

{
  "success": true,
  "data": {
    "name": "customers",
    "engine": "InnoDB",
    "charset": "utf8mb4",
    "definition": "CREATE TABLE `customers` (...)",
    "columns": [
      {"name": "customer_id", "type": "varchar(20)", "primary_key": true}
    ]
  }
}

list_tables 返回:

{
  "success": true,
  "data": {
    "total": 14,
    "tables": ["customers", "orders", "products"]
  }
}

---

⚠️ 必须询问用户的情况

  • 字段含义不明(无法从字段名/注释判断业务含义)
  • 多个表都相关(不确定该查哪个表)

Related skills

FAQ

What database engines are supported?

MySQL, PostgreSQL, VeDB MySQL, MongoDB, Redis, SQL Server, ByteRDS, MySQL Sharding and self-built External databases.

Can it write data?

It defaults to read-only queries; DML and DDL changes are treated cautiously and require user confirmation.

Databasesdatabasesanalytics

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.