Mastra is a framework for building AI applications and agents using a modern TypeScript tech stack, with the goal of covering the entire process from early prototyping to production-ready applications. It can integrate with frontend and backend frameworks such as React, Next.js, and Node, and can also be deployed as a standalone server to any environment.
Main capabilities
- Model routing: Connect to more than 40 model providers through a unified standard interface, and use models such as OpenAI, Anthropic, and Gemini.
- Agents: Build autonomous agents that use large language models and tools to solve open-ended tasks. Agents reason around goals, decide which tools to use, and iterate internally until the model gives a final answer or optional stop conditions are met.
- Workflows: When explicit control over the execution process is needed, use a graph-based workflow engine to orchestrate complex multi-step processes. Workflows provide intuitive control flow syntax such as .then(), .branch(), and .parallel().
- Human-in-the-loop: Pause an agent or workflow and wait for user input or approval before continuing. Mastra uses storage to remember execution state, so it can pause indefinitely and later resume from where it paused.
- Context management: Provide agents with the right context at the right time, including conversation history, retrieving data from data sources (APIs, databases, files), and adding human-like memory through Observational Memory so that agent behavior remains coherent.
- Integrations: Package agents and workflows into existing React, Next.js, or Node.js applications, or publish them as standalone endpoints. When building UIs, integrate with agent libraries such as Vercel AI SDK UI and CopilotKit to present AI assistants on the web.
- MCP server: Write Model Context Protocol servers to expose agents, tools, and other structured resources through the MCP interface for access by any system or agent that supports the protocol.
- Production essentials: Built-in evals and observability for continuously observing, measuring, and optimizing agents.
How to use It is officially recommended to get started with Mastra via the command line. The installation guide provides step-by-step setup using the CLI or manual installation. For those new to AI agents, you can refer to official templates, courses, and YouTube videos to start building. The official documentation provides complete instructions, and there is also a Build with AI guide to help turn agents into Mastra experts.
Use cases Suitable for developers who need to build AI applications and agents with TypeScript, especially projects that want to move quickly from prototype to production and need model routing, workflow orchestration, human-in-the-loop, context management, MCP integration, and evals and observability.
Limitations and licensing This repository uses a dual-licensing model: the core framework and the vast majority of the codebase are open source under the Apache License 2.0; code in any directory named ee/ (for example, packages/core/src/auth/ee/) is provided as source under the Mastra Enterprise License, and using these features in production requires a valid enterprise license, but they can be used freely in development and testing. See LICENSE.md for the complete license mapping, and ee/LICENSE for the enterprise license terms. Please disclose security vulnerabilities responsibly via security@mastra.ai.
Other information The project has an open Discord community, and discussion and questions are welcome. For contributions, all kinds of help are welcome, including coding, testing, and feature specifications; see CONTRIBUTING.md for details. Developers who want to contribute code are advised to open an issue for discussion before submitting a Pull Request. See the development documentation for project setup information.