# DSPy vs Mastra

> Mastra scores 78 (A) to DSPy's 68.3 (B) for agent frameworks. Prices, MCP, x402, uptime and agent notes side by side.

- Canonical: https://www.anchorterminal.com/compare/dspy-vs-mastra
- Markdown: https://www.anchorterminal.com/compare/dspy-vs-mastra.md (~4,550 tokens)
- Slim: https://www.anchorterminal.com/compare/dspy-vs-mastra.min.md (~930 tokens, same facts, less prose, for token-sensitive contexts)
- JSON: https://www.anchorterminal.com/compare/dspy-vs-mastra.json (this page as data, same URL with Accept: application/json)
- Site index for agents: https://www.anchorterminal.com/llms.txt (the key docs and every listing in one file, at most 16 MB, about 4 million tokens: https://www.anchorterminal.com/llms-full.txt)
- API: https://www.anchorterminal.com/api/v1/index.json
- MCP: https://www.anchorterminal.com/mcp (the whole catalogue as tools, no key)
- DNS: dig +short TXT <slug>.grade.anchorterminal.com (the grade as a DNS TXT record, for a sandbox with no HTTP where names still resolve; also top., best.<category>. and <a>.vs.<b>. under the zone, and the same under grade.letme.dev)
- Licence: CC BY 4.0, credit Anchor Terminal and link this page (https://www.anchorterminal.com/terms/#data)
- Updated: 2026-11-23

Mastra scores 78 (A) on agent readiness against DSPy's 68.3 (B), and leads in 6 of 7 scored categories. Both do agent frameworks.

- DSPy: grade B, 68.3/100, rank #414 of 1654. Markdown https://www.anchorterminal.com/tools/dspy.md · JSON https://www.anchorterminal.com/api/v1/tools/dspy.json
- Mastra: grade A, 78/100, rank #66 of 1654. Markdown https://www.anchorterminal.com/tools/mastra.md · JSON https://www.anchorterminal.com/api/v1/tools/mastra.json
- Best agent frameworks and SDKs: https://www.anchorterminal.com/best/frameworks/index.md
- All 253 frameworks comparisons: https://www.anchorterminal.com/compare/frameworks/index.md

## Which one, for what

### DSPy (B)

Good for: Python teams who want typed LM programs they can evaluate and optimise against a metric, with ReAct for tool use.

Also in its favour:
- No key needed to call it
- No incidents deducted, where Mastra loses 8 points for them

Watch for: 3.5 changed the default adapter, reasoning and API routing and removed CodeAct and ProgramOfThought in a minor release

### Mastra (A)

Good for: TypeScript teams that want agents, workflows, memory, evals and a local Studio in one framework.

Ahead on:
- Reliability, 87 against 62
- Schema & documentation, 98 against 71
- Agent ergonomics, 92 against 64
- Security & auth, 67 against 60
- Maintenance & community, 96 against 87
- Transparency & trust, 72 against 52

Also in its favour:
- Agent-ready, a grade of BB or better

Watch for: Malicious versions of Mastra npm packages, including @mastra/core 1.42.1, were published on 17 June 2026


## Why the edge

### Agent ergonomics: Mastra +28

- DSPy (64): Framework reading. MCP tools through the dspy[mcp] extra, converted one by one from a client session the developer opens (14). max_iters with a turn budget shown to the model and a forced final submit bound a run (17). Unknown tools and tool exceptions return to the model as error results (15). History continuation and saved programs, but no resume of an interrupted run or durable store; answer caching can mask repeated calls (8). Signatures keep required arguments few, an LM must be configured, Python only (10). 14+17+15+8+10 = 64.
- Mastra (92): An MCP client in about ten lines with listTools() for static or listToolsets() for per-request tools, and ToolSearchProcessor for loading tools on demand (25). Step limits, memory windows and processors such as a token limiter control what reaches the model (20). MastraError with ids and categories, and processors can abort with a reason the caller can read (17). Workflow step retries, snapshots and durable agents for resuming (20). create-mastra scaffolds a project and the model router takes a plain string, but it's TypeScript only (10).

### Schema & documentation: Mastra +27

- DSPy (71): Framework reading. A typed Python API with an API reference for modules, tools, adapters and errors (20). No llms.txt at dspy.ai; the docs are Markdown in the repository but not served for agents (0). The tools and ReAct pages say what each part is for and when to read on (15). Tools are typed from signatures and Pydantic annotations and validated against JSON Schema (14). Many tutorials with code, and an errors page in the reference (12). Versioned docs, GitHub release notes and an upgrade guide, with no changelog file (10). 20+0+15+14+12+10 = 71.
- Mastra (98): Typed TypeScript API with a reference section (25). llms.txt with a when-to-use list and condensed instructions for coding agents (10). The docs say when to use durable agents, and point multi-agent users from `.network()` to supervisor agents (20). Tools take Zod schemas (15). Examples on every page, and MastraError with ids and categories documented, though errors are spread across pages (13). Per-package changelogs and migration guides (15).

### Reliability: Mastra +25

- DSPy (62): Local-package reading. Official PyPI package dspy with Python 3.10 to below 3.16 stated (20). A public test workflow runs on pushes to main and pull requests for Python 3.10 to 3.15; whether main passes wasn't read, as the Actions API refused us (15). 352 open issues and 475 open pull requests on 23 November 2026. The 50 newest issues, opened from 6 October to 23 November, had 19 with a comment and 8 closed (10). Release notes and an upgrade guide for 3.5, but 3.5 changed defaults and removed APIs in a minor release (7). 3.x, while the package classifier still says Alpha, so partial (10). 20+15+10+7+10 = 62.
- Mastra (87): Official npm packages, Node 22.13 or newer (20). Public CI workflows for unit, store, workspace and e2e tests; on 6 November the newest runs on main (Version Packages, Trigger Cloud Integration Tests) succeeded, while the test workflows themselves run on pull requests (22). 436 open issues and 795 open issues and pull requests on 6 November from GitHub's API, with 2,077 issues opened in the 90 days to 3 November; all 50 newest had a comment and 24 were closed, with issue-triage automation (18). A changesets CHANGELOG per package, a CI gate that needs approval for any major bump and migration guides, but no written versioning policy found, and `.network()` is deprecated without a removal date (12). 1.82.0 (15). 20+22+18+12+15 = 87, up from 74 on 6 October, when GitHub couldn't be read.

### Transparency & trust: Mastra +20

- DSPy (52): MIT (30). The library keeps only its answer cache, in memory and on disk by default, which the cache guide describes; no terms or privacy policy exist for the project (18). Deprecation warnings name the removal version (ReActV2 removed in 3.6), but there is no written policy and 3.5 removed APIs without a prior deprecation release (8). No telemetry, though no page states it (12). 30+18+8+12 = 68.
- Mastra (72): Apache 2.0 for the core, with ee/ directories source-available under the Mastra Enterprise License (25). The privacy policy (last published 25 April 2025) covers the website, the Teams plan states six months' retention, and the subprocessor list sits in a trust centre our reader couldn't render (15). Migration guides and deprecation warnings, without dated removal windows (12). Every telemetry stream is documented with links to its source and one opt-out, and the reference now spells out what the project identifiers can be correlated with (20).

### Maintenance & community: Mastra +9

- DSPy (87): 3.5.0 tagged on 10 November 2026, 13 days before this check (30). Three releases in the 90 days to 23 November (3.4.0, 3.4.1, 3.5.0) (20). The 50 newest issues had 19 with a comment and 8 closed, with 352 issues and 475 pull requests open, while 213 commits from about 30 authors reached the repository in 90 days (12). The package is current (15). CI on six Python versions, Dependabot and actions pinned to commit SHAs (10). 30+20+12+15+10 = 87.
- Mastra (96): @mastra/core 1.82.0 on 2026-11-04 (30). 27 stable releases in the 90 days to 6 November, 8 of them since 6 October (20). 436 open issues on 6 November, all 50 newest issues commented and 24 of them closed (22). Client, MCP and store packages are current, and @mastra/mcp 1.x stays supported beside 2.x (15). Renovate and CI configured, with the newest runs on main passing (9). 30+20+22+15+9 = 96.

### Security & auth: Mastra +7

- DSPy (60): Framework reading (telemetry defaults, approvals, guardrails, sandboxing). No telemetry found, and the optional LiteLLM engine switches LiteLLM telemetry off (25). No tool approval hook; RLM runs generated code in a Deno and Pyodide sandbox with no filesystem or network access (10). No prompt-injection guidance found (5). MLflow tracing through OpenTelemetry and callbacks (12). SECURITY.md with GitHub private reporting and a maintainer address, but OSV lists CVE-2025-12695 for the PythonInterpreter sandbox with no fixed version (8). 25+10+5+12+8 = 60.
- Mastra (67): The CLI sends PostHog analytics, server startup sends token counts per model and a count of registered agents, tools and MCP servers, and Studio sends browser analytics, all on by default and documented, with one opt-out, MASTRA_TELEMETRY_DISABLED=1. Since #26986 (16 October 2026) each server process also reports token use per provider and model every 15 minutes, and the telemetry reference read on 6 November says server events carry a project identifier that is a raw Platform UUID or a hash of the Git origin remote, so they "aren't anonymous" (12). requireToolApproval on agents and MCP servers, allowedHosts for MCP HTTP, a curated environment for stdio servers, and sandboxed workspaces (20). PromptInjectionDetector, PII and moderation processors, and docs that call tool results untrusted model input (15). Built-in tracing with OpenTelemetry and other exporters (15). No SECURITY.md, no security.txt and no bug bounty found. A blog post says Mastra is SOC 2 Type II audited, which isn't scored for a framework, and we found no public advisory from Mastra about the June incident (5). Framework reading. 15+20+15+15+5 = 70 on 6 October, 12+20+15+15+5 = 67 on 6 November.

## Score by category

| Category | Weight | DSPy | Mastra | Edge |
| --- | --- | --- | --- | --- |
| Reliability | 16% | 62 | 87 | Mastra +25 |
| Performance | 10%, pending | pending | pending | not scored in this run |
| Schema & documentation | 13% | 71 | 98 | Mastra +27 |
| Agent ergonomics | 13% | 64 | 92 | Mastra +28 |
| Security & auth | 14% | 60 | 67 | Mastra +7 |
| Payments & pricing | 10% | 90 | 90 | even |
| Task success | 10%, pending | pending | pending | not scored in this run |
| Maintenance & community | 7% | 87 | 96 | Mastra +9 |
| Transparency & trust | 7% | 52 | 72 | Mastra +20 |
| Negative events | ≤15 | 0 | -8 | |
| **Total** | | **68.3 · B** | **78 · A** | |

## Facts side by side

| Fact | DSPy | Mastra |
| --- | --- | --- |
| Kind | Agent framework | Agent framework |
| Vendor | Stanford NLP | Kepler Software, Inc. |
| Hosted endpoint | no (local only) | no (local only) |
| Transports |  |  |
| Auth | None | API key |
| Pricing | Free | Free |
| x402 | no | no |
| Licence | MIT | Apache-2.0 for the core. Code under ee/ directories is source-available under the Mastra Enterprise License, free for development and testing |
| Read-only variant documented | no | no |
| llms.txt | no | yes |
| Last release | 2026-11-10 | 2026-11-04 |
| Terms last updated | no document linked | 2026-10-26 |
| Privacy policy last updated | no document linked | no date given |
| Customer content may train models | not read yet | yes |
| Terms restrict automated access | not read yet | yes |
| Terms restrict benchmarking | not read yet | not found in the text |
| Terms or service can change without notice | not read yet | yes |
| Arbitration or class-action waiver | not read yet | yes |
| Popularity | 39k stars | 29k stars, 3.1M npm/wk |

## How the scores have moved

### DSPy

No score change since it was listed.

### Mastra

- +3.8 on 13 November 2026 (BB to A): checklist

## Verdicts

**DSPy.** An MIT Python framework with typed signatures, a ReAct agent that returns tool errors to the model, MCP tool conversion, a Deno sandbox for generated code, no telemetry found and monthly releases. Release 3.5 changed defaults and removed APIs in a minor version, and there is no tool approval hook or llms.txt.

**Mastra.** A TypeScript framework with agents, workflows with suspend and resume, memory, an MCP client and server, per-server tool approval and built-in guardrail processors including a prompt-injection detector. On 17 June 2026 malicious versions of its npm packages were published, and the CLI, server and Studio send usage analytics by default, with token counts every 15 minutes.

## Before you call either

### DSPy

1. Re-evaluate saved programs after upgrading to 3.5, since the default adapter and prompts changed
2. Install dspy[mcp] and convert each MCP tool with dspy.Tool.from_mcp_tool while the client session stays open
3. Disable the answer cache for calls whose output must change between runs, since memory and disk caches are on by default
4. Wrap tools that send, pay or delete in your own confirmation step, because ReAct runs tools without approval
5. Pin dspy to a minor version, since minor releases remove APIs

### Mastra

1. Set MASTRA_TELEMETRY_DISABLED=1 in every environment that runs the CLI, the server or Studio
2. Pin exact versions with a lockfile, and make sure no 17 June 2026 release such as @mastra/core 1.42.1 is installed
3. Set requireToolApproval on MCP servers that write, and allowedHosts when server URLs come from configuration
4. Add PromptInjectionDetector as an input processor when tools return web or user content
5. Use supervisor agents through generate() or stream(). `.network()` is deprecated

## Questions

### Which is better for AI agents, DSPy or Mastra?

Mastra scores 78 (A) on agent readiness against DSPy's 68.3 (B), and leads in 6 of 7 scored categories.

### Are DSPy and Mastra open source?

Yes. DSPy is open source (MIT). Mastra is open source (Apache-2.0 for the core. Code under ee/ directories is source-available under the Mastra Enterprise License, free for development and testing).


## For agents

- This comparison as JSON: https://www.anchorterminal.com/compare/dspy-vs-mastra.json, and with the fewest tokens: https://www.anchorterminal.com/compare/dspy-vs-mastra.min.md
- Over MCP at https://www.anchorterminal.com/mcp (no key): `compare_tools {"a": "dspy", "b": "mastra"}`. From a terminal: `anchor compare dspy mastra`
- Each listing in full: https://www.anchorterminal.com/api/v1/tools/dspy.json and https://www.anchorterminal.com/api/v1/tools/mastra.json

## Other comparisons with DSPy or Mastra

- [AgentOS vs DSPy](https://www.anchorterminal.com/compare/agentos-vs-dspy.md)
- [AgentOS vs Mastra](https://www.anchorterminal.com/compare/agentos-vs-mastra.md)
- [Agno vs DSPy](https://www.anchorterminal.com/compare/agno-vs-dspy.md)
- [Agno vs Mastra](https://www.anchorterminal.com/compare/agno-vs-mastra.md)
- [BoxLang AI vs DSPy](https://www.anchorterminal.com/compare/boxlang-ai-vs-dspy.md)
- [BoxLang AI vs Mastra](https://www.anchorterminal.com/compare/boxlang-ai-vs-mastra.md)
- [Claude Agent SDK vs DSPy](https://www.anchorterminal.com/compare/claude-agent-sdk-vs-dspy.md)
- [Claude Agent SDK vs Mastra](https://www.anchorterminal.com/compare/claude-agent-sdk-vs-mastra.md)
- [CrewAI vs DSPy](https://www.anchorterminal.com/compare/crewai-vs-dspy.md)
- [CrewAI vs Mastra](https://www.anchorterminal.com/compare/crewai-vs-mastra.md)
- [Cursor Agent SDK vs DSPy](https://www.anchorterminal.com/compare/cursor-agent-sdk-vs-dspy.md)
- [Cursor Agent SDK vs Mastra](https://www.anchorterminal.com/compare/cursor-agent-sdk-vs-mastra.md)
- [Docker Agent vs DSPy](https://www.anchorterminal.com/compare/docker-agent-vs-dspy.md)
- [Docker Agent vs Mastra](https://www.anchorterminal.com/compare/docker-agent-vs-mastra.md)
- [DSPy vs Genkit](https://www.anchorterminal.com/compare/dspy-vs-genkit.md)
- [DSPy vs Agent Development Kit (ADK)](https://www.anchorterminal.com/compare/dspy-vs-google-adk.md)
- [DSPy vs guilds.run](https://www.anchorterminal.com/compare/dspy-vs-guilds-run.md)
- [DSPy vs Haystack](https://www.anchorterminal.com/compare/dspy-vs-haystack.md)
- [DSPy vs LangGraph](https://www.anchorterminal.com/compare/dspy-vs-langgraph.md)
- [DSPy vs LlamaIndex Framework](https://www.anchorterminal.com/compare/dspy-vs-llamaindex.md)
- [DSPy vs Microsoft Agent Framework](https://www.anchorterminal.com/compare/dspy-vs-microsoft-agent-framework.md)
- [DSPy vs OpenAI Agents SDK](https://www.anchorterminal.com/compare/dspy-vs-openai-agents-sdk.md)
- [DSPy vs Pydantic AI](https://www.anchorterminal.com/compare/dspy-vs-pydantic-ai.md)
- [DSPy vs smolagents](https://www.anchorterminal.com/compare/dspy-vs-smolagents.md)
- [DSPy vs Strands Agents](https://www.anchorterminal.com/compare/dspy-vs-strands-agents.md)
- [DSPy vs Terse Durable Actors](https://www.anchorterminal.com/compare/dspy-vs-terse-durable-actors.md)
- [DSPy vs TradingAgents](https://www.anchorterminal.com/compare/dspy-vs-tradingagents.md)
- [DSPy vs AI SDK](https://www.anchorterminal.com/compare/dspy-vs-vercel-ai-sdk.md)
- [Genkit vs Mastra](https://www.anchorterminal.com/compare/genkit-vs-mastra.md)
- [Agent Development Kit (ADK) vs Mastra](https://www.anchorterminal.com/compare/google-adk-vs-mastra.md)
- [guilds.run vs Mastra](https://www.anchorterminal.com/compare/guilds-run-vs-mastra.md)
- [Haystack vs Mastra](https://www.anchorterminal.com/compare/haystack-vs-mastra.md)
- [LangGraph vs Mastra](https://www.anchorterminal.com/compare/langgraph-vs-mastra.md)
- [LlamaIndex Framework vs Mastra](https://www.anchorterminal.com/compare/llamaindex-vs-mastra.md)
- [Mastra vs Microsoft Agent Framework](https://www.anchorterminal.com/compare/mastra-vs-microsoft-agent-framework.md)
- [Mastra vs OpenAI Agents SDK](https://www.anchorterminal.com/compare/mastra-vs-openai-agents-sdk.md)
- [Mastra vs Pydantic AI](https://www.anchorterminal.com/compare/mastra-vs-pydantic-ai.md)
- [Mastra vs smolagents](https://www.anchorterminal.com/compare/mastra-vs-smolagents.md)
- [Mastra vs Strands Agents](https://www.anchorterminal.com/compare/mastra-vs-strands-agents.md)
- [Mastra vs Terse Durable Actors](https://www.anchorterminal.com/compare/mastra-vs-terse-durable-actors.md)
- [Mastra vs TradingAgents](https://www.anchorterminal.com/compare/mastra-vs-tradingagents.md)
- [Mastra vs AI SDK](https://www.anchorterminal.com/compare/mastra-vs-vercel-ai-sdk.md)

---

Query this catalogue directly over MCP: https://www.anchorterminal.com/mcp (Streamable HTTP, no key). How: https://www.anchorterminal.com/agents/#mcp
