Mastra
A TypeScript framework where agents, typed workflow steps and memory arrive in one package
What is Mastra?
Agents are declared with instructions and a model, tools are validated on both ends by a schema, and workflows are chained from steps that can suspend mid-run and resume later because their execution state is written to storage. The breadth is the appeal — retrieval, memory, evaluation and tracing are in the same package rather than assembled from four — but breadth also means a large surface to learn, and the Apache-2.0 grant stops short of a few directories the project reserves under a separate enterprise licence.
What can you do with Mastra?
- Declare an agent, then call it — An agent is an object with an id, a name, the instructions that shape its behaviour and a model. Calling generate on it runs one turn, and agents registered with the Mastra instance can be fetched by id from anywhere in the app.
- Type both ends of a tool — createTool takes an input schema, an output schema and an execute function, so the arguments the model produces are validated before your code sees them and your return value is validated before the model does.
- Chain steps into a workflow you can pause — Steps compose with then for sequence, parallel for concurrency and branch for choice. A run can be suspended to wait for a person and resumed afterwards, and because state goes to storage the wait can outlive the process.
- Give the agent context that survives the turn — Conversation history, retrieval from your own APIs, databases and files, and an observational memory layer are all first-party, so persistence is configured rather than assembled.
- Build once, deploy where you already deploy — The build command emits a standalone Hono server for a VM or container, with targets for Vercel, Netlify, Cloudflare, AWS Lambda and Kubernetes, or you can run it inside an existing Next.js or Astro application.
Before you choose Mastra
- The Apache-2.0 grant excludes directories named ee, which the licence file identifies as authentication paths in the core and server packages and explicitly describes as a non-exhaustive list.
Star history
21 Aug to 30 Oct · +1.9k
Frequently asked questions
Is Mastra free for commercial use?
Mastra is released under the Apache-2.0 licence — OSI-approved open source, which permits commercial use.
How can Mastra be deployed?
Mastra is available as Self-hosted / Managed cloud.