LangChain vs Mastra: which agent framework to build on in 2026
LangChain is Python-first with a JavaScript version; Mastra is TypeScript only. How they differ on workflows, memory, MCP, evals, deployment and cost.
On this page14 sections
- Language, runtime and license
- The abstractions you will actually write
- State, durability and memory
- RAG, tools and MCP
- Evals and tracing
- Deployment
- Side by side
- Which to pick
- Questions people ask
- Is Mastra a LangChain alternative?
- Does Mastra work with Python?
- Is LangChain free?
- Can I use Mastra with Vercel AI SDK?
- Sources
LangChain and Mastra are both open-source frameworks for building AI agents: a model, tools, memory, and a loop that runs until the task is done. They are often shortlisted together, and the comparison is less close than it looks. LangChain is Python-first, with a full JavaScript implementation and a large commercial platform behind it. Mastra is TypeScript, with no Python version at all.
The thing that decides most of these choices is the language your production code is already in. If that is Python, Mastra is not an option. If it is TypeScript, both are, and the real comparison starts: long-running state, memory, MCP, evaluation, and what the paid cloud costs. The catalog's LangChain vs Mastra page keeps the live status and pricing of both.
Language, runtime and license
LangChain ships in two languages. The Python package requires Python 3.10 or newer; the JavaScript package runs on Node.js 20 to 24, Cloudflare Workers, Deno, Bun and browsers. Both are built on LangGraph, LangChain's "low-level orchestration framework and runtime for building, managing, and deploying long-running, stateful agents". The open-source layer is MIT licensed throughout.
Mastra calls itself "purpose-built for TypeScript". It runs on Node.js 22.13 or later, Bun, Deno and Cloudflare, and its docs contain no Python version. The core is Apache 2.0; code under ee/ directories carries a separate, source-available Mastra Enterprise License. GitHub stars at the time of writing: langchain 147.4k, langgraph 42.9k, langchainjs 18.2k, langgraphjs 3.3k, mastra 28.6k.
- langchain147.4k
- langgraph42.9k
- mastra28.6k
- langchainjs18.2k
- langgraphjs3.3k
The abstractions you will actually write
LangChain's pitch is "Agent = Model + Harness". create_agent (createAgent in JavaScript) takes a model string and tools, and you extend it with middleware: guardrails, retries, routing and a SummarizationMiddleware that compresses history past a token threshold. For explicit control flow you drop to LangGraph and write the graph yourself; its docs say it "does not abstract prompts or architecture".

create_agent takes a model string and tools, and you extend it with middleware.Open docs.langchain.com Mastra gives you three typed primitives. An Agent takes instructions, a provider/model string and a tools object; a tool is createTool() with a Zod input schema and an execute function; a workflow is createWorkflow() and createStep() with inputSchema and outputSchema, chained with .then(). The docs draw the line simply: agents for open-ended tasks, workflows for steps you want to control.
State, durability and memory
LangGraph persists state through a checkpointer keyed by thread_id. The in-memory saver dies with the process, so the docs point to PostgresSaver in production; checkpoints let a run resume after a failure, pause for human review, or rewind.
Mastra persists workflow runs as snapshots in whatever storage you configured, and the docs say they "persist across deployments and application restarts". A step can return suspend() to wait for a human or a timer, and run.resume() continues it with typed resumeData; run.restart() picks up a run that lost its server.
Memory follows the same split. LangChain keeps short-term memory as the checkpointed history on a thread and long-term memory in a store. Mastra's Memory class attaches to an agent with a resource for the user and a thread for the conversation, in three layers: working memory (structured user facts), semantic recall (past messages found by meaning) and observational memory, which "uses background agents to maintain a dense observation log that replaces raw message history as it grows".
RAG, tools and MCP
LangChain's retrieval layer is its oldest asset: document loaders, text splitters, embeddings, vector stores and retrievers, with three documented patterns (two-step, agentic and hybrid RAG). Mastra has the same pipeline: MDocument chunking, embedMany, and vector stores including pgvector, Pinecone, Qdrant and MongoDB.
On MCP the difference is direction. LangChain consumes MCP servers: in Python, langchain[mcp] 1.4 or later (still marked beta) provides an MCPAdapter over Streamable HTTP and stdio; in JavaScript, @langchain/mcp-adapters 2.0 adds legacy SSE. Neither docs page covers publishing one. Mastra's @mastra/mcp does both: MCPClient connects over stdio or Streamable HTTP, and MCPServer publishes your agents, tools and workflows as an MCP server.
Below, the two frameworks plus the two Python names most often shortlisted beside them: LlamaIndex for retrieval-heavy apps and CrewAI for role-based multi-agent crews.
MIT-licensed Python/JavaScript framework for building LLM agents, with 1,000+ model and tool integrations
Mastra
81Open-source TypeScript framework for building, running, and observing AI agents in production.
Data framework for retrieval over private documents
CrewAI
57Framework for teams of role-based cooperating agents
Evals and tracing
LangSmith is LangChain's commercial platform, "the framework-agnostic platform for testing, deploying, monitoring, and improving your agents". The Python and JavaScript client SDKs are MIT licensed; the platform is a hosted service that runs evaluations offline on datasets or online on live traffic. Developer is $0 for one seat with 5,000 base traces a month; Plus is $39 per seat per month with 10,000 base traces and one free small serverless deployment; Enterprise is custom. Base traces are kept 14 days, extended traces 180. Self-hosted and BYOC exist only on Enterprise.

Mastra's equivalents ship in the open-source package. @mastra/evals provides scorers, "automated tests that evaluate Agents outputs using model-graded, rule-based, and statistical methods", stored in your own database and sampled by a deterministic rate in production. Tracing covers every agent run, workflow step, tool call and model interaction, and exports to your own storage, to Langfuse, Arize, Datadog or any OpenTelemetry endpoint, and, through a listed integration, to LangSmith. Studio, the local UI for all of it, runs with mastra dev.
The paid cloud is Mastra Platform. Starter is $0 a month with 100,000 observability events, 24 CPU hours and 15 days of retention; Teams is $250 a month with one million events, 250 CPU hours and six months; Enterprise is custom. Self-hosting is free under Apache 2.0, with an enterprise license for RBAC, SSO and a flat annual fee.
Deployment
LangChain's hosted option is LangSmith Deployment, "a workflow orchestration runtime purpose-built for agent workloads": Cloud (Plus plan or above), Hybrid, self-hosted with a control plane (Enterprise), or a standalone Agent Server on Docker or Kubernetes with your own Postgres and Redis and a LangSmith license. The library itself runs in any process of your own; you then own persistence.
Mastra ships a Hono server. mastra build produces a bundle for a VM, container or PaaS; built-in deployers target Vercel, Netlify and Cloudflare; inside a Next.js or Astro app it deploys with the framework. mastra deploy or a GitHub connection pushes to Mastra Platform.
Side by side
| What | LangChain | Mastra |
|---|---|---|
| Language | Python 3.10+ and JavaScript | TypeScript only |
| License | MIT | Apache 2.0 core; ee/ under Mastra Enterprise License |
| Durable state | Checkpointers (Postgres, SQLite) and stores | Snapshots in your storage; Inngest or Temporal optional |
| MCP | Client only, in the docs | Client and server |
| Evals and tracing | LangSmith (hosted; MIT SDK) | @mastra/evals, tracing and Studio in the package |
| Free cloud tier | Developer: 1 seat, 5k base traces a month | Starter: 100k events, 24 CPU hours, 15-day retention |
| First paid tier | Plus, $39 per seat per month | Teams, $250 per month |
| Self-hosting the platform | Enterprise plan only | Free, Apache 2.0 |
Which to pick
Pick LangChain if your backend is Python, if you want the widest set of model and vector-store integrations, if you are buying evaluation, tracing and deployment as one platform and can live with its plan structure, or simply if the team already knows it: the ecosystem is far larger.
Pick Mastra if you ship TypeScript, especially inside Next.js; if you want typed workflows with suspend-and-resume and no external orchestrator; if you need to publish an MCP server as well as consume one; or if you want evals and tracing without a usage-metered platform. The price is a smaller ecosystem and a single language.
If neither fits, the catalog's agent frameworks and LLM frameworks categories hold the rest, including Langflow, a drag-and-drop canvas for models, tools and vector stores, and Langbase, a serverless platform that hosts the primitives.
Langbase
71A serverless platform for building, deploying, and monitoring AI agents across 600-plus LLMs.
Langflow
79Open-source visual builder for LLM agents and RAG flows, deployable as an HTTP API or an MCP server.
Questions people ask
Is Mastra a LangChain alternative?
For TypeScript teams, yes: it covers agents, workflows, memory, RAG, MCP, evals and tracing in one package; see the catalog's comparison page. For Python teams it is not, because Mastra has no Python version.
Does Mastra work with Python?
No. Its docs, runtimes and integrations are TypeScript only. A Python service can call a Mastra server over its REST API, but the agents themselves are written in TypeScript.

Is LangChain free?
The frameworks are: langchain, langgraph and their JavaScript ports are MIT licensed. LangSmith has a free Developer plan with one seat and 5,000 base traces a month; after that it is $39 per seat per month on Plus, and self-hosting requires an Enterprise plan.
Can I use Mastra with Vercel AI SDK?
Yes, on both ends. Any AI SDK provider module, such as @ai-sdk/groq, works anywhere Mastra accepts a provider/model string, and @mastra/ai-sdk streams agents to AI SDK UI's useChat(), useCompletion() and useObject() hooks, with a version option that defaults to v5 and covers v6 and v7.
Sources
- LangChain Docs
- LangSmith Plans and Pricing
- LangChain overview (Python)
- LangChain overview (JavaScript)
- Install LangChain (Python)
- LangGraph overview
- LangGraph persistence
- LangChain short-term memory
- LangChain retrieval
- LangChain MCP (Python)
- LangChain MCP (JavaScript)
- LangSmith Observability
- LangSmith Evaluation
- LangSmith Deployment
- LangSmith hosting options
- langchain-ai/langchain on GitHub
- langchain-ai/langchainjs on GitHub
- langchain-ai/langgraph on GitHub
- langchain-ai/langgraphjs on GitHub
- langchain-ai/langsmith-sdk on GitHub
- Mastra
- Mastra docs
- Mastra agents overview
- Mastra workflows overview
- Mastra suspend and resume
- Mastra memory overview
- Mastra RAG overview
- Mastra MCP overview
- Mastra evals overview
- Mastra observability overview
- Mastra deployment overview
- Mastra Studio
- Mastra platform overview
- Mastra models
- Mastra integrations
- Mastra AI SDK UI integration
- Mastra pricing
- mastra-ai/mastra on GitHub
AgentsFrameworksDevelopersGuides
Every tool named here has a live catalog page — price, status and when we last checked it.
Browse the catalogFollow new posts via the RSS feed.
Keep reading
All posts →AI personal assistants: what one can actually run for you, and what it still can't
Chat assistants, calendar assistants and agents that act need different access. What each can run in 2026, what to revoke, and what to check first.
State of AI tools, October 2026: 3,264 tools, by the numbers
3,264 AI tools counted on October 13, 2026: domain ages, .ai against .com, how they charge, median prices by category, platforms, countries and shutdowns.
State of AI directories, October 2026: 110 places, by the numbers
110 AI directories and launch sites checked on October 10, 2026: who still lists for free, what a badge buys, median prices, queues, links and closures.


