Sam Bhagwat from Mastra: the Gatsby founder building an agents framework
Mastra bet that the application layer of AI would move toward TypeScript. Sam Bhagwat explains why agent frameworks need more than model calls, what Gatsby taught him about APIs and community, and why his team hands out roughly 1,500 physical books a week.
Sam Bhagwat is the co-founder and CEO of Mastra, a TypeScript framework for building AI agents and workflows, and was previously a co-founder of Gatsby.
We talk about choosing TypeScript over Python, carrying hard-won framework lessons from Gatsby into Mastra, finding an unexpectedly large audience in Japan, using a physical book to teach the market, and why observability becomes even more important when software is nondeterministic.
The Q&A below is experimental — extracted from the episode transcript with AI. If you spot a mistake, let us know at jack@scalingdevtools.com.
What is Mastra?
Mastra is a TypeScript framework for building AI applications. It combines agents, workflows, retrieval, tools and evaluations rather than treating an agent as a single model call. People use it for internal automations, AI features inside existing SaaS products and entirely new vertical applications. We originally explored an agentic CRM, tried several libraries, and realized the framework underneath was the more important product.
Why build an agent framework in TypeScript instead of Python?
Python was the natural home for machine learning, but most agent applications call models and APIs, move context around and connect to web products. That work is increasingly done by application developers. In our YC batch, roughly a third of agent startups were using TypeScript; we heard that three months later the share was already over half. TypeScript lets those teams build in the language where the rest of their product already lives.
What lessons from Gatsby carried over to Mastra?
Framework details become permanent faster than founders expect. Bundling, tree-shaking, CommonJS versus ESM, and even the nouns and verbs in an API are difficult to change after adoption. Documentation is part of the product, and community support through issues and Discord becomes a major operating system for the company. Several people from Gatsby brought that experience into Mastra, so we knew to take those foundations seriously from the beginning.
Why did you write Principles of Building AI Agents?
People wanted to build agents but lacked a mental model for the pieces. We had developed a conceptual hierarchy while whiteboarding — what makes a workflow different from an agent, where retrieval fits, and why evaluations matter — and the book made that structure teachable. It is closer to a field guide than product documentation: it helps readers decide what kind of system they are actually building.
Why print and distribute a physical technical book?
A physical book is memorable, useful at events and signals that the category deserves a durable explanation. We use Amazon's logistics, order boxes of around 500 copies and leave them on conference tables for people to take. At the current pace we distribute about 1,500 copies a week. The demand confirms that many developers are curious about agents but do not yet know how to begin.
How did Japan become such a large part of Mastra’s community?
About 20% of our users are in Japan. Developer Twitter still has enormous reach there, and early enthusiasm spread through X and local developer article sites. Japan was the first language for which we localized the documentation. The combination of a strong software community and broad excitement about AI gave Mastra a distribution path we had not planned at the outset.
What is Mastra Cloud meant to add to the framework?
The public beta provides hosting, GitHub deployment, observability and evaluations around the open-source framework. Gatsby Cloud gave us experience building a platform around developer infrastructure, but doing it again for AI also exposes the engineering questions that will matter over the next five or ten years. We can revisit old platform assumptions rather than copying them blindly.
Why is observability especially important for AI applications?
AI systems are nondeterministic, so observability may be ten times as important as it is in conventional software. A request can succeed technically while producing a poor answer, taking an unexpected tool path or failing only for a subset of prompts. Teams need traces and evaluations that explain what happened, not merely an HTTP status and a log line.
What has worked for Mastra’s marketing?
Documentation and the changelog are foundational because a steady cadence shows the slope of the project. We also publish two or three customer stories a week and invest in a polished, visual local development experience that people want to show one another. Word of mouth grows when the product is easy to understand and the team continually gives the community concrete evidence of progress.
How do you think about MCP?
Every public API should consider whether agents will need an MCP interface, because agentic traffic is becoming a real distribution surface. We use a documentation MCP server so coding agents can retrieve current Mastra guidance instead of relying on stale training data. But tool use also introduces trust questions: an agent should not be allowed to invoke arbitrary, untrusted capabilities without boundaries.
Links & references
This episode is brought to you by WorkOS.