Skip to content
ML2

Mastra

Added Updated New

Published Last verified Released

Our verdict

The natural choice if your stack is TypeScript and you'd rather not drop into Python for LangGraph or CrewAI. Agents, workflows, memory, evals and tracing live in one framework that sits next to a Next.js app, and the core is Apache-2.0. Start with a single agent and add workflows only when steps must run in a fixed order. Expect to configure a storage provider as soon as you want memory or pause-and-resume, and to run Node.js 22.13 or later.

Who it's for
TypeScript and Next.js builders adding agents to a product
Leverage
Agents and workflows in the same language as your app
Effort
Medium
Date added

What Mastra does

Mastra (mastra-ai/mastra) is a TypeScript framework for A.I. applications and agents. An agent combines a model, instructions and typed tools. A workflow is a graph of steps you compose with createStep and createWorkflow and control with .then(), .branch() and .parallel(). Memory has four layers: message history, observational memory (background agents keep a dense observation log as raw history grows), working memory for persistent facts such as user preferences, and semantic recall. A suspended workflow keeps its state in your storage provider, so it can wait for a person and resume later, even after a restart. A model router reaches many providers through one provider/model string; the README says 40+. Mastra can also author MCP servers, ships scorers, datasets and experiments for evals, records traces and metrics, and includes Studio, a local UI (port 4111 by default) for testing agents and workflows. The README says it integrates with frontend and backend frameworks such as React, Next.js and Node, or deploys anywhere as a standalone server.

How builders use Mastra

  • Scaffold with npm create mastra@latest, pick a provider, and open Studio to chat with the starter agent before you wire it into your UI.
  • Give an agent one or two typed tools with createTool (an id, a description, a Zod input schema and an execute function) and call it from a Next.js API route.
  • Turn a fragile prompt chain, such as extract, then validate, then draft, into a workflow so each step has its own schema and can be retried on its own.
  • Add a human approval step: suspend the workflow at the risky step, store the state, and resume it when someone clicks approve.
  • Add memory with the @mastra/memory package and a storage provider (the quickstart uses @mastra/libsql), starting with message history before you try observational or working memory.
  • Write a few scorers and a dataset, then run an experiment each time you change a prompt or swap a model, in CI if you like.

Agents, workflows or both

Mastra's own docs draw the line this way (checked 26 Nov 2026).

UseWhen it fitsWhat you control
AgentOpen-ended tasks where the model decides which tools to call and when to stopInstructions, tools, model, optional stopping condition
WorkflowTasks defined upfront with a specific order of stepsStep schemas, branching, parallelism, suspend and resume
BothWorkflow steps can use agents and tools (the docs have an Agents and Tools page)Where the model is free and where it is boxed in

What you need to run it

  • Node.js 22.13 or later for @mastra/core (its package.json sets that engine), and a package manager such as npm.
  • An API key for your model provider, read from an environment variable such as OPENAI_API_KEY or ANTHROPIC_API_KEY.
  • A storage provider for memory and for suspended workflows. Without one, nothing persists.
  • Your own server or host: Mastra is a library and server you deploy, not a hosted service by default.

Mastra: limits and gotchas

  • Code in any directory named ee/ is under the Mastra Enterprise License, not Apache-2.0. The README says it needs a valid enterprise licence for production use but is free for development and testing, so check what you use before you ship it.
  • Memory and suspended workflows need a configured storage provider. That is a database to run and back up, even if you start with a local file.
  • Tools must be defined with createTool. Mastra's docs warn that a plain object tool definition silently fails to execute.
  • The surface is large and moving fast. Observational memory is the recommended memory mode in the current docs, and the Knowledge section is labelled Alpha, so expect docs and APIs to shift between releases.
  • It is TypeScript-first. If your team writes Python, the entries for LangGraph or CrewAI fit better.
  • A framework does not decide quality for you. Without scorers and datasets, you still won't know whether a prompt change helped.

Mastra compared with other tools here

  • LangGraph: low-level, stateful, controllable agent workflows. Pick it if your team works in Python or already uses the LangChain ecosystem.
  • CrewAI: Python crews of role-based agents, plus Flows for step-by-step control. Pick it if the role-play model of a team of agents suits your problem.
  • OpenAI Agents SDK: a small loop with handoffs and guardrails. Pick it for a lightweight multi-agent setup centred on OpenAI models.
  • Claude Agent SDK: the harness behind Claude Code, as a library. Pick it when you want Claude's coding-agent behaviour inside your own app.
  • Langfuse: open-source tracing and evals that work with Mastra, among other frameworks. Add it if you want observability that isn't tied to one framework.

When to pick Mastra

  • Pick Mastra if your product is already TypeScript or Next.js and you want agents, workflows, memory and evals without a second language.
  • Pick it when part of the job must be deterministic: steps in a fixed order, approval gates, resumable runs.
  • Pick LangGraph or CrewAI instead if your team is Python-first.
  • Skip it for a single prompt-and-response feature. A plain model call is simpler.

How it compares

If you only need a small agent loop with handoffs and guardrails, the OpenAI Agents SDK also ships a TypeScript package. For checkpointed graph workflows that pause for approval, LangGraph has a JS/TS version too. See how Mastra compares with other agent SDKs, with languages, licences, MCP support, tracing and hosting side by side.

Mastra questions

Is Mastra free and open source?

The core framework is Apache-2.0. Code in directories named ee/ is source-available under the Mastra Enterprise License and needs a licence for production use. Model and hosting costs are separate.

Which Node.js version does it need?

@mastra/core declares Node.js 22.13.0 or later. Node 22.18 and later can also run TypeScript files directly, according to Mastra's quickstart.

Can an agent remember users across sessions?

Yes, with the memory package and a storage provider. Mastra offers message history, observational memory, working memory and semantic recall, and recommends observational memory.

Can I use it inside Next.js?

Yes. The README names React, Next.js and Node as supported fit, and says you can also deploy it anywhere as a standalone server.

How do I test an agent before I ship it?

Run the dev server and open Studio, the local UI for trying agents, workflows and tools. For repeatable checks, use scorers, datasets and experiments from the evals package.

Related discoveries

See the newest picks →
  • ToolMulti-Step Agent Setups

    LangGraph

    Low-level framework for stateful, controllable agent workflows.

    Effort: High#Open source

  • ToolMulti-Step Agent Setups

    CrewAI

    An open-source Python framework for role-based agent crews, plus Flows for step-by-step control.

    Effort: Medium#Open source

Get the best new A.I. picks in your inbox

The best new agent workflows and tools we’ve vetted, with a clear verdict on each. Short, occasional, useful.

More in Multi-Step Agent Setups →

Free. No spam. Unsubscribe anytime.