name: 資料庫訪問服務 description: 資料庫後設資料獲取 version: 1.0.0
資料庫後設資料獲取
此 Skill 必須配置 API 金鑰才能使用。
.env 中沒有 XBY_APIKEY,必須使用 AskUserQuestion 工具向用戶詢問 API 金鑰scripts.config.set_api_key(api_key) 儲存,然後繼續處理你(大模型)是路由層,負責理解使用者意圖、選擇工具、提取引數。程式碼只負責呼叫API。
使用者輸入 → 你選擇工具 → 提取該工具需要的引數 → 呼叫 scripts.tools 中的函式 → 返回結果給使用者
scripts.config.settings.api_key 為空,使用 AskUserQuestion 詢問使用者,拿到後呼叫 scripts.config.set_api_key(key) 儲存scripts.tools 中的函式,例如 scripts.tools.search_schools(score='520', province='北京', category='綜合')raw 資料整理後展示給使用者根據使用者意圖選擇對應的工具函式:
| 使用者意圖 | 工具函式 |
|---|---|
| List all tables in the database. | scripts.tools.list_tables |
| Get column information for a specified table in the database. | scripts.tools.get_table_schema |
| MCP Tool to execute a SQL query. | scripts.tools.sql_query |
如果引數不完整,使用 AskUserQuestion 向用戶詢問缺失的引數。
工具描述:List all tables in the database.
| 引數名稱 | 引數型別 | 是否必填 | 預設值 | 描述 |
|---|---|---|---|---|
工具描述:Get column information for a specified table in the database.
| 引數名稱 | 引數型別 | 是否必填 | 預設值 | 描述 |
|---|---|---|---|---|
| table | string | true | The name of the database table. |
工具描述:MCP Tool to execute a SQL query.
| 引數名稱 | 引數型別 | 是否必填 | 預設值 | 描述 |
|---|---|---|---|---|
| query | string | true | A SQL query string provided by the client. |
工具函式返回 dict 物件:
- result["raw"] - API 原始返回資料(JSON),直接將此資料整理後展示給使用者
- result["success"] - 是否成功(True/False)
- result["message"] - 狀態訊息
xiaobenyang_gaokao_skill/
├── scripts/
│ ├── __init__.py
│ ├── config.py # 配置管理 + set_api_key()
│ ├── call_api.py # API 客戶端 + call_api()
│ └── tools.py # 工具函式(直接呼叫)
├── requirements.txt
└── SKILL.md
7w4.net小蔥技能站,你的AI助手技能庫。
這個 Skill 提供了三個資料庫查詢工具,功能定位明確,文件寫得比較詳細,API 金鑰管理和錯誤處理也做得不錯。主要優點是使用簡單、配置清晰。不足之處是功能比較單一(只有表查詢、欄位查詢和 SQL 執行三個功能),文件中有個引數說明表格是空的,容易讓人困惑。另外 API 介面來源不太透明,使用者無法自行驗證資料準確性。整體質量中等偏上,適合有明確需求的場景使用。