Mastra
TypeScript-first agent framework with workflows, RAG, evals, and Cloud deploy
Mastra is a TypeScript framework for building AI agents, structured workflows, and RAG pipelines. It ships with a built-in dev playground, model-graded evals, and a graph-based workflow engine that handles suspend, resume, and human-in-the-loop steps natively. Built by the team that created Gatsby, Mastra targets JavaScript and TypeScript shops that don't want to run Python in production. The core is Apache 2.0 open source, with enterprise features and a hosted Cloud tier for teams that need managed deployment, observability, and a memory gateway. At version 1.32.0 with 23k+ GitHub stars and real production users including Replit and Medusa, Mastra has moved past the early-experiment phase, though it still trails LangChain in ecosystem breadth and community-contributed tooling.
If your team writes TypeScript and you're building something with AI agents, you've probably had the same uncomfortable conversation: do we run Python for this, or do we find a way to stay in one language? Mastra is the most credible answer the TypeScript ecosystem has produced so far. It's not a thin wrapper around the OpenAI SDK. It's a full framework with workflow orchestration, RAG, evals, and a dev playground, built by the team behind Gatsby.
The honest pitch is this: for JS-first organizations, Mastra removes the cost of a Python context switch without asking you to sacrifice the primitives that matter in production.
What Mastra Is
Mastra was released in 2024 by the Gatsby founders after they wound down Gatsby Cloud. At version 1.32.0 in May 2026, it has crossed 23,700 GitHub stars and 2,000 forks. The codebase is 99.3% TypeScript. Real companies (Replit, Medusa, Factorial) run it in production.
The core package is @mastra/core, licensed Apache 2.0. Enterprise features live in a /ee/ directory under a separate source-available license that restricts building competing hosted services, which is worth reading if you plan to build a product on top of Mastra's enterprise layer. The Cloud tier (hosted Studio, Memory Gateway, managed runtime) is a separate paid product.
What the framework ships with out of the box:
- An agent API that routes across 40+ LLM providers using a simple
provider/model-namestring - A typed workflow engine with step composition, suspend/resume, and state persistence
- Built-in RAG with vector store integrations
- Model-graded, rule-based, and statistical evals, with no separate tool required
- Mastra Studio, a local dev playground for tracing runs and inspecting state
- MCP server support for tool distribution
- Integrations with Next.js, Express, Hono, SvelteKit, and React
The positioning on the Mastra site says "Python trains, TypeScript ships." That's directionally accurate. Python dominates AI research. TypeScript dominates production web services. Mastra bets that teams building for the second category shouldn't have to master the first.
Key Features
TypeScript-native API
The agent definition in Mastra is a typed class instantiation, not a config file or a decorator:
export const researchAgent = new Agent({
id: 'research-agent',
name: 'Research Agent',
instructions: 'You answer factual questions using provided tools.',
model: 'openai/gpt-4o',
})
Every agent registered on your Mastra instance gets access to shared memory, logging, and evals automatically. You retrieve it with mastra.getAgentById(), which means TypeScript can infer the agent's type from registration. Agents expose .generate() for complete responses and .stream() for real-time delivery, and they can be composed as subagents. Registered agents become callable tools for other agents, which is how multi-agent networks get built.
The model string format (provider/model-name) is one of the cleaner API decisions in the framework. Switching from openai/gpt-4o to anthropic/claude-3-7-sonnet is one character change. No provider-specific client imports, no different call signatures.
Workflows and primitives
Mastra's workflow engine is where it pulls clearly ahead of most TypeScript competitors. Workflows are built by composing typed steps:
const summarizeStep = createStep({
id: 'summarize',
inputSchema: z.object({ text: z.string() }),
outputSchema: z.object({ summary: z.string() }),
execute: async ({ inputData }) => {
// call an agent, run logic, return typed output
},
})
const pipeline = createWorkflow({ id: 'summarize-pipeline' })
.then(fetchStep)
.then(summarizeStep)
.commit()
Each step declares its input and output schemas using Zod, Valibot, or ArkType. The framework enforces that a step's output shape is compatible with the next step's input at runtime, which catches schema mismatches before they reach production. The workflow execution returns a discriminated union with status values of success, failed, suspended, tripwire, or paused. You pattern-match against those, which is cleaner than exception-based flow control.
Suspend and resume is built in. A step can call .suspend() to pause execution and preserve state. The workflow can be resumed later from where it left off, which is how you implement human-in-the-loop approval steps without managing your own persistence layer. Workflows can be cloned with cloneWorkflow() for independent run tracking, and run.restart() resets from the last active step.
This is roughly the same conceptual model as LangGraph: explicit state machines with typed transitions, expressed in TypeScript idioms rather than Python's networkx-style graph API.
Built-in RAG and memory
Mastra ships vector store integrations and a RAG pipeline as part of the core package. You define a vector index, embed documents, and query semantically without pulling in separate libraries. The Memory Gateway (part of the Mastra Cloud offering) extends this with cross-deployment context management, so agents can maintain coherent state across multiple user sessions and service restarts.
The memory system handles three layers: conversation history (what was said in this session), semantic recall (what's retrievable from a vector index), and agent state (typed variables persisted across suspend/resume cycles). In practice this means an agent can "remember" a user's preferences from a previous session without you writing custom storage logic.
Evals and observability
Evals are a first-class primitive in Mastra, not an afterthought. The framework ships three eval types:
- Model-graded: An LLM judges the quality of another LLM's output against a rubric you define
- Rule-based: Deterministic checks against output properties (length, format, presence of required fields)
- Statistical: Cosine similarity and related metrics for semantic correctness
In most agent frameworks you'd reach for LangSmith, Braintrust, or a custom eval harness to get this. Mastra bundles it. The tradeoff is that Mastra's eval tooling is less mature than dedicated eval platforms. For teams that want a single tool rather than assembling a stack, it's a reasonable starting point.
Mastra Studio provides local tracing during development. Every agent run, workflow execution, and tool call shows up with timing, inputs, outputs, and any errors. The Studio is a web UI that runs alongside your dev server. You don't need to instrument your code or set up a separate service to see what's happening.
Mastra Cloud for deployment
Mastra Cloud is the hosted layer, covering managed infrastructure for running agents and workflows, a team-accessible Studio for shared observability, and the Memory Gateway for cross-deployment context. Pricing isn't public as of May 2026, which makes it hard to plan a budget. Teams evaluating Mastra Cloud should request pricing early in the process.
The framework also integrates with standard deployment targets. Because Mastra is just TypeScript, you can deploy agents as serverless functions on Vercel or Cloudflare Workers, containerize them with Docker, or run them on any Node.js host. Mastra Cloud is the convenience option, not a requirement.
Who It's Built For
Mastra fits three types of teams well.
The first is the Node.js shop that has avoided AI because adding Python to the stack felt expensive. If your backend runs Express or Hono, Mastra drops in without a new runtime. You write agents the same way you write the rest of your service.
The second is the team building a customer-facing product (chat, voice, or a domain-specific copilot) where workflow reliability matters. The suspend/resume pattern and typed step schemas give you the kind of control flow that doesn't fall apart when an external API is slow or a human needs to approve something before the pipeline continues.
The third is the team prototyping AI features who wants to move to production without switching tools. Mastra Studio makes the dev loop fast. The same primitives you use for prototyping are the ones you'd use in production.
It's a worse fit for research teams who live in notebooks, for Python shops that already have LangChain working, and for projects that need deep LangChain ecosystem integrations (document loaders, memory backends, chain types) that Mastra hasn't built equivalents for yet.
How It Compares to LangChain and LangGraph
This is the question most teams ask. The short answer is that Mastra and LangGraph are solving similar problems with different language assumptions and different levels of ecosystem maturity.
LangGraph is Python-first. It has a JavaScript SDK that works, but the Python version gets features first, has more community examples, and is what most tutorials target. LangGraph's graph-based mental model is explicit and powerful, but it asks you to think in nodes and edges, which has a real learning curve.
Mastra uses the same underlying mental model: typed state flowing through discrete steps, expressed in TypeScript with chained method calls that feel native to the language. The createStep().then().then().commit() chain reads like JavaScript. The workflow status as a discriminated union fits TypeScript's type system well.
Where LangGraph wins is ecosystem. More integrations. More tutorials. More Stack Overflow answers. More people at conference talks who've used it in production. If your team is split between Python and TypeScript, standardizing on LangGraph gives you access to both communities.
Where Mastra wins is type safety and runtime. If you're running a TypeScript service and you want compile-time guarantees on your workflow step interfaces, Mastra delivers that in a way LangGraph's JS SDK doesn't fully match. And if you want zero Python anywhere in your stack, Mastra is the cleaner choice.
CrewAI is less relevant here. It's Python-only and role-based rather than graph-based, which makes it a different kind of tool. The comparison that matters is LangGraph vs. Mastra, and the deciding factor is usually language.
For teams building AI coding tools or integrating agents into developer workflows, Mastra's TypeScript-native API makes it easy to embed AI into existing IDE extensions, CLI tools, and web dashboards without adding a language boundary. Tools like Cursor run on Electron and VS Code, JavaScript runtimes where Mastra fits naturally.
Pricing
The Apache 2.0 core is free. The enterprise /ee/ directory features are source-available under the Mastra Enterprise License, which prevents building a competing hosted service. Mastra Cloud pricing is not published. For open-source deployment on your own infrastructure using the Apache 2.0 core, the cost is zero beyond compute.
Verdict
Mastra is the most serious TypeScript-native answer to the question LangChain solved for Python. It's not just a wrapper. It's a complete framework with typed workflows, built-in RAG, evals, and a dev playground that actually reduces the time between writing code and understanding what it's doing.
The maturity gap to LangChain is real. If you need a deep library of pre-built integrations or an answer to every edge case on Stack Overflow, LangChain still has the advantage. But for TypeScript teams who've been waiting for a framework they can use without a Python detour, Mastra is past the experimental phase. Version 1.32.0, 23k stars, and production deployments at recognizable companies put it firmly in the "serious option" column.
If your stack is TypeScript, start with Mastra. If your stack is Python, start with LangGraph. If you're evaluating both languages for a new project, the agent framework question might actually tip the decision.
Key features
- TypeScript-native agent and workflow API
- Graph-based workflow engine with suspend and resume
- Built-in RAG with vector store integrations
- Model-graded and rule-based evals system
- Mastra Studio dev playground with live tracing
- MCP server support and 40+ LLM provider routing
- Human-in-the-loop suspension and state persistence