TOOL WIKI · AGENT SDKS
Mastra
Provides TypeScript building blocks for agents, workflows, and application integrations.
Jump to a section 10 sections
EXAMPLE USE CASE
Add a typed order tool to a TypeScript agent
A developer needs a small, observable agent or retrieval step before connecting real business services.
- Input
- An orderId argument, Zod schemas and a Mastra model configuration.
- Expected output
- A generated answer based on the packed tool output.
- Success check: The agent calls the tool and answers packed.
- Try a failure: Pass an unknown ID and check that not_found reaches the final answer.
Example scope: Actual JavaScript agent/tool integration with a fixture result.
Authenticate the request and define the goal before calling the framework.
taskTo 02 · MastraAgent applications built around a TypeScript codebase. Keep deployment assumptions and persistent state requirements explicit.
invokeTo 03 · Model providertool callTo 04 · Tool servicemeasureTo 06 · EvaluationThe application supplies provider credentials, model selection, and budgets.
decisionBack to 02 · MastraValidate each operation and return authoritative observations.
resultBack to 02 · MastraChoose the checkpoint or session store and its retention policy deliberately.
Result or stopping pointCheck completion, cost, latency, and tool behavior against fixtures.
Result or stopping point
Agent applications built around a TypeScript codebase. Keep deployment assumptions and persistent state requirements explicit.
When to consider it
- Agent applications built around a TypeScript codebase.
A design decision to make
- Keep deployment assumptions and persistent state requirements explicit.
Prerequisites and setup
- Node.js 22.18+ and an OpenAI key. Calls may incur provider usage.
- Set MASTRA_MODEL to provider/model format, for example openai followed by a slash and an enabled model ID.
npm init -y
npm install @mastra/core zod
export OPENAI_API_KEY="YOUR_API_KEY"
export MASTRA_MODEL="openai/YOUR_ENABLED_MODEL"Try a small integration
agent.mjs
import { Agent } from '@mastra/core/agent';
import { createTool } from '@mastra/core/tools';
import { z } from 'zod';
const orderStatus=createTool({id:'order-status',description:'Read one demo order',
inputSchema:z.object({orderId:z.string()}),
outputSchema:z.object({status:z.string()}),
execute:async({orderId})=>({status:orderId==='A104'?'packed':'not_found'})});
const agent=new Agent({id:'support',name:'Order reader',model:process.env.MASTRA_MODEL,
instructions:'Use orderStatus for every order lookup.',tools:{orderStatus}});
const result=await agent.generate('Look up A104.');
console.log(result.text);Run and check the result
node agent.mjs- The agent calls the tool and answers packed.
- Switch to A999 and inspect the not_found tool result.
Common failures
- Mastra model identifiers use provider/model; do not reuse provider:model identifiers from another SDK.
- The current tool execute receives validated input as its first argument; outdated nested inputData examples need migration.
Production decisions
- Bind tool execution to the authenticated user and resource permissions. Keep keys in server environment variables.
- Add deadlines, a turn budget, redacted traces, regression fixtures and explicit handling for refused or incomplete runs.
Keep exploring
Explore the same layer
Compare candidates on your own workload. This entry describes a product’s role; it is not a claim that products in the category are interchangeable.