Reference for every toolset class that ships with the Vibes SDK, with constructor signatures, options, and usage examples.
The SDK ships ten toolset classes in jsr:@vibesjs/sdk. All implement the Toolset<TDeps> interface and can be passed in the toolsets array when constructing an Agent.
Wraps an inner toolset with a per-turn boolean predicate. When the predicate returns false the entire inner toolset is hidden from the model for that turn. When it returns true the full inner toolset is exposed.This is an all-or-nothing gate. For per-tool filtering, use PreparedToolset.
import { FilteredToolset } from "jsr:@vibesjs/sdk";// Only expose admin tools when the user is an adminconst adminGated = new FilteredToolset( adminToolset, (ctx) => ctx.deps.user.isAdmin,);const agent = new Agent({ model, toolsets: [adminGated] });
Wraps an inner toolset with a prepare function that runs once per turn. Unlike FilteredToolset, which hides the entire set, PreparedToolset can add, remove, or reorder individual tools.
import { PreparedToolset } from "jsr:@vibesjs/sdk";// Hide the "delete" tool until the user has explicitly confirmedconst safe = new PreparedToolset( adminTools, (ctx, tools) => ctx.deps.confirmed ? tools : tools.filter((t) => t.name !== "delete"),);
import { PrefixedToolset } from "jsr:@vibesjs/sdk";const prefixed = new PrefixedToolset(searchToolset, "web_");// A tool named "search" becomes "web_search"
An abstract base class that intercepts every tool execution in the wrapped toolset. Subclass it and implement callTool to add cross-cutting behaviour: logging, metrics, rate limiting, argument transformation, or result transformation.
Merges any number of toolsets into one. Tools are collected from all members on each turn. When two toolsets expose a tool with the same name, the last one in the constructor argument list wins.
constructor(...toolsets: Toolset<TDeps>[])
import { CombinedToolset } from "jsr:@vibesjs/sdk";const combined = new CombinedToolset(searchToolset, fetchToolset, dbToolset);const agent = new Agent({ model, toolsets: [combined] });
Wraps a toolset and sets requiresApproval: true on every tool inside it. When the model calls any of these tools, the run pauses and throws ApprovalRequiredError with a DeferredToolRequests object.
constructor(inner: Toolset<TDeps>)
import { ApprovalRequiredToolset, ApprovalRequiredError } from "jsr:@vibesjs/sdk";const gated = new ApprovalRequiredToolset(dangerousToolset);const agent = new Agent({ model, toolsets: [gated] });try { const result = await agent.run("Delete all temporary files");} catch (err) { if (err instanceof ApprovalRequiredError) { // Inspect pending calls for (const req of err.deferred.requests) { console.log(`Pending: ${req.toolName}(${JSON.stringify(req.args)})`); } // Approve and resume const result = await agent.resume(err.deferred, { results: err.deferred.requests.map((r) => ({ toolCallId: r.toolCallId, result: "approved", })), }); }}
For tools whose execution happens outside the agent process — in the browser, a sandboxed environment, or a remote service. The agent is shown the tools and can call them; each call pauses the run and throws ApprovalRequiredError so the caller can execute the tool externally and return results.Uses raw JSON Schema instead of Zod for parameter validation.
Wraps a single MCPClient and adapts it to the Toolset interface. Tools are fetched lazily on the first call to tools() and cached for toolCacheTtlMs milliseconds.
Manages multiple MCP server connections, connects them in parallel, and merges their tools into a single flat list. Implements Toolset directly — pass it to an agent without further wrapping.
constructor() // no arguments
Methods:
Method
Signature
Description
addServer(client, opts?)
(MCPClient, opts?) => this
Register an MCP server (chainable)
connect()
() => Promise<void>
Connect all registered servers in parallel
disconnect()
() => Promise<void>
Disconnect all servers. Throws AggregateError on partial failure.
tools(ctx)
(RunContext) => Promise<ToolDefinition[]>
Merged tool list (last-wins on name collision)
getServerInstructions()
() => string | undefined
Aggregated instructions from all servers
serverCount
number
Number of registered servers
import { MCPManager, MCPStdioClient, MCPHttpClient, Agent } from "jsr:@vibesjs/sdk";import { anthropic } from "npm:@ai-sdk/anthropic";const manager = new MCPManager() .addServer(new MCPStdioClient({ command: "npx", args: ["-y", "@mcp/filesystem", "/data"] }), { name: "fs" }) .addServer(new MCPHttpClient({ url: "https://search-mcp.example.com/mcp" }), { name: "search" });await manager.connect();const agent = new Agent({ model: anthropic("claude-opus-4-5"), toolsets: [manager],});try { const result = await agent.run("Search for docs and list /data/results"); console.log(result.output);} finally { await manager.disconnect();}
MCPManager and MCPToolset live in the MCP module but are re-exported from the main jsr:@vibesjs/sdk entry point alongside the other toolsets.