Mastra is a TypeScript framework for building AI applications and agents. It covers the pieces an agent application needs (model access, agents, workflows, memory, retrieval, MCP, evals, and observability) under one TypeScript API, and the result can be bundled into React, Next.js, or Node.js apps or deployed as a standalone server.
Two execution styles sit side by side. Agents use a model and tools to work through open-ended tasks, deciding which tools to call and iterating until the model returns a final answer or a stopping condition is met. Workflows run on a graph-based engine for cases that need explicit control, with chainable steps for sequencing, branching, and parallel execution. Either can be suspended to wait for user input or approval, with execution state kept in storage so a run can resume later.
A model router connects to more than 40 providers through one interface, including OpenAI, Anthropic, and Gemini. Context management combines conversation history, retrieval from APIs, databases, and files, and an Observational Memory component for longer-lived recall. Mastra can also author MCP (Model Context Protocol) servers that expose its agents and tools to other systems. Mastra Studio is a local interface for building, testing, and managing agents, workflows, and tools.
“Own your agent. Own your harness. Own your intelligence. Build on open source. Build model agnostic. Build on Mastra.”
Features
- Model routing: one interface to more than 40 model providers, including OpenAI, Anthropic, and Gemini
- Agents: autonomous agents that choose tools and iterate until a final answer or an optional stopping condition
- Graph workflows: multi-step processes with sequential, branching, and parallel control flow
- Human-in-the-loop: suspend an agent or workflow for input or approval and resume from stored state
- Memory: conversation history plus Observational Memory for longer-lived context
- Retrieval: pull context from APIs, databases, and files for retrieval-augmented generation
- MCP server authoring: expose agents, tools, and resources to any MCP-capable client
- UI integration: connects to frontend agent libraries such as the AI SDK UI and CopilotKit
- Evals and observability: built-in evaluation and tracing for measuring agent behavior over time
- Mastra Studio: an interface for building, testing, and managing agents, workflows, and tools


