Skip to main content

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

Basic tool

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 },
});

Load remote tools for an agent

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

tool(config)

Create a typed tool definition.
PropertyTypeDescriptionSource
id?stringTool identifier (optional, inferred from filename)source
descriptionstringTool description for the AI modelsource
inputSchemaSchema<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?booleanAllow 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> | TOutputTool execution functionsource
mcp?objectMCP configurationsource
Returns: Tool<TInput, TOutput>

Exports

Components

NameDescriptionSource
DEFAULT_SLEEP_TOOL_MAX_SECONDSDefault value for sleep tool max seconds.source

Functions

NameDescriptionSource
createContext7ToolSourceCreate context7 tool source.source
createProjectScopedRemoteToolCatalogCreate project scoped remote tool catalog.source
createRemoteMCPToolSourceCreate remote MCP tool source.source
createSleepToolCreate sleep tool.source
createToolsFromHostDefinitionsCreate tools from host definitions.source
createToolsFromHostDefinitionsCreate tools from host definitions.source
createToolsFromHostDefinitionsCreate tools from host definitions.source
createToolsFromRemoteDefinitionsCreate tools from remote definitions.source
dynamicToolCreate a dynamic tool definition.source
executeToolExecute a tool definition with validated input.source
filterProjectScopedRemoteToolDefinitionsFilter project scoped remote tool definitions.source
hasToolExecutionErrorMarkerCheck whether tool execution error marker is present.source
hydrateProjectScopedRemoteToolInputInput payload for hydrate project scoped remote tool.source
isErroredToolExecutionResultResult returned from is errored tool execution.source
isProjectNavigationRemoteToolCheck whether a remote tool is project-navigation scoped.source
isRemoteToolNameAllowedCheck whether a remote tool name is allowed.source
listProjectScopedRemoteToolNamesList project scoped remote tool names.source
loadRemoteToolsFromSourceLoads remote tools from source.source
resolveProjectScopedRemoteToolProjectIdResolves project scoped remote tool project ID.source
toolCreate a typed tool definition.source
traceHostToolsWrap host tools with tracing metadata.source

Types

NameDescriptionSource
Context7ToolSourceConfigConfiguration used by context7 tool source.source
CreateSleepToolOptionsOptions accepted by create sleep tool.source
DynamicToolConfigConfiguration used by dynamic tool.source
HostToolDefinitionDefinition for host tool.source
HostToolMaterializationOptionsOptions accepted by host tool materialization.source
HostToolSetPublic API contract for host tool set.source
HostToolTraceAttributeInputInput payload for host tool trace attribute.source
HostToolTraceAttributesPublic API contract for host tool trace attributes.source
HostToolTraceRunnerPublic API contract for host tool trace runner.source
JsonSchemaMinimal 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
ListProjectScopedRemoteToolNameOptionsOptions accepted by list project scoped remote tool name.source
ProjectScopedRemoteToolCatalogPublic API contract for project scoped remote tool catalog.source
ProjectScopedRemoteToolCatalogOptionsOptions accepted by project scoped remote tool catalog.source
ProjectScopedRemoteToolDefaultProjectIdPublic API contract for project scoped remote tool default project ID.source
ProjectScopedRemoteToolDefinitionsPublic API contract for project scoped remote tool definitions.source
ProjectScopedRemoteToolExecutionPublic API contract for project scoped remote tool execution.source
ProjectScopedRemoteToolExecutionInputInput payload for project scoped remote tool execution.source
ProjectScopedRemoteToolOptionsOptions accepted by project scoped remote tool.source
RemoteMCPToolSourceConfigConfiguration used by remote MCP tool source.source
RemoteToolMaterializationOptionsOptions accepted by remote tool materialization.source
RemoteToolSourceRemote 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
SleepToolInputInput payload for sleep tool.source
SleepToolOutputOutput from sleep tool.source
SleepToolWaitPublic API contract for sleep tool wait.source
ToolTool instance (returned by tool() function)source
ToolConfigTool configuration optionssource
ToolDefinitionProvider-facing tool definition used for model/tool registration.source
ToolExecutionContextContext passed to tool executionsource
ToolExecutionDataEventEvent emitted for tool execution data.source
ToolSetRuntime tool map keyed by the tool name exposed to an agent.source
TraceHostToolsOptionsOptions accepted by trace host tools.source

Constants

NameDescriptionSource
sleepToolDefault 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
toolRegistryShared tool registry value.source
Reference modules: User guides:
  • tools: Define and call tools
Architecture: