Skip to content

Function: tool()

tool(opts): Tool

AppKit-shaped tool factory. Lets users mix-and-match tools across AppKit’s agents plugin and mastra with a single import:

import { tool } from "@dbx-tools/appkit-mastra";
import { z } from "zod";
get_weather: tool({
description: "Weather",
schema: z.object({ city: z.string() }),
execute: async ({ city }) => `Sunny in ${city}`,
}),

Maps onto Mastra’s createTool:

  • description -> description (required)
  • schema -> inputSchema (optional)
  • execute(input) -> execute(input, ctx) - Mastra already calls the first arg with the parsed inputs, so the body shape is identical. The Mastra context arg is forwarded as the second parameter when the caller declares it.
  • id: optional. Defaults to a stable identifier derived from description (slugified, with a short hash suffix for uniqueness). Pass an explicit id when you need a stable string for tracing or MCP exposure.

Reach for createTool when you need Mastra-only fields (outputSchema, suspendSchema, requireApproval, mcp, etc.).

AppKitToolOptions

Tool