Mastra
Open-source TypeScript AI agent framework — developed by the founder of Gatsby.
Mastra is an open-source TypeScript AI agent framework developed by Mastra Inc., which was founded in late 2024 by Sam Bhagwat, the co-founder of Gatsby. Similar to how React builds web interfaces by combining UI components, Mastra builds AI agent applications by combining four core primitives: Agent, Workflow, Memory, and Tool. It features a Model Router that connects over 90 LLM providers (including OpenAI, Anthropic, and Google Gemini) through a single interface, requiring only one line of code to be modified when switching providers. In April 2026, it secured a $22 million Series A investment led by Spark Capital (totaling $35 million), and has established itself as a leading AI agent framework in the TypeScript ecosystem, with 25.2k stars on GitHub and over 300,000 weekly downloads on npm.
The existing AI agent framework market has been dominated by Python-based tools such as LangChain, CrewAI, and AutoGen. For web full-stack developers to build agents, they had to set up a separate Python environment or bear the cost of language conversion, and there was also the issue of type safety being broken between the front-end, back-end, and agent. Mastra directly addresses this gap. Its graph-based workflow engine allows complex multi-step pipelines to be declaratively constructed using method chaining such as .then(), .branch(), and .parallel(), and it also incorporates human-in-the-loop pausing and resuming, state persistence, and time-travel debugging, providing a one-stop infrastructure for production-level agent operation. It also natively supports the creation of MCP (Model Context Protocol) servers, allowing agents and tools to be exposed externally using a standardized protocol.
From a practical application perspective, Mastra demonstrates strengths in three main scenarios. First, it can be used to embed AI agents into existing SaaS products, with companies like Replit, Sanity, and MongoDB integrating Mastra agents into their platforms to implement natural language-based data retrieval and workflow automation. Second, it can be used to build internal workflow automation copilots, allowing for the creation of long-term conversational assistants using a Memory Gateway in domains such as HR, sales, DevOps, and clinical research. Third, it can be used as a data analysis agent, where connecting Mastra agents to TypeScript-based research data portals or dashboards allows for database queries, report generation, and analysis pipeline triggering to be handled within a single conversational interface. Through Mastra Studio (localhost:4111), agent behavior can be visually monitored, and agent quality can be quantitatively measured using the built-in scorer and evaluation tools, allowing the entire lifecycle from prototyping to production deployment to be managed within a single framework.
💻 System Requirements
Not required (LLM uses an external API call method; if using a local LLM, follow the requirements of that model)
Framework ~200MB (including node_modules), additional storage per project
⚡ Installation
4-1. Quick Start
npm create mastra@latest
Or, using a package manager:
pnpm create mastra
yarn create mastra
bunx create-mastra
4-2. Detailed Installation and Basic Usage
# Create a project (interactive setup)
npm create mastra@latest my-agent-app --default --llm openai
# Run the development server + Mastra Studio
cd my-agent-app
npx mastra dev
# → Mastra Studio: http://localhost:4111
Example agent definition:
import { Agent } from '@mastra/core/agent'
export const myAgent = new Agent({
id: 'my-agent',
name: 'Research Assistant',
instructions: 'You are a helpful research assistant.',
model: 'openai/gpt-4o',
})
// Usage
const result = await myAgent.generate('Summarize recent findings on CRISPR delivery.')
console.log(result.text)
🧬 Bio Use Cases
SaaS Embedded Agent
Add a natural language interface to your web application, allowing users to query data, modify settings, and trigger automations through conversation. This is a pattern adopted by companies like Replit, Sanity, and Brex, and can be implemented by connecting Mastra Agent with existing REST API tools.
Multi-Step Data Analysis Pipeline
Automate the process of collecting data from multiple sources, cleaning it, analyzing it, and generating reports using the .branch() and .parallel() functions of the Workflow engine. Human-in-the-loop validation steps can be inserted for intermediate verification.
Internal Task Copilot
Build a domain-specific assistant that connects to 251 MCP tools, including Slack, Notion, and GitHub, while maintaining conversational context with the Memory Gateway. This can be used for onboarding new employees, automatically summarizing code reviews, and triaging issues.
FAQ
What is Mastra?
Mastra is an open-source TypeScript AI agent framework developed by Mastra Inc., which was founded in late 2024 by Sam Bhagwat, the co-founder of Gatsby. Similar to how React builds web interfaces by combining UI components, Mastra builds AI agent applications by combining four core primitives: Agent, Workflow, Memory, and Tool. It features a Model Router that connects over 90 LLM providers (including OpenAI, Anthropic, and Google Gemini) through a single interface, requiring only one line of code to be modified when switching providers. In April 2026, it secured a $22 million Series A investment led by Spark Capital (totaling $35 million), and has established itself as a leading AI agent framework in the TypeScript ecosystem, with 25.2k stars on GitHub and over 300,000 weekly downloads on npm. The existing AI agent framework market has been dominated by Python-based tools such as LangChain, CrewAI, and AutoGen. For web full-stack developers to build agents, they had to set up a separate Python environment or bear the cost of language conversion, and there was also the issue of type safety being broken between the front-end, back-end, and agent. Mastra directly addresses this gap. Its graph-based workflow engine allows complex multi-step pipelines to be declaratively constructed using method chaining such as .then(), .branch(), and .parallel(), and it also incorporates human-in-the-loop pausing and resuming, state persistence, and time-travel debugging, providing a one-stop infrastructure for production-level agent operation. It also natively supports the creation of MCP (Model Context Protocol) servers, allowing agents and tools to be exposed externally using a standardized protocol. From a practical application perspective, Mastra demonstrates strengths in three main scenarios. First, it can be used to embed AI agents into existing SaaS products, with companies like Replit, Sanity, and MongoDB integrating Mastra agents into their platforms to implement natural language-based data retrieval and workflow automation. Second, it can be used to build internal workflow automation copilots, allowing for the creation of long-term conversational assistants using a Memory Gateway in domains such as HR, sales, DevOps, and clinical research. Third, it can be used as a data analysis agent, where connecting Mastra agents to TypeScript-based research data portals or dashboards allows for database queries, report generation, and analysis pipeline triggering to be handled within a single conversational interface. Through Mastra Studio (localhost:4111), agent behavior can be visually monitored, and agent quality can be quantitatively measured using the built-in scorer and evaluation tools, allowing the entire lifecycle from prototyping to production deployment to be managed within a single framework.
When should I use Mastra?
Open-source TypeScript AI agent framework — developed by the founder of Gatsby.
What is a biomedical use case for Mastra?
SaaS Embedded Agent: Add a natural language interface to your web application, allowing users to query data, modify settings, and trigger automations through conversation. This is a pattern adopted by companies like Replit, Sanity, and Brex, and can be implemented by connecting Mastra Agent with existing REST API tools.
📝 Update Notes
- v@mastra/core@1.66.09/13/2026
이번 Mastra 업데이트에서는 실험 데이터의 추적과 관리가 더욱 정교해졌습니다. 특히 '메모리 변환 훅' 기능이 추가되어, 모델에 데이터를 전달하기 전 민감한 생물학적 정보를 자동으로 필터링하거나 재구성할 수 있어 데이터 보안과 전처리가 용이해졌습니다. 또한, 더욱 강력해진 트레이스 쿼리 기능을 통해 복잡한 실험 결과나 모델의 실행 이력을 상세한 조건으로 검색하고 분석할 수 있습니다. 스트리밍 안정성 및 성능 개선을 통해 대규모 바이오 데이터를 처리하는 AI 워크플로우의 신뢰성을 한층 높일 수 있습니다.
- v@mastra/core@1.51.07/15/2026
이번 업데이트에서는 에이전트의 작업 중단 시 자동 복구 기능이 도입되어, 대규모 유전체 데이터 분석과 같이 긴 시간이 소요되는 작업이 서버 재시작 후에도 끊김 없이 이어질 수 있습니다. 또한, 동일한 리소스에 대해 독립적인 여러 세션을 동시에 실행할 수 있어, 하나의 샘플을 다양한 실험 조건으로 병렬 분석할 때 매우 효율적입니다. 새로운 샌드박스 제공 기능은 복잡한 바이오 시뮬레이션 도구를 안전하고 확장 가능한 환경에서 실행할 수 있도록 지원합니다. 이를 통해 더욱 안정적이고 정교한 AI 기반 생명공학 연구 워크플로우를 구축할 수 있습니다.
- v@mastra/core@1.50.07/8/2026
이번 업데이트에서는 LiveKit 기반의 실시간 음성 에이전트 기능이 도입되어, 실험 중 장갑을 착용한 상태에서도 음성으로 AI와 상호작용하며 데이터를 기록하거나 명령을 내릴 수 있어요. 또한, 파일 시스템 기반의 자동 설정 기능 덕분에 복잡한 바이오 워크플로우와 실험 파이프라인을 별도의 복잡한 코드 없이도 훨씬 간결하게 관리할 수 있게 되었답니다. 통합된 스케줄링 API를 통해 실험 주기나 데이터 모니터링 작업을 더욱 안정적으로 자동화할 수 있으니, 실험 자동화 시스템을 구축 중인 연구원님들께 유용한 업데이트가 될 거예요.
- v@mastra/core@1.49.07/7/2026
이번 업데이트에서는 실험 로그와 대규모 데이터를 효율적으로 관리할 수 있는 데이터 보관 정책 및 자동 삭제 기능이 도입되어 저장 공간 관리가 훨씬 용이해졌어요. 프로젝트별 데이터 격리 기능이 강화되어 여러 연구 프로젝트나 협업 그룹 간의 보안을 더욱 안전하게 유지할 수 있습니다. 또한, 복잡한 계층 구조의 서브 에이전트 지원과 기존 데이터를 재실행 없이 평가하는 기능 덕분에 정교한 바이오 데이터 분석 워크플로우를 더욱 효율적으로 자동화할 수 있어요.
- v@mastra/core@1.48.07/1/2026
Mastra 1.48.0에서는 주기적인 스케줄링 기능인 'Heartbeats'가 도입되어, 실험 데이터의 정기적인 모니터링이나 분석 작업을 자동화하기 훨씬 좋아졌어요. 파일 기반의 에이전트 관리 기능 덕분에 복잡한 생물정보학 워크플로우를 구성하는 여러 에이전트를 더욱 체계적으로 운영할 수 있습니다. 특히 연구자의 승인이 필요한 단계에서 시스템이 재시작되더라도 작업 흐름이 유실되지 않도록 안정성이 크게 강화되었습니다. 또한, 업그레이드된 메모리 추출 API를 통해 연구 문헌이나 실험 노트에서 구조화된 데이터를 더욱 정교하게 추출할 수 있게 되었습니다.
- v@mastra/core@1.46.06/24/2026
Highlights
Multi-session Harness architecture (Session-first APIs)
Harness is now a pure factory/shared-resource owner: create isolated sessions via
harness.createSession()(get-or-create byresourceId), with run control, state, event bus, model/mode switching, permissions, OM, subagent settings, and thread lifecycle all moved ontoSessiondomains (e.g.session.sendMessage(),session.thread.*,session.model.switch(),session.subscribe()), enabling safe concurrent multi-u - v@mastra/core@1.45.06/19/2026
긴 대화 기록을 훨씬 빠르고 저렴하게 불러올 수 있는 기능이 추가되어, 방대한 실험 로그나 연구 데이터를 다루는 작업이 더욱 쾌적해졌어요. AI 에이전트의 신호 처리 로직이 개선됨에 따라 복잡한 실험 워크플로우를 자동화할 때 발생하던 오류가 줄어들어 더욱 신뢰할 수 있는 결과물을 얻을 수 있습니다. 또한, 시스템 가이드가 명확해지면서 자동화된 태스크 수행 중 발생할 수 있는 프롬프트 혼선을 방지하여 더욱 안정적인 연구 환경을 제공합니다.
- v@mastra/core@1.42.06/17/2026
이번 업데이트에서는 백그라운드 작업의 신뢰성이 향상되어, 대규모 바이오 데이터 분석이나 주기적인 실험 데이터 수집 프로세스를 더욱 안정적으로 자동화할 수 있어요. 특히 AI가 제안한 실험 계획을 연구원이 직접 검토하고 승인하는 '도구 중단 및 재개' 기능이 강화되어, 실험 프로토콜의 정확성을 높이는 Human-in-the-loop 워크플로우 구축이 훨씬 쉬워졌답니다. 또한, VoyageAI 임베딩 지원을 통해 방대한 생명공학 문헌이나 멀티모달 데이터를 더욱 정교하게 검색하고 분석할 수 있는 강력한 기능도 추가되었습니다.
🧪 Related Code of Life
No related Code of Life posts yet.