Kavvo Agents

Mastra

November 29, 2026 · 4 min read · By the Kavvo Agents team

What it is

Mastra is an open-source TypeScript framework for building AI agents and the applications around them. Its docs describe it as a framework for building AI agents and applications, and its README calls it a framework for building AI-powered applications and agents with a modern TypeScript stack. It bundles agents, graph-based workflows, memory, MCP, evals, and observability, and it runs inside Next.js and Node.js apps or as its own server.

Mastra is built on the Vercel AI SDK for model access, and it adds the application layer that turns a single model call into a dependable agent system: durable workflows, persistent memory, a built-in eval harness, RAG utilities, and a local dev studio called Mastra Studio, where you can chat with your agents and inspect every tool call.

Who made it

Mastra is made by Mastra, a company whose team previously built Gatsby, the React static-site framework. The project is open source on GitHub, and the docs are at mastra.ai.

What it does

A Mastra agent wraps a language model with a system prompt, a set of tools, and optionally a memory instance. You can give it tools built with createTool, which requires an ID, a description, an input schema, and an execute function. The agent reasons about a goal and iterates until it emits a final answer or a stopping condition is met.

Workflows give you deterministic control where agents give the model control. A workflow is a graph-based state machine built from typed steps, chained with .then() for sequential steps, .branch() for conditionals, and .parallel() for fan-out. Each step declares input and output schemas with Zod, so data is validated at every boundary. Mastra also provides model routing, so one interface covers many providers through a single provider/model string, with model fallbacks, memory, RAG, evals, and MCP support. Mastra Studio is a local playground for testing agents without deploying them.

How it works

You organise an application around five primitives: agents, tools, workflows, memory, and evals, composed in a central Mastra instance. The model router takes a string such as openai/gpt-5 — the exact model name depends on the current docs — and looks up the provider automatically, reading the API key from an environment variable such as OPENAI_API_KEY.

To build a first agent, you create a tool with createTool, create an Agent with an ID, a name, instructions, and a model, and register it in a Mastra instance. You can call the agent with generate() for a full response or stream() for streaming output. Memory stores conversation history across sessions, and evals let you grade an agent’s outputs on a dataset so you can catch regressions when you change a prompt or a model.

How to start

  1. Scaffold a project with npm create mastra@latest, the recommended route in the docs. It creates the project and installs the core packages.
  2. Set your model API key as an environment variable, for example OPENAI_API_KEY for OpenAI. Check the models page in the docs for the variable name for your provider.
  3. Follow the quickstart in the docs, which builds a weather agent from a tool, an agent, and an entry point. The tool uses createTool from @mastra/core/tools, and the agent uses Agent from @mastra/core/agent.
  4. Run Mastra Studio with the mastra CLI and chat with your agent there, inspecting each tool call.
  5. Add memory, then a workflow with two steps, and run an eval on a small set of test questions before you change the prompt.
  6. When it works, deploy it in your Next.js or Node.js app, or as a standalone server, following the deployment page in the docs.

Check the official docs for current commands and model names, because both change between releases.

Who it is for

Mastra is for TypeScript developers who want a modern, typed framework for agents and who already work with Next.js, Node.js, or the Vercel AI SDK. It suits teams that want agents, workflows, memory, and evals in one framework, and developers who want a local studio for testing. It is not a no-code builder: you write TypeScript.

Watch out for

Mastra’s core is Apache 2.0, but code in directories named ee/ is under a separate Mastra Enterprise License and requires a valid enterprise licence for production use, although it can be used freely for development and testing. Read the licence file before you ship anything that uses ee/ code. Mastra changes quickly, so check the docs for the version you installed and do not copy model names from old examples — the docs warn that plain object tool definitions fail silently and tools must be defined with createTool(). As with any agent, set limits, test with read-only tools first, and add human approval for irreversible actions.

Source