Tool Structure
A tool has three core components:- name - Unique identifier (e.g.,
"send_email","create_ticket") - description - Natural language description of what the tool does
- input - TypeBox schema defining expected parameters
- execute - Async function that performs the action
Registering Tools
Register tools via the Plugin API:Tool Options
Mark the tool as optional, requiring explicit allowlisting in agent config.Then allowlist in
config.json:Override the tool name (useful for tool factories).
Register multiple names for the same tool (for tool factories that generate multiple tools).
TypeBox Schemas
OpenClaw uses @sinclair/typebox for tool input schemas. TypeBox generates JSON Schema and provides TypeScript type inference.Basic Types
Arrays
Objects
Enums (String Literals)
Important: Do not useType.Union with enum-like values. Use the stringEnum helper from the plugin SDK:
stringEnum helper uses Type.Unsafe to generate a schema compatible with all LLM providers.
Nested Schemas
Tool Execution
Theexecute function receives validated parameters and returns a result:
Return Values
Tools should return an object with:result- Status string ("success","error","pending", etc.)details- Additional data (optional)error- Error message (for failures)
Async Operations
Tool execution can be async:Error Handling
Tool Context
Tools can access context via closures:Tool Factories
Tool factories generate tools dynamically based on context:- A single tool
- An array of tools
nullorundefined(to skip registration)

