Import
Examples
Basic tool
Use with an agent
Load remote tools for an agent
API
tool(config)
Create a typed tool definition.
| Property | Type | Description | Source |
|---|---|---|---|
id? | string | Tool identifier (optional, inferred from filename) | source |
description | string | Tool description for the AI model | source |
inputSchema | Schema<TInput> | JsonSchema | Input schema produced via defineSchema((v) => …) (or any SchemaValidator-backed builder), or a raw JSON Schema object for dynamic/project-authored tools. Schema validators parse before execute; raw JSON Schema is passed through to providers without runtime parsing. | source |
outputSchema? | Schema<TOutput> | JsonSchema | Optional output schema. Hosts can use this to document or validate structured tool results. | source |
allowUnknownSchema? | boolean | Allow unknown/non-contract schemas to fall back to a permissive JSON schema. Use only for truly dynamic tools; prefer v.unknown() or v.any() from the SchemaValidator DSL instead. | source |
execute | (input: TInput, context?: ToolExecutionContext) => Promise<TOutput> | TOutput | Tool execution function | source |
mcp? | object | MCP configuration | source |
Tool<TInput, TOutput>
Exports
Components
| Name | Description | Source |
|---|---|---|
DEFAULT_SLEEP_TOOL_MAX_SECONDS | Default value for sleep tool max seconds. | source |
Functions
| Name | Description | Source |
|---|---|---|
createContext7ToolSource | Create context7 tool source. | source |
createProjectScopedRemoteToolCatalog | Create project scoped remote tool catalog. | source |
createRemoteMCPToolSource | Create remote MCP tool source. | source |
createSleepTool | Create sleep tool. | source |
createToolsFromHostDefinitions | Create tools from host definitions. | source |
createToolsFromHostDefinitions | Create tools from host definitions. | source |
createToolsFromHostDefinitions | Create tools from host definitions. | source |
createToolsFromRemoteDefinitions | Create tools from remote definitions. | source |
dynamicTool | Create a dynamic tool definition. | source |
executeTool | Execute a tool definition with validated input. | source |
filterProjectScopedRemoteToolDefinitions | Filter project scoped remote tool definitions. | source |
hasToolExecutionErrorMarker | Check whether tool execution error marker is present. | source |
hydrateProjectScopedRemoteToolInput | Input payload for hydrate project scoped remote tool. | source |
isErroredToolExecutionResult | Result returned from is errored tool execution. | source |
isProjectNavigationRemoteTool | Check whether a remote tool is project-navigation scoped. | source |
isRemoteToolNameAllowed | Check whether a remote tool name is allowed. | source |
listProjectScopedRemoteToolNames | List project scoped remote tool names. | source |
loadRemoteToolsFromSource | Loads remote tools from source. | source |
resolveProjectScopedRemoteToolProjectId | Resolves project scoped remote tool project ID. | source |
tool | Create a typed tool definition. | source |
traceHostTools | Wrap host tools with tracing metadata. | source |
Types
| Name | Description | Source |
|---|---|---|
Context7ToolSourceConfig | Configuration used by context7 tool source. | source |
CreateSleepToolOptions | Options accepted by create sleep tool. | source |
DynamicToolConfig | Configuration used by dynamic tool. | source |
HostToolDefinition | Definition for host tool. | source |
HostToolMaterializationOptions | Options accepted by host tool materialization. | source |
HostToolSet | Public API contract for host tool set. | source |
HostToolTraceAttributeInput | Input payload for host tool trace attribute. | source |
HostToolTraceAttributes | Public API contract for host tool trace attributes. | source |
HostToolTraceRunner | Public API contract for host tool trace runner. | source |
JsonSchema | Minimal JSON Schema type used by the SchemaValidator contract for toJsonSchema(). Kept in the extensions/schema category so the contract can reference it without depending on any non-leaf module. | source |
ListProjectScopedRemoteToolNameOptions | Options accepted by list project scoped remote tool name. | source |
ProjectScopedRemoteToolCatalog | Public API contract for project scoped remote tool catalog. | source |
ProjectScopedRemoteToolCatalogOptions | Options accepted by project scoped remote tool catalog. | source |
ProjectScopedRemoteToolDefaultProjectId | Public API contract for project scoped remote tool default project ID. | source |
ProjectScopedRemoteToolDefinitions | Public API contract for project scoped remote tool definitions. | source |
ProjectScopedRemoteToolExecution | Public API contract for project scoped remote tool execution. | source |
ProjectScopedRemoteToolExecutionInput | Input payload for project scoped remote tool execution. | source |
ProjectScopedRemoteToolOptions | Options accepted by project scoped remote tool. | source |
RemoteMCPToolSourceConfig | Configuration used by remote MCP tool source. | source |
RemoteToolMaterializationOptions | Options accepted by remote tool materialization. | source |
RemoteToolSource | Remote tool source loaded dynamically at runtime. Hosts can provide these to expose tools from remote MCP-compatible systems without registering those tools globally inside the framework. | source |
SleepToolInput | Input payload for sleep tool. | source |
SleepToolOutput | Output from sleep tool. | source |
SleepToolWait | Public API contract for sleep tool wait. | source |
Tool | Tool instance (returned by tool() function) | source |
ToolConfig | Tool configuration options | source |
ToolDefinition | Provider-facing tool definition used for model/tool registration. | source |
ToolExecutionContext | Context passed to tool execution | source |
ToolExecutionDataEvent | Event emitted for tool execution data. | source |
ToolSet | Runtime tool map keyed by the tool name exposed to an agent. | source |
TraceHostToolsOptions | Options accepted by trace host tools. | source |