mcpField
A
agent-tool-builder

agent-tool-builder

github.com/sickn33Agent 工作流48.7k962 次安装今天更新
代码仓库

关于 agent-tool-builder

用于设计 AI Agent 工具的技能,面向定义工具模式与行为的开发者。内容涵盖 JSON Schema、描述、验证、错误处理和 MCP,并强调实现必须落实安全与授权。

主要功能

  1. 01JSON Schema 设计指南
  2. 02工具描述编写
  3. 03验证与错误处理
  4. 04MCP 工具设计考量
  5. 05安全与授权测试

适用场景

  1. 01定义 Agent 工具的模式
  2. 02改进便于工具选择的描述
  3. 03规划验证与错误处理
  4. 04设计 MCP 工具

MCP 相关

介绍围绕新兴 MCP 标准设计 Agent 工具,涉及 MCP 工具设计,但不提供 MCP 服务。

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/sickn33/agentic-awesome-skills --skill agent-tool-builder

安装后在 Claude Code 中输入/agent-tool-builder确认已加载。

附带文件references/detailed-guide.md

详细介绍

Agent 工具构建器

工具是 AI Agent 与世界交互的方式。设计良好的工具,决定了 Agent 能否正常工作,还是会产生幻觉、悄无声息地失败或浪费令牌。

本技能涵盖从架构到错误处理的工具设计,包括 JSON Schema 最佳实践、编写真正能帮助大模型的描述、验证,以及正在兴起并逐渐成为 AI 工具通用语言的 MCP 标准。

描述有助于选择工具,但实现负责确保正确性、授权和安全性。两者都需要测试;模型也可能检查已公开的代码和结果。

详细指南

执行此技能前,请阅读详细指南。其中保留了完整流程和参考资料。必须遵循其中的安全要求、前提条件和验证要求。针对特定任务,请加载相关章节;若要端到端完成任务,请完整阅读指南。

历史 Python SDK 示例

仅用于模拟:固定天气数据是合成数据,并非当前天气预报。在进行任何会产生费用的调用前,请固定并验证 SDK 测试版 API,以及账户可访问的模型。工具需要有界的执行/审批策略;运行器不会授权外部操作。

import json
import anthropic
from anthropic import beta_tool

client = anthropic.Anthropic()

@beta_tool
def get_weather(location: str, unit: str = "fahrenheit") -> str:
    '''Get the current weather in a given location.

    Args:
        location: The city and state, e.g. San Francisco, CA
        unit: Temperature unit, either 'celsius' or 'fahrenheit'
    '''
    # Implementation
    return json.dumps({"temperature": "72°F", "conditions": "Sunny"})

@beta_tool
def search_web(query: str) -> str:
    '''Search the web for information.

    Args:
        query: The search query
    '''
    # Implementation
    return json.dumps({"results": [], "mock": True})

# Tool runner handles the loop
runner = client.beta.messages.tool_runner(
    model="claude-sonnet-4-5",
    max_tokens=1024,
    tools=[get_weather, search_web],
    messages=[
        {"role": "user", "content": "What's the weather in Paris?"}
    ]
)

# Process each message
for message in runner:
    for block in message.content:
        if getattr(block, "type", None) == "text":
            print(block.text)

# Or just get final result
final = runner.until_done()

适用场景

  • 用户提及或暗示:Agent 工具
  • 用户提及或暗示:函数调用
  • 用户提及或暗示:工具架构
  • 用户提及或暗示:工具设计
  • 用户提及或暗示:MCP 服务
  • 用户提及或暗示:MCP 工具
  • 用户提及或暗示:工具使用
  • 用户提及或暗示:为 Agent 构建工具
  • 用户提及或暗示:定义函数
  • 用户提及或暗示:input_schema
  • 用户提及或暗示:tool_use
  • 用户提及或暗示:tool_result

局限性

  • 仅当任务明确符合上述范围时,才使用此技能。
  • 不要将输出视为环境特定验证、测试或专家审查的替代品。
  • 如果缺少必要输入、权限、安全边界或成功标准,请停止并要求澄清。

评论

支持 Markdown