Mastra

From the team behind Gatsby, Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack.

Last verified:

Visit Mastra

What is Mastra?

Mastra is an open-source TypeScript framework for building AI-powered applications and agents. Built by the team behind Gatsby, it provides a complete set of AI primitives including agents, workflows, memory, integrations, and evals to help developers go from prototypes to production-ready applications. Mastra integrates with frontend and backend frameworks like React, Next.js, and Node.js, or can be deployed anywhere as a standalone server using Hono.

Key features include a graph-based workflow engine with explicit control flow (.then(), .branch(), .parallel() methods), human-in-the-loop functionality that pauses workflows awaiting user input, built-in memory system for conversation history and semantic memory, model routing connecting to 90+ providers (OpenAI, Anthropic, Gemini, Llama, and 3000+ models), built-in observability with searchable traces/logs/metrics, Mastra Studio for visual testing and managing agents, custom evals for model-graded/rule-based/statistical evaluation, and MCP server support for exposing agents and tools via the Model Context Protocol.

Mastra is designed for TypeScript/JavaScript developers who want to build AI agents without learning a new ecosystem. It's used by companies like Factorial, Counsel Health, Cedar, SoftBank, Index, PLAID Japan, Sanity, StarSling, Kestral, and WorkOS. Typical use cases include customer-facing assistants, internal copilots for HR/sales/clinical documentation, data analysis agents that query databases, content automation, DevOps automation, and sales/GTM workflows.

Mastra pricing

Pricing model: Freemium

Mastra offers a free open-source framework (Apache 2.0 licensed) at $0/month with core features: Agents, Workflows, and Observational Memory. The Mastra Platform has three tiers: Starter ($0/month) includes 100K observability events, 24 CPU hours, 15 days data retention, 10GB data egress, 1GB storage, unlimited users/deployments/projects; Teams ($250/month per team) includes 1M observability events, 250 CPU hours, 6 months retention, 100GB egress, 100GB storage, multiple teams, SSO, SOC 2 docs; Enterprise (custom pricing) includes custom volume/retention, RBAC, audit logs, support SLA, dedicated support engineer. Memory Gateway is metered separately: 100K tokens free then $10/1M tokens, 250MB storage then $20/GB. Persistent Server (24/7 uptime) costs $100/project. Enterprise self-hosted features available with flat annual fee, no per-trace or per-seat metering, data stays in your VPC.

Mastra pros

  • Open-source under Apache 2.0 license with no seat or usage limits for core framework
  • Purpose-built for TypeScript with modern stack designed around established AI patterns
  • Supports 90+ AI providers and 3000+ models through single model routing interface
  • Graph-based workflow engine with intuitive .then(), .branch(), .parallel() control flow
  • Human-in-the-loop workflows that suspend execution and await user approval
  • Built-in memory system with conversation history, semantic memory, and external data retrieval
  • Mastra Studio provides visual UI for building, testing, and managing agents and workflows
  • Built-in observability with searchable traces, logs, and metrics across projects
  • Custom evals support model-graded, rule-based, and statistical evaluation methods
  • Integrates seamlessly with React, Next.js, Node.js, Express, Hono, Fastify
  • Deploy anywhere as standalone server or bundle agents with existing app infrastructure
  • MCP server support for exposing agents and tools via Model Context Protocol
  • Guardrails to prevent prompt injection and sanitize responses
  • Free Starter tier includes unlimited users, unlimited deployments, 100K observability events
  • Templates available for common use cases like Chat with Database, Google Sheet Analysis, Browser Agent

Mastra cons

  • Core framework requires TypeScript/JavaScript knowledge, not suitable for Python developers
  • Setup complexity for beginners new to AI agent development
  • Enterprise pricing is custom and varies based on requirements
  • Observability events metered beyond free tier at $10 per 100K events on Starter plan
  • CPU time limited to 24 hours on Starter plan, overage at $0.35/hour
  • Data retention only 15 days on Starter plan versus 6 months on Teams plan
  • Memory Gateway costs additional at market rate plus 5.5% on top of framework costs
  • Persistent Server for 24/7 uptime costs $100 per project额外
  • Enterprise features like RBAC, audit logs, SSO only available on paid Teams/Enterprise plans
  • Data egress billed at $0.10/GB beyond included 10GB on Starter plan

Frequently asked questions about Mastra

What is Mastra?

Mastra is an open-source TypeScript framework for building AI-powered applications and agents. It provides agents, workflows, memory, workspaces and observability, letting developers go from idea to implementation. Mastra integrates with frontend and backend frameworks like React, Next.js and Node, or can be deployed anywhere as a standalone server. It's the leading open-source TypeScript agent framework with millions of downloads each month.

Why use Mastra instead of a Python AI framework?

Mastra is purpose-built for TypeScript and designed around established AI patterns, giving TypeScript developers everything they need to build AI applications out of the box. Mastra bundles agents and workflows directly into existing React, Next.js and Node.js apps, or ships them as standalone endpoints. It provides a complete set of AI primitives including workflows, agents, workspaces and observability in one modular framework.

Is Mastra an agent builder?

Mastra is a TypeScript framework for building AI agents and AI-powered applications, not just a drag-and-drop agent builder. Mastra agents use LLMs and tools to solve open-ended tasks, reasoning about goals, deciding which tools to use and iterating internally until the model emits a final answer. Mastra also provides workflows, memory, workspaces and observability to support the full agent development lifecycle.

What AI models and providers does Mastra support?

Mastra's model routing connects to 90+ providers through one standard interface. Mastra supports models from OpenAI, Anthropic, Gemini, Groq, Cerebras, Mistral, and Llama, allowing developers to use different AI providers through a single API. The model router gives access to 3000+ models from many providers.

What are Mastra workflows?

Mastra's graph-based workflow engine orchestrates complex multi-step processes with explicit control over execution. Workflows use intuitive syntax with .then(), .branch() and .parallel() methods for control flow. They support human-in-the-loop functionality, allowing developers to suspend a workflow and await user input or approval before resuming. Mastra uses storage to remember execution state, so workflows can pause indefinitely and resume where they left off.

How does Mastra handle agent memory and context?

Mastra's memory system provides conversation history, data retrieval from APIs, databases and files, and human-like working and semantic memory so agents behave coherently. Developers can give Mastra agents the right context at the right time by combining message history with retrieval from external data sources. Observational Memory persists conversation context and application state across sessions.

Does Mastra support MCP servers?

Yes, Mastra supports authoring Model Context Protocol (MCP) servers, exposing agents, tools and other structured resources via the MCP interface. MCP servers built with Mastra can be accessed by any system or agent that supports the protocol. This enables interoperability with other MCP-compatible systems.

How does Mastra handle testing and observability?

Mastra includes built-in scorers and observability tools to observe, measure and refine agent performance continuously. It supports evaluating agent output using model-graded, rule-based and statistical methods, with custom evals to track performance over time. Observability features trace agent calls and token usage with support for external observability platforms. Guardrails process inputs/outputs to prevent prompt injection and sanitize responses.

How do you deploy Mastra applications?

Mastra applications can be deployed to any Node.js-compatible environment. Mastra includes optional built-in deployers for Vercel, Netlify and Cloudflare to automate deployment. Developers can deploy Mastra as a standalone server powered by Hono, integrate it with existing web frameworks like Next.js, or use their existing Hono, Express, Fastify or any other server app. Mastra Server provides a production deployment target that runs your application as an API server.

Is Mastra open source?

Yes, Mastra's core framework is open source under the Apache 2.0 license, free to start with no seats or usage tiers. Enterprise features are source-available under the Mastra Enterprise License. You can build and host agents anywhere with the open-source framework. Enterprise self-hosted option includes enterprise controls, RBAC, SSO, IAM, network policy integration, with data staying in your VPC and predictable flat annual fee pricing.

Categories

Use cases

Browse all AI tools on NeedAnAI