Documentation Index
Fetch the complete documentation index at: https://veryfront.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
veryfront/tool
Define tools with schema-backed inputs for agents and MCP.
Import
import {
tool,
dynamicTool,
loadRemoteToolsFromSource,
toolRegistry,
createContext7ToolSource,
createProjectScopedRemoteToolCatalog,
} from "veryfront/tool";
Examples
import { tool } from "veryfront/tool";
import { z } from "zod";
const convertLength = tool({
id: "convert_length",
description: "Convert meters to feet",
inputSchema: z.object({ meters: z.number().nonnegative() }),
execute: ({ meters }) => {
return { feet: meters * 3.28084 };
},
});
Use with an agent
import { agent } from "veryfront/agent";
import { tool } from "veryfront/tool";
import { z } from "zod";
const convertLength = tool({
id: "convert_length",
description: "Convert meters to feet",
inputSchema: z.object({ meters: z.number().nonnegative() }),
execute: ({ meters }) => {
return { feet: meters * 3.28084 };
},
});
const assistant = agent({
system: "You answer unit-conversion questions.",
tools: { convert_length: convertLength },
});
import { agent } from "veryfront/agent";
import { createRemoteMCPToolSource, loadRemoteToolsFromSource } from "veryfront/tool";
const docsTools = createRemoteMCPToolSource({
id: "docs-mcp",
endpoint: "https://docs.example.com/mcp",
headers: { Authorization: "Bearer <TOKEN>" },
});
const runtimeTools = await loadRemoteToolsFromSource(docsTools, {
context: { projectId: "proj_123" },
toolNameAliases: { search_docs: "docs_search" },
});
const assistant = agent({
system: "Use the docs tools when a question needs project documentation.",
tools: runtimeTools,
maxSteps: 5,
});
const result = await assistant.generate({
input: "Find the deployment guide for this project.",
});
API
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> | Input schema produced via defineSchema((v) => …) (or any SchemaValidator-backed builder). Validates input before execute runs and seeds the JSON Schema exposed to AI providers. | 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 |
Returns: 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 |
Constants
| Name | Description | Source |
|---|
sleepTool | Default sleep tool (max 60 s) exposed as a property accessor so the underlying tool({...}) materialization is deferred until first use. Preserves the existing sleepTool.execute(...) call shape. | source |
toolRegistry | Shared tool registry value. | source |
Reference modules:
User guides:
- tools: Define and call tools
Architecture: