AgentSkillsCN

spoon-tool-development

为 SpoonOS 代理开发定制工具。适用于创建自定义工具、MCP 服务器、工具集扩展,或配置工具管理器时使用。

SKILL.md
--- frontmatter
name: spoon-tool-development
description: Develop tools for SpoonOS agents. Use when creating custom tools, MCP servers, toolkit extensions, or configuring tool managers.

Tool Development

Build tools for SpoonOS agents using BaseTool and FastMCP.

Tool Types

TypeUse Case
BaseToolLocal Python tools
MCPToolExternal MCP servers
FastMCPBuild MCP servers

Quick Start

python
from spoon_ai.tools.base import BaseTool
from pydantic import Field

class MyTool(BaseTool):
    name: str = "my_tool"
    description: str = "Tool description"
    parameters: dict = Field(default={
        "type": "object",
        "properties": {
            "param": {"type": "string"}
        },
        "required": ["param"]
    })

    async def execute(self, param: str) -> str:
        return f"Result: {param}"

Scripts

ScriptPurpose
base_tool.pyBaseTool implementation
mcp_tool.pyMCPTool configuration
fastmcp_server.pyFastMCP server
tool_manager.pyToolManager usage

References

ReferenceContent
error_handling.mdError patterns
testing.mdTesting tools

ToolManager Methods

MethodDescription
add_tool(tool)Add single tool
remove_tool(name)Remove by name
execute(name, input)Execute tool
to_params()Get OpenAI specs

Best Practices

  1. Use async for all I/O operations
  2. Return ToolResult/ToolFailure
  3. Validate inputs before execution
  4. Implement proper error handling
  5. Use environment variables for secrets