跳到主要内容Skip to main content
← Frameworks

MastraMastra

Mastra AI
TypeScriptTypeScript 开源Open source Apache-2.0Apache-2.0 编排框架Orchestration framework 工作流Workflows 图执行Graph execution 事件驱动Event-driven 多AgentMulti-agent 状态管理State management 持久化Persistence 自托管Self-hosted MCPMCP RAGRAG 检索Retrieval evaleval 上下文压缩Context compression 集成生态Integration ecosystem 商业平台Commercial platform partial lifecycle: active 核验Checked 2026-10-23

Mastra 是「TypeScript 生态的全栈式 agent 框架」。

装一个包,Agents、图工作流、Memory、RAG、Evals、MCP、内置 server 与 Studio 就都在里面。

官方自述很直白:

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.

关键词是 everything。它与 LangGraph 的差别,正好是本站反复强调的那条分野: LangGraph 自认 low-level、不预置工具与文件系统;Mastra 走 batteries included 的厚路线。

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

适合 TypeScript / Node 团队。 理由:

  • 要一套开箱即用的 agent 框架(Agents + 图 Workflows + Memory + RAG + Evals + MCP + server + Studio)
  • 需要 suspend/resume 与 durable run
  • 要接大量 provider 与本地模型
  • 要把 agent/workflow 用 MCP 暴露出去
  • 要嵌进 Next.js / React

不适合四类情况:

  • Python 栈(看 LangGraph / Pydantic AI)
  • 想要 lowest-level、自己掌控图引擎与工具面
  • 坚持不用任何商业组件(平台与 ee/ 是单独授权)
  • 需要框架自带进程级沙箱与网络策略

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-20

出品属地Origin
国外出品foreign-made 国外主体(网信办公示名单未见对应备案主体)。foreign entity (no matching filing entity in the CAC registry).
国内使用Direct access
大陆可直连direct OK 官网直连实测 200。official site measured 200 direct.
备案状态CAC filing
未见于备案名单not in filing list:未见于网信办公示名单(2026-10-20 检索 13 批附件,https://www.cac.gov.cn/2024-04/02/c_1713729983803145.htm);该产品未面向大陆公众提供服务,备案不适用。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.

备案信息以网信办《生成式人工智能服务已备案信息》公示名单为准(按批次滚动更新,本站只抄编号不解读);「大陆可直连」是本站从大陆网络直连实测的结果,不是厂商承诺。GitHub 类站点当日实测有波动,口径写在依据里。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.

固定坐标系Fixed coordinate system

8 个维度dimensions, 与同分区其他对象逐项可比each comparable item by item against others in the same section.

模型与开放条件Model & openness

它的答案是 model routing,规格写得最狠。 官方 /models 目录页原文:

"giving you access to 7815 models from 213 providers through a single API."

用法是 provider/model 字符串。官方示例: openai/gpt-5.6-sol、anthropic/claude-sonnet-4-6、openrouter/anthropic/claude-haiku-4.5。

缺 key 时,运行时错误会明确指出缺哪个变量。

官方原文:"Mastra reads the relevant environment variable (e.g. ANTHROPIC_API_KEY) and routes requests to the provider."

官方支持 model fallbacks。

也可按任务 mix-and-match 不同模型。 还能用 requestContext 动态选模型。

官方原文:"If a provider experiences an outage, Mastra can automatically switch to another provider at the application level"

本地模型是官方明确支持的。 /models 页有专节:

官方原文:"Use local models with Mastra"

官方原文:"Mastra also supports local models like gpt-oss, Qwen3, DeepSeek ... that you run on your own hardware"

前提是本地要提供 OpenAI 兼容 API server。官方推荐 LMStudio。

本地示例:

  • id: "lmstudio/qwen/qwen3-30b-a3b-2507"
  • url: "http://localhost:1234/v1"

⚠ 一处官方自身数字打架:README 亮点段写的是 "Connect to 40+ providers", 而 /models 目录页写 "213 providers / 7815 models"。

旧口径:本站以目录页为准,README 的 40+ 视为旧口径。

换 provider 后各家 tool calling / structured output 的对齐度,官方未说明(已查 /models 页)。

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/model string. 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

纯库起步,但官方把「独立 server」和「托管平台」两条路都铺好了。

形态是 npm 包(@mastra/core,官方 .npmrc 要求 Node.js >=22.13.0)。

官方原文:"Mastra applications can be deployed to any Node.js-compatible environment."

运行时支持 Node.js v22.13.0+、Bun、Deno、Cloudflare。

它内置一个基于 Hono 的 server。可用 mastra build 打出后部署到任意 VM / 容器 / PaaS, 或作为 standalone server 独立运行;也能嵌进 Next.js / React / Node 应用。

本地开发:用 mastra dev,Studio 起在 http://localhost:4111。

谁运营 agent loop:默认是你自己(自托管)。要托管可选 Mastra 平台 Server —— 官方原文:"A production deployment target that runs your Mastra application as an API server"。

多 agent 并发调度:走 workflows(内置执行引擎),或部署到 Inngest 等 workflow runner。 生产可用独立 worker 进程跑编排与 cron(官方 Workers 页)。

即「代码在哪」= 你的进程;「要不要托管」= 可选平台。

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 .npmrc requires 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 build produces 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 at http://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

核心框架不内置文件系统,文件能力要显式加装。

Mastra 的定位是 AI 应用/agent 框架。官方文档没有把文件读写当成默认 agent 能力。

工具面:README 与 agents 页讲的工具面是两样。一是 createTool() 自定义工具,二是 MCP。

官方给的三条文件路径(已查 harness 页与 platform 页):

① 自己用 createTool() 提供文件工具。

② 走 Harness 的 createCodingAgent()(官方 harness 表)。官方原文:"Give an agent files, a shell, and the defaults a coding agent needs → createCodingAgent()"

它 "Build a standard agent with a workspace, task tracking, and retries already configured"。

③ 用 Mastra 平台的 Workspace(官方称每个 environment 会得到一个 managed Workspace):

"gives agents a filesystem and sandbox with no manual configuration"

核心框架自身的文件访问默认边界(是否限制在项目目录、越界是否拦截),官方未说明。

核验:已查 agents 页、harness 页、deployment 页。宿主权限模型落在平台 Workspace 那侧,不在 OSS 核心。

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

这是它非常强的一维:durable agents + 可跨重启的 snapshot 都是可查证的核心机制。 官方 suspend-and-resume 页原文:

"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."

机制细节:

  • suspend() 在某个 step 内暂停,并把状态标为 suspended
  • workflow 级 .sleep()/.sleepUntil() 标 waiting
  • resume({ step, resumeData }) 从暂停处继续;只给 runId 时需先 createRun({ runId })
  • suspendData 可在恢复时取回当初传给 suspend() 的数据
  • workflow.getWorkflowRunById() + createWorkflowStateReader() 可从存储中恢复悬挂的 run

Harness 层还有:

  • Durable Agents:"Persist run state and let clients reconnect to its stream"
  • Background Tasks:"Run slow tools, workflows, or subagents without blocking"
  • Schedules:cron 定时起 run

托管后台:Mastra 平台 Server 提供 24/7 常驻(Persistent Server 按项目计费,单价见官方页)。 OSS 自托管则是「你自己把进程跑起来」,关了就停。

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 state suspended
  • workflow-level .sleep()/.sleepUntil() mark waiting
  • resume({ step, resumeData }) continues from the pause point; with only a runId you must first createRun({ runId })
  • suspendData can retrieve the data originally passed to suspend() upon resume
  • workflow.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

工具面是三件套:自定义工具 + MCP 一等支持 + 可作 MCP server。官方文档给得很全。

自定义工具必须用 createTool()。

官方 agents 页明确警告:plain object 工具会 静默失败。

官方原文:"silently fail to execute" —— 需 id / description / inputSchema / execute()。

MCP 是独立包 @mastra/mcp,官方给两个类:

  • MCPClient:连一个或多个 MCP server
  • MCPServer:把 Mastra 的 agents / tools / workflows / prompts / resources 暴露成 MCP server

传输方式官方示例覆盖 stdio(command: npx ...)与远程 HTTP(S)(url: new URL(...))。 并给了 Klavis AI、mcp.run、Composio、Smithery、Ampersand 等注册表接入示例。

还区分两类工具:静态工具(getTools(),配置固定) 与 动态工具(getToolsets()):按用户/请求带凭据。对多租户 SaaS 很有用。

另有 A2A(@mastra/core 暴露 ./a2a 子路径)与 skills(./skills)子模块。 子代理/多 agent 委派官方称 supervisor + subagents(见 memory 页的 delegation 说明)。

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 servers
  • MCPServer: 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/core exposes the ./a2a subpath) and skills (./skills) submodules. Subagent/multi-agent delegation is officially called supervisor + subagents (see the delegation notes on the memory page).

上下文与记忆Context & memory

它把「记忆」拆成多层,且有「状态 ≠ 上下文」的两套机制。

官方 memory 页:默认存 message history,可另开三样:

  • Observational Memory(推荐):"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:存结构化的用户数据(名字、偏好、目标)
  • Semantic recall:按语义而非关键词召回历史消息

超限时用 memory processors filter / trim / prioritize。 作用域用两个 ID 划分:resource(用户/实体)和 thread(会话)。 多 agent 间可共享或隔离(scope: 'resource' | 'thread')。

状态那一套是 workflow 的 snapshot(suspend/resume,见 background 轴)—— 与 memory 分离。

RAG 是独立系统(@mastra/rag):MDocument 切块(recursive / sliding window)、embedding, 再落向量库(官方点名 pgvector、Pinecone、Qdrant、MongoDB)。

即:snapshot 存流程状态。memory 存对话与用户长期信息。RAG 存外部知识。三者用途不同。

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) and thread (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

认证是「可选、多 provider」,HITL 是完整的暂停/恢复,沙箱只落在平台侧。 官方 auth 页原文:

"Authentication is optional. If no auth is configured, all routes and Studio are publicly accessible."

配置后可同时锁住 Studio UI(登录 + RBAC)与 API 路由。 自定义路由可用 requiresAuth: false 单开。

  • 内置:Simple Auth / JWT
  • 第三方:Auth0、Better Auth、Clerk、Firebase、Google、Okta、Supabase、WorkOS
  • 其他:Composite / 自定义 provider

已查:auth 页与定价页。

人工介入:用 workflow 的 suspend/resume 做审批(见 background 轴)。 官方另有 human-in-the-loop 页与 AgentController(会话内审批、排队跟进、停止 run)。

沙箱:OSS 核心是否提供进程/容器级沙箱,官方未说明。 沙箱能力落在平台 Workspace 与 createCodingAgent()。

企业级权限(RBAC、SSO、IAM、network policy)属 ee/ 企业许可 (官方定价页 Self-Hosted Enterprise 卖点)。

核心框架的网络访问控制机制,官方未说明(已查 auth 页与定价页)。

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

适合:

  • TypeScript / Node 团队要一套「开箱即用」的 agent 框架 —— Agents + 图 Workflows + Memory + RAG + Evals + MCP + 内置 server + Studio 全在一个包里
  • 需要材料化的 suspend/resume 与 durable run(snapshot 存在你自己的存储、跨重启可恢复)
  • 要接大量模型 provider 与本地模型(官方推荐 LMStudio)
  • 需要把 agent/workflow 用 MCP 暴露出去,或当 MCP 客户端
  • 想把 agent 嵌进 Next.js / React 应用

不适合:

  • Python 栈(该看 LangGraph / Pydantic AI)
  • 想要 low-level、自己掌控图引擎与工具面(Mastra 抽象更高、包更大、约定更多)
  • 坚持完全不用任何商业组件(平台 Studio/观测/托管部署是单独的付费产品,ee/ 目录需企业许可)
  • 需要框架自带进程级沙箱与网络策略(那部分不在 OSS 核心)

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)

头号误解Top misconception

  • 以为 Mastra 全是 Apache-2.0 免费 —— ee/ 目录是 source-available,生产用需企业许可,仓库 license API 返回 NOASSERTIONAssuming 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
  • 把 Mastra Studio / 观测 / 托管部署当成框架自带 —— 那些是 Mastra 平台产品,按 Starter / Teams / Enterprise 分档计费Treating Mastra Studio / observability / hosted deployment as part of the framework - those are Mastra platform products, billed on Starter $0 / Teams $250 / Enterprise tiers
  • 把 README 的「40+ providers」当作上限 —— 官方 /models 目录页写的是 213 providers / 7815 modelsTaking the README's "40+ providers" as the ceiling - the official /models directory page states 213 providers / 7815 models
  • 以为本地模型要改代码 —— 官方支持 OpenAI 兼容端点,推荐 LMStudio,属配置项(id + url)Assuming local models need code changes - the official path is an OpenAI-compatible endpoint with LMStudio recommended, configured via id + url

未知项清单Known unknowns

  • 换 provider 后各家 tool calling / structured output 的能力对齐度(官方未说明)
  • 核心框架自身的文件访问默认边界(官方未说明,已查 agents 页、harness 页、deployment 页)
  • OSS 核心是否有网络访问控制的官方机制(官方未说明)
  • ee/ 目录之外还有哪些功能属企业许可范围(官方 README 只给目录示例,未给完整功能清单)
  • 跨进程 / 多实例并发 resume 同一 snapshot 的冲突语义(官方未说明)
  • Observational Memory 压缩后的信息损失与成本(本站未做端到端实测)
  • Mastra 平台各档的实际吞吐与超量计费在真实负载下的表现(官方只给计费口径)
  • 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)

证据来源Evidence sources

判断可回到以下一手源复核。本站核验日Every judgement can be rechecked against the primary sources below. Verified on 2026-10-23,内容更新日content updated on 2026-10-08。

类型Type名称Name链接Link
repomastra-ai/mastra · 仓库(29,020★,NOASSERTION 双许可,滚动核验 2026-10-23)mastra-ai/mastra · repository (29,020★, NOASSERTION dual license, rolling verification 2026-10-23)https://github.com/mastra-ai/mastra
docs仓库 README(TypeScript 定位、model routing 40+、agents/workflows/HITL/memory/RAG/evals/MCP 亮点、Licensing 双许可段)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官方文档 · Model Providers(7815 models / 213 providers、provider/model、fallbacks、本地模型与 LMStudio)Official docs · Model Providers (7815 models / 213 providers, provider/model, fallbacks, local models and LMStudio)https://mastra.ai/models
docs官方文档 · Provider 目录(OpenAI/Anthropic/Google/xAI 等 provider 与模型数)Official docs · Provider catalog (OpenAI/Anthropic/Google/xAI and other providers with model counts)https://mastra.ai/models/providers
docs官方文档 · Suspend and resume(snapshot 存 storage、跨重启恢复、resume/suspendData、state reader)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官方文档 · Workflows(createStep/createWorkflow、标准 JSON Schema、内置执行引擎)Official docs · Workflows (createStep/createWorkflow, standard JSON Schema, built-in execution engine)https://mastra.ai/docs/workflows/overview
docs官方文档 · Memory(message history、Observational Memory、working memory、semantic recall、processors)Official docs · Memory (message history, Observational Memory, working memory, semantic recall, processors)https://mastra.ai/docs/memory/overview
docs官方文档 · RAG(MDocument 切块、embedding、pgvector/Pinecone/Qdrant/MongoDB 向量库)Official docs · RAG (MDocument chunking, embedding, pgvector/Pinecone/Qdrant/MongoDB vector stores)https://mastra.ai/docs/rag/overview
docs官方文档 · Evals(Scorers:model-graded / rule-based / statistical,返回 0-1 分数)Official docs · Evals (Scorers: model-graded / rule-based / statistical, returning 0-1 scores)https://mastra.ai/docs/evals/overview
docs官方文档 · MCP Overview(MCPClient / MCPServer、stdio 与远程 HTTP、注册表接入、静态/动态工具)Official docs · MCP Overview (MCPClient / MCPServer, stdio and remote HTTP, registry access, static/dynamic tools)https://mastra.ai/docs/tools-mcp/mcp-overview
docs官方文档 · Deploy(Node/Bun/Deno/Cloudflare、Hono server、Mastra 平台、workflow runners、workers)Official docs · Deploy (Node/Bun/Deno/Cloudflare, Hono server, Mastra platform, workflow runners, workers)https://mastra.ai/docs/deployment/overview
docs官方文档 · Mastra 平台(Observability / Studio / Server、托管 Workspace 带 filesystem 与 sandbox)Official docs · Mastra platform (Observability / Studio / Server, hosted Workspace with filesystem and sandbox)https://mastra.ai/docs/mastra-platform/overview
docs官方文档 · Harness(Durable Agents、Background Tasks、Schedules、createCodingAgent)Official docs · Harness (Durable Agents, Background Tasks, Schedules, createCodingAgent)https://mastra.ai/docs/harness/overview
docs官方文档 · Auth(认证可选、默认公开、JWT/SSO/RBAC、Studio 与 API 一起保护)Official docs · Auth (auth optional, public by default, JWT/SSO/RBAC, Studio and API protected together)https://mastra.ai/docs/auth/overview
pricing官方定价页(核验 2026-10-08:Platform 三档 Starter/Teams/Enterprise;Self-Hosted Free 与 Enterprise;Persistent Server 按项目计费;Gateway 有加价费率)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
changelogReleases(@mastra/core 1.75.0 @ 2026-10-07)Releases (@mastra/core 1.75.0 @ 2026-10-07)https://github.com/mastra-ai/mastra/releases

实测记录Measured runs

本档未跑集成与性能实测;结论只覆盖 API 与官方文档披露的能力面。

实测建议(按编排框架 + TS 生态维度定制):

#测什么为什么值得测
1一个最小 agent + workflow 要几个文件、多少行量化「everything you need」的真实上手成本
2workflow 跑到一半 kill 进程,靠 snapshot 能否真从暂停 step 恢复官方承诺 persist across restarts,须验证
3用 LMStudio 接本地模型跑通一个 workflow官方点名推荐,验证真实可行性
4同一任务分别用 agent 与 workflow 实现,代码量差多少验证「明确流程用 workflow」的官方建议
5Observational Memory 压缩后的信息损失与额外 LLM 成本官方推荐默认开,代价未做实测
6OSS 自托管走 mastra build 部署到自有容器的最小路径验证「纯库也能上生产」的程度

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 testWhy it is worth testing
1How many files and lines for a minimal agent + workflowquantifies the real onboarding cost of "everything you need"
2Kill the process mid-workflow; can the snapshot truly resume from the suspended stepthe official docs promise persist across restarts — must verify
3Run one workflow with a local model via LMStudioofficially recommended by name; verify real feasibility
4Same task implemented as agent vs workflow — code-volume differencetests the official advice "use workflows for explicit flows"
5Information loss and extra LLM cost after Observational Memory compressionofficially recommended as default-on; the cost is unmeasured
6Minimal path from OSS self-hosted mastra build to your own containerstests how far "pure library can also go to production" really goes

TypeScript 生态里的「batteries included」一极The "batteries included" pole of the TypeScript ecosystem

本站 harness 分区里,Python 侧已经有一批对象:LangGraph / CrewAI / OpenAI Agents SDK / Pydantic AI。

Mastra 就是把同一件事翻译到 TypeScript 世界的那一个。而且它的抽象层次更高:

LangGraphMastra
语言Python(另有 langgraphjs)TypeScript(主业)
自述low-level 编排框架"everything you need",out-of-the-box
图工作流显式 graph / superstepcreateWorkflow() + .then()/.branch()/.parallel()
预置能力不管工具/文件系统Memory / RAG / Evals / MCP / server / Studio 全预置
商业线LangSmith DeploymentMastra 平台(Observability / Studio / Server,YC W25)

一句口诀:想自己画流程、要最低层 → LangGraph。想少接线、要开箱就全 → Mastra。

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:

LangGraphMastra
LanguagePython (plus langgraphjs)TypeScript (main game)
Self-descriptionlow-level orchestration framework"everything you need", out-of-the-box
Graph workflowsexplicit graph / superstepcreateWorkflow() + .then()/.branch()/.parallel()
Preset capabilitiesno tools/file systemMemory / RAG / Evals / MCP / server / Studio all preset
Commercial lineLangSmith DeploymentMastra 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

它的第一决策点答案是 model routing,而且规格写得最完整:一个 provider/model 字符串就能换 provider。 官方 /models 目录页原文:

giving you access to 7815 models from 213 providers through a single API.

用法就是 provider/model 字符串。Mastra 自己读对应环境变量并路由。官方还给三种选法:

  • model fallbacks:provider 挂了自动切
  • 按任务 mix-and-match 不同模型
  • 用 requestContext 动态选模型

本地模型是官方明确支持的。 /models 页有专节 "Use local models with Mastra":

Mastra also supports local models like gpt-oss, Qwen3, DeepSeek ... that you run on your own hardware

本地服务需提供 OpenAI 兼容 API。官方推荐 LMStudio。

本地示例:

  • id: "lmstudio/qwen/qwen3-30b-a3b-2507"
  • url: "http://localhost:1234/v1"
⚠ 一处要替读者校准的官方数字:仓库 README 亮点段写 "Connect to 40+ providers", 而 /models 目录页写 213 providers / 7815 models —— 两者差得远。本站以目录页为准, README 的 40+ 视为旧口径。

未知:换 provider 后各家 tool calling / structured output 的对齐度,官方未说明。

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 like gpt-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 把「流程状态」和「对话记忆」分得很清,这是它最值得记的一处设计。

  • 流程状态 = workflow 的 snapshot,粒度到 step。官方 suspend-and-resume 页原文:
Suspension saves the current execution state as a snapshot ... stored in your configured storage provider and persist across deployments and application restarts.

这就是本站要找的「可跨进程恢复的状态持久化」。

  • 对话/长期记忆 = memory 的多层:
  • message history(默认)
  • Observational Memory:后台 agent 把旧消息压成 observation,官方推荐
  • working memory:结构化用户数据
  • semantic recall:语义召回

超限时用 memory processors 裁剪。

  • 外部知识 = RAG(@mastra/rag + 向量库)。

三者用途不同、存储也可分开配置。这正是本站主张的「状态 ≠ 上下文」的落地形态。

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.

工具与 MCP:既能当客户端,也能当 serverTools and MCP: both a client and a server

工具面是三件套:自定义工具、MCP 客户端、MCP server。 官方给两个类(独立包 @mastra/mcp):

  • MCPClient:连一个或多个 MCP server —— stdio(command: npx ...)或远程 HTTP(url)。
  • MCPServer:把你自己的 agents / tools / workflows / prompts / resources 暴露成 MCP server。

还区分两类工具:

  • 静态工具 getTools():配置固定
  • 动态工具 getToolsets():按用户/请求带凭据

官方给了 Klavis AI、mcp.run、Composio、Smithery、Ampersand 等注册表接入示例。

自定义工具必须走 createTool()。官方 agents 页明确警告:plain object 工具会 静默失败。

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

结论先说:核心框架 Apache-2.0。ee/ 目录 source-available。生产用需企业许可。

仓库 README 的 Licensing 段说得很清楚,是双许可:

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 的 license API 对整仓返回 NOASSERTION。 它与这段双许可声明一致:不是「无许可」,是「非标准双许可」。

另一条线是 Mastra 平台(YC W25)。官方定价页(核验 2026-10-08)分两处:

  • 平台三档:Starter(免费档)、Teams(付费档)、Enterprise(定制)
  • 自托管两档:Free 与 Enterprise

Studio、Observability、托管 Server 与 24/7 常驻都是平台产品(常驻托管按项目计费,单价见官方页)。它们不是框架自带。报价按本站的报价记录约定不存。

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

confidence: partial 的依据:

为什么仍是 partial:八维已全部从官方页核到结论。但仍有若干处官方确实没写、 只能记「官方未说明」的项。共四处:

  • 换 provider 后各家 tool calling / structured output 的对齐度
  • 核心框架自身的文件访问默认边界
  • OSS 核心的网络访问控制机制
  • ee/ 与开源的功能分界

这些不是「没查到」,是官方文档本身没给,故不足以升到 verified。

已核到的官方页:仓库 README(定位、亮点、Licensing 双许可段)、 /models(provider 与本地模型)、/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、官方定价页 mastra.ai/pricing、 releases(@mastra/[email protected] @ 2026-10-07)、npm registry(@mastra/core engines Node >=22.13.0)。 核验方法:WebFetch 打开各官方页与 GitHub API(仓库元数据、releases)。

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 page mastra.ai/pricing, releases (@mastra/[email protected] @ 2026-10-07), npm registry (@mastra/core engines Node >=22.13.0). Verification method: WebFetch on each official page plus the GitHub API (repo metadata, releases).

相关条目Related entries

  • LangGraphLangGraphTS vs Python 的正面照:LangGraph 是 low-level 图引擎(不预置工具/文件系统),Mastra 是 TypeScript 的 batteries-included 全栈框架。要底座还是要开箱,这是第一张对照表。The 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 AIPydantic AI另一语言的对位:Pydantic AI 用 Python 的类型安全做结构化输出与 durable execution,Mastra 用 TypeScript 的 model routing 与全栈能力。两边的「第一决策点」答案不同。The 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.
  • CrewAICrewAI同为 batteries-included 编排框架:CrewAI 走 Crew/Flow 业务比喻(Python),Mastra 走 agents + graph workflows 工程词汇(TypeScript)。Both 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 SDKOpenAI Agents SDK反面对照:那个是 primitives-only 的薄 harness,Mastra 是把 memory/RAG/evals/MCP/server 都预置的厚框架。The 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 ServerFilesystem MCP Server另一层 · MCP 工具Other layer · MCP tools

本页由This page is generated from the ai-handbook 数据层生成(CC BY 4.0)。data layer (CC BY 4.0). 方法论与坐标系定义见仓库内For the methodology and coordinate definitions, see METHODOLOGY.md.