Skip to main content
A tool is a typed function an agent can call. It declares input, describes when to use it, and runs server-side code.

Prerequisites

  • A Veryfront project running locally (see Create project).
  • An agent that will call the tool, or an API route that invokes the tool directly (see Agents and API routes).
  • defineSchema is available from veryfront/schemas.

Define a tool

Create a file in tools/:
The filename becomes the tool’s ID. tools/get-weather.ts registers as getWeather.

Try a tool directly

Agents usually invoke tools, but direct execution is useful for testing and for API routes that expose a specific action:
Run the dev server and call the route:
Use this pattern to verify the tool contract before giving the tool to an agent.

How agents use tools

When you add a tool to an agent, the framework sends the input schema to the model. The model decides when to call the tool and provides the parameters:
In most projects, you can omit model and use openai/gpt-5.4-nano. Set model: "auto" when you want runtime defaults to choose local or Veryfront Cloud inference automatically. When a user asks “What’s the weather in Tokyo?”, the agent:
  1. Sends the question to the model
  2. The model calls getWeather({ city: "Tokyo" })
  3. The tool returns { temperature: 22, conditions: "sunny" }
  4. The model formats a natural language response

Tool surfaces in agent config

Agent config separates tools by execution boundary: Use tools for functions you define in the project. Do not add provider-native tools or skill loader tools to tools. Use providerTools for provider-executed capabilities:
Use mcpServers for remote MCP tools. Put remote visibility policy on the MCP server. When tools is an explicit object, also list the remote tool name in tools so the model can use it.

Tool configuration

Writing good descriptions

The description field is what the model reads to decide when to call your tool. Be specific, and use .describe() on schema fields to help the model understand what to pass:

Returning errors

Throw from execute to signal an error. The agent sees the error message and can retry or respond accordingly:

Tools with context

The execute function receives an optional second argument with runtime context:
Pass context from the API route:

Inline tools

For one-off tools that don’t need auto-discovery, define them inline:
evaluateMathExpression is your own validated math evaluator. Avoid passing free-form input into eval() or Function().

Verify it worked

Restart veryfront dev after creating the tool file. To run the tool by itself, expose a small debug API route:
A working tool returns the JSON your execute function produced. Remove the debug route before deploying.