Mastra
Last reviewed
May 16, 2026
Sources
20 citations
Review status
Source-backed
Revision
v1 ยท 3,988 words
Improve this article
Add missing citations, update stale details, or suggest a clearer explanation.
Last reviewed
May 16, 2026
Sources
20 citations
Review status
Source-backed
Revision
v1 ยท 3,988 words
Add missing citations, update stale details, or suggest a clearer explanation.
Mastra is an open-source TypeScript framework for building AI agents, workflows, and retrieval-augmented generation pipelines. The project is developed by Kepler Software, a San Francisco startup whose three co-founders, Sam Bhagwat, Abhi Aiyer, and Shane Thomas, previously built Gatsby, one of the more widely used React static site generators in the 2010s. Mastra began as an internal experiment in October 2024, opened its GitHub repository in early 2025, and graduated from Y Combinator's Winter 2025 batch before hitting a stable 1.0 release on January 21, 2026.
The framework is designed for engineers working in the JavaScript and TypeScript ecosystem, particularly those already building on Next.js, Vercel, and serverless runtimes. Mastra delegates low-level model calls to the Vercel AI SDK and layers higher-level primitives on top: an Agent class, a graph-based Workflow engine, a Tool definition system backed by Zod schemas, a Memory subsystem with conversation history and semantic recall, and an Eval harness for measuring agent quality. The same package can run as a standalone Node, Bun, or Deno server, or be embedded into an existing Next.js or Express app through framework adapters.
Mastra closed a $13 million seed round on October 8, 2025, led by Y Combinator and Gradient Ventures with participation from more than 120 angels including Paul Graham, Guillermo Rauch, Amjad Masad, Balaji Srinivasan, and Shay Banon. A $22 million Series A led by Spark Capital followed on April 9, 2026, bringing total capital raised to $35 million. By mid-2026 the repository had crossed 23,000 GitHub stars and was averaging more than 1.8 million monthly downloads on npm, making it one of the fastest-growing JavaScript frameworks measured by adoption rate in its first eighteen months.
All three Mastra co-founders worked together on Gatsby, the React-based static site framework launched in 2015 by Kyle Mathews. Sam Bhagwat joined Gatsby in 2017 as a co-founder of Gatsby Inc., the commercial company built around the open-source project, and helped scale its cloud business to roughly five million dollars of annual recurring revenue before Netlify acquired the company in February 2023. Abhi Aiyer led engineering on Gatsby Cloud, and Shane Thomas worked on developer experience and the Gatsby plugin ecosystem. After the acquisition, the three left Netlify and spent most of 2024 looking for a new problem to solve.
They arrived at AI agents the way many engineers did in 2024, by trying to build internal tools and hitting friction with the available libraries. Bhagwat has described the period in interviews as small frustrations with Python-first agent frameworks: type-unfriendly APIs, awkward deployment to serverless edges, and a mental model of chains and graphs that did not match how JavaScript developers compose code. The three started prototyping a TypeScript-native alternative in October 2024 under the name Mastra, a play on the Italian word for stove or hearth.
The Mastra GitHub repository went public in January 2025, the same month the team joined Y Combinator's Winter 2025 batch. The project's first viral moment came in February 2025, when a post about the framework reached the front page of Hacker News and the star count jumped from roughly 1,500 to 7,500 in a single week. The team has cited that week as the point where they shifted from prototype mode to product mode, hiring a small group of engineers and moving from weekly to daily releases.
Throughout 2025 the framework went through a steady cadence of API revisions. The workflow primitive landed its current form in May, the evaluation system in September, and the observability layer in October. A beta of version 1.0 shipped on November 6, 2025, and the stable 1.0 release followed on January 21, 2026 with a Product Hunt launch that finished third for the day and crossed 460 upvotes. The 1.0 release was framed as an API stability commitment rather than a feature push, with most of the user-visible work going into standardizing naming conventions, error handling, and migration paths from earlier versions.
Mastra's positioning leans heavily on the argument that TypeScript is the natural language for the people who already ship the web. Python dominates the research side of AI, but most production user interfaces, mobile backends, and serverless functions in 2025 and 2026 are written in TypeScript, often on top of Next.js. Bhagwat has argued in podcasts and blog posts that the agent layer should live in the same codebase as the rest of the application, so that types flow end to end, the tooling story is one editor and one debugger, and deployment can reuse the same hosting that already runs the web app.
This is a deliberate contrast with LangChain and other early agent frameworks, which started in Python and exported JavaScript ports later. Mastra inverts that order. Its primary surface is TypeScript, its testing and documentation are TypeScript first, and many of its examples assume a Next.js or Vercel target. The framework still works fine in plain Node or Deno, and there is no requirement to use any particular hosting provider, but the design choices show their origins.
Mastra is organized around five primitives that fit together rather than nest. An application can use any subset of them. A simple chat endpoint might use only Agent and Tool, while a workflow-heavy backend might lean on Workflow, Memory, and Eval with Agent only at certain steps.
An Agent in Mastra is a class that wraps a model, a set of instructions, an optional list of tools, and an optional memory configuration. The Agent exposes two main methods: .generate() returns a complete response, and .stream() returns a stream of tokens and tool call events. Internally, the Agent uses the Vercel AI SDK to handle the underlying provider protocol, including tool call serialization, streaming, and structured output parsing. The Mastra layer adds prompt assembly, tool selection, memory access, retry behavior, and observability hooks on top of the SDK's primitives.
Agents are stateless by default. Conversation state is held in the Memory subsystem rather than on the Agent object itself, which makes Agents safe to reuse across requests in serverless environments where a single Lambda or edge function might serve many users. The same Agent can be invoked with different memory scopes, different user identifiers, and different tool sets per call, and the framework handles the bookkeeping.
Workflows are Mastra's mechanism for structured, deterministic multi-step processes. A workflow is defined as a graph of steps, each of which can be an agent invocation, a tool call, a plain function, a sub-workflow, or a control-flow primitive such as parallel, conditional, or loop. Steps connect through typed input and output schemas, and the workflow engine handles execution order, error propagation, and serialization of intermediate state.
The workflow engine supports suspend-and-resume, which is how Mastra implements human-in-the-loop approvals. A step can pause execution and return control to the caller, and the workflow can be resumed later with a user decision or external input. State between suspend and resume is serialized to a backing store, which in production is usually PostgreSQL or LibSQL. Workflows can also run on top of external durable execution engines such as Inngest through a pluggable adapter, which lets teams keep their existing scheduling infrastructure while using Mastra primitives at the step level.
A Tool is created with a createTool factory that takes an identifier, a description, a Zod schema for inputs, an optional Zod schema for outputs, and an execute function. Mastra serializes the schema into the tool definition that the model sees, and validates inputs and outputs at runtime. Tools can be attached to agents as a list, or surfaced through the Model Context Protocol so that external clients such as Cursor and Claude Desktop can call them through an MCP server.
Mastra ships an MCP client and an MCP server in the same package. The client lets a Mastra agent treat any MCP-compliant server as a tool source, while the server lets a Mastra deployment expose its own tools and agents to MCP-aware clients. This bidirectional support is one of the framework's distinguishing features compared to alternatives that integrate MCP in one direction only.
The Memory subsystem provides four mechanisms, layered to cover different use cases. Conversation history is the raw sequence of messages exchanged with the model in a session, stored in a backing database. Working memory is a structured scratchpad that the agent can read and write across turns, useful for tracking variables that should persist within a conversation. Semantic recall uses embeddings to fetch relevant past messages or facts when a new query comes in, even when those messages fall outside the immediate conversation window. Observational memory is a background compression process that summarizes long conversations into structured facts, with the team citing a reported 94.87 percent score on the LongMemEval benchmark for the technique as of early 2026.
Memory can be scoped per user, per thread, or per resource, and the backing store is pluggable. Default deployments use LibSQL through Turso, but the framework ships adapters for PostgreSQL, MongoDB, DynamoDB, and MSSQL, with vector storage handled by a separate set of adapters described below.
The Eval system covers model-graded, rule-based, and statistical evaluations of agent outputs. A model-graded eval uses a second model as a judge to score outputs against criteria such as relevance, faithfulness, toxicity, or tone consistency. A rule-based eval uses deterministic checks against the output, such as schema validation or regex matches. A statistical eval computes metrics like response length distribution, latency, or token usage across a run.
Evals can be triggered from CI, from a Mastra Studio dashboard, or from inside a workflow as a step. The framework treats evals as first-class artifacts: a run produces an eval report, the report is stored alongside the trace and the conversation, and changes in evaluation scores over time can be tracked through the dashboard.
The table below summarizes the main capabilities exposed by the framework as of the 1.0 release and subsequent point releases through April 2026.
| Feature | Description |
|---|---|
| Agents | Stateless Agent class with .generate() and .stream() methods, instructions, tools, and memory configuration |
| Workflows | Graph-based engine with parallel, conditional, loop, and suspend-and-resume control flow |
| Tools | Zod-typed tool definitions with input and output validation, attachable to agents or exposed via MCP |
| Memory | Conversation history, working memory, semantic recall, and observational memory with pluggable storage |
| Eval | Model-graded, rule-based, and statistical evaluation with CI and dashboard integration |
| Model routing | Unified provider-prefixed routing across more than 40 model providers and 3,000 plus models |
| RAG | Document chunking, embedding, indexing, and retrieval with adapters for major vector databases |
| Voice | Voice input and output utilities for speech-to-text and text-to-speech pipelines |
| MCP support | Both MCP client and MCP server implementations in the same package |
| Mastra Studio | Local and hosted UI for inspecting traces, prompts, eval reports, and conversation history |
| Mastra Server | Standalone deployment target for Node, Bun, and Deno runtimes |
| Framework adapters | First-class integration with Next.js, Express, and Hono routing |
| Observability | OpenTelemetry tracing, structured logs, and token usage metrics |
| Auth | Built-in authentication helpers with adapters for common identity providers |
| Memory Gateway | Managed hosted memory service introduced with the Series A platform launch |
| Guardrails | Prompt injection detection and content filtering hooks |
Most primitives are independently optional. A team can use Mastra purely for its workflow engine without touching the agent layer, or it can use only the agent layer and bring its own workflow tooling. The framework is consistent about exposing internals so that primitives can be replaced where needed.
Mastra implements model access through a unified router that takes provider-prefixed strings such as openai/gpt-4o or anthropic/claude-sonnet-4-6 and dispatches to the underlying provider client. The router relies on the Vercel AI SDK for the actual network calls, which gives Mastra access to the full set of providers that the SDK supports. As of early 2026 the router covers more than 3,300 models across more than 90 providers, with new entries added as the SDK absorbs them.
The table below lists the main provider families that the framework documents as first-class targets. The list is not exhaustive, and the router accepts any provider that the Vercel AI SDK can reach, including custom OpenAI-compatible endpoints.
| Provider | Notes |
|---|---|
| OpenAI | GPT-4 and GPT-5 families, plus o-series reasoning models with effort settings |
| Anthropic | Claude Sonnet, Opus, and Haiku families |
| Gemini Pro and Flash families through both AI Studio and Vertex AI | |
| Amazon Bedrock | Anthropic, Meta, Mistral, and Amazon-hosted models |
| Mistral | Hosted Mistral models including Large and Small variants |
| Groq | Hosted open weight models with low-latency inference |
| DeepSeek | DeepSeek V3 and reasoning model families |
| xAI | Grok family |
| Cohere | Command family |
| Nvidia | NIM-hosted models |
| Ollama | Local model serving for offline development |
| OpenAI-compatible | Any custom endpoint that speaks the OpenAI protocol |
The routing layer also supports model fallback chains, where a primary model can be backed up by one or more alternatives if the first call fails. Fallbacks are configured at the agent or workflow step level rather than globally, which lets different parts of an application pick different reliability strategies.
The agent framework landscape is crowded, and Mastra positions itself by language choice, deployment target, and degree of opinionation. The table below sketches the differences against the most commonly compared alternatives. It is not a ranking, since the right choice depends on the team and the workload.
| Framework | Primary language | Primary abstractions | Bundled UI or runtime | License |
|---|---|---|---|---|
| Mastra | TypeScript | Agent, Workflow, Tool, Memory, Eval | Yes (Mastra Studio, Mastra Server) | Apache 2.0 (core), commercial (enterprise) |
| LangChain JS | TypeScript and JavaScript | Chain, Agent, Runnable, LangGraph | LangSmith and LangGraph Platform optional | MIT |
| Vercel AI SDK | TypeScript | generateText, streamText, tool, maxSteps | No bundled UI | Apache 2.0 |
| Inngest | TypeScript | Function, Step, Event | Inngest Dev Server and Cloud | Apache 2.0 |
| Agno | Python | Agent, Team, Workflow | AgentOS FastAPI runtime | Apache 2.0 |
Against LangChain.js, Mastra typically presents itself as a more opinionated, narrower API that favors functional composition with Zod-validated tools over LangChain's deeper class hierarchy and runnable interface. LangChain has a larger integration catalog and a longer history, while Mastra has tighter typing, bundled observability, and a simpler mental model that some teams find easier to onboard. Independent comparison articles published in early 2026 generally describe Mastra as the better fit for new TypeScript projects and LangChain as the safer choice for teams already heavily invested in the LangChain ecosystem.
Against the Vercel AI SDK, the relationship is closer to layering than competition. Mastra builds on the AI SDK and adds workflow orchestration, persistent memory, evaluations, and a dashboard, so the comparison is really between the AI SDK alone and the AI SDK plus Mastra. Teams that need only a tool-calling loop in a single endpoint often find the AI SDK sufficient. Teams that need durable multi-step processes, shared memory across requests, or evaluation pipelines usually adopt Mastra on top.
Against Inngest, the overlap is in durable execution. Both frameworks expose the idea of a step, retry, and suspend, and Mastra workflows can run on Inngest as a backing engine through an adapter. Inngest is general purpose and not specifically designed for AI; Mastra is narrower but ships with agent and memory primitives built in. A common pattern in 2026 is to use both, with Inngest as the durable execution layer and Mastra as the agent layer that sits on top.
Against Agno, the comparison is mostly about language. Agno occupies a similar conceptual space in Python that Mastra occupies in TypeScript: agent plus workflow plus runtime under a single Apache 2.0 license. Teams that have Python on the backend often pick Agno, while teams that have TypeScript on the backend often pick Mastra. The two frameworks are sometimes described in podcasts as siblings rather than rivals, since they rarely compete for the same project.
Mastra has closed two priced rounds since its founding, both in support of the open-source framework and the surrounding commercial platform.
| Round | Date | Amount | Lead investors | Selected participants |
|---|---|---|---|---|
| Seed | October 8, 2025 | $13 million | Y Combinator, Gradient Ventures, basecase capital | Paul Graham, Guillermo Rauch, Amjad Masad, Balaji Srinivasan, Shay Banon, Arash Ferdowsi, plus 120 plus angels |
| Series A | April 9, 2026 | $22 million | Spark Capital | Existing seed investors |
The seed round was described in coverage as one of the largest post-Y Combinator cap tables in several years, with the team choosing breadth over concentration to bring in operators across developer tools, frontend, and AI. The Series A was paired with the launch of the Mastra platform, including Mastra Studio in its hosted form, Mastra Server, and a Memory Gateway service. Total reported capital raised stood at $35 million as of April 2026, with the round funding engineering hires for multi-agent coordination, IDE integration, and managed cloud infrastructure.
The team has not disclosed revenue. Series A coverage described production deployments at Brex, Sanity, Factorial, Indeed, Marsh McLennan, MongoDB, Workday, Salesforce, PayPal, Adobe, Replit, SoftBank, and Docker, though scope and contract terms are not described in primary sources.
Growth on GitHub and npm has been one of the steadier signals of the project's adoption. The repository accumulated about 1,500 stars in its first month, jumped to 7,500 after the February 2025 Hacker News post, and reached 22,000 by the 1.0 launch in January 2026. By mid-2026 the count had crossed 23,000, with new stars arriving at a rate the team has described as 30 to 35 per day during the growth phase around the Series A.
Npm download numbers tracked a similar curve. The team reported about 60,000 monthly downloads in March 2025, 220,000 weekly downloads at the November 2025 beta, 300,000 weekly downloads at the January 2026 1.0 launch, and 1.8 million monthly downloads by February 2026. In Bhagwat's framing during the Series A announcement, this made Mastra the third-fastest-growing JavaScript framework ever measured by weekly downloads in its first year, well ahead of Gatsby's own early curve.
Adoption has spread through community projects, agency engagements, and direct enterprise sales. The team distributed more than 70,000 physical copies of a book titled Principles of Building AI Agents between March 2025 and the Series A, hosted a TypeScript AI Conference in San Francisco in November 2025, and runs a Discord that crossed several thousand members during the same period.
Mastra uses a dual-licensing model. The core framework, published as the @mastra/core package and a family of companion packages, is released under the Apache License 2.0. The license grants the usual permissions for commercial use, modification, redistribution, and sublicensing, with patent grants and attribution requirements. Most of the framework's surface area, including agents, workflows, tools, memory, evals, the model router, and the framework adapters, sits inside the Apache 2.0 portion of the repository.
A smaller set of enterprise modules lives under directories that are explicitly labeled as enterprise edition code and are governed by a separate Mastra Enterprise License. These modules cover features such as multi-tenant control plane integrations, advanced authentication options, and hosted deployment helpers that ship with the commercial platform. The split is meant to keep the developer-facing core fully open while letting the company sell features that only matter at company scale.
The hosted platform, including the cloud version of Mastra Studio and the Memory Gateway service, is offered as a subscription product with usage-based components. Pricing for the hosted services was announced alongside the Series A in April 2026, with a free tier for individual developers and paid tiers for teams and enterprises. Self-hosting of all open-source components remains supported and is documented as a first-class deployment option.
Reception within the JavaScript and TypeScript developer community has been broadly positive, with most commentary focused on a few recurring themes. The first is the framework's TypeScript ergonomics. Reviewers writing in 2025 and 2026 frequently describe Mastra as the rare AI framework that feels like it was designed in TypeScript rather than ported to it, with end-to-end typing across tools, workflows, and memory, and with Zod schemas threading through the API in a way that catches mistakes at build time rather than runtime.
The second theme is the breadth of bundled tooling. Engineers comparing Mastra to alternatives often single out the fact that observability, evals, and a debugging UI come with the framework rather than as separate paid products. This is treated as a positive by teams that want a single project to handle most of the stack, and as a mixed blessing by teams that already have their own observability or evaluation infrastructure and would prefer a thinner library.
The third theme is API stability. The frequent API revisions during 2025, while in line with a framework approaching its 1.0 release, produced migration friction for early adopters. The 1.0 stability commitment in January 2026 and the codemod-based migration tooling that shipped with it were generally well received, though some users still describe the framework as moving faster than they would prefer.
Criticism tends to fall in three areas. Some reviewers question whether the framework needs to bundle as much as it does, arguing that the AI SDK plus a few smaller libraries can cover the same ground with less surface area. Others note that the closest competitor in many TypeScript stacks is often a custom internal toolkit, so Mastra has to argue against the cost of writing that toolkit rather than against another vendor. A smaller group raises the usual questions about open core models and the risk of features migrating from open to closed over time. The team has addressed these concerns in blog posts and on podcasts, framing the dual license as a way to keep the framework itself fully open while funding development through hosted services.
In the broader landscape of agent frameworks in 2026, Mastra is most often described as the default choice for TypeScript projects that need more than a tool-calling loop, with the Vercel AI SDK as the simpler alternative below it and LangChain JS as the heavier alternative above it. Commentators have noted the symmetry: a team that once helped define the React static site era is now trying to define the TypeScript agent era.