Agent tools
Turn a Fieldwork instance into tool definitions for a model, with JSON Schema inputs that list only the options its provider supports.
A tool for each capability the instance supports, from @howells/fieldwork-sdk/tools. The definitions are plain JSON Schema with MCP annotations, so they work with the AI SDK, MCP servers and any framework that accepts JSON Schema tools.
With the AI SDK
import { jsonSchema, tool } from "ai";
import { toolsFor } from "@howells/fieldwork-sdk/tools";
const tools = Object.fromEntries(
toolsFor(web).map((t) => [
t.name,
tool({
description: t.description,
inputSchema: jsonSchema(t.inputSchema),
execute: (input, { abortSignal }) =>
t.execute(input, { signal: abortSignal }),
}),
])
);
What each tool has
- a description that says when to use it and which tool to use instead;
- a JSON Schema input that lists only the options its provider supports;
- an output schema;
- MCP annotations: whether it is read-only, destructive or idempotent, and whether it reaches the open web.
execute(input) checks the input, calls the capability, and returns the result without raw, with long text cut to a shared budget of 20,000 characters. Bad input throws InvalidRequest.
The tools
| Tool | Capability |
|---|---|
search_web |
search |
search_images |
images |
search_by_image |
reverseImage |
read_page |
read |
read_pages |
readMany |
extract_values |
extract |
read_product |
product |
find_images |
read and act, through bestImages |
map_site |
map |
crawl_site |
crawl |
answer_question |
answer |
research_question |
research |
find_entities |
discover |
make_decisions |
decide |
parse_document |
parse |
check_usage |
usage |
run_browser_script |
act |
open_browser, close_browser |
browser |
create_monitor, get_monitor, list_monitors, delete_monitor, list_monitor_events |
monitor |
toolsFor makes a tool only for the capabilities the instance supports. On a router, each tool is served by the provider its capability routes to. To expose several providers behind one tool name — such as lexical search (brave) and semantic search (exa) behind search_web — use toolCatalog(clients, { defaults }): multi-provider tools expose a provider enum with per-provider oneOf option branches and query-style guidance in search_web’s description, and never fall back on error.
Tools left out by default
Tools that start remote browsers or create lasting, billed resources are left out unless you allow them:
toolsFor(web, { allow: ["act", "browser", "monitor"] });ToolsOptions: No interface or type named "ToolsOptions" found.Errors for a model
toolError(error) formats an error for a model: the code, the message, whether repeating can succeed, and the jobId of a job that may still be running, without the provider’s response.
import { toolError } from "@howells/fieldwork-sdk/tools";
try {
return await tool.execute(input);
} catch (error) {
return toolError(error);
}Over MCP
For MCP clients such as Claude, Cursor and Codex, the MCP server serves these tools over stdio, and the HTTP gateway serves them over HTTP and remote MCP.