← 返回 Skills 市场
tencent-adm

TencentDB DatabaseClaw Skill

作者 腾讯开源 · GitHub ↗ · v1.0.1 · MIT-0
cross-platform ✓ 安全检测通过
45
总下载
1
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install tencentdb-databaseclaw-skill
功能描述
This skill should be used when an AI agent or automated system needs to send messages to a TencentDB DatabaseClaw instance and receive streaming responses. I...
使用说明 (SKILL.md)

TencentDB-DatabaseClaw

Send messages to a DatabaseClaw instance via the CreateChatCompletion SSE API and receive streaming Agent responses.

When to Use

  • An AI agent needs to invoke DatabaseClaw for SQL execution, inspection, or data analysis
  • Building an AI workflow that integrates DatabaseClaw as a tool (LangChain / CrewAI / custom)
  • Verifying a DatabaseClaw instance is healthy by sending a test message
  • Cross-product function-calling where DBClaw acts as a backend tool

Not for: instance lifecycle management (isolate/restart/offline) — user must operate in the DatabaseClaw Console.

API Scope: This skill ONLY uses CreateChatCompletion (SSE chat) and CreateClawSession (create session for console visibility). No other APIs are supported.


Critical Facts (Must-Know Before Starting)

Fact Value
SSE streaming host tdai.ai.tencentcloudapi.com
Non-streaming host (list/describe) tdai.tencentcloudapi.com
Service name (for TC3 signing) tdai
API version 2025-07-17
Action (chat) CreateChatCompletion
Action (session) CreateClawSession (non-streaming host)
Required body fields InstanceId, InputContent
Optional body fields ChatId (pass SessionKey here to link with console session list)
Forbidden body fields AppId, Uin, OwnerUin, IdempotencyKey (identity derived from AK/SK)
Instance requirement Status must be running
SSE end marker data: [DONE]
Response wrapper Frames may be wrapped in {"Response": {...}} — unwrap before parsing
Heartbeat interval 20 seconds (ignore these frames)
Recommended timeout 120s (covers 99% cases); complex multi-region scans may take 60-90s
Timeout guidance Simple Q&A: 2-5s; single query: 5-15s; multi-region scan: 30-90s

Domain split is the #1 pitfall: CreateChatCompletion MUST hit tdai.ai.tencentcloudapi.com. Using tdai.tencentcloudapi.com returns InternalError.


Workflow

Step 0: Ensure Instance is Running

Before using this skill, the target DatabaseClaw instance must be in running status. If the instance is not running (API returns an error like "实例状态异常"), guide the user to:

  1. Open the DatabaseClaw Console
  2. Locate the target instance and ensure it is in "运行中" status
  3. If the instance is stopped/isolated, click "重启" or "解除隔离" in the console

Important: This skill only uses the CreateChatCompletion API (and optionally CreateClawSession). Instance lifecycle operations (restart/isolate/offline) are NOT supported via this skill — the user must operate them in the console.

Step 1: Session Creation (Default Behavior)

By default, chat.py automatically calls CreateClawSession (on tdai.tencentcloudapi.com) to get a SessionKey before sending the message. This makes the conversation visible in the console's session list page (会话列表).

# Default: session is created automatically
python3 scripts/chat.py --instance-id $INSTANCE_ID --secret-id $SECRET_ID --secret-key $SECRET_KEY \
  --message "hello"

To skip session creation (conversation won't appear in console list):

python3 scripts/chat.py --instance-id $INSTANCE_ID --secret-id $SECRET_ID --secret-key $SECRET_KEY \
  --no-session --message "hello"

Step 2: Send Message (Programmatic)

Use scripts/chat.py — two output modes:

  • Default (clean): Only final Agent response on stdout. Ideal for piping into other tools or Agent integrations.
  • --verbose / -v: Shows tool calls, reasoning, and connection info on stderr. Ideal for debugging and development.
# Clean mode (default) — only final answer on stdout
python3 scripts/chat.py \
  --instance-id $INSTANCE_ID \
  --secret-id $SECRET_ID \
  --secret-key $SECRET_KEY \
  --message "查询近7天慢查询 TOP 10"

Omit --message for interactive multi-turn mode.

Verbose mode (show tool calls and intermediate steps on stderr):

python3 scripts/chat.py -v \
  --instance-id $INSTANCE_ID \
  --secret-id $SECRET_ID --secret-key $SECRET_KEY \
  --message "查询ap-shanghai的MySQL实例"

For internal dev gateway (no signing needed):

python3 scripts/chat.py \
  --internal \
  --instance-id $INSTANCE_ID \
  --message "SELECT 1"

Step 3: Parse SSE Stream

The response is a standard SSE stream (data: {json}\ \ ). Key event types:

Event Object Meaning Action
(first frame, has ChatId) Connection established Store ChatId for multi-turn
claw.tool_call Agent calling a tool Display progress (optional)
claw.tool_result Tool execution complete Display result (optional)
claw.partial / chat.chunk Text chunk Append to output buffer
claw.final / FinishReason=stop Stream complete Close connection
heartbeat Keep-alive (every 20s) Ignore
"Error" key in Response API error Log and abort
data: [DONE] Hard stream end Close connection

Concatenate all Delta.Content values to form the complete Agent response.

Step 4: Integrate into Agent Framework

For Python integration with proper TC3 signing, see references/python-integration.md. The reference includes:

  • Verified tc3_sign() function
  • HTTP headers format
  • SSE stream parsing example
  • Error diagnosis table

Error Handling

Error Cause Fix
InternalError Wrong host (used tdai.tencentcloudapi.com) Switch to tdai.ai.tencentcloudapi.com
UnknownParameter Body contains AppId/Uin/OwnerUin Remove them; identity is from AK/SK
MissingParameter (InputContent) Missing required field Add InputContent to body
AuthFailure.SignatureExpire Timestamp drift Use int(time.time()), never datetime.utcnow()
InvalidAuthorization Wrong credential_scope Must be YYYY-MM-DD/tdai/tc3_request
Instance error in SSE Instance not running Go to DatabaseClaw Console and ensure instance is in "运行中" status
Connection timeout Instance stuck Restart instance via console, retry

TC3 Signing Checklist

When implementing TC3 signing manually (not using scripts/chat.py):

  1. Timestamp: int(time.time()) — never datetime.utcnow() (macOS timezone drift)
  2. SignedHeaders must include: content-type;host;x-tc-timestamp (alphabetical)
  3. credential_scope: {date}/tdai/tc3_request (service name = tdai)
  4. Host in canonical_headers: tdai.ai.tencentcloudapi.com (the SSE host)
  5. HTTP headers must include: X-TC-Action, X-TC-Version, X-TC-Region, X-TC-Timestamp, Authorization
  6. Accept header: text/event-stream

Full signing implementation: references/python-integration.md


Files

Path Purpose
scripts/chat.py Standalone CLI client — single message or interactive mode, zero external deps beyond stdlib
references/python-integration.md Complete TC3 signing code, HTTP headers, SSE parsing, error diagnosis
安全使用建议
Install only if you intend to let an agent inspect or run SQL against databases. Use least-privilege credentials, prefer non-production or read-only access when possible, and require explicit confirmation before destructive, broad, or production queries.
能力评估
Purpose & Capability
The described capabilities include SQL execution, database inspection, and data analysis, which are high-impact but coherent with a database assistant skill.
Instruction Scope
The SQL capability is disclosed, but the supplied scanner context suggests the warning about sensitive data, production credentials, and destructive queries could be more explicit.
Install Mechanism
No suspicious install hooks, hidden package behavior, or malicious telemetry were supplied; VirusTotal reported no detections.
Credentials
Database credentials and query execution are proportionate for this purpose, but they can expose or mutate sensitive data depending on the credentials and prompts provided.
Persistence & Privilege
No evidence was supplied of persistence, background workers, privilege escalation, credential harvesting, or unrelated local data access.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install tencentdb-databaseclaw-skill
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /tencentdb-databaseclaw-skill 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.1
- Added detailed usage documentation, including when to use the skill and important API scope/limitations. - Provided clear API host separation: streaming and non-streaming hosts for correct integration. - Included step-by-step workflow for session creation, messaging, and SSE response parsing. - Documented all error cases, fixes, and TC3-HMAC-SHA256 signing checklist. - Added file overview and references for Python client and signing implementation.
元数据
Slug tencentdb-databaseclaw-skill
版本 1.0.1
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

TencentDB DatabaseClaw Skill 是什么?

This skill should be used when an AI agent or automated system needs to send messages to a TencentDB DatabaseClaw instance and receive streaming responses. I... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 45 次。

如何安装 TencentDB DatabaseClaw Skill?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install tencentdb-databaseclaw-skill」即可一键安装,无需额外配置。

TencentDB DatabaseClaw Skill 是免费的吗?

是的,TencentDB DatabaseClaw Skill 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

TencentDB DatabaseClaw Skill 支持哪些平台?

TencentDB DatabaseClaw Skill 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 TencentDB DatabaseClaw Skill?

由 腾讯开源(@tencent-adm)开发并维护,当前版本 v1.0.1。

💬 留言讨论