Mastra is an open-source framework, a code library that gives a program its basic structure, for building AI applications and agents in TypeScript. An agent is a program that uses a large language model (LLM) and tools: it reasons about a goal, decides which tool to call, and repeats until it reaches a final answer.
A developer defines agents in code with instructions, a model and tools. Model routing reaches models from OpenAI, Anthropic, Gemini and other providers through one interface. A graph-based workflow engine runs multi-step processes with branches and parallel steps; it stores its state, so a workflow can pause for human approval and resume later. A memory system keeps conversation history and retrieves data from APIs, databases and files. Mastra runs inside React, Next.js or Node apps, or as a standalone server, and can also expose tools as MCP servers (Model Context Protocol, a standard way for AI systems to call tools).
The core framework is free under the Apache 2.0 license. Mastra also sells the hosted Mastra Platform for deployment and observability, with a free Starter plan, a monthly Teams plan and usage charges.