# Mastra

> A TypeScript framework for building AI agents, workflows, and applications

- Category: Agents & Automation / Agent Frameworks & Builders
- Language: TypeScript
- Licence: Apache-2.0
- Repository: https://github.com/mastra-ai/mastra
- Website: https://mastra.ai
- Canonical page: https://ai-tldr.dev/tools/mastra/

## In short

Mastra is an open-source framework for building AI-powered applications and agents on a modern TypeScript stack. It sits in the Agent Frameworks & Builders category of the Agents & Automation tools and is open-source, written in TypeScript and licensed Apache-2.0. To get started: scaffold a new project.

## Overview

Mastra is an open-source framework for building AI-powered applications and agents on a modern TypeScript stack. It bundles the common pieces of an AI app — agents, a workflow engine, memory, retrieval (RAG), and observability — so you can go from a prototype to a production service without stitching the parts together yourself.

It is built for TypeScript developers who work with React, Next.js, or Node. You can drop Mastra agents and workflows into an existing app, or run them as a standalone server. A model router lets you reach providers like OpenAI, Anthropic, and Gemini through one interface, so you are not locked to a single vendor.

As a general agent framework, Mastra covers both ends of the control spectrum: autonomous agents that decide which tools to call and iterate on their own, and graph-based workflows for cases where you need explicit, step-by-step execution. It can also expose your agents and tools as MCP servers for other systems to use.

## What it does

- Model routing to 40+ providers (OpenAI, Anthropic, Gemini, and more) through one standard interface
- Autonomous agents that reason about goals, choose tools, and iterate until a final answer or stopping condition
- Graph-based workflow engine with control-flow syntax like .then(), .branch(), and .parallel()
- Human-in-the-loop suspend-and-resume backed by storage, so a run can pause and continue later
- Context management with conversation history, RAG retrieval, and Observational Memory
- Author MCP servers and ship with built-in evals and observability for production

## Getting started

The recommended way to start is the create-mastra CLI, which scaffolds a new project and walks you through setup.

1. Scaffold a new project

   Run the create command and follow the prompts. The CLI sets up a Mastra project with a chosen model provider.

```bash
npm create mastra@latest
```

2. Start the dev server

   From the project directory, start the dev server. This opens Mastra Studio at http://localhost:4111, a UI to build, test, and manage your agents, workflows, and tools.

```bash
npm run dev
```

3. Read the docs

   Follow the official Installation guide for step-by-step CLI or manual setup, and browse the docs for agents, workflows, and RAG.

## When to use it

- Build an autonomous agent that uses tools to answer open-ended user requests
- Orchestrate a multi-step process with explicit branching and parallel steps using the workflow engine
- Add a RAG-backed assistant with conversation memory to a React or Next.js app
- Expose your agents and tools as an MCP server for other agents and systems to consume
