Agentbrisk
TypeScript Apache-2.0 orchestrationtypescriptfull-stack

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-name string
  • 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

Frequently Asked Questions

What is Mastra?
Mastra is an open-source TypeScript framework for building AI agents and structured workflows. It gives you primitives for defining agents with tools, memory, and model routing, plus a workflow engine that chains typed steps with suspend and resume support. The same package includes built-in RAG, evals, and a local Studio UI for tracing runs during development. It was created by the founders of Gatsby and reached version 1.32.0 by May 2026 with over 23,000 GitHub stars.
Is Mastra free?
The core Mastra framework is free under the Apache 2.0 license. Enterprise features (inside the /ee/ directory) are source-available under a separate Mastra Enterprise License that restricts building competing hosted services. Mastra Cloud (the hosted Studio, Memory Gateway, and managed deployment service) is a separate paid product. Pricing was not publicly listed as of May 2026.
How does Mastra compare to LangChain?
Mastra is TypeScript-native while LangChain's primary surface is Python (with a JS SDK that lags behind). Mastra's workflow engine uses typed step schemas with Zod, which gives you compile-time safety LangChain chains don't provide. LangChain has a much larger ecosystem: more integrations, more tutorials, more Stack Overflow answers. For a Python team, LangChain or LangGraph is still the safer default. For a TypeScript shop that wants one language from API to agent, Mastra is a serious alternative that is closing the gap quickly.
Why TypeScript instead of Python?
Most production web services at JavaScript shops run Node.js. Adding a Python sidecar for agents creates a second runtime, a second deploy target, and a second set of dependencies to manage. Mastra keeps everything in one language and integrates directly into Next.js, Express, and Hono apps. The framework also gives you full TypeScript inference on workflow step inputs and outputs, which catches bugs at build time rather than at runtime.
What is Mastra Cloud?
Mastra Cloud is the hosted platform layer on top of the open-source framework. It includes a hosted Mastra Studio for team observability, a Memory Gateway for managing agent context across deployments, and managed infrastructure for running agents and workflows without configuring your own servers. Pricing is not publicly listed; teams need to contact Mastra directly or sign up for early access.
Is Mastra production-ready?
Yes, with caveats. At version 1.32.0 with 23k+ GitHub stars and companies like Replit and Medusa running it in production, it is past the proof-of-concept stage. The workflow engine is stable, the evals system works, and the LLM provider routing is reliable. Where it is still maturing is ecosystem breadth. Community-contributed integrations, tutorials, and community support lag well behind LangChain. Teams adopting Mastra today should expect to write more glue code than they would with a more established framework.
Search