Mastra
Read the two badges separately: the first is whether this page is backed by evidence, the second is whether the product is still maintained. An archived product can have complete evidence; complete evidence does not mean the product is active.
30-second check: should it make your shortlist?
Mastra is the batteries-included agent framework for TypeScript - official README…
Local / self-hosted · Framework / SDK
Open licence
Read the original licence before commercial useDirect in mainland · Not in filing list
These four cards help you rule things out, not decide for you. The real differences are in the eight questions and sources below.
Information not confirmed
- Capability alignment of each vendor's tool calling / structured output after switching providers (not stated officially)
- The default boundary of file access in the core framework itself (not stated officially; agents, harness, and deployment pages checked)
- Whether the OSS core has an official network-access-control mechanism (not stated officially)
- Which features beyond the
ee/directory fall under the enterprise license (the official README gives directory examples only, no complete feature list) - Conflict semantics of cross-process / multi-instance concurrent resume of the same snapshot (not stated officially)
- Information loss and cost after Observational Memory compression (not measured by us)
- Real-throughput and overage-billing behavior of each Mastra platform tier under real load (the official docs give billing rules only)
Mastra is a TypeScript framework for building AI agents and applications - official README: "Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack. It includes everything you need to go from early prototypes to production-ready applications."
One package covers Agents, graph Workflows, Memory, RAG, Evals/Scorers, MCP client and server, a built-in Hono server, Studio and observability.
Model routing is where it goes furthest: provider/model strings, plus model fallbacks, per-task mix-and-match and requestContext.
State is separate from context: workflow snapshots persist across deployments and restarts, while memory covers message history, Observational Memory, working memory and semantic recall.
The licence splits in two - the core framework is Apache-2.0, but code under any ee/ directory is source-available under the Mastra Enterprise License (the repo licence API returns NOASSERTION). Studio, Observability and hosted deployment are Mastra platform products, billed on Starter $0 / Teams $250 / Enterprise tiers.
When to use it, when not to
Fits:
- TypeScript / Node teams that want an out-of-the-box agent framework - Agents, graph Workflows, Memory, RAG, Evals, MCP, a built-in server and Studio all in one package
- Durable runs with suspend/resume - snapshots live in your own storage and survive restarts
- Wiring up many model providers and local models (LMStudio is officially recommended)
- Exposing agents and workflows over MCP, or acting as an MCP client
- Embedding an agent into a Next.js / React app
Not a fit for:
- A Python stack (see LangGraph / Pydantic AI)
- Wanting a low-level engine you control - Mastra sits higher, ships a bigger package and more conventions
- Refusing any commercial component - platform Studio, observability and hosted deployment are separately billed, and
ee/needs an enterprise licence - Needing a framework-provided process sandbox or network policy - that part is not in the OSS core
China availability domestic / direct access / CAC filing · snapshot 2026-10-23
- Origin
- foreign-made foreign entity (no matching filing entity in the CAC registry).
- Direct access
- direct OK official site measured 200 direct.
- CAC filing
- not in filing list:not in the CAC public registry (13 batch attachments searched 2026-10-20, https://www.cac.gov.cn/2024-04/02/c_1713729983803145.htm); the product does not serve the mainland public, so filing does not apply.
Filing status is quoted from the CAC public registry (updated batch by batch; this site copies the number and does not interpret it). "Direct access" is this site's own reachability measurement from a mainland network, not a vendor promise. GitHub-hosted sites fluctuated on the measurement day — the note says so.
8 questions, one table
8 questions, each comparable item by item with its peers.
- Model & openness
Its answer is model routing, with the most aggressive spec. Official /models catalog page, verbatim:
"giving you access to 7815 models from 213 providers through a single API."
Usage is a
provider/modelstring. Official examples:openai/gpt-5.6-sol,anthropic/claude-sonnet-4-6,openrouter/anthropic/claude-haiku-4.5.When a key is missing, the runtime error names the missing variable.
Official wording: "Mastra reads the relevant environment variable (e.g.
ANTHROPIC_API_KEY) and routes requests to the provider."Official model fallbacks are supported.
You can also mix-and-match different models per task. And select models dynamically via
requestContext.Official wording: "If a provider experiences an outage, Mastra can automatically switch to another provider at the application level"
Local models are explicitly supported by the official docs. The /models page has a dedicated section:
Official wording: "Use local models with Mastra"
Official wording: "Mastra also supports local models like
gpt-oss,Qwen3,DeepSeek... that you run on your own hardware"The prerequisite is that the local side provides an OpenAI-compatible API server. The official docs recommend LMStudio.
Local example:
id: "lmstudio/qwen/qwen3-30b-a3b-2507"url: "http://localhost:1234/v1"
⚠ One place where the official numbers conflict: the README highlights section says "Connect to 40+ providers", while the /models catalog page says "213 providers / 7815 models".
Old wording: we take the catalog page as authoritative; the README's 40+ is treated as outdated.
After switching providers, the alignment of each vendor's tool calling / structured output is not stated by the official docs (/models page checked).
- Where it runs
It starts as a pure library, but the official docs pave both the "standalone server" and "hosted platform" roads.
The form is an npm package (
@mastra/core; the official.npmrcrequires Node.js>=22.13.0).Official wording: "Mastra applications can be deployed to any Node.js-compatible environment."
Runtime support: Node.js v22.13.0+, Bun, Deno, Cloudflare.
It ships a built-in Hono-based server.
mastra buildproduces a bundle deployable to any VM / container / PaaS, or runs as a standalone server; it can also be embedded in Next.js / React / Node apps.Local development:
mastra dev; Studio starts athttp://localhost:4111.Who runs the agent loop: by default you do (self-hosted). For hosting there is the Mastra platform Server — Official wording: "A production deployment target that runs your Mastra application as an API server".
Multi-agent concurrent scheduling: via workflows (built-in execution engine), or deploy to workflow runners like Inngest. Production can run orchestration and cron in separate worker processes (official Workers page).
In short: "where the code lives" = your process; "whether to host" = an optional platform.
- Local files
The core framework does not ship a file system; file capability must be added explicitly.
Mastra positions itself as an AI application/agent framework. The official docs do not treat file read/write as a default agent capability.
Tool surface: the README and agents page describe two different tool surfaces. One is
createTool()custom tools, the other is MCP.The three file paths the official docs give (harness page and platform page checked):
① Provide file tools yourself via
createTool().② Use the Harness's
createCodingAgent()(official harness table). Official wording: "Give an agent files, a shell, and the defaults a coding agent needs →createCodingAgent()"It "Build a standard agent with a workspace, task tracking, and retries already configured".
③ Use the Mastra platform's Workspace (officially each environment gets a managed Workspace):
"gives agents a filesystem and sandbox with no manual configuration"
The default boundary of file access in the core framework itself (restricted to the project directory? out-of-bounds intercepted?) is not stated by the official docs.
Verified: agents page, harness page, deployment page checked. The host permission model sits on the platform Workspace side, not in the OSS core.
- Tasks after shutdown
A very strong dimension: durable agents + restart-surviving snapshots are verifiable core mechanisms. Official suspend-and-resume page, verbatim:
"Suspension saves the current execution state as a snapshot. Later, resume from a specific step ID to restore the exact captured state. Snapshots are stored in your configured storage provider and persist across deployments and application restarts."
Mechanism details:
suspend()pauses within a step and marks the statesuspended- workflow-level
.sleep()/.sleepUntil()markwaiting resume({ step, resumeData })continues from the pause point; with only arunIdyou must firstcreateRun({ runId })suspendDatacan retrieve the data originally passed tosuspend()upon resumeworkflow.getWorkflowRunById()+createWorkflowStateReader()can recover dangling runs from storage
The Harness layer adds:
- Durable Agents: "Persist run state and let clients reconnect to its stream"
- Background Tasks: "Run slow tools, workflows, or subagents without blocking"
- Schedules: cron starts runs
Hosted background: the Mastra platform Server provides 24/7 residency (Persistent Server billed per project; unit price on the official page). OSS self-hosting is "you run the process yourself" — stop it and it's gone.
- Tools & extensions
The tool surface is a three-piece set: custom tools + first-class MCP support + acting as an MCP server. The official docs cover it well.
Custom tools must use
createTool().The official agents page warns explicitly: plain-object tools fail silently.
Official wording: "silently fail to execute" — requires
id/description/inputSchema/execute().MCP is the standalone package
@mastra/mcp, with two official classes:MCPClient: connect to one or more MCP serversMCPServer: expose Mastra's agents / tools / workflows / prompts / resources as an MCP server
Official transport examples cover stdio (
command: npx ...) and remote HTTP(S) (url: new URL(...)). And registry-access examples for Klavis AI, mcp.run, Composio, Smithery, Ampersand.It also distinguishes two tool kinds: static tools (
getTools(), fixed config) and dynamic tools (getToolsets()): per-user/per-request credentials. Very useful for multi-tenant SaaS.There are also A2A (
@mastra/coreexposes the./a2asubpath) and skills (./skills) submodules. Subagent/multi-agent delegation is officially called supervisor + subagents (see the delegation notes on the memory page).- Context & memory
It splits "memory" into multiple layers, with two separate mechanisms for "state ≠ context".
Official memory page: stores message history by default, with three more opt-in:
- Observational Memory (recommended): "Uses background agents to maintain a dense observation log that replaces raw message history as it grows. This keeps the context window small while preserving long-term memory."
- Working memory: structured user data (names, preferences, goals)
- Semantic recall: recall past messages semantically rather than by keyword
When over budget, memory processors filter / trim / prioritize. Scope is split by two IDs:
resource(user/entity) andthread(conversation). Across agents it can be shared or isolated (scope: 'resource' | 'thread').The state side is the workflow snapshot (suspend/resume, see the background axis) — separate from memory.
RAG is a standalone system (
@mastra/rag): MDocument chunking (recursive / sliding window), embedding, then into a vector store (officially named: pgvector, Pinecone, Qdrant, MongoDB).In short: snapshots store flow state. Memory stores conversation and long-term user information. RAG stores external knowledge. The three serve different purposes.
- Permissions & limits
Authentication is "optional, multi-provider"; HITL is full suspend/resume; sandboxing sits only on the platform side. Official auth page, verbatim:
"Authentication is optional. If no auth is configured, all routes and Studio are publicly accessible."
Once configured, it locks both the Studio UI (login + RBAC) and API routes. Custom routes can opt out with
requiresAuth: false.- Built-in: Simple Auth / JWT
- Third-party: Auth0, Better Auth, Clerk, Firebase, Google, Okta, Supabase, WorkOS
- Other: Composite / custom providers
Checked: auth page and pricing page.
Human intervention: use workflow suspend/resume for approvals (see the background axis). The official docs also have a human-in-the-loop page and AgentController (in-session approvals, queued follow-ups, stopping runs).
Sandbox: whether the OSS core provides process/container-level sandboxing is not stated by the official docs. Sandbox capability sits in the platform Workspace and
createCodingAgent().Enterprise permissions (RBAC, SSO, IAM, network policy) belong to the
ee/enterprise license (Self-Hosted Enterprise selling points on the official pricing page).Network access control in the core framework is not stated by the official docs (auth page and pricing page checked).
- Best for
Fits:
- TypeScript / Node teams wanting a batteries-included agent framework — Agents + graph Workflows + Memory + RAG + Evals + MCP + built-in server + Studio all in one package
- You need materialized suspend/resume and durable runs (snapshots in your own storage, resumable across restarts)
- You want many model providers and local models (officially recommended: LMStudio)
- You need to expose agents/workflows over MCP, or act as an MCP client
- You want to embed agents in Next.js / React apps
Does not fit:
- Python stacks (look at LangGraph / Pydantic AI)
- Wanting low-level control over the graph engine and tool surface (Mastra's abstraction is higher, the package bigger, the conventions more)
- Insisting on zero commercial components (platform Studio/observability/hosted deployment are separate paid products; the
ee/directory needs an enterprise license) - Needing framework-shipped process-level sandbox and network policy (that part is not in the OSS core)
Licence and terms of use
核心 Apache-2.0 + ee/ 目录 Mastra Enterprise License(仓库 license API 返回 NOASSERTION)
Top misconception
- Assuming Mastra is entirely Apache-2.0 and free - the
ee/directory is source-available and needs an enterprise licence for production; the repo licence API returns NOASSERTION - Treating Mastra Studio / observability / hosted deployment as part of the framework - those are Mastra platform products, billed on Starter $0 / Teams $250 / Enterprise tiers
- Taking the README's "40+ providers" as the ceiling - the official
/modelsdirectory page states 213 providers / 7815 models - Assuming local models need code changes - the official path is an OpenAI-compatible endpoint with LMStudio recommended, configured via
id+url
Evidence sources
Checked 2026-10-23,Content updated 2026-10-08。This is the date of the entry, not a claim that every field was rechecked that day.
| Type | Name | Link |
|---|---|---|
| repo | mastra-ai/mastra · repository (29,020★, NOASSERTION dual license, rolling verification 2026-10-23) | https://github.com/mastra-ai/mastra |
| docs | Repo README (TypeScript positioning, model routing 40+, agents/workflows/HITL/memory/RAG/evals/MCP highlights, Licensing dual-license section) | https://github.com/mastra-ai/mastra |
| docs | Official docs · Model Providers (7815 models / 213 providers, provider/model, fallbacks, local models and LMStudio) | https://mastra.ai/models |
| docs | Official docs · Provider catalog (OpenAI/Anthropic/Google/xAI and other providers with model counts) | https://mastra.ai/models/providers |
| docs | Official docs · Suspend and resume (snapshot stored in storage, resume across restarts, resume/suspendData, state reader) | https://mastra.ai/docs/workflows/suspend-and-resume |
| docs | Official docs · Workflows (createStep/createWorkflow, standard JSON Schema, built-in execution engine) | https://mastra.ai/docs/workflows/overview |
| docs | Official docs · Memory (message history, Observational Memory, working memory, semantic recall, processors) | https://mastra.ai/docs/memory/overview |
| docs | Official docs · RAG (MDocument chunking, embedding, pgvector/Pinecone/Qdrant/MongoDB vector stores) | https://mastra.ai/docs/rag/overview |
| docs | Official docs · Evals (Scorers: model-graded / rule-based / statistical, returning 0-1 scores) | https://mastra.ai/docs/evals/overview |
| docs | Official docs · MCP Overview (MCPClient / MCPServer, stdio and remote HTTP, registry access, static/dynamic tools) | https://mastra.ai/docs/tools-mcp/mcp-overview |
| docs | Official docs · Deploy (Node/Bun/Deno/Cloudflare, Hono server, Mastra platform, workflow runners, workers) | https://mastra.ai/docs/deployment/overview |
| docs | Official docs · Mastra platform (Observability / Studio / Server, hosted Workspace with filesystem and sandbox) | https://mastra.ai/docs/mastra-platform/overview |
| docs | Official docs · Harness (Durable Agents, Background Tasks, Schedules, createCodingAgent) | https://mastra.ai/docs/harness/overview |
| docs | Official docs · Auth (auth optional, public by default, JWT/SSO/RBAC, Studio and API protected together) | https://mastra.ai/docs/auth/overview |
| pricing | Official pricing page (verified 2026-10-08: Platform three tiers Starter/Teams/Enterprise; Self-Hosted Free and Enterprise; Persistent Server billed per project; Gateway has markup rates) | https://mastra.ai/pricing |
| changelog | Releases (@mastra/core 1.75.0 @ 2026-10-07) | https://github.com/mastra-ai/mastra/releases |
Test notes
This site has not completed measured runs. The test protocol is at protocols/framework/_protocol.md.
Suggested runs (tailored to orchestration framework + TS ecosystem dimensions):
| # | What to test | Why it is worth testing |
|---|---|---|
| 1 | How many files and lines for a minimal agent + workflow | quantifies the real onboarding cost of "everything you need" |
| 2 | Kill the process mid-workflow; can the snapshot truly resume from the suspended step | the official docs promise persist across restarts — must verify |
| 3 | Run one workflow with a local model via LMStudio | officially recommended by name; verify real feasibility |
| 4 | Same task implemented as agent vs workflow — code-volume difference | tests the official advice "use workflows for explicit flows" |
| 5 | Information loss and extra LLM cost after Observational Memory compression | officially recommended as default-on; the cost is unmeasured |
| 6 | Minimal path from OSS self-hosted mastra build to your own containers | tests how far "pure library can also go to production" really goes |
The "batteries included" pole of the TypeScript ecosystem
In our harness section, the Python side already has a batch of objects: LangGraph / CrewAI / OpenAI Agents SDK / Pydantic AI.
Mastra is the one that translates the same idea into the TypeScript world. And its abstraction level is higher:
| LangGraph | Mastra | |
|---|---|---|
| Language | Python (plus langgraphjs) | TypeScript (main game) |
| Self-description | low-level orchestration framework | "everything you need", out-of-the-box |
| Graph workflows | explicit graph / superstep | createWorkflow() + .then()/.branch()/.parallel() |
| Preset capabilities | no tools/file system | Memory / RAG / Evals / MCP / server / Studio all preset |
| Commercial line | LangSmith Deployment | Mastra platform (Observability / Studio / Server, YC W25) |
One-line rule: want to draw the flow yourself, want the lowest layer → LangGraph. Want less wiring, want everything out of the box → Mastra.
Model routing: the most complete answer to the first decision point
Its answer to the first decision point is model routing, and the spec is the most complete: one provider/model string switches providers. Official /models catalog page, verbatim:
giving you access to 7815 models from 213 providers through a single API.
Usage is a provider/model string. Mastra reads the matching environment variable and routes. The official docs also give three selection modes:
- model fallbacks: if a provider goes down, switch automatically
- mix-and-match different models per task
- select models dynamically via
requestContext
Local models are explicitly supported by the official docs. The /models page has a dedicated section "Use local models with Mastra":
Mastra also supports local models likegpt-oss,Qwen3,DeepSeek... that you run on your own hardware
The local service must provide an OpenAI-compatible API. The official docs recommend LMStudio.
Local example:
id: "lmstudio/qwen/qwen3-30b-a3b-2507"url: "http://localhost:1234/v1"
⚠ One official number to calibrate for readers: the repo README highlights say "Connect to 40+ providers", while the /models catalog page says 213 providers / 7815 models — far apart. We take the catalog page as authoritative; the README's 40+ is treated as outdated.
Unknown: after switching providers, the alignment of each vendor's tool calling / structured output is not stated by the official docs.
State ≠ context: it gives both mechanisms
Mastra separates "flow state" from "conversation memory" cleanly — its most memorable design choice.
- Flow state = the workflow's snapshot, granular to the step. Official suspend-and-resume page, verbatim:
Suspension saves the current execution state as a snapshot ... stored in your configured storage provider and persist across deployments and application restarts.
This is exactly the "state persistence that survives process restarts" we look for.
- Conversation/long-term memory = memory's multiple layers:
- message history (default)
- Observational Memory: background agents compress old messages into observations, officially recommended
- working memory: structured user data
- semantic recall: semantic retrieval
When over budget, memory processors trim.
- External knowledge = RAG (
@mastra/rag+ vector stores).
The three serve different purposes and their storage can be configured separately. This is exactly the landing form of our "state ≠ context" claim.
Tools and MCP: both a client and a server
The tool surface is a three-piece set: custom tools, MCP client, MCP server. The official docs give two classes (standalone package @mastra/mcp):
MCPClient: connect to one or more MCP servers — stdio (command: npx ...) or remote HTTP (url).MCPServer: expose your own agents / tools / workflows / prompts / resources as an MCP server.
It also distinguishes two tool kinds:
- Static tools
getTools(): fixed config - Dynamic tools
getToolsets(): per-user/per-request credentials
Official registry-access examples for Klavis AI, mcp.run, Composio, Smithery, Ampersand.
Custom tools must go through createTool(). The official agents page warns explicitly: plain-object tools fail silently.
License and commercial line: must be read separately
Conclusion first: the core framework is Apache-2.0. The ee/ directory is source-available. Production use requires an enterprise license.
The repo README's Licensing section is clear — it is a dual license:
Apache License 2.0: The core framework and the vast majority of this codebase is open source under Apache-2.0. Mastra Enterprise License: Code in any directory named ee/ ... is source-available ... require a valid enterprise license for production use.
GitHub's license API returns NOASSERTION for the whole repo. That is consistent with the dual-license statement: not "no license", but "non-standard dual license".
The other line is the Mastra platform (YC W25). The official pricing page (verified 2026-10-08) splits into two places:
- Platform three tiers: Starter (free), Teams (paid), Enterprise (custom)
- Self-hosted two tiers: Free and Enterprise
Studio, Observability, hosted Server, and 24/7 residency are all platform products (hosted residency billed per project; unit price on the official page). They are not shipped with the framework. Quotes not stored per our price-recording policy.
Verification notes
Basis for confidence: partial:
Why still partial: all eight axes have been verified to conclusions from official pages. But several items remain that the official docs genuinely do not state, recordable only as "not stated officially". Four in total:
- After switching providers, the alignment of each vendor's tool calling / structured output
- The default boundary of file access in the core framework itself
- Network access control mechanisms in the OSS core
- The functional boundary of what falls under the enterprise license beyond
ee/
These are not "we couldn't find it" — the official docs themselves don't give them, so it cannot rise to verified.
Official pages checked the 2026-10-08 check: repo README (positioning, highlights, Licensing dual-license section),/models(providers and local models),/models/providers,docs/workflows/overview,docs/workflows/suspend-and-resume,docs/memory/overview,docs/rag/overview,docs/evals/overview,docs/tools-mcp/mcp-overview,docs/deployment/overview,docs/mastra-platform/overview,docs/harness/overview,docs/auth/overview,docs/agents/overview, the official pricing pagemastra.ai/pricing, releases (@mastra/[email protected]@ 2026-10-07), npm registry (@mastra/coreengines Node>=22.13.0). Verification method: WebFetch on each official page plus the GitHub API (repo metadata, releases).
Related entries
- LangGraphThe TS-vs-Python head-on shot: LangGraph is a low-level graph engine (no preset tools/file system); Mastra is TypeScript's batteries-included full-stack framework. Foundation vs out-of-the-box — this is the first comparison table.
- Pydantic AIThe counterpart in another language: Pydantic AI uses Python's type safety for structured output and durable execution; Mastra uses TypeScript's model routing and full-stack capability. Their answers to the "first decision point" differ.
- CrewAIBoth batteries-included orchestration frameworks: CrewAI goes with the Crew/Flow business metaphor (Python); Mastra goes with the engineering vocabulary of agents + graph workflows (TypeScript).
- OpenAI Agents SDKThe opposite contrast: that one is a primitives-only thin harness; Mastra is a thick framework with memory/RAG/evals/MCP/server all preset.
- Filesystem MCP ServerOther layer · MCP tools
Same-category peers
Look at these three before reading further
Selected by overlap in jobs, not ranked. Compare where it runs, licence and status first; if one of the three fails, skip it.
| Object | Where | Licence | Evidence / status | What it is for |
|---|---|---|---|---|
| Google ADK(Agent Development Kit) | Cloud / API | Open licence | 8 questions checked Active | In one line: Google ADK is a code-first agent orchestration framework wh |
| AG2 | Local / self-hosted | Open licence | 8 questions checked Active | The community continuation of AutoGen after the original repo stalled. T |
| DSPy | Local / self-hosted | Open licence | 8 questions checked Active | DSPy turns 'tuning prompts' into a programming problem (MIT, Stanford NL |
This page is generated from the ai-handbook data layer (CC BY 4.0).
For the judging criteria and method notes, see METHODOLOGY.md.