@mastra/mcp-docs-server 0.0.0-commonjs-20250414101718

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (254) hide show
  1. package/.docs/organized/changelogs/%40mastra%2Fastra.md +302 -0
  2. package/.docs/organized/changelogs/%40mastra%2Fchroma.md +302 -0
  3. package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +161 -0
  4. package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +302 -0
  5. package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +110 -0
  6. package/.docs/organized/changelogs/%40mastra%2Fcore.md +302 -0
  7. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +302 -0
  8. package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +302 -0
  9. package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +302 -0
  10. package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +302 -0
  11. package/.docs/organized/changelogs/%40mastra%2Fevals.md +302 -0
  12. package/.docs/organized/changelogs/%40mastra%2Ffirecrawl.md +302 -0
  13. package/.docs/organized/changelogs/%40mastra%2Fgithub.md +302 -0
  14. package/.docs/organized/changelogs/%40mastra%2Floggers.md +302 -0
  15. package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +302 -0
  16. package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +26 -0
  17. package/.docs/organized/changelogs/%40mastra%2Fmcp.md +302 -0
  18. package/.docs/organized/changelogs/%40mastra%2Fmem0.md +196 -0
  19. package/.docs/organized/changelogs/%40mastra%2Fmemory.md +302 -0
  20. package/.docs/organized/changelogs/%40mastra%2Fpg.md +302 -0
  21. package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +302 -0
  22. package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +302 -0
  23. package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +302 -0
  24. package/.docs/organized/changelogs/%40mastra%2Frag.md +302 -0
  25. package/.docs/organized/changelogs/%40mastra%2Fragie.md +302 -0
  26. package/.docs/organized/changelogs/%40mastra%2Fserver.md +302 -0
  27. package/.docs/organized/changelogs/%40mastra%2Fspeech-azure.md +302 -0
  28. package/.docs/organized/changelogs/%40mastra%2Fspeech-deepgram.md +302 -0
  29. package/.docs/organized/changelogs/%40mastra%2Fspeech-elevenlabs.md +302 -0
  30. package/.docs/organized/changelogs/%40mastra%2Fspeech-google.md +302 -0
  31. package/.docs/organized/changelogs/%40mastra%2Fspeech-ibm.md +302 -0
  32. package/.docs/organized/changelogs/%40mastra%2Fspeech-murf.md +302 -0
  33. package/.docs/organized/changelogs/%40mastra%2Fspeech-openai.md +302 -0
  34. package/.docs/organized/changelogs/%40mastra%2Fspeech-playai.md +302 -0
  35. package/.docs/organized/changelogs/%40mastra%2Fspeech-replicate.md +302 -0
  36. package/.docs/organized/changelogs/%40mastra%2Fspeech-speechify.md +302 -0
  37. package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +302 -0
  38. package/.docs/organized/changelogs/%40mastra%2Fupstash.md +302 -0
  39. package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +302 -0
  40. package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +250 -0
  41. package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +250 -0
  42. package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +302 -0
  43. package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +302 -0
  44. package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +302 -0
  45. package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +302 -0
  46. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +302 -0
  47. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +302 -0
  48. package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +302 -0
  49. package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +302 -0
  50. package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +302 -0
  51. package/.docs/organized/changelogs/create-mastra.md +302 -0
  52. package/.docs/organized/changelogs/mastra.md +302 -0
  53. package/.docs/organized/code-examples/agent-network.md +282 -0
  54. package/.docs/organized/code-examples/agent.md +388 -0
  55. package/.docs/organized/code-examples/ai-sdk-useChat.md +378 -0
  56. package/.docs/organized/code-examples/assistant-ui.md +37 -0
  57. package/.docs/organized/code-examples/bird-checker-with-express.md +235 -0
  58. package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +360 -0
  59. package/.docs/organized/code-examples/bird-checker-with-nextjs.md +250 -0
  60. package/.docs/organized/code-examples/client-side-tools.md +69 -0
  61. package/.docs/organized/code-examples/crypto-chatbot.md +96 -0
  62. package/.docs/organized/code-examples/fireworks-r1.md +159 -0
  63. package/.docs/organized/code-examples/mcp-registry-registry.md +63 -0
  64. package/.docs/organized/code-examples/memory-todo-agent.md +164 -0
  65. package/.docs/organized/code-examples/memory-with-context.md +167 -0
  66. package/.docs/organized/code-examples/memory-with-libsql.md +204 -0
  67. package/.docs/organized/code-examples/memory-with-mem0.md +121 -0
  68. package/.docs/organized/code-examples/memory-with-pg.md +224 -0
  69. package/.docs/organized/code-examples/memory-with-upstash.md +268 -0
  70. package/.docs/organized/code-examples/quick-start.md +129 -0
  71. package/.docs/organized/code-examples/stock-price-tool.md +124 -0
  72. package/.docs/organized/code-examples/weather-agent.md +353 -0
  73. package/.docs/organized/code-examples/workflow-ai-recruiter.md +159 -0
  74. package/.docs/organized/code-examples/workflow-with-inline-steps.md +111 -0
  75. package/.docs/organized/code-examples/workflow-with-memory.md +393 -0
  76. package/.docs/organized/code-examples/workflow-with-separate-steps.md +131 -0
  77. package/.docs/raw/agents/adding-tools.mdx +317 -0
  78. package/.docs/raw/agents/adding-voice.mdx +175 -0
  79. package/.docs/raw/agents/agent-memory.mdx +62 -0
  80. package/.docs/raw/agents/mcp-guide.mdx +215 -0
  81. package/.docs/raw/agents/overview.mdx +303 -0
  82. package/.docs/raw/community/discord.mdx +12 -0
  83. package/.docs/raw/community/licensing.mdx +63 -0
  84. package/.docs/raw/deployment/client.mdx +120 -0
  85. package/.docs/raw/deployment/deployment.mdx +127 -0
  86. package/.docs/raw/deployment/server.mdx +282 -0
  87. package/.docs/raw/evals/custom-eval.mdx +22 -0
  88. package/.docs/raw/evals/overview.mdx +95 -0
  89. package/.docs/raw/evals/running-in-ci.mdx +81 -0
  90. package/.docs/raw/evals/textual-evals.mdx +54 -0
  91. package/.docs/raw/faq/index.mdx +63 -0
  92. package/.docs/raw/frameworks/ai-sdk.mdx +296 -0
  93. package/.docs/raw/frameworks/next-js.mdx +238 -0
  94. package/.docs/raw/getting-started/installation.mdx +442 -0
  95. package/.docs/raw/getting-started/mcp-docs-server.mdx +141 -0
  96. package/.docs/raw/getting-started/project-structure.mdx +80 -0
  97. package/.docs/raw/index.mdx +22 -0
  98. package/.docs/raw/integrations/index.mdx +213 -0
  99. package/.docs/raw/local-dev/add-to-existing-project.mdx +48 -0
  100. package/.docs/raw/local-dev/creating-a-new-project.mdx +54 -0
  101. package/.docs/raw/local-dev/mastra-dev.mdx +108 -0
  102. package/.docs/raw/memory/memory-processors.mdx +131 -0
  103. package/.docs/raw/memory/overview.mdx +119 -0
  104. package/.docs/raw/memory/semantic-recall.mdx +122 -0
  105. package/.docs/raw/memory/working-memory.mdx +87 -0
  106. package/.docs/raw/observability/logging.mdx +38 -0
  107. package/.docs/raw/observability/nextjs-tracing.mdx +108 -0
  108. package/.docs/raw/observability/tracing.mdx +115 -0
  109. package/.docs/raw/rag/chunking-and-embedding.mdx +156 -0
  110. package/.docs/raw/rag/overview.mdx +85 -0
  111. package/.docs/raw/rag/retrieval.mdx +365 -0
  112. package/.docs/raw/rag/vector-databases.mdx +340 -0
  113. package/.docs/raw/reference/agents/createTool.mdx +229 -0
  114. package/.docs/raw/reference/agents/generate.mdx +334 -0
  115. package/.docs/raw/reference/agents/getAgent.mdx +54 -0
  116. package/.docs/raw/reference/agents/stream.mdx +369 -0
  117. package/.docs/raw/reference/cli/build.mdx +55 -0
  118. package/.docs/raw/reference/cli/dev.mdx +134 -0
  119. package/.docs/raw/reference/cli/init.mdx +43 -0
  120. package/.docs/raw/reference/client-js/agents.mdx +107 -0
  121. package/.docs/raw/reference/client-js/error-handling.mdx +38 -0
  122. package/.docs/raw/reference/client-js/logs.mdx +24 -0
  123. package/.docs/raw/reference/client-js/memory.mdx +97 -0
  124. package/.docs/raw/reference/client-js/telemetry.mdx +20 -0
  125. package/.docs/raw/reference/client-js/tools.mdx +44 -0
  126. package/.docs/raw/reference/client-js/vectors.mdx +79 -0
  127. package/.docs/raw/reference/client-js/workflows.mdx +136 -0
  128. package/.docs/raw/reference/core/mastra-class.mdx +232 -0
  129. package/.docs/raw/reference/deployer/cloudflare.mdx +207 -0
  130. package/.docs/raw/reference/deployer/deployer.mdx +159 -0
  131. package/.docs/raw/reference/deployer/netlify.mdx +109 -0
  132. package/.docs/raw/reference/deployer/vercel.mdx +117 -0
  133. package/.docs/raw/reference/evals/answer-relevancy.mdx +186 -0
  134. package/.docs/raw/reference/evals/bias.mdx +186 -0
  135. package/.docs/raw/reference/evals/completeness.mdx +174 -0
  136. package/.docs/raw/reference/evals/content-similarity.mdx +183 -0
  137. package/.docs/raw/reference/evals/context-position.mdx +190 -0
  138. package/.docs/raw/reference/evals/context-precision.mdx +189 -0
  139. package/.docs/raw/reference/evals/context-relevancy.mdx +188 -0
  140. package/.docs/raw/reference/evals/contextual-recall.mdx +191 -0
  141. package/.docs/raw/reference/evals/faithfulness.mdx +193 -0
  142. package/.docs/raw/reference/evals/hallucination.mdx +219 -0
  143. package/.docs/raw/reference/evals/keyword-coverage.mdx +176 -0
  144. package/.docs/raw/reference/evals/prompt-alignment.mdx +238 -0
  145. package/.docs/raw/reference/evals/summarization.mdx +205 -0
  146. package/.docs/raw/reference/evals/textual-difference.mdx +161 -0
  147. package/.docs/raw/reference/evals/tone-consistency.mdx +181 -0
  148. package/.docs/raw/reference/evals/toxicity.mdx +165 -0
  149. package/.docs/raw/reference/index.mdx +12 -0
  150. package/.docs/raw/reference/memory/Memory.mdx +212 -0
  151. package/.docs/raw/reference/memory/createThread.mdx +95 -0
  152. package/.docs/raw/reference/memory/getThreadById.mdx +46 -0
  153. package/.docs/raw/reference/memory/getThreadsByResourceId.mdx +48 -0
  154. package/.docs/raw/reference/memory/query.mdx +167 -0
  155. package/.docs/raw/reference/networks/agent-network.mdx +159 -0
  156. package/.docs/raw/reference/observability/create-logger.mdx +106 -0
  157. package/.docs/raw/reference/observability/logger.mdx +55 -0
  158. package/.docs/raw/reference/observability/otel-config.mdx +120 -0
  159. package/.docs/raw/reference/observability/providers/braintrust.mdx +40 -0
  160. package/.docs/raw/reference/observability/providers/dash0.mdx +40 -0
  161. package/.docs/raw/reference/observability/providers/index.mdx +16 -0
  162. package/.docs/raw/reference/observability/providers/laminar.mdx +41 -0
  163. package/.docs/raw/reference/observability/providers/langfuse.mdx +51 -0
  164. package/.docs/raw/reference/observability/providers/langsmith.mdx +48 -0
  165. package/.docs/raw/reference/observability/providers/langwatch.mdx +45 -0
  166. package/.docs/raw/reference/observability/providers/new-relic.mdx +40 -0
  167. package/.docs/raw/reference/observability/providers/signoz.mdx +40 -0
  168. package/.docs/raw/reference/observability/providers/traceloop.mdx +40 -0
  169. package/.docs/raw/reference/rag/astra.mdx +258 -0
  170. package/.docs/raw/reference/rag/chroma.mdx +281 -0
  171. package/.docs/raw/reference/rag/chunk.mdx +235 -0
  172. package/.docs/raw/reference/rag/document.mdx +127 -0
  173. package/.docs/raw/reference/rag/embeddings.mdx +160 -0
  174. package/.docs/raw/reference/rag/extract-params.mdx +226 -0
  175. package/.docs/raw/reference/rag/graph-rag.mdx +182 -0
  176. package/.docs/raw/reference/rag/libsql.mdx +357 -0
  177. package/.docs/raw/reference/rag/metadata-filters.mdx +298 -0
  178. package/.docs/raw/reference/rag/pg.mdx +477 -0
  179. package/.docs/raw/reference/rag/pinecone.mdx +281 -0
  180. package/.docs/raw/reference/rag/qdrant.mdx +236 -0
  181. package/.docs/raw/reference/rag/rerank.mdx +212 -0
  182. package/.docs/raw/reference/rag/turbopuffer.mdx +249 -0
  183. package/.docs/raw/reference/rag/upstash.mdx +247 -0
  184. package/.docs/raw/reference/rag/vectorize.mdx +298 -0
  185. package/.docs/raw/reference/storage/libsql.mdx +74 -0
  186. package/.docs/raw/reference/storage/postgresql.mdx +48 -0
  187. package/.docs/raw/reference/storage/upstash.mdx +86 -0
  188. package/.docs/raw/reference/tools/client.mdx +207 -0
  189. package/.docs/raw/reference/tools/document-chunker-tool.mdx +141 -0
  190. package/.docs/raw/reference/tools/graph-rag-tool.mdx +154 -0
  191. package/.docs/raw/reference/tools/mcp-configuration.mdx +206 -0
  192. package/.docs/raw/reference/tools/vector-query-tool.mdx +212 -0
  193. package/.docs/raw/reference/voice/composite-voice.mdx +140 -0
  194. package/.docs/raw/reference/voice/deepgram.mdx +164 -0
  195. package/.docs/raw/reference/voice/elevenlabs.mdx +216 -0
  196. package/.docs/raw/reference/voice/google.mdx +198 -0
  197. package/.docs/raw/reference/voice/mastra-voice.mdx +394 -0
  198. package/.docs/raw/reference/voice/murf.mdx +251 -0
  199. package/.docs/raw/reference/voice/openai-realtime.mdx +431 -0
  200. package/.docs/raw/reference/voice/openai.mdx +168 -0
  201. package/.docs/raw/reference/voice/playai.mdx +159 -0
  202. package/.docs/raw/reference/voice/sarvam.mdx +260 -0
  203. package/.docs/raw/reference/voice/speechify.mdx +145 -0
  204. package/.docs/raw/reference/voice/voice.answer.mdx +122 -0
  205. package/.docs/raw/reference/voice/voice.connect.mdx +124 -0
  206. package/.docs/raw/reference/voice/voice.listen.mdx +195 -0
  207. package/.docs/raw/reference/voice/voice.on.mdx +189 -0
  208. package/.docs/raw/reference/voice/voice.send.mdx +118 -0
  209. package/.docs/raw/reference/voice/voice.speak.mdx +203 -0
  210. package/.docs/raw/reference/workflows/after.mdx +88 -0
  211. package/.docs/raw/reference/workflows/afterEvent.mdx +76 -0
  212. package/.docs/raw/reference/workflows/commit.mdx +37 -0
  213. package/.docs/raw/reference/workflows/createRun.mdx +77 -0
  214. package/.docs/raw/reference/workflows/else.mdx +72 -0
  215. package/.docs/raw/reference/workflows/events.mdx +305 -0
  216. package/.docs/raw/reference/workflows/execute.mdx +110 -0
  217. package/.docs/raw/reference/workflows/if.mdx +107 -0
  218. package/.docs/raw/reference/workflows/resume.mdx +155 -0
  219. package/.docs/raw/reference/workflows/resumeWithEvent.mdx +133 -0
  220. package/.docs/raw/reference/workflows/snapshots.mdx +207 -0
  221. package/.docs/raw/reference/workflows/start.mdx +84 -0
  222. package/.docs/raw/reference/workflows/step-class.mdx +100 -0
  223. package/.docs/raw/reference/workflows/step-condition.mdx +134 -0
  224. package/.docs/raw/reference/workflows/step-function.mdx +92 -0
  225. package/.docs/raw/reference/workflows/step-options.mdx +69 -0
  226. package/.docs/raw/reference/workflows/step-retries.mdx +203 -0
  227. package/.docs/raw/reference/workflows/suspend.mdx +70 -0
  228. package/.docs/raw/reference/workflows/then.mdx +74 -0
  229. package/.docs/raw/reference/workflows/until.mdx +165 -0
  230. package/.docs/raw/reference/workflows/watch.mdx +118 -0
  231. package/.docs/raw/reference/workflows/while.mdx +168 -0
  232. package/.docs/raw/reference/workflows/workflow.mdx +233 -0
  233. package/.docs/raw/storage/overview.mdx +378 -0
  234. package/.docs/raw/voice/overview.mdx +135 -0
  235. package/.docs/raw/voice/speech-to-text.mdx +45 -0
  236. package/.docs/raw/voice/text-to-speech.mdx +52 -0
  237. package/.docs/raw/voice/voice-to-voice.mdx +310 -0
  238. package/.docs/raw/workflows/control-flow.mdx +778 -0
  239. package/.docs/raw/workflows/dynamic-workflows.mdx +236 -0
  240. package/.docs/raw/workflows/error-handling.mdx +183 -0
  241. package/.docs/raw/workflows/nested-workflows.mdx +352 -0
  242. package/.docs/raw/workflows/overview.mdx +203 -0
  243. package/.docs/raw/workflows/steps.mdx +108 -0
  244. package/.docs/raw/workflows/suspend-and-resume.mdx +404 -0
  245. package/.docs/raw/workflows/variables.mdx +313 -0
  246. package/LICENSE.md +46 -0
  247. package/README.md +129 -0
  248. package/dist/_tsup-dts-rollup.d.ts +149 -0
  249. package/dist/chunk-QWYMT5LP.js +194 -0
  250. package/dist/prepare-docs/prepare.d.ts +1 -0
  251. package/dist/prepare-docs/prepare.js +1 -0
  252. package/dist/stdio.d.ts +1 -0
  253. package/dist/stdio.js +518 -0
  254. package/package.json +60 -0
@@ -0,0 +1,81 @@
1
+ ---
2
+ title: "Running in CI"
3
+ description: "Learn how to run Mastra evals in your CI/CD pipeline to monitor agent quality over time."
4
+ ---
5
+
6
+ # Running Evals in CI
7
+
8
+ Running evals in your CI pipeline helps bridge this gap by providing quantifiable metrics for measuring agent quality over time.
9
+
10
+ ## Setting Up CI Integration
11
+
12
+ We support any testing framework that supports ESM modules. For example, you can use [Vitest](https://vitest.dev/), [Jest](https://jestjs.io/) or [Mocha](https://mochajs.org/) to run evals in your CI/CD pipeline.
13
+
14
+ ```typescript copy showLineNumbers filename="src/mastra/agents/index.test.ts"
15
+ import { describe, it, expect } from 'vitest';
16
+ import { evaluate } from "@mastra/evals";
17
+ import { ToneConsistencyMetric } from "@mastra/evals/nlp";
18
+ import { myAgent } from './index';
19
+
20
+ describe('My Agent', () => {
21
+ it('should validate tone consistency', async () => {
22
+ const metric = new ToneConsistencyMetric();
23
+ const result = await evaluate(myAgent, 'Hello, world!', metric)
24
+
25
+ expect(result.score).toBe(1);
26
+ });
27
+ });
28
+ ```
29
+
30
+ You will need to configure a testSetup and globalSetup script for your testing framework to capture the eval results. It allows us to show these results in your mastra dashboard.
31
+
32
+ ## Framework Configuration
33
+
34
+ ### Vitest Setup
35
+
36
+ Add these files to your project to run evals in your CI/CD pipeline:
37
+
38
+ ```typescript copy showLineNumbers filename="globalSetup.ts"
39
+ import { globalSetup } from '@mastra/evals';
40
+
41
+ export default function setup() {
42
+ globalSetup()
43
+ }
44
+ ```
45
+
46
+ ```typescript copy showLineNumbers filename="testSetup.ts"
47
+ import { beforeAll } from 'vitest';
48
+ import { attachListeners } from '@mastra/evals';
49
+
50
+ beforeAll(async () => {
51
+ await attachListeners();
52
+ });
53
+ ```
54
+
55
+ ```typescript copy showLineNumbers filename="vitest.config.ts"
56
+ import { defineConfig } from 'vitest/config'
57
+
58
+ export default defineConfig({
59
+ test: {
60
+ globalSetup: './globalSetup.ts',
61
+ setupFiles: ['./testSetup.ts'],
62
+ },
63
+ })
64
+ ```
65
+
66
+ ## Storage Configuration
67
+
68
+ To store eval results in Mastra Storage and capture results in the Mastra dashboard:
69
+
70
+ ```typescript copy showLineNumbers filename="testSetup.ts"
71
+ import { beforeAll } from 'vitest';
72
+ import { attachListeners } from '@mastra/evals';
73
+ import { mastra } from './your-mastra-setup';
74
+
75
+ beforeAll(async () => {
76
+ // Store evals in Mastra Storage (requires storage to be enabled)
77
+ await attachListeners(mastra);
78
+ });
79
+ ```
80
+
81
+ With file storage, evals persist and can be queried later. With memory storage, evals are isolated to the test process.
@@ -0,0 +1,54 @@
1
+ ---
2
+ title: "Textual Evals"
3
+ description: "Understand how Mastra uses LLM-as-judge methodology to evaluate text quality."
4
+ ---
5
+
6
+ # Textual Evals
7
+
8
+ Textual evals use an LLM-as-judge methodology to evaluate agent outputs. This approach leverages language models to assess various aspects of text quality, similar to how a teaching assistant might grade assignments using a rubric.
9
+
10
+ Each eval focuses on specific quality aspects and returns a score between 0 and 1, providing quantifiable metrics for non-deterministic AI outputs.
11
+
12
+ Mastra provides several eval metrics for assessing Agent outputs. Mastra is not limited to these metrics, and you can also [define your own evals](/docs/evals/custom-eval).
13
+
14
+ ## Why Use Textual Evals?
15
+
16
+ Textual evals help ensure your agent:
17
+
18
+ - Produces accurate and reliable responses
19
+ - Uses context effectively
20
+ - Follows output requirements
21
+ - Maintains consistent quality over time
22
+
23
+ ## Available Metrics
24
+
25
+ ### Accuracy and Reliability
26
+
27
+ These metrics evaluate how correct, truthful, and complete your agent's answers are:
28
+
29
+ - [`hallucination`](/reference/evals/hallucination): Detects facts or claims not present in provided context
30
+ - [`faithfulness`](/reference/evals/faithfulness): Measures how accurately responses represent provided context
31
+ - [`content-similarity`](/reference/evals/content-similarity): Evaluates consistency of information across different phrasings
32
+ - [`completeness`](/reference/evals/completeness): Checks if responses include all necessary information
33
+ - [`answer-relevancy`](/reference/evals/answer-relevancy): Assesses how well responses address the original query
34
+ - [`textual-difference`](/reference/evals/textual-difference): Measures textual differences between strings
35
+
36
+ ### Understanding Context
37
+
38
+ These metrics evaluate how well your agent uses provided context:
39
+
40
+ - [`context-position`](/reference/evals/context-position): Analyzes where context appears in responses
41
+ - [`context-precision`](/reference/evals/context-precision): Evaluates whether context chunks are grouped logically
42
+ - [`context-relevancy`](/reference/evals/context-relevancy): Measures use of appropriate context pieces
43
+ - [`contextual-recall`](/reference/evals/contextual-recall): Assesses completeness of context usage
44
+
45
+ ### Output Quality
46
+
47
+ These metrics evaluate adherence to format and style requirements:
48
+
49
+ - [`tone`](/reference/evals/tone-consistency): Measures consistency in formality, complexity, and style
50
+ - [`toxicity`](/reference/evals/toxicity): Detects harmful or inappropriate content
51
+ - [`bias`](/reference/evals/bias): Detects potential biases in the output
52
+ - [`prompt-alignment`](/reference/evals/prompt-alignment): Checks adherence to explicit instructions like length restrictions, formatting requirements, or other constraints
53
+ - [`summarization`](/reference/evals/summarization): Evaluates information retention and conciseness
54
+ - [`keyword-coverage`](/reference/evals/keyword-coverage): Assesses technical terminology usage
@@ -0,0 +1,63 @@
1
+ ---
2
+ title: "Licensing"
3
+ description: "Mastra License"
4
+ ---
5
+
6
+ # License
7
+
8
+ ## Elastic License 2.0 (ELv2)
9
+
10
+ Mastra is licensed under the Elastic License 2.0 (ELv2), a modern license designed to balance open-source principles with sustainable business practices.
11
+
12
+ ### What is Elastic License 2.0?
13
+
14
+ The Elastic License 2.0 is a source-available license that grants users broad rights to use, modify, and distribute the software while including specific limitations to protect the project's sustainability. It allows:
15
+
16
+ - Free use for most purposes
17
+ - Viewing, modifying, and redistributing the source code
18
+ - Creating and distributing derivative works
19
+ - Commercial use within your organization
20
+
21
+ The primary limitation is that you cannot provide Mastra as a hosted or managed service that offers users access to the substantial functionality of the software.
22
+
23
+ ### Why We Chose Elastic License 2.0
24
+
25
+ We selected the Elastic License 2.0 for several important reasons:
26
+
27
+ 1. **Sustainability**: It enables us to maintain a healthy balance between openness and the ability to sustain long-term development.
28
+
29
+ 2. **Innovation Protection**: It ensures we can continue investing in innovation without concerns about our work being repackaged as competing services.
30
+
31
+ 3. **Community Focus**: It maintains the spirit of open source by allowing users to view, modify, and learn from our code while protecting our ability to support the community.
32
+
33
+ 4. **Business Clarity**: It provides clear guidelines for how Mastra can be used in commercial contexts.
34
+
35
+ ### Building Your Business with Mastra
36
+
37
+ Despite the licensing restrictions, there are numerous ways to build successful businesses using Mastra:
38
+
39
+ #### Allowed Business Models
40
+
41
+ - **Building Applications**: Create and sell applications built with Mastra
42
+ - **Offering Consulting Services**: Provide expertise, implementation, and customization services
43
+ - **Developing Custom Solutions**: Build bespoke AI solutions for clients using Mastra
44
+ - **Creating Add-ons and Extensions**: Develop and sell complementary tools that extend Mastra's functionality
45
+ - **Training and Education**: Offer courses and educational materials about using Mastra effectively
46
+
47
+ #### Examples of Compliant Usage
48
+
49
+ - A company builds an AI-powered customer service application using Mastra and sells it to clients
50
+ - A consulting firm offers implementation and customization services for Mastra
51
+ - A developer creates specialized agents and tools with Mastra and licenses them to other businesses
52
+ - A startup builds a vertical-specific solution (e.g., healthcare AI assistant) powered by Mastra
53
+
54
+ #### What to Avoid
55
+
56
+ The main restriction is that you cannot offer Mastra itself as a hosted service where users access its core functionality. This means:
57
+
58
+ - Don't create a SaaS platform that is essentially Mastra with minimal modifications
59
+ - Don't offer a managed Mastra service where customers are primarily paying to use Mastra's features
60
+
61
+ ### Questions About Licensing?
62
+
63
+ If you have specific questions about how the Elastic License 2.0 applies to your use case, please [contact us](https://discord.gg/BTYqqHKUrf) on Discord for clarification. We're committed to supporting legitimate business use cases while protecting the sustainability of the project.
@@ -0,0 +1,296 @@
1
+ ---
2
+ title: "Using with AI SDK"
3
+ description: "Learn how Mastra leverages the AI SDK library and how you can leverage it further with Mastra"
4
+ ---
5
+
6
+ # AI SDK
7
+
8
+ Mastra leverages AI SDK's model routing (a unified interface on top of OpenAI, Anthropic, etc), structured output, and tool calling.
9
+
10
+ We explain this in greater detail in [this blog post](https://mastra.ai/blog/using-ai-sdk-with-mastra)
11
+
12
+ ## Mastra + AI SDK
13
+
14
+ Mastra acts as a layer on top of AI SDK to help teams productionize their proof-of-concepts quickly and easily.
15
+
16
+ <img
17
+ src="/docs/mastra-ai-sdk.png"
18
+ alt="Agent interaction trace showing spans, LLM calls, and tool executions"
19
+ style={{ maxWidth: "800px", width: "100%", margin: "8px 0" }}
20
+ className="nextra-image rounded-md py-8"
21
+ data-zoom
22
+ width={800}
23
+ height={400}
24
+ />
25
+
26
+ ## Model routing
27
+
28
+ When creating agents in Mastra, you can specify any AI SDK-supported model:
29
+
30
+ ```typescript
31
+ import { openai } from "@ai-sdk/openai";
32
+ import { Agent } from "@mastra/core/agent";
33
+
34
+ const agent = new Agent({
35
+ name: "WeatherAgent",
36
+ instructions: "Instructions for the agent...",
37
+ model: openai("gpt-4-turbo"), // Model comes directly from AI SDK
38
+ });
39
+
40
+ const result = await agent.generate("What is the weather like?");
41
+ ```
42
+
43
+ ## AI SDK Hooks
44
+
45
+ Mastra is compatible with AI SDK's hooks for seamless frontend integration:
46
+
47
+ ### useChat
48
+
49
+ The `useChat` hook enables real-time chat interactions in your frontend application
50
+
51
+ - Works with agent data streams i.e. `.toDataStreamResponse()`
52
+ - The useChat `api` defaults to `/api/chat`
53
+ - Works with the Mastra REST API agent stream endpoint `{MASTRA_BASE_URL}/agents/:agentId/stream` for data streams,
54
+ i.e. no structured output is defined.
55
+
56
+ ```typescript filename="app/api/chat/route.ts" copy
57
+ import { mastra } from "@/src/mastra";
58
+
59
+ export async function POST(req: Request) {
60
+ const { messages } = await req.json();
61
+ const myAgent = mastra.getAgent("weatherAgent");
62
+ const stream = await myAgent.stream(messages);
63
+
64
+ return stream.toDataStreamResponse();
65
+ }
66
+ ```
67
+
68
+ ```typescript copy
69
+ import { useChat } from '@ai-sdk/react';
70
+
71
+ export function ChatComponent() {
72
+ const { messages, input, handleInputChange, handleSubmit } = useChat({
73
+ api: '/path-to-your-agent-stream-api-endpoint'
74
+ });
75
+
76
+ return (
77
+ <div>
78
+ {messages.map(m => (
79
+ <div key={m.id}>
80
+ {m.role}: {m.content}
81
+ </div>
82
+ ))}
83
+ <form onSubmit={handleSubmit}>
84
+ <input
85
+ value={input}
86
+ onChange={handleInputChange}
87
+ placeholder="Say something..."
88
+ />
89
+ </form>
90
+ </div>
91
+ );
92
+ }
93
+ ```
94
+
95
+ > **Gotcha**: When using `useChat` with agent memory functionality, make sure to check out the [Agent Memory section](/docs/agents/agent-memory#usechat) for important implementation details.
96
+
97
+ ### useCompletion
98
+
99
+ For single-turn completions, use the `useCompletion` hook:
100
+
101
+ - Works with agent data streams i.e. `.toDataStreamResponse()`
102
+ - The useCompletion `api` defaults to `/api/completion`
103
+ - Works with the Mastra REST API agent stream endpoint `{MASTRA_BASE_URL}/agents/:agentId/stream` for data streams,
104
+ i.e. no structured output is defined.
105
+
106
+ ```typescript filename="app/api/completion/route.ts" copy
107
+ import { mastra } from "@/src/mastra";
108
+
109
+ export async function POST(req: Request) {
110
+ const { messages } = await req.json();
111
+ const myAgent = mastra.getAgent("weatherAgent");
112
+ const stream = await myAgent.stream(messages);
113
+
114
+ return stream.toDataStreamResponse();
115
+ }
116
+ ```
117
+
118
+ ```typescript
119
+ import { useCompletion } from "@ai-sdk/react";
120
+
121
+ export function CompletionComponent() {
122
+ const {
123
+ completion,
124
+ input,
125
+ handleInputChange,
126
+ handleSubmit,
127
+ } = useCompletion({
128
+ api: '/path-to-your-agent-stream-api-endpoint'
129
+ });
130
+
131
+ return (
132
+ <div>
133
+ <form onSubmit={handleSubmit}>
134
+ <input
135
+ value={input}
136
+ onChange={handleInputChange}
137
+ placeholder="Enter a prompt..."
138
+ />
139
+ </form>
140
+ <p>Completion result: {completion}</p>
141
+ </div>
142
+ );
143
+ }
144
+ ```
145
+
146
+ ### useObject
147
+
148
+ For consuming text streams that represent JSON objects and parsing them into a complete object based on a schema.
149
+
150
+ - Works with agent text streams i.e. `.toTextStreamResponse()`
151
+ - The useObject `api` defaults to `/api/completion`
152
+ - Works with the Mastra REST API agent stream endpoint `{MASTRA_BASE_URL}/agents/:agentId/stream` for text streams,
153
+ i.e. structured output is defined.
154
+
155
+ ```typescript filename="app/api/use-object/route.ts" copy
156
+ import { mastra } from "@/src/mastra";
157
+
158
+ export async function POST(req: Request) {
159
+ const { messages } = await req.json();
160
+ const myAgent = mastra.getAgent("weatherAgent");
161
+ const stream = await myAgent.stream(messages, {
162
+ output: z.object({
163
+ weather: z.string(),
164
+ }),
165
+ });
166
+
167
+ return stream.toTextStreamResponse();
168
+ }
169
+ ```
170
+
171
+ ```typescript
172
+ import { experimental_useObject as useObject } from '@ai-sdk/react';
173
+
174
+ export default function Page() {
175
+ const { object, submit } = useObject({
176
+ api: '/api/use-object',
177
+ schema: z.object({
178
+ weather: z.string(),
179
+ }),
180
+ });
181
+
182
+ return (
183
+ <div>
184
+ <button onClick={() => submit('example input')}>Generate</button>
185
+ {object?.content && <p>{object.content}</p>}
186
+ </div>
187
+ );
188
+ }
189
+ ```
190
+
191
+ ## Tool Calling
192
+
193
+ ### AI SDK Tool Format
194
+
195
+ Mastra supports tools created using the AI SDK format, so you can use
196
+ them directly with Mastra agents. See our tools doc on [Vercel AI SDK Tool Format
197
+ ](/docs/agents/adding-tools#vercel-ai-sdk-tool-format) for more details.
198
+
199
+ ### Client-side tool calling
200
+
201
+ Mastra leverages AI SDK's tool calling, so what applies in AI SDK applies here still.
202
+ [Agent Tools](/docs/agents/adding-tools) in Mastra are 100% percent compatible with AI SDK tools.
203
+
204
+ Mastra tools also expose an optional `execute` async function. It is optional because you might want to forward tool calls to the client or to a queue instead of executing them in the same process.
205
+
206
+ One way to then leverage client-side tool calling is to use the `@ai-sdk/react` `useChat` hook's `onToolCall` property for
207
+ client-side tool execution
208
+
209
+ ## Custom DataStream
210
+ In certain scenarios you need to write custom data, message annotations to an agent's dataStream.
211
+ This can be useful for:
212
+
213
+ - Streaming additional data to the client
214
+ - Passing progress info back to the client in real time
215
+
216
+ Mastra integrates well with AI SDK to make this possible
217
+
218
+ ### CreateDataStream
219
+ The `createDataStream` function allows you to stream additional data to the client
220
+
221
+ ```typescript copy
222
+ import { createDataStream } from "ai"
223
+ import { Agent } from '@mastra/core/agent';
224
+
225
+ export const weatherAgent = new Agent({
226
+ name: 'Weather Agent',
227
+ instructions: `
228
+ You are a helpful weather assistant that provides accurate weather information.
229
+
230
+ Your primary function is to help users get weather details for specific locations. When responding:
231
+ - Always ask for a location if none is provided
232
+ - If the location name isn’t in English, please translate it
233
+ - If giving a location with multiple parts (e.g. "New York, NY"), use the most relevant part (e.g. "New York")
234
+ - Include relevant details like humidity, wind conditions, and precipitation
235
+ - Keep responses concise but informative
236
+
237
+ Use the weatherTool to fetch current weather data.
238
+ `,
239
+ model: openai('gpt-4o'),
240
+ tools: { weatherTool },
241
+ });
242
+
243
+ const stream = createDataStream({
244
+ async execute(dataStream) {
245
+ // Write data
246
+ dataStream.writeData({ value: 'Hello' });
247
+
248
+ // Write annotation
249
+ dataStream.writeMessageAnnotation({ type: 'status', value: 'processing' });
250
+
251
+ //mastra agent stream
252
+ const agentStream = await weatherAgent.stream('What is the weather')
253
+
254
+ // Merge agent stream
255
+ agentStream.mergeIntoDataStream(dataStream);
256
+ },
257
+ onError: error => `Custom error: ${error.message}`,
258
+ });
259
+
260
+ ```
261
+ ### CreateDataStreamResponse
262
+ The `createDataStreamResponse` function creates a Response object that streams data to the client
263
+
264
+ ```typescript filename="app/api/chat/route.ts" copy
265
+ import { mastra } from "@/src/mastra";
266
+
267
+ export async function POST(req: Request) {
268
+ const { messages } = await req.json();
269
+ const myAgent = mastra.getAgent("weatherAgent");
270
+ //mastra agent stream
271
+ const agentStream = await myAgent.stream(messages);
272
+
273
+ const response = createDataStreamResponse({
274
+ status: 200,
275
+ statusText: 'OK',
276
+ headers: {
277
+ 'Custom-Header': 'value',
278
+ },
279
+ async execute(dataStream) {
280
+ // Write data
281
+ dataStream.writeData({ value: 'Hello' });
282
+
283
+ // Write annotation
284
+ dataStream.writeMessageAnnotation({ type: 'status', value: 'processing' });
285
+
286
+ // Merge agent stream
287
+ agentStream.mergeIntoDataStream(dataStream);
288
+ },
289
+ onError: error => `Custom error: ${error.message}`,
290
+ });
291
+
292
+ return response
293
+ }
294
+ ```
295
+
296
+