Building with AI

Mastra

3 min readintermediateUpdated 28 Sept 2026
1 · In one line

Mastra is an open-source TypeScript toolkit for making AI agents, step-by-step workflows and the apps that use them.

1 · What it is

Mastra is an open-source toolkit that helps developers make AI agents and apps. Open source means anyone can read and reuse the code. It is written for TypeScript. A toolkit like this, often called a framework, is a set of ready-made parts plus rules for how they fit. Mastra’s parts include agents, tools, memory, workflows and tests for answer quality. The core is free to use under the Apache 2.0 licence.

The main part is the agent. An agent is a language model (the kind of AI behind chatbots) that can pick tools. It keeps working until it has an answer. A tool is a small function the agent may call, such as a weather lookup or a database search. Say a travel app gets the question “Should I pack an umbrella for Paris?” A Mastra agent sees it has a weather tool, calls it with the city name, reads the result and replies. Memory lets the agent recall earlier messages, so a follow-up like “what about Rome?” still makes sense.

Not every job should be left to the model’s choices. For jobs with fixed steps, Mastra has workflows. You join steps in order, in branches or side by side. A workflow can pause for a person’s approval and pick up later where it stopped. You can place agents and workflows inside a web app you already have (made with Next.js, React or Node.js). Or you can ship them as standalone endpoints (web addresses other apps can call). A tool called Studio lets developers test agents, workflows and tools. Mastra can also publish agents and tools through MCP. MCP is a shared standard that lets other AI apps connect to them.

2 · Why it exists

Three jobs Mastra takes on.

Many model makersMastra connects to 40+ model providers through one standard interface.
Loose agent loopsAn agent must pick its own tools and keep working until it reaches a final answer.
Hard to measureThe same question can get a different AI answer each time, so ordinary pass or fail tests are not enough.
3 · How it works

Follow one question through a Mastra agent.

The agent decides which tool to call and keeps going until the model gives a final answer.
  1. 1 · defineA developer writes an agent with a name, instructions and a model named in provider/model form.
  2. 2 · equipTools are added so the agent can call APIs, query databases or run custom functions.
  3. 3 · decideWhen a question arrives, the agent reasons about the goal and picks the tools it needs.
  4. 4 · answerIt keeps iterating until the model gives a final answer or a stop condition is met.

Use an agent when the path is open-ended, and a workflow when you already know the steps.

4 · Where it's used
WhoWhat they askWhat it works with
Web developer“Can I add a chat assistant to my Next.js app?”An agent bundled into the existing app
Support team“Can the bot remember what the customer said earlier?”Message history kept by memory
Operations team“Can a refund wait for a person to approve it?”A workflow that pauses and resumes
Quality lead“Are the agent's answers getting better or worse?”Scores from scorers
5 · What it solves, and what it doesn't
solves
  • One interface reaches models from many providers, such as OpenAI, Anthropic and Gemini.
  • Workflows give explicit control with steps joined in order, in branches or in parallel.
  • An agent or workflow can pause for a person's approval and resume later.
  • Scorers return numbers, usually between 0 and 1, that show how well an answer meets your criteria.
doesn't solve
  • It is built around TypeScript, so it suits teams that already work in TypeScript.
  • Code in its ee folders needs an enterprise licence for production use.
6 · Go deeper

Sources used

This explainer is written in original language. The links below support its factual claims.

  1. docsGet started, Mastra · read 28 Sept 2026
  2. docsAgents, Mastra · read 28 Sept 2026
  3. docsTools, Mastra · read 28 Sept 2026
  4. docsWorkflows, Mastra · read 28 Sept 2026
  5. docsMemory, Mastra · read 28 Sept 2026
  6. docsEvals, Mastra · read 28 Sept 2026
  7. repomastra-ai/mastra, Mastra on GitHub · read 28 Sept 2026