devtu-auto-discover-apis
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAutomated Life Science API Discovery & Tool Creation
生命科学API自动发现与工具创建
Discover, create, validate, and integrate life science APIs into ToolUniverse through fully automated workflows with human review checkpoints.
通过带有人工审核检查点的全自动化工作流,将生命科学API发现、创建、验证并集成到ToolUniverse中。
When to Use This Skill
何时使用此技能
Use this skill when:
- Expanding ToolUniverse coverage in underrepresented domains
- Systematically discovering new life science APIs and databases
- Building a batch of tools from multiple APIs at once
- Identifying gaps in current ToolUniverse tool coverage
- Automating the tool creation pipeline from discovery to PR
- Adding emerging APIs from recent publications or releases
Triggers: "find new APIs", "expand tool coverage", "discover missing tools", "add APIs for [domain]"
在以下场景使用此技能:
- 扩展ToolUniverse在代表性不足领域的覆盖范围
- 系统性发现新的生命科学API和数据库
- 一次性基于多个API构建批量工具
- 识别当前ToolUniverse工具覆盖的缺口
- 自动化从发现到PR的工具创建流程
- 添加近期发布或文献中提到的新兴API
触发词:"find new APIs", "expand tool coverage", "discover missing tools", "add APIs for [domain]"
Table of Contents
目录
Overview
概述
This skill orchestrates a complete pipeline:
Gap Analysis → API Discovery → Tool Creation → Validation → Integration
↓ ↓ ↓ ↓ ↓
Coverage Web Search devtu-create devtu-fix Git PR
Report + Docs patterns validation ReadyAutomation Level: Fully automated with human approval gates at:
- After gap analysis (approve focus areas)
- After tool creation (review generated tools)
- Before PR submission (final review)
Authentication Handling: Supports public APIs, API keys, OAuth, and complex authentication schemes
Output: Working tool files (.py + .json), validation reports, discovery documentation, and integration-ready PRs
此技能编排完整的流水线:
差距分析 → API发现 → 工具创建 → 验证 → 集成
↓ ↓ ↓ ↓ ↓
覆盖范围 网络搜索 devtu-create devtu-fix Git PR
报告 + 文档 模式 验证 待审核自动化级别:全自动化,在以下节点设置人工审批关卡:
- 差距分析后(批准重点领域)
- 工具创建后(审核生成的工具)
- PR提交前(最终审核)
认证处理:支持公共API、API密钥、OAuth和复杂认证方案
输出:可运行的工具文件(.py + .json)、验证报告、发现文档和待集成的PR
Four-Phase Workflow
四阶段工作流
Phase 1: Discovery & Gap Analysis (15-30 minutes)
阶段1:发现与差距分析(15-30分钟)
Objectives:
- Analyze current ToolUniverse tools by domain/category
- Identify underrepresented areas (gap domains)
- Search web for APIs in gap domains
- Scrape API documentation for endpoints and schemas
- Generate discovery report with prioritized candidates
Key Activities:
- Load ToolUniverse and categorize existing tools
- Calculate coverage metrics by domain
- Execute targeted web searches for gaps
- Extract API metadata from documentation
- Score APIs by quality, coverage, and integration feasibility
Output: with prioritized API candidates
discovery_report.md目标:
- 按领域/类别分析当前ToolUniverse工具
- 识别代表性不足的领域(缺口领域)
- 搜索缺口领域的API
- 抓取API文档的端点和模式
- 生成包含优先级候选API的发现报告
关键活动:
- 加载ToolUniverse并对现有工具分类
- 按领域计算覆盖指标
- 针对缺口执行定向网络搜索
- 从文档中提取API元数据
- 按质量、覆盖范围和集成可行性对API评分
输出:,包含优先级API候选列表
discovery_report.mdPhase 2: Tool Creation (30-60 minutes per API)
阶段2:工具创建(每个API 30-60分钟)
Objectives:
- Design tool architecture (multi-operation vs single-operation)
- Generate Python tool classes following devtu-create-tool patterns
- Create JSON configurations with proper schemas
- Handle authentication (API keys, OAuth, tokens)
- Generate realistic test examples
Key Activities:
- Map API endpoints to ToolUniverse operations
- Generate tool class with error handling
- Create return schemas with oneOf + data wrapper structure
- Find real test IDs from API documentation
- Register in default_config.py
Output: and files for each tool
.py.json目标:
- 设计工具架构(多操作 vs 单操作)
- 遵循devtu-create-tool模式生成Python工具类
- 创建带正确模式的JSON配置
- 处理认证(API密钥、OAuth、令牌)
- 生成真实的测试示例
关键活动:
- 将API端点映射到ToolUniverse操作
- 生成带错误处理的工具类
- 创建包含oneOf + 数据包装结构的返回模式
- 从API文档中查找真实测试ID
- 在default_config.py中注册
输出:每个API对应的和文件
.py.jsonPhase 3: Validation (10-20 minutes per tool)
阶段3:验证(每个工具10-20分钟)
Objectives:
- Run automated schema validation
- Execute integration tests with real API calls
- Verify devtu compliance (6-step checklist)
- Check tool loading in ToolUniverse
- Generate validation reports
Key Activities:
- Run
python scripts/test_new_tools.py <tool> -v - Verify return_schema has oneOf structure
- Test examples use real IDs (no placeholders)
- Confirm tools load into ToolUniverse registry
- Apply devtu-fix-tool patterns for any failures
Output: with pass/fail metrics
validation_report.md目标:
- 运行自动化模式验证
- 通过真实API调用执行集成测试
- 验证devtu合规性(6步检查清单)
- 检查工具在ToolUniverse中的加载情况
- 生成验证报告
关键活动:
- 运行
python scripts/test_new_tools.py <tool> -v - 验证return_schema包含oneOf结构
- 测试示例使用真实ID(无占位符)
- 确认工具加载到ToolUniverse注册表
- 对任何失败应用devtu-fix-tool模式
输出:,包含通过/失败指标
validation_report.mdPhase 4: Integration (5-10 minutes)
阶段4:集成(5-10分钟)
Objectives:
- Create git branch for new tools
- Commit tools with descriptive messages
- Generate PR with full documentation
- Include discovery notes and validation results
Key Activities:
- Create feature branch:
feature/add-<api-name>-tools - Commit tool files with Co-Authored-By Claude
- Write PR description with API info, tool list, validation results
- Push to remote and create PR
Output: Integration-ready PR for human review
目标:
- 为新工具创建Git分支
- 用描述性消息提交工具
- 生成带完整文档的PR
- 包含发现说明和验证结果
关键活动:
- 创建功能分支:
feature/add-<api-name>-tools - 提交工具文件并添加Co-Authored-By Claude
- 编写包含API信息、工具列表、验证结果的PR描述
- 推送到远程仓库并创建PR
输出:待人工审核的可集成PR
Phase 1: Discovery & Gap Analysis
阶段1:发现与差距分析
Step 1.1: Analyze Current Coverage
步骤1.1:分析当前覆盖范围
Load and categorize existing tools:
-
Initialize ToolUniverse and load all tools
-
Extract tool names and descriptions
-
Categorize by domain using keywords:
- Genomics: sequence, genome, gene, variant, SNP
- Proteomics: protein, structure, PDB, fold, domain
- Drug Discovery: drug, compound, molecule, ligand, ADMET
- Clinical: disease, patient, trial, phenotype, diagnosis
- Omics: expression, transcriptome, metabolome, proteome
- Imaging: microscopy, imaging, scan, radiology
- Literature: pubmed, citation, publication, article
- Pathways: pathway, network, interaction, signaling
- Systems Biology: model, simulation, flux, dynamics
-
Count tools per category
-
Calculate coverage percentages
Output: Coverage matrix with tool counts
加载并分类现有工具:
-
初始化ToolUniverse并加载所有工具
-
提取工具名称和描述
-
使用关键词按领域分类:
- 基因组学:sequence, genome, gene, variant, SNP
- 蛋白质组学:protein, structure, PDB, fold, domain
- 药物发现:drug, compound, molecule, ligand, ADMET
- 临床:disease, patient, trial, phenotype, diagnosis
- 组学:expression, transcriptome, metabolome, proteome
- 成像:microscopy, imaging, scan, radiology
- 文献:pubmed, citation, publication, article
- 通路:pathway, network, interaction, signaling
- 系统生物学:model, simulation, flux, dynamics
-
统计每个类别的工具数量
-
计算覆盖百分比
输出:带工具数量的覆盖矩阵
Step 1.2: Identify Gap Domains
步骤1.2:识别缺口领域
Find underrepresented areas:
Gap Detection Criteria:
- Critical Gap: <5 tools in category (or 0 tools)
- Moderate Gap: 5-15 tools but missing key subcategories
- Emerging Gap: New technologies not yet represented
Common Gap Areas (as of 2026):
- Single-cell genomics (spatial transcriptomics, ATAC-seq)
- Metabolomics databases (metabolite structures, pathways)
- Patient registries (rare disease, specific conditions)
- Clinical variant databases (somatic, germline beyond ClinVar)
- Microbial genomics (metagenomics, pathogen databases)
- Multi-omics integration platforms
- Synthetic biology tools (parts, circuits, chassis)
- Toxicology databases
- Agricultural genomics
Prioritization Factors:
- Impact: How many researchers need this?
- Complementarity: Fills existing workflow gaps?
- Quality: Well-documented, maintained API?
- Accessibility: Public or simple authentication?
- Freshness: Recent updates, active development?
发现代表性不足的领域:
缺口检测标准:
- 关键缺口:类别中工具数<5(或0个)
- 中等缺口:5-15个工具但缺少关键子类别
- 新兴缺口:尚未有代表的新技术
常见缺口领域(截至2026年):
- 单细胞基因组学(空间转录组学、ATAC-seq)
- 代谢组学数据库(代谢物结构、通路)
- 患者注册库(罕见病、特定病症)
- 临床变异数据库(体细胞、除ClinVar外的生殖系)
- 微生物基因组学(宏基因组学、病原体数据库)
- 多组学整合平台
- 合成生物学工具(元件、电路、底盘)
- 毒理学数据库
- 农业基因组学
优先级因素:
- 影响:有多少研究人员需要它?
- 互补性:是否填补现有工作流缺口?
- 质量:文档完善、维护良好的API?
- 可访问性:公共或简单认证?
- 新鲜度:近期更新、活跃开发?
Step 1.3: Web Search for Gap APIs
步骤1.3:搜索缺口领域的API
Search Strategy:
For each gap domain, execute multiple search queries:
-
Direct API Search:
- "[domain] API REST JSON"
- "[domain] database API documentation"
- "[domain] web services programmatic access"
-
Database Discovery:
- "[domain] public database"
- "list of [domain] databases"
- "[domain] resources bioinformatics"
-
Recent Releases:
- "[domain] API 2025 OR 2026"
- "new [domain] database"
-
Academic Sources:
- "[domain] database" site:nar.oxfordjournals.org (NAR Database Issue)
- "[domain] tool" site:bioinformatics.oxfordjournals.org
Documentation Extraction:
For each discovered API:
- Find base URL and version
- List available endpoints
- Identify authentication method
- Extract parameter schemas
- Find example requests/responses
- Check rate limits and terms of service
搜索策略:
针对每个缺口领域,执行多个搜索查询:
-
直接API搜索:
- "[domain] API REST JSON"
- "[domain] database API documentation"
- "[domain] web services programmatic access"
-
数据库发现:
- "[domain] public database"
- "list of [domain] databases"
- "[domain] resources bioinformatics"
-
近期发布:
- "[domain] API 2025 OR 2026"
- "new [domain] database"
-
学术来源:
- "[domain] database" site:nar.oxfordjournals.org(NAR数据库特刊)
- "[domain] tool" site:bioinformatics.oxfordjournals.org
文档提取:
针对每个发现的API:
- 查找基础URL和版本
- 列出可用端点
- 识别认证方法
- 提取参数模式
- 查找示例请求/响应
- 检查速率限制和服务条款
Step 1.4: Score and Prioritize APIs
步骤1.4:API评分与优先级排序
Scoring Matrix (0-100 points):
| Criterion | Max Points | Evaluation |
|---|---|---|
| Documentation Quality | 20 | OpenAPI/Swagger=20, detailed docs=15, basic=10, poor=5 |
| API Stability | 15 | Versioned+stable=15, versioned=10, unversioned=5 |
| Authentication | 15 | Public/API-key=15, OAuth=10, complex=5 |
| Coverage | 15 | Comprehensive=15, good=10, limited=5 |
| Maintenance | 10 | Active (updates <6mo)=10, moderate=6, stale=2 |
| Community | 10 | Popular (citations/stars)=10, moderate=6, unknown=2 |
| License | 10 | Open/Academic=10, free commercial=7, restricted=3 |
| Rate Limits | 5 | Generous=5, moderate=3, restrictive=1 |
Prioritization:
- High Priority (≥70 points): Implement immediately
- Medium Priority (50-69): Implement if time permits
- Low Priority (<50): Document for future consideration
评分矩阵(0-100分):
| 标准 | 最高分 | 评估 |
|---|---|---|
| 文档质量 | 20 | OpenAPI/Swagger=20,详细文档=15,基础文档=10,差=5 |
| API稳定性 | 15 | 版本化+稳定=15,版本化=10,无版本=5 |
| 认证方式 | 15 | 公共/API密钥=15,OAuth=10,复杂=5 |
| 覆盖范围 | 15 | 全面=15,良好=10,有限=5 |
| 维护状态 | 10 | 活跃(更新<6个月)=10,中等=6,停滞=2 |
| 社区热度 | 10 | 流行(引用/星标多)=10,中等=6,未知=2 |
| 许可证 | 10 | 开源/学术=10,免费商用=7,受限=3 |
| 速率限制 | 5 | 宽松=5,中等=3,严格=1 |
优先级排序:
- 高优先级(≥70分):立即实现
- 中等优先级(50-69分):时间允许时实现
- 低优先级(<50分):记录供未来考虑
Step 1.5: Generate Discovery Report
步骤1.5:生成发现报告
Report Structure:
markdown
undefined报告结构:
markdown
undefinedAPI Discovery Report
API发现报告
Generated: [Timestamp]
生成时间:[时间戳]
Executive Summary
执行摘要
- Total APIs discovered: X
- High priority: Y
- Gap domains addressed: Z
- 发现的API总数:X
- 高优先级:Y
- 覆盖的缺口领域:Z
Coverage Analysis
覆盖分析
[Table showing tool counts by category, gaps highlighted]
[显示各类别工具数量的表格,高亮缺口]
Prioritized API Candidates
优先级API候选
High Priority
高优先级
1. [API Name]
1. [API名称]
- Domain: [Category]
- Score: [Points]/100
- Base URL: [URL]
- Auth: [Method]
- Endpoints: [Count]
- Rationale: [Why this fills a gap]
- Example Operations:
- Operation 1: Description
- Operation 2: Description
[Repeat for each high-priority API]
- 领域:[类别]
- 评分:[分数]/100
- 基础URL:[URL]
- 认证:[方法]
- 端点数量:[Count]
- 理由:[填补缺口的原因]
- 示例操作:
- 操作1:描述
- 操作2:描述
[重复每个高优先级API]
Medium Priority
中等优先级
[Similar structure]
[类似结构]
Implementation Roadmap
实施路线图
- Batch 1 (Week 1): [APIs]
- Batch 2 (Week 2): [APIs]
- 第一批(第1周):[APIs]
- 第二批(第2周):[APIs]
Appendix: Search Methodology
附录:搜索方法
[Search queries used, sources consulted]
---[使用的搜索查询、参考来源]
---Phase 2: Tool Creation
阶段2:工具创建
Step 2.1: Design Tool Architecture
步骤2.1:设计工具架构
Decision Tree:
API has multiple endpoints?
├─ YES → Multi-operation tool (single class, multiple JSON wrappers)
└─ NO → Consider if more endpoints likely in future
├─ YES → Still use multi-operation (future-proof)
└─ NO → Single-operation acceptableMulti-Operation Pattern (Recommended):
- One Python class handles all operations
- Each endpoint gets a JSON wrapper
- Operations routed via parameter
operation
File Naming:
- Python:
src/tooluniverse/[api_name]_tool.py - JSON:
src/tooluniverse/data/[api_name]_tools.json - Category key: (lowercase, underscores)
[api_category]
决策树:
API有多个端点?
├─ 是 → 多操作工具(单个类,多个JSON包装器)
└─ 否 → 考虑未来是否可能添加更多端点
├─ 是 → 仍使用多操作(面向未来)
└─ 否 → 单操作可接受多操作模式(推荐):
- 一个Python类处理所有操作
- 每个端点对应一个JSON包装器
- 通过参数路由操作
operation
文件命名:
- Python:
src/tooluniverse/[api_name]_tool.py - JSON:
src/tooluniverse/data/[api_name]_tools.json - 类别键:(小写,下划线分隔)
[api_category]
Step 2.2: Generate Python Tool Class
步骤2.2:生成Python工具类
Template Structure:
python
from typing import Dict, Any
from tooluniverse.tool import BaseTool
from tooluniverse.tool_utils import register_tool
import requests
import os
@register_tool("[APIName]Tool")
class [APIName]Tool(BaseTool):
"""Tool for [API Name] - [brief description]."""
BASE_URL = "[API base URL]"
def __init__(self, tool_config):
super().__init__(tool_config)
self.parameter = tool_config.get("parameter", {})
self.required = self.parameter.get("required", [])
# For optional API keys
self.api_key = os.environ.get("[API_KEY_NAME]", "")
def run(self, arguments: Dict[str, Any]) -> Dict[str, Any]:
"""Route to operation handler."""
operation = arguments.get("operation")
if not operation:
return {"status": "error", "error": "Missing required parameter: operation"}
# Route to handlers
if operation == "operation1":
return self._operation1(arguments)
elif operation == "operation2":
return self._operation2(arguments)
else:
return {"status": "error", "error": f"Unknown operation: {operation}"}
def _operation1(self, arguments: Dict[str, Any]) -> Dict[str, Any]:
"""Description of operation1."""
# Validate required parameters
param1 = arguments.get("param1")
if not param1:
return {"status": "error", "error": "Missing required parameter: param1"}
try:
# Build request
headers = {}
if self.api_key:
headers["Authorization"] = f"Bearer {self.api_key}"
# Make API call
response = requests.get(
f"{self.BASE_URL}/endpoint",
params={"param1": param1},
headers=headers,
timeout=30
)
response.raise_for_status()
# Parse response
data = response.json()
# Return with data wrapper
return {
"status": "success",
"data": data.get("results", []),
"metadata": {
"total": data.get("total", 0),
"source": "[API Name]"
}
}
except requests.exceptions.Timeout:
return {"status": "error", "error": "API timeout after 30 seconds"}
except requests.exceptions.HTTPError as e:
return {"status": "error", "error": f"HTTP {e.response.status_code}: {e.response.text[:200]}"}
except Exception as e:
return {"status": "error", "error": f"Unexpected error: {str(e)}"}Critical Requirements:
- Always return
{"status": "success|error", "data": {...}} - NEVER raise exceptions in method
run() - Set timeout on all HTTP requests (30s recommended)
- Handle specific exceptions (Timeout, HTTPError, ConnectionError)
- Include helpful error messages with context
模板结构:
python
from typing import Dict, Any
from tooluniverse.tool import BaseTool
from tooluniverse.tool_utils import register_tool
import requests
import os
@register_tool("[APIName]Tool")
class [APIName]Tool(BaseTool):
"""Tool for [API Name] - [brief description]."""
BASE_URL = "[API base URL]"
def __init__(self, tool_config):
super().__init__(tool_config)
self.parameter = tool_config.get("parameter", {})
self.required = self.parameter.get("required", [])
# 可选API密钥
self.api_key = os.environ.get("[API_KEY_NAME]", "")
def run(self, arguments: Dict[str, Any]) -> Dict[str, Any]:
"""路由到操作处理函数。"""
operation = arguments.get("operation")
if not operation:
return {"status": "error", "error": "Missing required parameter: operation"}
# 路由到处理函数
if operation == "operation1":
return self._operation1(arguments)
elif operation == "operation2":
return self._operation2(arguments)
else:
return {"status": "error", "error": f"Unknown operation: {operation}"}
def _operation1(self, arguments: Dict[str, Any]) -> Dict[str, Any]:
"""Description of operation1."""
# 验证必填参数
param1 = arguments.get("param1")
if not param1:
return {"status": "error", "error": "Missing required parameter: param1"}
try:
# 构建请求
headers = {}
if self.api_key:
headers["Authorization"] = f"Bearer {self.api_key}"
# 发起API调用
response = requests.get(
f"{self.BASE_URL}/endpoint",
params={"param1": param1},
headers=headers,
timeout=30
)
response.raise_for_status()
# 解析响应
data = response.json()
# 带数据包装器返回
return {
"status": "success",
"data": data.get("results", []),
"metadata": {
"total": data.get("total", 0),
"source": "[API Name]"
}
}
except requests.exceptions.Timeout:
return {"status": "error", "error": "API timeout after 30 seconds"}
except requests.exceptions.HTTPError as e:
return {"status": "error", "error": f"HTTP {e.response.status_code}: {e.response.text[:200]}"}
except Exception as e:
return {"status": "error", "error": f"Unexpected error: {str(e)}"}关键要求:
- 始终返回格式
{"status": "success|error", "data": {...}} - 方法中绝不抛出异常
run() - 所有HTTP请求设置超时(推荐30秒)
- 处理特定异常(Timeout、HTTPError、ConnectionError)
- 包含带上下文的有用错误消息
Step 2.3: Generate JSON Configuration
步骤2.3:生成JSON配置
Template Structure:
json
[
{
"name": "[APIName]_operation1",
"class": "[APIName]Tool",
"description": "[What it does]. Returns [data format]. [Input details]. Example: [usage example]. [Special notes].",
"parameter": {
"type": "object",
"required": ["operation", "param1"],
"properties": {
"operation": {
"const": "operation1",
"description": "Operation identifier (fixed)"
},
"param1": {
"type": "string",
"description": "Description of param1 with format/constraints"
}
}
},
"return_schema": {
"oneOf": [
{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {"type": "string"},
"name": {"type": "string"}
}
}
},
"metadata": {
"type": "object",
"properties": {
"total": {"type": "integer"},
"source": {"type": "string"}
}
}
}
},
{
"type": "object",
"properties": {
"error": {"type": "string"}
},
"required": ["error"]
}
]
},
"test_examples": [
{
"operation": "operation1",
"param1": "real_value_from_api_docs"
}
]
}
]Critical Requirements:
- return_schema MUST have oneOf: Success schema + error schema
- Success schema MUST have data field: Top-level wrapper required
data - test_examples MUST use real IDs: NO "TEST", "DUMMY", "PLACEHOLDER", "example_*"
- Tool name ≤55 characters: For MCP compatibility
- Description 150-250 chars: Include what, format, example, special notes
模板结构:
json
[
{
"name": "[APIName]_operation1",
"class": "[APIName]Tool",
"description": "[功能说明]。返回[数据格式]。[输入细节]。示例:[使用示例]。[特殊说明]。",
"parameter": {
"type": "object",
"required": ["operation", "param1"],
"properties": {
"operation": {
"const": "operation1",
"description": "Operation identifier (fixed)"
},
"param1": {
"type": "string",
"description": "Description of param1 with format/constraints"
}
}
},
"return_schema": {
"oneOf": [
{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {"type": "string"},
"name": {"type": "string"}
}
}
},
"metadata": {
"type": "object",
"properties": {
"total": {"type": "integer"},
"source": {"type": "string"}
}
}
}
},
{
"type": "object",
"properties": {
"error": {"type": "string"}
},
"required": ["error"]
}
]
},
"test_examples": [
{
"operation": "operation1",
"param1": "real_value_from_api_docs"
}
]
}
]关键要求:
- return_schema必须包含oneOf:成功模式 + 错误模式
- 成功模式必须包含data字段:顶层包装器是必填项
data - test_examples必须使用真实ID:禁止使用"TEST", "DUMMY", "PLACEHOLDER", "example_*"
- 工具名称≤55字符:兼容MCP
- 描述150-250字符:包含功能、格式、示例、特殊说明
Step 2.4: Handle Authentication
步骤2.4:处理认证
Authentication Patterns:
认证模式:
Pattern 1: Public API (No Auth)
模式1:公共API(无需认证)
python
undefinedpython
undefinedNo special handling needed
无需特殊处理
response = requests.get(url, params=params, timeout=30)
undefinedresponse = requests.get(url, params=params, timeout=30)
undefinedPattern 2: API Key (Optional)
模式2:API密钥(可选)
python
undefinedpython
undefinedIn init
在__init__中
self.api_key = os.environ.get("API_KEY_NAME", "")
self.api_key = os.environ.get("API_KEY_NAME", "")
In JSON config
在JSON配置中
"optional_api_keys": ["API_KEY_NAME"],
"description": "... Rate limits: 3 req/sec without key, 10 req/sec with API_KEY_NAME."
"optional_api_keys": ["API_KEY_NAME"],
"description": "... 速率限制:无密钥3次/秒,使用API_KEY_NAME为10次/秒。"
In request
在请求中
headers = {}
if self.api_key:
headers["Authorization"] = f"Bearer {self.api_key}"
response = requests.get(url, headers=headers, timeout=30)
undefinedheaders = {}
if self.api_key:
headers["Authorization"] = f"Bearer {self.api_key}"
response = requests.get(url, headers=headers, timeout=30)
undefinedPattern 3: API Key (Required)
模式3:API密钥(必填)
python
undefinedpython
undefinedIn init
在__init__中
self.api_key = os.environ.get("API_KEY_NAME")
if not self.api_key:
raise ValueError("API_KEY_NAME environment variable required")
self.api_key = os.environ.get("API_KEY_NAME")
if not self.api_key:
raise ValueError("API_KEY_NAME环境变量为必填项")
In JSON config
在JSON配置中
"required_api_keys": ["API_KEY_NAME"]
"required_api_keys": ["API_KEY_NAME"]
In request
在请求中
headers = {"Authorization": f"Bearer {self.api_key}"}
response = requests.get(url, headers=headers, timeout=30)
undefinedheaders = {"Authorization": f"Bearer {self.api_key}"}
response = requests.get(url, headers=headers, timeout=30)
undefinedPattern 4: OAuth (Complex)
模式4:OAuth(复杂)
python
undefinedpython
undefinedDocument in skill: requires manual OAuth setup
在技能中记录:需要手动设置OAuth
Store tokens in environment
将令牌存储在环境变量中
Implement token refresh logic
实现令牌刷新逻辑
Include example OAuth flow in documentation
在文档中包含OAuth流程示例
undefinedundefinedStep 2.5: Find Real Test Examples
步骤2.5:查找真实测试示例
Strategy: List → Get pattern
- Find List Endpoint: Identify endpoint that lists resources
- Extract Real ID: Call list endpoint, extract first valid ID
- Test Get Endpoint: Verify ID works in detail endpoint
- Document in test_examples: Use discovered real ID
Example Process:
1. API docs show: GET /items → returns [{id: "ABC123", ...}]
2. Make request: curl https://api.example.com/items
3. Extract: id = "ABC123"
4. Verify: curl https://api.example.com/items/ABC123 → 200 OK
5. Use in test_examples: {"operation": "get_item", "item_id": "ABC123"}Fallback: Search API documentation examples, tutorial code, or forum posts for real IDs
策略:列表 → 获取模式
- 查找列表端点:识别列出资源的端点
- 提取真实ID:调用列表端点,提取第一个有效ID
- 测试详情端点:验证ID在详情端点中可用
- 记录到test_examples:使用发现的真实ID
示例流程:
1. API文档显示:GET /items → 返回 [{id: "ABC123", ...}]
2. 发起请求:curl https://api.example.com/items
3. 提取:id = "ABC123"
4. 验证:curl https://api.example.com/items/ABC123 → 200 OK
5. 在test_examples中使用:{"operation": "get_item", "item_id": "ABC123"}备选方案:在API文档示例、教程代码或论坛帖子中搜索真实ID
Step 2.6: Register in default_config.py
步骤2.6:在default_config.py中注册
Add to :
src/tooluniverse/default_config.pypython
TOOLS_CONFIGS = {
# ... existing entries ...
"[api_category]": os.path.join(current_dir, "data", "[api_name]_tools.json"),
}Critical: This step is commonly missed! Tools won't load without it.
添加到:
src/tooluniverse/default_config.pypython
TOOLS_CONFIGS = {
# ... 现有条目 ...
"[api_category]": os.path.join(current_dir, "data", "[api_name]_tools.json"),
}注意:这一步常被遗漏!没有此步骤工具无法加载。
Phase 3: Validation
阶段3:验证
Step 3.1: Schema Validation
步骤3.1:模式验证
Check return_schema structure:
python
import json
with open("src/tooluniverse/data/[api_name]_tools.json") as f:
tools = json.load(f)
for tool in tools:
schema = tool.get("return_schema", {})
# Must have oneOf
assert "oneOf" in schema, f"{tool['name']}: Missing oneOf in return_schema"
# oneOf must have 2 schemas (success + error)
assert len(schema["oneOf"]) == 2, f"{tool['name']}: oneOf must have 2 schemas"
# Success schema must have 'data' field
success_schema = schema["oneOf"][0]
assert "properties" in success_schema, f"{tool['name']}: Missing properties in success schema"
assert "data" in success_schema["properties"], f"{tool['name']}: Missing 'data' field in success schema"
print(f"✅ {tool['name']}: Schema valid")检查return_schema结构:
python
import json
with open("src/tooluniverse/data/[api_name]_tools.json") as f:
tools = json.load(f)
for tool in tools:
schema = tool.get("return_schema", {})
# 必须包含oneOf
assert "oneOf" in schema, f"{tool['name']}: Missing oneOf in return_schema"
# oneOf必须包含2个模式(成功 + 错误)
assert len(schema["oneOf"]) == 2, f"{tool['name']}: oneOf must have 2 schemas"
# 成功模式必须包含'data'字段
success_schema = schema["oneOf"][0]
assert "properties" in success_schema, f"{tool['name']}: Missing properties in success schema"
assert "data" in success_schema["properties"], f"{tool['name']}: Missing 'data' field in success schema"
print(f"✅ {tool['name']}: Schema valid")Step 3.2: Test Example Validation
步骤3.2:测试示例验证
Check for placeholder values:
python
PLACEHOLDER_PATTERNS = [
"test", "dummy", "placeholder", "example", "sample",
"xxx", "temp", "fake", "mock", "your_"
]
for tool in tools:
examples = tool.get("test_examples", [])
for i, example in enumerate(examples):
for key, value in example.items():
if isinstance(value, str):
value_lower = value.lower()
if any(pattern in value_lower for pattern in PLACEHOLDER_PATTERNS):
print(f"❌ {tool['name']}: test_examples[{i}][{key}] contains placeholder: {value}")
else:
print(f"✅ {tool['name']}: test_examples[{i}][{key}] appears real")检查占位符值:
python
PLACEHOLDER_PATTERNS = [
"test", "dummy", "placeholder", "example", "sample",
"xxx", "temp", "fake", "mock", "your_"
]
for tool in tools:
examples = tool.get("test_examples", [])
for i, example in enumerate(examples):
for key, value in example.items():
if isinstance(value, str):
value_lower = value.lower()
if any(pattern in value_lower for pattern in PLACEHOLDER_PATTERNS):
print(f"❌ {tool['name']}: test_examples[{i}][{key}] contains placeholder: {value}")
else:
print(f"✅ {tool['name']}: test_examples[{i}][{key}] appears real")Step 3.3: Tool Loading Verification
步骤3.3:工具加载验证
Verify three-step registration:
python
import sys
sys.path.insert(0, 'src')验证三步注册流程:
python
import sys
sys.path.insert(0, 'src')Step 1: Check class registered
步骤1:检查类是否注册
from tooluniverse.tool_registry import get_tool_registry
import tooluniverse.[api_name]_tool
registry = get_tool_registry()
assert "[APIName]Tool" in registry, "❌ Step 1 FAILED: Class not registered"
print("✅ Step 1: Class registered")
from tooluniverse.tool_registry import get_tool_registry
import tooluniverse.[api_name]_tool
registry = get_tool_registry()
assert "[APIName]Tool" in registry, "❌ Step 1 FAILED: Class not registered"
print("✅ Step 1: Class registered")
Step 2: Check config registered
步骤2:检查配置是否注册
from tooluniverse.default_config import TOOLS_CONFIGS
assert "[api_category]" in TOOLS_CONFIGS, "❌ Step 2 FAILED: Config not in default_config.py"
print("✅ Step 2: Config registered")
from tooluniverse.default_config import TOOLS_CONFIGS
assert "[api_category]" in TOOLS_CONFIGS, "❌ Step 2 FAILED: Config not in default_config.py"
print("✅ Step 2: Config registered")
Step 3: Check wrappers generated
步骤3:检查包装器是否生成
from tooluniverse import ToolUniverse
tu = ToolUniverse()
tu.load_tools()
assert hasattr(tu.tools, '[APIName]_operation1'), "❌ Step 3 FAILED: Wrapper not generated"
print("✅ Step 3: Wrappers generated")
print("✅ All registration steps complete!")
undefinedfrom tooluniverse import ToolUniverse
tu = ToolUniverse()
tu.load_tools()
assert hasattr(tu.tools, '[APIName]_operation1'), "❌ Step 3 FAILED: Wrapper not generated"
print("✅ Step 3: Wrappers generated")
print("✅ All registration steps complete!")
undefinedStep 3.4: Integration Tests
步骤3.4:集成测试
Run test_new_tools.py:
bash
undefined运行test_new_tools.py:
bash
undefinedTest specific tools
测试特定工具
python scripts/test_new_tools.py [api_name] -v
python scripts/test_new_tools.py [api_name] -v
Expected output:
预期输出:
Testing [APIName]_operation1...
Testing [APIName]_operation1...
✅ PASS - Schema valid
✅ PASS - Schema valid
Results:
结果:
Total: 3 tests
总计:3个测试
Passed: 3 (100.0%)
通过:3个(100.0%)
Failed: 0
失败:0
Schema invalid: 0
模式无效:0
**Handle failures**:
- **404 ERROR**: Invalid test example ID → find real ID
- **Schema Mismatch**: return_schema doesn't match response → fix schema
- **Timeout**: API slow/down → increase timeout or add retry
- **Parameter Error**: Wrong parameter names → verify with API docs
**处理失败**:
- **404错误**:测试示例ID无效 → 查找真实ID
- **模式不匹配**:return_schema与响应不符 → 修复模式
- **超时**:API缓慢/不可用 → 增加超时或添加重试
- **参数错误**:参数名称错误 → 与API文档验证Step 3.5: Generate Validation Report
步骤3.5:生成验证报告
Report Structure:
markdown
undefined报告结构:
markdown
undefinedValidation Report: [API Name]
验证报告:[API名称]
Generated: [Timestamp]
生成时间:[时间戳]
Summary
摘要
- Total tools: X
- Passed: Y (Z%)
- Failed: N
- Schema issues: M
- 工具总数:X
- 通过:Y(Z%)
- 失败:N
- 模式问题:M
Tool Loading
工具加载
- Class registered in tool_registry
- Config registered in default_config.py
- Wrappers generated in tools/
- 类已在tool_registry中注册
- 配置已在default_config.py中注册
- 包装器已在tools/中生成
Schema Validation
模式验证
- All tools have oneOf structure
- All success schemas have data wrapper
- All error schemas have error field
- 所有工具都有oneOf结构
- 所有成功模式都有data包装器
- 所有错误模式都有error字段
Test Examples
测试示例
- No placeholder values detected
- All examples use real IDs
- 未检测到占位符值
- 所有示例使用真实ID
Integration Tests
集成测试
[APIName]_operation1
[APIName]_operation1
- Status: ✅ PASS
- Response time: 1.2s
- Schema: Valid
- 状态:✅ PASS
- 响应时间:1.2s
- 模式:有效
[APIName]_operation2
[APIName]_operation2
- Status: ✅ PASS
- Response time: 0.8s
- Schema: Valid
- 状态:✅ PASS
- 响应时间:0.8s
- 模式:有效
Issues Found
发现的问题
None - all tests passing!
无 - 所有测试通过!
devtu Compliance Checklist
devtu合规性检查清单
- Tool Loading: Verified
- API Verification: Checked against docs
- Error Pattern Detection: None found
- Schema Validation: All valid
- Test Examples: All real IDs
- Parameter Verification: Matched API requirements
- 工具加载:已验证
- API验证:已对照文档检查
- 错误模式检测:未发现
- 模式验证:全部有效
- 测试示例:全部为真实ID
- 参数验证:匹配API要求
Conclusion
结论
All tools ready for integration.
---所有工具已准备好集成。
---Phase 4: Integration
阶段4:集成
Step 4.1: Create Git Branch
步骤4.1:创建Git分支
bash
undefinedbash
undefinedCreate feature branch
创建功能分支
git checkout -b feature/add-[api-name]-tools
git checkout -b feature/add-[api-name]-tools
Verify clean state
检查干净状态
git status
undefinedgit status
undefinedStep 4.2: Commit Tool Files
步骤4.2:提交工具文件
Commit structure:
bash
undefined提交结构:
bash
undefinedStage tool files
暂存工具文件
git add src/tooluniverse/[api_name]_tool.py
git add src/tooluniverse/data/[api_name]_tools.json
git add src/tooluniverse/default_config.py
git add src/tooluniverse/[api_name]_tool.py
git add src/tooluniverse/data/[api_name]_tools.json
git add src/tooluniverse/default_config.py
Commit with descriptive message
用描述性消息提交
git commit -m "$(cat <<'EOF'
Add [API Name] tools for [domain]
Implements X tools for [API Name] API:
- [APIName]_operation1: Description
- [APIName]_operation2: Description
- [APIName]_operation3: Description
API Details:
- Base URL: [URL]
- Authentication: [Method]
- Documentation: [URL]
Coverage:
- Addresses gap in [domain] tools
- Enables [use cases]
Validation:
- All tests passing (X/X passed)
- 100% schema validation
- Real test examples verified
Co-Authored-By: Claude Sonnet 4.5 noreply@anthropic.com
EOF
)"
undefinedgit commit -m "$(cat <<'EOF'
Add [API Name] tools for [domain]
为[API Name] API实现了X个工具:
- [APIName]_operation1:描述
- [APIName]_operation2:描述
- [APIName]_operation3:描述
API详情:
- 基础URL:[URL]
- 认证方式:[Method]
- 文档:[URL]
覆盖范围:
- 填补[domain]工具的关键缺口
- 支持[使用场景]
验证结果:
- 所有测试通过(X/X通过)
- 100%模式验证通过
- 真实测试示例已验证
Co-Authored-By: Claude Sonnet 4.5 noreply@anthropic.com
EOF
)"
undefinedStep 4.3: Generate PR Description
步骤4.3:生成PR描述
PR Template:
markdown
undefinedPR模板:
markdown
undefinedAdd [API Name] Tools
添加[API名称]工具
Summary
摘要
Adds X new tools integrating the [API Name] API for [domain] research.
添加了X个新工具,集成[API名称] API以支持[domain]研究。
Motivation
动机
Current ToolUniverse has limited coverage in [domain]. These tools fill critical gaps:
- Gap 1: [Description]
- Gap 2: [Description]
当前ToolUniverse在[domain]领域覆盖有限。这些工具填补了以下关键缺口:
- 缺口1:[描述]
- 缺口2:[描述]
API Information
API信息
- Name: [API Name]
- Base URL: [URL]
- Documentation: [URL]
- Authentication: [Method]
- Rate Limits: [Details]
- License: [License type]
- 名称:[API Name]
- 基础URL:[URL]
- 文档:[URL]
- 认证方式:[Method]
- 速率限制:[详情]
- 许可证:[许可证类型]
Tools Added
添加的工具
| Tool Name | Operation | Description |
|---|---|---|
| [APIName]_operation1 | operation1 | [Description] |
| [APIName]_operation2 | operation2 | [Description] |
| 工具名称 | 操作 | 描述 |
|---|---|---|
| [APIName]_operation1 | operation1 | [描述] |
| [APIName]_operation2 | operation2 | [描述] |
Validation Results
验证结果
✅ All tests passing (X/X passed)
✅ 100% schema validation
✅ Real test examples verified
✅ devtu compliance checklist complete
✅ 所有测试通过(X/X通过)
✅ 100%模式验证通过
✅ 真实测试示例已验证
✅ devtu合规性检查清单已完成
Test Output
测试输出
Testing [APIName] tools...
Total: X tests
Passed: X (100.0%)
Failed: 0
Schema invalid: 0Testing [APIName] tools...
Total: X tests
Passed: X (100.0%)
Failed: 0
Schema invalid: 0Files Changed
修改的文件
- - Tool implementation
src/tooluniverse/[api_name]_tool.py - - Tool configurations
src/tooluniverse/data/[api_name]_tools.json - - Registration
src/tooluniverse/default_config.py
- - 工具实现
src/tooluniverse/[api_name]_tool.py - - 工具配置
src/tooluniverse/data/[api_name]_tools.json - - 注册信息
src/tooluniverse/default_config.py
Discovery & Prioritization
发现与优先级
- Discovery Score: [Score]/100
- Priority: High
- Rationale: [Why this API was prioritized]
- 发现评分:[Score]/100
- 优先级:高
- 理由:[选择此API的原因]
Usage Examples
使用示例
python
from tooluniverse import ToolUniverse
tu = ToolUniverse()
tu.load_tools()python
from tooluniverse import ToolUniverse
tu = ToolUniverse()
tu.load_tools()Example 1: [Operation 1]
示例1:[操作1]
result = tu.tools.[APIName]_operation1(
operation="operation1",
param1="value"
)
result = tu.tools.[APIName]_operation1(
operation="operation1",
param1="value"
)
Example 2: [Operation 2]
示例2:[操作2]
result = tu.tools.[APIName]_operation2(
operation="operation2",
param1="value"
)
undefinedresult = tu.tools.[APIName]_operation2(
operation="operation2",
param1="value"
)
undefinedRelated Issues
相关问题
- Closes #[issue number if applicable]
- Addresses gap identified in [previous discussion/issue]
- 关闭 #[问题编号(如有)]
- 解决[先前讨论/问题]中提出的缺口
Checklist
检查清单
- All tests passing
- Schema validation complete
- Real test examples
- No placeholder values
- Tool names ≤55 chars
- default_config.py updated
- Documentation clear
- Error handling comprehensive
- 所有测试通过
- 模式验证完成
- 真实测试示例
- 无占位符值
- 工具名称≤55字符
- default_config.py已更新
- 文档清晰
- 错误处理全面
Additional Notes
额外说明
[Any special considerations, limitations, or future enhancements]
Generated by devtu-auto-discover-apis skill
Discovery Report: [link to discovery_report.md]
Validation Report: [link to validation_report.md]
undefined[任何特殊注意事项、限制或未来增强计划]
由devtu-auto-discover-apis技能生成
发现报告:[discovery_report.md链接]
验证报告:[validation_report.md链接]
undefinedStep 4.4: Push and Create PR
步骤4.4:推送并创建PR
bash
undefinedbash
undefinedPush branch to remote
将分支推送到远程仓库
git push -u origin feature/add-[api-name]-tools
git push -u origin feature/add-[api-name]-tools
Create PR using gh CLI
使用gh CLI创建PR
gh pr create
--title "Add [API Name] tools for [domain]"
--body-file pr_description.md
--label "enhancement,tools"
--title "Add [API Name] tools for [domain]"
--body-file pr_description.md
--label "enhancement,tools"
gh pr create
--title "Add [API Name] tools for [domain]"
--body-file pr_description.md
--label "enhancement,tools"
--title "Add [API Name] tools for [domain]"
--body-file pr_description.md
--label "enhancement,tools"
Get PR URL
获取PR URL
gh pr view --web
---gh pr view --web
---Configuration Options
配置选项
Agent Configuration
Agent配置
yaml
undefinedyaml
undefinedconfig.yaml (optional)
config.yaml(可选)
discovery:
focus_domains:
- "metabolomics"
- "single-cell"
exclude_domains:
- "deprecated_category"
max_apis_per_batch: 5
search:
max_results_per_query: 20
include_academic_sources: true
date_filter: "2024-2026"
creation:
architecture: "multi-operation" # or "auto-detect"
include_async_support: true
timeout_seconds: 30
validation:
run_integration_tests: true
require_100_percent_pass: true
max_retries: 3
integration:
auto_create_pr: false # Require manual approval
branch_prefix: "feature/add-"
pr_labels: ["enhancement", "tools"]
undefineddiscovery:
focus_domains:
- "metabolomics"
- "single-cell"
exclude_domains:
- "deprecated_category"
max_apis_per_batch: 5
search:
max_results_per_query: 20
include_academic_sources: true
date_filter: "2024-2026"
creation:
architecture: "multi-operation" # 或 "auto-detect"
include_async_support: true
timeout_seconds: 30
validation:
run_integration_tests: true
require_100_percent_pass: true
max_retries: 3
integration:
auto_create_pr: false # 需要手动批准
branch_prefix: "feature/add-"
pr_labels: ["enhancement", "tools"]
undefinedUser Inputs
用户输入
Required:
- None (fully automated with defaults)
Optional:
- : List of specific domains to prioritize
focus_domains - : Specific APIs to integrate (skip discovery)
api_names - : Number of APIs to process in one run
batch_size - : Skip human approval gates (not recommended)
auto_approve
必填:
- 无(使用默认值全自动化)
可选:
- :要优先处理的特定领域列表
focus_domains - :要集成的特定API(跳过发现阶段)
api_names - :一次运行处理的API数量
batch_size - :跳过人工审批关卡(不推荐)
auto_approve
Output Artifacts
输出产物
Generated During Execution
执行期间生成
-
discovery_report.md
- Coverage analysis
- Gap identification
- Prioritized API candidates
- Implementation roadmap
-
[api_name]_tool.py (per API)
- Python tool class implementation
- Error handling
- Authentication logic
-
[api_name]_tools.json (per API)
- Tool configurations
- Parameter schemas
- Return schemas
- Test examples
-
validation_report.md (per API)
- Schema validation results
- Integration test results
- devtu compliance checklist
- Issues found and resolved
-
pr_description.md (per batch)
- Comprehensive PR description
- Validation results
- Usage examples
-
discovery_report.md
- 覆盖分析
- 缺口识别
- 优先级API候选
- 实施路线图
-
[api_name]_tool.py(每个API)
- Python工具类实现
- 错误处理
- 认证逻辑
-
[api_name]_tools.json(每个API)
- 工具配置
- 参数模式
- 返回模式
- 测试示例
-
validation_report.md(每个API)
- 模式验证结果
- 集成测试结果
- devtu合规性检查清单
- 发现并解决的问题
-
pr_description.md(每批)
- 全面的PR描述
- 验证结果
- 使用示例
Persistent Logs
持久化日志
- discovery_log.json: All APIs discovered with metadata
- creation_log.json: Tool creation decisions and rationale
- validation_log.json: Detailed test results
- integration_log.json: Git operations and PR links
- discovery_log.json:所有发现的API及其元数据
- creation_log.json:工具创建决策和理由
- validation_log.json:详细测试结果
- integration_log.json:Git操作和PR链接
Quality Gates
质量关卡
Gate 1: Post-Discovery (Human Approval)
关卡1:发现后(人工批准)
Review: discovery_report.md
Decision:
- ✅ Approve: Prioritization looks good → proceed to creation
- 🔄 Modify: Change priorities, focus domains
- ❌ Abort: No suitable APIs found
审核:discovery_report.md
决策:
- ✅ 批准:优先级设置合理 → 进入创建阶段
- 🔄 修改:调整优先级、重点领域
- ❌ 中止:未找到合适的API
Gate 2: Post-Creation (Human Approval)
关卡2:创建后(人工批准)
Review: Generated .py and .json files
Decision:
- ✅ Approve: Implementation looks good → proceed to validation
- 🔄 Modify: Adjust parameters, schemas, examples
- ❌ Abort: API integration not feasible
审核:生成的.py和.json文件
决策:
- ✅ 批准:实现符合要求 → 进入验证阶段
- 🔄 修改:调整参数、模式、示例
- ❌ 中止:API集成不可行
Gate 3: Post-Validation (Human Approval)
关卡3:验证后(人工批准)
Review: validation_report.md
Decision:
- ✅ Approve: All tests passing → proceed to integration
- 🔄 Fix: Apply devtu-fix-tool patterns, retry validation
- ❌ Abort: Fundamental issues with API
审核:validation_report.md
决策:
- ✅ 批准:所有测试通过 → 进入集成阶段
- 🔄 修复:应用devtu-fix-tool模式,重新验证
- ❌ 中止:API存在根本性问题
Gate 4: Pre-PR (Human Approval)
关卡4:PR提交前(人工批准)
Review: Full PR description
Decision:
- ✅ Approve: Create PR and push
- 🔄 Modify: Edit commit messages, PR description
- ❌ Abort: Not ready for integration
审核:完整的PR描述
决策:
- ✅ 批准:创建并推送PR
- 🔄 修改:编辑提交消息、PR描述
- ❌ 中止:未准备好集成
Common Patterns
常见模式
Pattern 1: Batch Processing
模式1:批量处理
Process multiple APIs in one execution:
Discovery → [API1, API2, API3] → Create All → Validate All → Single PRBenefits: Efficient, cohesive PR
Use When: APIs from same domain, similar structure
一次执行处理多个API:
发现 → [API1, API2, API3] → 创建所有 → 验证所有 → 单个PR优势:高效,PR内聚
适用场景:同一领域、结构相似的API
Pattern 2: Iterative Single-API
模式2:迭代单API
Process one API at a time with validation:
Discovery → API1 → Create → Validate → Integrate
→ API2 → Create → Validate → IntegrateBenefits: Catch issues early, smaller PRs
Use When: APIs have complex authentication, novel patterns
逐个处理API并验证:
发现 → API1 → 创建 → 验证 → 集成
→ API2 → 创建 → 验证 → 集成优势:早期发现问题,PR更小
适用场景:认证复杂、模式新颖的API
Pattern 3: Discovery-Only Mode
模式3:仅发现模式
Just discover and document APIs, create tools later:
Discovery → Generate Report → [Manual Review] → Schedule ImplementationBenefits: Rapid survey of landscape
Use When: Planning long-term roadmap, research phase
仅发现并记录API,后续再创建工具:
发现 → 生成报告 → [人工审核] → 安排实施优势:快速调研领域现状
适用场景:规划长期路线图、研究阶段
Pattern 4: Validation-Only Mode
模式4:仅验证模式
Validate previously created tools:
[Existing Tools] → Validation → Fix Issues → Re-validate → ReportBenefits: Quality assurance for existing tools
Use When: Reviewing PRs, auditing tool quality
验证已创建的工具:
[现有工具] → 验证 → 修复问题 → 重新验证 → 报告优势:为现有工具提供质量保证
适用场景:审核PR、审计工具质量
Troubleshooting
故障排除
Issue 1: API Documentation Not Found
问题1:API文档未找到
Symptom: Web search finds API reference but no programmatic docs
Solutions:
- Check for OpenAPI/Swagger spec (often at or
/api/docs)/openapi.json - Look for SDKs in GitHub (reverse-engineer from SDK code)
- Inspect browser network tab on web interface
- Contact API provider for documentation
- Document as "low priority" for future manual integration
症状:网络搜索到API参考但无编程文档
解决方案:
- 查找OpenAPI/Swagger规范(通常在或
/api/docs)/openapi.json - 在GitHub查找SDK(从SDK代码反向工程)
- 检查Web界面的浏览器网络标签
- 联系API提供商获取文档
- 标记为“低优先级”供未来人工集成
Issue 2: Authentication Too Complex
问题2:认证过于复杂
Symptom: OAuth flow requires interactive login, token management
Solutions:
- Document OAuth setup in skill README
- Implement token refresh logic
- Use environment variables for tokens
- Create setup guide for users
- Consider if API worth the complexity
症状:OAuth流程需要交互式登录、令牌管理
解决方案:
- 在技能README中记录OAuth设置步骤
- 实现令牌刷新逻辑
- 使用环境变量存储令牌
- 为用户创建设置指南
- 评估API是否值得投入复杂度
Issue 3: No Real Test Examples Available
问题3:无真实测试示例可用
Symptom: Can't find valid IDs for test_examples
Solutions:
- Use List endpoint to discover IDs
- Search API documentation for examples
- Check API GitHub issues/discussions for sample data
- Use API playground/sandbox if available
- Contact API provider for test IDs
- Last resort: Create test data via API POST endpoints
症状:无法找到有效的测试ID
解决方案:
- 使用列表端点发现ID
- 在API文档中搜索示例
- 查看API GitHub问题/讨论中的样本数据
- 使用API沙箱/游乐场(如有)
- 联系API提供商获取测试ID
- 最后手段:通过API POST端点创建测试数据
Issue 4: Tools Won't Load
问题4:工具无法加载
Symptom: ToolUniverse doesn't see new tools
Solutions:
- Check registration (Step 2 of 3-step process)
default_config.py - Verify JSON syntax:
python -m json.tool file.json - Check class decorator:
@register_tool("ClassName") - Run verification script (see Phase 3, Step 3.3)
- Clear Python cache:
find . -type d -name __pycache__ -exec rm -rf {} + - Regenerate wrappers:
python -m tooluniverse.generate_tools --force
症状:ToolUniverse无法识别新工具
解决方案:
- 检查中的注册信息(三步流程的步骤2)
default_config.py - 验证JSON语法:
python -m json.tool file.json - 检查类装饰器:
@register_tool("ClassName") - 运行验证脚本(见阶段3,步骤3.3)
- 清除Python缓存:
find . -type d -name __pycache__ -exec rm -rf {} + - 重新生成包装器:
python -m tooluniverse.generate_tools --force
Issue 5: Schema Validation Fails
问题5:模式验证失败
Symptom: return_schema doesn't match actual API response
Solutions:
- Call API directly, inspect raw response
- Update return_schema to match actual structure
- Add nullable types for optional fields:
{"type": ["string", "null"]} - Use oneOf for fields with multiple possible structures
- Ensure data wrapper in success schema
- Check for nested data structures
症状:return_schema与实际API响应不匹配
解决方案:
- 直接调用API,检查原始响应
- 更新return_schema以匹配实际结构
- 为可选字段添加可空类型:
{"type": ["string", "null"]} - 对结构多样的字段使用oneOf
- 确保成功模式中包含数据包装器
- 检查嵌套数据结构
Issue 6: Rate Limits Hit During Testing
问题6:测试中触发速率限制
Symptom: API returns 429 Too Many Requests
Solutions:
- Add rate limiting to tool: between requests
time.sleep(1) - Use optional API key if available (higher limits)
- Reduce number of test examples
- Implement exponential backoff on retry
- Document rate limits in tool description
症状:API返回429 Too Many Requests
解决方案:
- 为工具添加速率限制:请求间
time.sleep(1) - 如有可用,使用可选API密钥(更高限制)
- 减少测试示例数量
- 实现指数退避重试
- 在工具描述中记录速率限制
Issue 7: API Changed Since Documentation
问题7:API与文档不符
Symptom: Parameters/endpoints don't match docs
Solutions:
- Check API version (may need to specify in base URL)
- Look for API changelog or migration guide
- Test with different API versions
- Update documentation URL to correct version
- Contact API maintainers about discrepancy
症状:参数/端点与文档不一致
解决方案:
- 检查API版本(可能需要在基础URL中指定)
- 查找API变更日志或迁移指南
- 测试不同API版本
- 更新文档URL到正确版本
- 联系API维护者反馈差异
Advanced Features
高级功能
Async Polling Support
异步轮询支持
For job-based APIs (submit → poll → retrieve):
python
def _submit_job(self, arguments: Dict[str, Any]) -> Dict[str, Any]:
"""Submit job and poll for completion."""
# Submit
submit_resp = requests.post(
f"{self.BASE_URL}/jobs",
json={"data": arguments.get("data")},
timeout=30
)
job_id = submit_resp.json().get("job_id")
# Poll (with timeout)
for attempt in range(60): # 2 min max
status_resp = requests.get(
f"{self.BASE_URL}/jobs/{job_id}",
timeout=30
)
result = status_resp.json()
if result.get("status") == "completed":
return {"status": "success", "data": result.get("results")}
elif result.get("status") == "failed":
return {"status": "error", "error": result.get("error")}
time.sleep(2)
return {"status": "error", "error": "Job timeout after 2 minutes"}JSON Config:
json
{
"is_async": true,
"poll_interval": 2,
"max_wait_time": 120
}针对基于任务的API(提交 → 轮询 → 获取结果):
python
def _submit_job(self, arguments: Dict[str, Any]) -> Dict[str, Any]:
"""提交任务并轮询完成状态。"""
# 提交任务
submit_resp = requests.post(
f"{self.BASE_URL}/jobs",
json={"data": arguments.get("data")},
timeout=30
)
job_id = submit_resp.json().get("job_id")
# 轮询(带超时)
for attempt in range(60): # 最长2分钟
status_resp = requests.get(
f"{self.BASE_URL}/jobs/{job_id}",
timeout=30
)
result = status_resp.json()
if result.get("status") == "completed":
return {"status": "success", "data": result.get("results")}
elif result.get("status") == "failed":
return {"status": "error", "error": result.get("error")}
time.sleep(2)
return {"status": "error", "error": "Job timeout after 2 minutes"}JSON配置:
json
{
"is_async": true,
"poll_interval": 2,
"max_wait_time": 120
}SOAP API Support
SOAP API支持
For SOAP-based APIs:
python
undefined针对基于SOAP的API:
python
undefinedAdd operation parameter
添加operation参数
def run(self, arguments: Dict[str, Any]) -> Dict[str, Any]:
operation = arguments.get("operation")
if not operation:
return {"status": "error", "error": "SOAP APIs require 'operation' parameter"}
# ... rest of implementation
**JSON Config**:
```json
{
"parameter": {
"properties": {
"operation": {
"const": "search_items",
"description": "SOAP operation name (required)"
}
}
}
}def run(self, arguments: Dict[str, Any]) -> Dict[str, Any]:
operation = arguments.get("operation")
if not operation:
return {"status": "error", "error": "SOAP APIs require 'operation' parameter"}
# ... 其余实现
**JSON配置**:
```json
{
"parameter": {
"properties": {
"operation": {
"const": "search_items",
"description": "SOAP operation name (required)"
}
}
}
}Pagination Handling
分页处理
For paginated APIs:
python
def _list_all(self, arguments: Dict[str, Any]) -> Dict[str, Any]:
"""Fetch all pages."""
all_results = []
page = 1
while True:
response = requests.get(
f"{self.BASE_URL}/items",
params={"page": page, "limit": 100},
timeout=30
)
data = response.json()
results = data.get("results", [])
if not results:
break
all_results.extend(results)
if len(results) < 100: # Last page
break
page += 1
return {
"status": "success",
"data": all_results,
"metadata": {"total_pages": page, "total_items": len(all_results)}
}针对分页API:
python
def _list_all(self, arguments: Dict[str, Any]) -> Dict[str, Any]:
"""获取所有页面数据。"""
all_results = []
page = 1
while True:
response = requests.get(
f"{self.BASE_URL}/items",
params={"page": page, "limit": 100},
timeout=30
)
data = response.json()
results = data.get("results", [])
if not results:
break
all_results.extend(results)
if len(results) < 100: # 最后一页
break
page += 1
return {
"status": "success",
"data": all_results,
"metadata": {"total_pages": page, "total_items": len(all_results)}
}Success Criteria
成功标准
Discovery Phase Success
发现阶段成功
- ✅ Coverage analysis complete with tool counts
- ✅ ≥3 high-priority APIs identified
- ✅ API documentation URLs verified accessible
- ✅ Authentication methods documented
- ✅ Discovery report generated
- ✅ 完成覆盖分析并统计工具数量
- ✅ 识别出≥3个高优先级API
- ✅ 验证API文档URL可访问
- ✅ 记录认证方法
- ✅ 生成发现报告
Creation Phase Success
创建阶段成功
- ✅ All tool classes implement
@register_tool() - ✅ All JSON configs have proper structure
- ✅ return_schema has oneOf with data wrapper
- ✅ test_examples use real IDs (no placeholders)
- ✅ Tool names ≤55 characters
- ✅ default_config.py updated
- ✅ 所有工具类实现
@register_tool() - ✅ 所有JSON配置结构正确
- ✅ return_schema包含带数据包装器的oneOf
- ✅ test_examples使用真实ID(无占位符)
- ✅ 工具名称≤55字符
- ✅ 更新default_config.py
Validation Phase Success
验证阶段成功
- ✅ All tools load into ToolUniverse
- ✅ test_new_tools.py shows 100% pass rate
- ✅ No schema validation errors
- ✅ devtu compliance checklist complete
- ✅ Validation report generated
- ✅ 所有工具加载到ToolUniverse
- ✅ test_new_tools.py显示100%通过率
- ✅ 无模式验证错误
- ✅ 完成devtu合规性检查清单
- ✅ 生成验证报告
Integration Phase Success
集成阶段成功
- ✅ Git branch created successfully
- ✅ Commits follow format with Co-Authored-By
- ✅ PR description comprehensive
- ✅ PR created and URL provided
- ✅ All files included in PR
- ✅ 成功创建Git分支
- ✅ 提交信息符合格式并包含Co-Authored-By
- ✅ PR描述全面
- ✅ 创建PR并提供URL
- ✅ 所有文件包含在PR中
Maintenance
维护
Updating Discovered APIs
更新发现的API
Re-run discovery periodically to find:
- New APIs in existing domains
- Emerging technologies (new domains)
- API version updates
- Deprecated APIs to remove
Recommended: Quarterly discovery runs
定期重新运行发现流程以查找:
- 现有领域的新API
- 新兴技术(新领域)
- API版本更新
- 需移除的废弃API
推荐:每季度运行一次发现流程
Monitoring Tool Health
监控工具健康状态
Track tool success rates:
python
undefined跟踪工具成功率:
python
undefinedPeriodic health check
定期健康检查
from tooluniverse import ToolUniverse
tu = ToolUniverse()
tu.load_tools()
for tool_name in tu.all_tool_dict.keys():
# Run with test_examples
# Log success/failure rates
# Alert on degradation
undefinedfrom tooluniverse import ToolUniverse
tu = ToolUniverse()
tu.load_tools()
for tool_name in tu.all_tool_dict.keys():
# 使用test_examples运行
# 记录成功/失败率
# 性能下降时发出警报
undefinedGap Analysis Automation
差距分析自动化
Set up automated gap detection:
- Weekly: Scan ToolUniverse for new tools
- Update coverage metrics
- Compare with target coverage goals
- Generate gap report
- Trigger discovery for critical gaps
设置自动化缺口检测:
- 每周:扫描ToolUniverse的新工具
- 更新覆盖指标
- 与目标覆盖目标对比
- 生成缺口报告
- 针对关键缺口触发发现流程
Summary
总结
The skill provides a complete automation pipeline for:
devtu-auto-discover-apis- Discovery: Systematic identification of API gaps and candidates
- Creation: Automated tool generation following devtu-create-tool patterns
- Validation: Comprehensive testing with devtu-fix-tool integration
- Integration: Git workflow management with PR generation
Key Benefits:
- Reduces manual tool creation time by 80%
- Ensures consistent quality through automated validation
- Systematic gap filling improves ToolUniverse coverage
- Lowers barrier to adding new APIs
Best Practices:
- Always verify API documentation before creation
- Use real test examples (never placeholders)
- Follow devtu validation workflow strictly
- Include human approval at quality gates
- Document authentication requirements clearly
Apply this skill to systematically expand ToolUniverse with high-quality, validated tools for life science research.
devtu-auto-discover-apis- 发现:系统性识别API缺口和候选API
- 创建:遵循devtu-create-tool模式自动生成工具
- 验证:与devtu-fix-tool集成的全面测试
- 集成:Git工作流管理与PR生成
核心优势:
- 减少80%的手动工具创建时间
- 通过自动化验证确保一致质量
- 系统性填补缺口提升ToolUniverse覆盖范围
- 降低添加新API的门槛
最佳实践:
- 工具创建前始终验证API文档
- 使用真实测试示例(绝不使用占位符)
- 严格遵循devtu验证工作流
- 在质量关卡加入人工审批
- 清晰记录认证要求
应用此技能可系统性地为生命科学研究扩展ToolUniverse,添加高质量、经过验证的工具。