Mastra - TypeScript AI Agent Framework
Mastra is an open-source TypeScript framework for building AI agents and AI-powered applications. From the team behind Gatsby.js, backed by Y Combinator W25.
TL;DR
TL;DR: Mastra is an open-source TypeScript framework by the Gatsby.js team for building production-ready AI agents and AI-powered applications, backed by Y Combinator W25.
Source and Accuracy Notes
⚠️ This section is MANDATORY. All links must be verified from actual source, not guessed.
- Project page: mastra.ai
- Source repository: github.com/mastra-ai/mastra
- License: Apache 2.0 (core), Mastra Enterprise License (ee/ directory) — verified via README
- Y Combinator: W25 batch — verified via README badge
- Stars: 25,458 (GitHub API, June 2026)
- HN launch thread: news.ycombinator.com/item?id= — verify from README or search
What Is Mastra?
Mastra is a TypeScript framework for building AI-powered applications and agents. It comes from the team behind Gatsby.js and raised funding through Y Combinator’s W25 batch.
From the 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.
The framework gives you agents, workflows, memory, MCP server authoring, model routing, evals, and observability — all wired together in TypeScript.
Core features
Agents — Autonomous agents that use LLMs and tools to solve open-ended tasks. Agents reason about goals, decide which tools to call, and iterate internally until they emit a final answer or hit a stopping condition.
Workflows — Graph-based workflow engine for explicit multi-step control. Uses an intuitive syntax with .then(), .branch(), and .parallel() for control flow.
Model routing — Connect to 40+ providers through one standard interface. OpenAI, Anthropic, Gemini, Groq, Cerebras, Mistral, and more.
MCP servers — Author Model Context Protocol servers that expose agents, tools, and structured resources via the MCP interface. Any MCP-compatible client can consume them.
Context and memory — Conversation history, RAG-style retrieval from your own data sources (APIs, databases, files), and observational memory so agents behave coherently across long sessions.
Human-in-the-loop — Suspend an agent or workflow and await user input or approval before resuming. Execution state is persisted in storage so you can pause indefinitely.
Production essentials — Built-in evals and observability for measuring and refining agent quality over time.
Setup Workflow
Step 1: Install via CLI
The fastest path is the official scaffolder:
npm create mastra@latest
This prompts for a project name and LLM provider, then scaffolds a ready-to-run project.
Step 2: Manual install
npm install @mastra/core
Or withpnpm:
pnpm add @mastra/core
Step 3: Configure an LLM provider
Create a .env file:
OPENAI_API_KEY=sk-your-key-here
Step 4: Initialize Mastra
import { Mastra } from '@mastra/core';
const mastra = new Mastra({
agents: {
myAgent: {
model: 'gpt-4o',
system: 'You are a helpful assistant.',
},
},
});
export { mastra };
Step 5: Run the dev server
npx bgproc start -n my-project -w -- npm run dev
Mastra Studio (the built-in UI for building, testing, and managing agents) starts at http://localhost:4111.
Deeper Analysis
Architecture
Mastra is structured around three pillars: agents (the reasoning units), tools (what agents can call), and workflows (how you orchestrate multi-step processes). The framework is runtime-agnostic — you can bundle it into a React/Next.js app, a Node.js backend, or run it as a standalone server.
The dual-license model is worth noting. The core packages/core/src/ is Apache 2.0. Any code under a directory named ee/ (enterprise) is source-available under the Mastra Enterprise License — free for dev and testing, but requires a paid license for production use.
How it compares to alternatives
| Feature | Mastra | LangChain.ts | Vercel AI SDK | |---|---|---|---| | Language | TypeScript | TypeScript/Python | TypeScript | | Agents | Native | Via LCEL | Via separate packages | | Workflows | Graph-based | LCEL | Streams/chains | | MCP support | Native authoring | Via integrations | No | | Self-hosted | Yes | Yes | Yes | | Commercial license | Enterprise only for ee/ | Apache 2.0 | Apache 2.0 |
Mastra’s tight TypeScript-first design and built-in MCP server authoring set it apart from the more general-purpose LangChain.ts ecosystem.
Practical Evaluation Checklist
- [ ] Clone repo:
git clone https://github.com/mastra-ai/mastra - [ ] Run
npm create mastra@latestto scaffold a project - [ ] Set
OPENAI_API_KEYin.env - [ ] Start dev server:
npx bgproc start -n my-app -w -- npm run dev - [ ] Open
http://localhost:4111for Mastra Studio - [ ] Create a simple agent with one tool and verify it responds
- [ ] Try the MCP server authoring docs at
https://mastra.ai/docs/tools-mcp/mcp-overview
Security Notes
- API keys must be stored in environment variables, never hardcoded
- The
ee/enterprise components require a commercial license for production - Report security findings to
[email protected] - MCP servers authored with Mastra should follow MCP security best practices (validate tool inputs server-side)
FAQ
Q: Is Mastra production-ready? A: Yes. Mastra is used by companies including Replit, SoftBank, and Sanity (listed on mastra.ai/customers). It ships with built-in observability and evals for monitoring production agents.
Q: Can I self-host Mastra? A: Yes. Mastra runs as a standalone Node.js server. You can deploy it to any hosting platform — Fly.io, Railway, Render, AWS, or a private VPS.
Q: What LLMs does Mastra support?
A: 40+ providers including OpenAI, Anthropic, Google Gemini, Groq, Cerebras, Mistral, and more via a unified model router. See https://mastra.ai/models.
Q: Is the framework free?
A: The core framework is Apache 2.0 (free). Enterprise features under ee/ require a Mastra Enterprise License for production use.
Q: Does Mastra support MCP? A: Yes. You can author Model Context Protocol servers directly in Mastra, exposing agents, tools, and resources via the MCP interface.
Conclusion
Mastra fills a real gap in the TypeScript AI tooling landscape. The team behind Gatsby.js built it with production instincts — the dual-license model, built-in observability, MCP authoring, and enterprise patterns show they are thinking beyond the prototype. If you are building AI agents in TypeScript, it is worth spending an afternoon with the quickstart and Mastra Studio to see if it fits your stack.
Related Posts
dev-tools
Automotive Skills Suite for AI Engineering
Evaluate Automotive Skills Suite for APQP, ASPICE, HARA, safety-plan, and DIA workflows with setup notes, governance risks, and SME review guidance.
5/28/2026
dev-tools
awesome-agentic-ai-zh Roadmap Guide
Explore awesome-agentic-ai-zh as a Chinese agentic AI learning roadmap, with setup notes, track selection, study workflow, and evaluation guidance.
5/28/2026
dev-tools
Baguette iOS Simulator Automation Guide
Set up Baguette for iOS Simulator automation, web dashboards, device farms, gesture input, streaming, and camera testing with Xcode caveats.
5/28/2026