Mastra
Mastra is an open-source TypeScript toolkit for making AI agents, step-by-step workflows and the apps that use them.
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.
Three jobs Mastra takes on.
Follow one question through a Mastra agent.
- 1 · defineA developer writes an agent with a name, instructions and a model named in provider/model form.
- 2 · equipTools are added so the agent can call APIs, query databases or run custom functions.
- 3 · decideWhen a question arrives, the agent reasons about the goal and picks the tools it needs.
- 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.
| Who | What they ask | What 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 |
- 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.
- 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.
Sources used
This explainer is written in original language. The links below support its factual claims.
- docsGet started, Mastra · read 28 Sept 2026
- docsAgents, Mastra · read 28 Sept 2026
- docsTools, Mastra · read 28 Sept 2026
- docsWorkflows, Mastra · read 28 Sept 2026
- docsMemory, Mastra · read 28 Sept 2026
- docsEvals, Mastra · read 28 Sept 2026
- repomastra-ai/mastra, Mastra on GitHub · read 28 Sept 2026