Skip to content
effecthub

GuideAgents7 min read

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.

EffectHub Research
On this page14 sections
  1. Language, runtime and license
  2. The abstractions you will actually write
  3. State, durability and memory
  4. RAG, tools and MCP
  5. Evals and tracing
  6. Deployment
  7. Side by side
  8. Which to pick
  9. Questions people ask
  10. Is Mastra a LangChain alternative?
  11. Does Mastra work with Python?
  12. Is LangChain free?
  13. Can I use Mastra with Vercel AI SDK?
  14. 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.

GitHub stars at the time of writing
  • 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".

LangChain docs, docs.langchain.com — the page's first screen
LangChain's pitch is "Agent = Model + Harness": 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.

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.

LangSmith pricing, langchain.com — the page's first screen
LangSmith's Developer plan is $0 for one seat; Plus is $39 per seat per month, and self-hosting exists only on Enterprise.Open langchain.com

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

WhatLangChainMastra
LanguagePython 3.10+ and JavaScriptTypeScript only
LicenseMITApache 2.0 core; ee/ under Mastra Enterprise License
Durable stateCheckpointers (Postgres, SQLite) and storesSnapshots in your storage; Inngest or Temporal optional
MCPClient only, in the docsClient and server
Evals and tracingLangSmith (hosted; MIT SDK)@mastra/evals, tracing and Studio in the package
Free cloud tierDeveloper: 1 seat, 5k base traces a monthStarter: 100k events, 24 CPU hours, 15-day retention
First paid tierPlus, $39 per seat per monthTeams, $250 per month
Self-hosting the platformEnterprise plan onlyFree, 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.

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.

Mastra docs, mastra.ai — the page's first screen
Mastra's docs, runtimes and integrations are TypeScript only; a Python service can call a Mastra server over its REST API.Open mastra.ai

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

AgentsFrameworksDevelopersGuides

Every tool named here has a live catalog page — price, status and when we last checked it.

Browse the catalog

Follow new posts via the RSS feed.

Keep reading

All posts →