@mastra/mcp-docs-server 0.0.1-alpha.1

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 (246) 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%2Fclient-js.md +302 -0
  4. package/.docs/organized/changelogs/%40mastra%2Fcomposio.md +302 -0
  5. package/.docs/organized/changelogs/%40mastra%2Fcore.md +302 -0
  6. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +302 -0
  7. package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +302 -0
  8. package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +302 -0
  9. package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +302 -0
  10. package/.docs/organized/changelogs/%40mastra%2Fevals.md +302 -0
  11. package/.docs/organized/changelogs/%40mastra%2Ffirecrawl.md +302 -0
  12. package/.docs/organized/changelogs/%40mastra%2Fgithub.md +302 -0
  13. package/.docs/organized/changelogs/%40mastra%2Floggers.md +302 -0
  14. package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +11 -0
  15. package/.docs/organized/changelogs/%40mastra%2Fmcp.md +302 -0
  16. package/.docs/organized/changelogs/%40mastra%2Fmemory.md +302 -0
  17. package/.docs/organized/changelogs/%40mastra%2Fpg.md +302 -0
  18. package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +302 -0
  19. package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +302 -0
  20. package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +302 -0
  21. package/.docs/organized/changelogs/%40mastra%2Frag.md +302 -0
  22. package/.docs/organized/changelogs/%40mastra%2Fragie.md +302 -0
  23. package/.docs/organized/changelogs/%40mastra%2Fspeech-azure.md +302 -0
  24. package/.docs/organized/changelogs/%40mastra%2Fspeech-deepgram.md +302 -0
  25. package/.docs/organized/changelogs/%40mastra%2Fspeech-elevenlabs.md +302 -0
  26. package/.docs/organized/changelogs/%40mastra%2Fspeech-google.md +302 -0
  27. package/.docs/organized/changelogs/%40mastra%2Fspeech-ibm.md +302 -0
  28. package/.docs/organized/changelogs/%40mastra%2Fspeech-murf.md +302 -0
  29. package/.docs/organized/changelogs/%40mastra%2Fspeech-openai.md +302 -0
  30. package/.docs/organized/changelogs/%40mastra%2Fspeech-playai.md +302 -0
  31. package/.docs/organized/changelogs/%40mastra%2Fspeech-replicate.md +302 -0
  32. package/.docs/organized/changelogs/%40mastra%2Fspeech-speechify.md +302 -0
  33. package/.docs/organized/changelogs/%40mastra%2Fstabilityai.md +302 -0
  34. package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +59 -0
  35. package/.docs/organized/changelogs/%40mastra%2Fupstash.md +302 -0
  36. package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +302 -0
  37. package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +302 -0
  38. package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +302 -0
  39. package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +302 -0
  40. package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +302 -0
  41. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +24 -0
  42. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +302 -0
  43. package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +302 -0
  44. package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +12 -0
  45. package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +302 -0
  46. package/.docs/organized/changelogs/create-mastra.md +302 -0
  47. package/.docs/organized/changelogs/mastra.md +302 -0
  48. package/.docs/organized/code-examples/agent.md +385 -0
  49. package/.docs/organized/code-examples/ai-sdk-useChat.md +377 -0
  50. package/.docs/organized/code-examples/assistant-ui.md +37 -0
  51. package/.docs/organized/code-examples/bird-checker-with-express.md +235 -0
  52. package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +360 -0
  53. package/.docs/organized/code-examples/bird-checker-with-nextjs.md +250 -0
  54. package/.docs/organized/code-examples/crypto-chatbot.md +96 -0
  55. package/.docs/organized/code-examples/fireworks-r1.md +159 -0
  56. package/.docs/organized/code-examples/integrations.md +184 -0
  57. package/.docs/organized/code-examples/mcp-configuration.md +341 -0
  58. package/.docs/organized/code-examples/memory-todo-agent.md +161 -0
  59. package/.docs/organized/code-examples/memory-with-context.md +167 -0
  60. package/.docs/organized/code-examples/memory-with-libsql.md +204 -0
  61. package/.docs/organized/code-examples/memory-with-pg.md +224 -0
  62. package/.docs/organized/code-examples/memory-with-upstash.md +268 -0
  63. package/.docs/organized/code-examples/quick-start.md +127 -0
  64. package/.docs/organized/code-examples/stock-price-tool.md +124 -0
  65. package/.docs/organized/code-examples/weather-agent.md +352 -0
  66. package/.docs/organized/code-examples/workflow-ai-recruiter.md +159 -0
  67. package/.docs/organized/code-examples/workflow-with-inline-steps.md +111 -0
  68. package/.docs/organized/code-examples/workflow-with-memory.md +393 -0
  69. package/.docs/organized/code-examples/workflow-with-separate-steps.md +131 -0
  70. package/.docs/raw/agents/00-overview.mdx +185 -0
  71. package/.docs/raw/agents/01-agent-memory.mdx +610 -0
  72. package/.docs/raw/agents/02-adding-tools.mdx +224 -0
  73. package/.docs/raw/agents/03-adding-voice.mdx +170 -0
  74. package/.docs/raw/deployment/deployment.mdx +156 -0
  75. package/.docs/raw/deployment/logging-and-tracing.mdx +242 -0
  76. package/.docs/raw/deployment/server.mdx +114 -0
  77. package/.docs/raw/evals/00-overview.mdx +106 -0
  78. package/.docs/raw/evals/01-supported-evals.mdx +31 -0
  79. package/.docs/raw/evals/02-custom-eval.mdx +187 -0
  80. package/.docs/raw/faq/index.mdx +63 -0
  81. package/.docs/raw/frameworks/01-next-js.mdx +238 -0
  82. package/.docs/raw/frameworks/02-ai-sdk.mdx +218 -0
  83. package/.docs/raw/getting-started/installation.mdx +436 -0
  84. package/.docs/raw/getting-started/project-structure.mdx +80 -0
  85. package/.docs/raw/guides/01-chef-michel.mdx +242 -0
  86. package/.docs/raw/guides/02-stock-agent.mdx +182 -0
  87. package/.docs/raw/guides/03-recruiter.mdx +187 -0
  88. package/.docs/raw/index.mdx +22 -0
  89. package/.docs/raw/local-dev/creating-projects.mdx +74 -0
  90. package/.docs/raw/local-dev/integrations.mdx +127 -0
  91. package/.docs/raw/local-dev/mastra-dev.mdx +65 -0
  92. package/.docs/raw/rag/chunking-and-embedding.mdx +128 -0
  93. package/.docs/raw/rag/overview.mdx +85 -0
  94. package/.docs/raw/rag/retrieval.mdx +362 -0
  95. package/.docs/raw/rag/vector-databases.mdx +271 -0
  96. package/.docs/raw/reference/agents/createTool.mdx +190 -0
  97. package/.docs/raw/reference/agents/generate.mdx +327 -0
  98. package/.docs/raw/reference/agents/getAgent.mdx +54 -0
  99. package/.docs/raw/reference/agents/stream.mdx +361 -0
  100. package/.docs/raw/reference/cli/build.mdx +48 -0
  101. package/.docs/raw/reference/cli/deploy.mdx +22 -0
  102. package/.docs/raw/reference/cli/dev.mdx +97 -0
  103. package/.docs/raw/reference/cli/init.mdx +43 -0
  104. package/.docs/raw/reference/client-js/agents.mdx +90 -0
  105. package/.docs/raw/reference/client-js/error-handling.mdx +38 -0
  106. package/.docs/raw/reference/client-js/index.mdx +127 -0
  107. package/.docs/raw/reference/client-js/logs.mdx +24 -0
  108. package/.docs/raw/reference/client-js/memory.mdx +94 -0
  109. package/.docs/raw/reference/client-js/telemetry.mdx +20 -0
  110. package/.docs/raw/reference/client-js/tools.mdx +44 -0
  111. package/.docs/raw/reference/client-js/vectors.mdx +79 -0
  112. package/.docs/raw/reference/client-js/workflows.mdx +137 -0
  113. package/.docs/raw/reference/core/mastra-class.mdx +232 -0
  114. package/.docs/raw/reference/deployer/cloudflare.mdx +176 -0
  115. package/.docs/raw/reference/deployer/deployer.mdx +159 -0
  116. package/.docs/raw/reference/deployer/netlify.mdx +88 -0
  117. package/.docs/raw/reference/deployer/vercel.mdx +97 -0
  118. package/.docs/raw/reference/evals/answer-relevancy.mdx +186 -0
  119. package/.docs/raw/reference/evals/bias.mdx +186 -0
  120. package/.docs/raw/reference/evals/completeness.mdx +174 -0
  121. package/.docs/raw/reference/evals/content-similarity.mdx +183 -0
  122. package/.docs/raw/reference/evals/context-position.mdx +190 -0
  123. package/.docs/raw/reference/evals/context-precision.mdx +189 -0
  124. package/.docs/raw/reference/evals/context-relevancy.mdx +188 -0
  125. package/.docs/raw/reference/evals/contextual-recall.mdx +191 -0
  126. package/.docs/raw/reference/evals/faithfulness.mdx +193 -0
  127. package/.docs/raw/reference/evals/hallucination.mdx +219 -0
  128. package/.docs/raw/reference/evals/keyword-coverage.mdx +176 -0
  129. package/.docs/raw/reference/evals/prompt-alignment.mdx +238 -0
  130. package/.docs/raw/reference/evals/summarization.mdx +205 -0
  131. package/.docs/raw/reference/evals/textual-difference.mdx +161 -0
  132. package/.docs/raw/reference/evals/tone-consistency.mdx +181 -0
  133. package/.docs/raw/reference/evals/toxicity.mdx +165 -0
  134. package/.docs/raw/reference/index.mdx +8 -0
  135. package/.docs/raw/reference/memory/Memory.mdx +186 -0
  136. package/.docs/raw/reference/memory/createThread.mdx +93 -0
  137. package/.docs/raw/reference/memory/getThreadById.mdx +43 -0
  138. package/.docs/raw/reference/memory/getThreadsByResourceId.mdx +45 -0
  139. package/.docs/raw/reference/memory/query.mdx +164 -0
  140. package/.docs/raw/reference/observability/create-logger.mdx +106 -0
  141. package/.docs/raw/reference/observability/logger.mdx +55 -0
  142. package/.docs/raw/reference/observability/otel-config.mdx +120 -0
  143. package/.docs/raw/reference/observability/providers/braintrust.mdx +40 -0
  144. package/.docs/raw/reference/observability/providers/index.mdx +15 -0
  145. package/.docs/raw/reference/observability/providers/laminar.mdx +41 -0
  146. package/.docs/raw/reference/observability/providers/langfuse.mdx +51 -0
  147. package/.docs/raw/reference/observability/providers/langsmith.mdx +46 -0
  148. package/.docs/raw/reference/observability/providers/langwatch.mdx +45 -0
  149. package/.docs/raw/reference/observability/providers/new-relic.mdx +40 -0
  150. package/.docs/raw/reference/observability/providers/signoz.mdx +40 -0
  151. package/.docs/raw/reference/observability/providers/traceloop.mdx +40 -0
  152. package/.docs/raw/reference/rag/astra.mdx +258 -0
  153. package/.docs/raw/reference/rag/chroma.mdx +281 -0
  154. package/.docs/raw/reference/rag/chunk.mdx +237 -0
  155. package/.docs/raw/reference/rag/document.mdx +129 -0
  156. package/.docs/raw/reference/rag/embeddings.mdx +160 -0
  157. package/.docs/raw/reference/rag/extract-params.mdx +72 -0
  158. package/.docs/raw/reference/rag/graph-rag.mdx +182 -0
  159. package/.docs/raw/reference/rag/libsql.mdx +357 -0
  160. package/.docs/raw/reference/rag/metadata-filters.mdx +298 -0
  161. package/.docs/raw/reference/rag/pg.mdx +477 -0
  162. package/.docs/raw/reference/rag/pinecone.mdx +249 -0
  163. package/.docs/raw/reference/rag/qdrant.mdx +236 -0
  164. package/.docs/raw/reference/rag/rerank.mdx +212 -0
  165. package/.docs/raw/reference/rag/turbopuffer.mdx +249 -0
  166. package/.docs/raw/reference/rag/upstash.mdx +198 -0
  167. package/.docs/raw/reference/rag/vectorize.mdx +253 -0
  168. package/.docs/raw/reference/storage/libsql.mdx +74 -0
  169. package/.docs/raw/reference/storage/postgresql.mdx +48 -0
  170. package/.docs/raw/reference/storage/upstash.mdx +86 -0
  171. package/.docs/raw/reference/tools/client.mdx +180 -0
  172. package/.docs/raw/reference/tools/document-chunker-tool.mdx +141 -0
  173. package/.docs/raw/reference/tools/graph-rag-tool.mdx +154 -0
  174. package/.docs/raw/reference/tools/mcp-configuration.mdx +206 -0
  175. package/.docs/raw/reference/tools/vector-query-tool.mdx +212 -0
  176. package/.docs/raw/reference/voice/composite-voice.mdx +140 -0
  177. package/.docs/raw/reference/voice/deepgram.mdx +164 -0
  178. package/.docs/raw/reference/voice/elevenlabs.mdx +216 -0
  179. package/.docs/raw/reference/voice/google.mdx +198 -0
  180. package/.docs/raw/reference/voice/mastra-voice.mdx +394 -0
  181. package/.docs/raw/reference/voice/murf.mdx +251 -0
  182. package/.docs/raw/reference/voice/openai-realtime.mdx +431 -0
  183. package/.docs/raw/reference/voice/openai.mdx +168 -0
  184. package/.docs/raw/reference/voice/playai.mdx +159 -0
  185. package/.docs/raw/reference/voice/speechify.mdx +145 -0
  186. package/.docs/raw/reference/workflows/after.mdx +88 -0
  187. package/.docs/raw/reference/workflows/commit.mdx +37 -0
  188. package/.docs/raw/reference/workflows/createRun.mdx +77 -0
  189. package/.docs/raw/reference/workflows/else.mdx +72 -0
  190. package/.docs/raw/reference/workflows/execute.mdx +110 -0
  191. package/.docs/raw/reference/workflows/if.mdx +107 -0
  192. package/.docs/raw/reference/workflows/resume.mdx +155 -0
  193. package/.docs/raw/reference/workflows/start.mdx +84 -0
  194. package/.docs/raw/reference/workflows/step-class.mdx +100 -0
  195. package/.docs/raw/reference/workflows/step-condition.mdx +134 -0
  196. package/.docs/raw/reference/workflows/step-function.mdx +92 -0
  197. package/.docs/raw/reference/workflows/step-options.mdx +69 -0
  198. package/.docs/raw/reference/workflows/suspend.mdx +80 -0
  199. package/.docs/raw/reference/workflows/then.mdx +74 -0
  200. package/.docs/raw/reference/workflows/until.mdx +165 -0
  201. package/.docs/raw/reference/workflows/watch.mdx +118 -0
  202. package/.docs/raw/reference/workflows/while.mdx +168 -0
  203. package/.docs/raw/reference/workflows/workflow.mdx +233 -0
  204. package/.docs/raw/workflows/00-overview.mdx +168 -0
  205. package/.docs/raw/workflows/control-flow.mdx +712 -0
  206. package/.docs/raw/workflows/dynamic-workflows.mdx +232 -0
  207. package/.docs/raw/workflows/steps.mdx +98 -0
  208. package/.docs/raw/workflows/suspend-and-resume.mdx +196 -0
  209. package/.docs/raw/workflows/variables.mdx +248 -0
  210. package/LICENSE +44 -0
  211. package/README.md +129 -0
  212. package/dist/index.d.ts +3 -0
  213. package/dist/index.js +19 -0
  214. package/dist/prepare-docs/code-examples.d.ts +4 -0
  215. package/dist/prepare-docs/code-examples.js +91 -0
  216. package/dist/prepare-docs/copy-raw.d.ts +1 -0
  217. package/dist/prepare-docs/copy-raw.js +41 -0
  218. package/dist/prepare-docs/index.d.ts +1 -0
  219. package/dist/prepare-docs/index.js +8 -0
  220. package/dist/prepare-docs/package-changes.d.ts +4 -0
  221. package/dist/prepare-docs/package-changes.js +92 -0
  222. package/dist/prepare-docs/prepare.d.ts +1 -0
  223. package/dist/prepare-docs/prepare.js +13 -0
  224. package/dist/sse.d.ts +1 -0
  225. package/dist/sse.js +9 -0
  226. package/dist/stdio.d.ts +1 -0
  227. package/dist/stdio.js +8 -0
  228. package/dist/tools/__tests__/blog.test.d.ts +1 -0
  229. package/dist/tools/__tests__/blog.test.js +48 -0
  230. package/dist/tools/__tests__/changes.test.d.ts +1 -0
  231. package/dist/tools/__tests__/changes.test.js +36 -0
  232. package/dist/tools/__tests__/docs.test.d.ts +1 -0
  233. package/dist/tools/__tests__/docs.test.js +46 -0
  234. package/dist/tools/__tests__/examples.test.d.ts +1 -0
  235. package/dist/tools/__tests__/examples.test.js +52 -0
  236. package/dist/tools/blog.d.ts +15 -0
  237. package/dist/tools/blog.js +73 -0
  238. package/dist/tools/changes.d.ts +11 -0
  239. package/dist/tools/changes.js +69 -0
  240. package/dist/tools/docs.d.ts +11 -0
  241. package/dist/tools/docs.js +176 -0
  242. package/dist/tools/examples.d.ts +11 -0
  243. package/dist/tools/examples.js +61 -0
  244. package/dist/utils.d.ts +6 -0
  245. package/dist/utils.js +9 -0
  246. package/package.json +66 -0
@@ -0,0 +1,361 @@
1
+ ---
2
+ title: "Reference: Agent.stream() | Streaming | Agents | Mastra Docs"
3
+ description: Documentation for the `.stream()` method in Mastra agents, which enables real-time streaming of responses.
4
+ ---
5
+
6
+ # `stream()`
7
+
8
+ The `stream()` method enables real-time streaming of responses from an agent. This method accepts `messages` and an optional `options` object as parameters, similar to `generate()`.
9
+
10
+ ## Parameters
11
+
12
+ ### `messages`
13
+
14
+ The `messages` parameter can be:
15
+
16
+ - A single string
17
+ - An array of strings
18
+ - An array of message objects with `role` and `content` properties
19
+
20
+ The message object structure:
21
+
22
+ ```typescript
23
+ interface Message {
24
+ role: 'system' | 'user' | 'assistant';
25
+ content: string;
26
+ }
27
+ ```
28
+
29
+ ### `options` (Optional)
30
+
31
+ An optional object that can include configuration for output structure, memory management, tool usage, telemetry, and more.
32
+
33
+ <PropertiesTable
34
+ content={[
35
+ {
36
+ name: "abortSignal",
37
+ type: "AbortSignal",
38
+ isOptional: true,
39
+ description: "Signal object that allows you to abort the agent's execution. When the signal is aborted, all ongoing operations will be terminated.",
40
+ },
41
+ {
42
+ name: "context",
43
+ type: "CoreMessage[]",
44
+ isOptional: true,
45
+ description: "Additional context messages to provide to the agent.",
46
+ },
47
+ {
48
+ name: "experimental_output",
49
+ type: "Zod schema | JsonSchema7",
50
+ isOptional: true,
51
+ description: "Enables structured output generation alongside text generation and tool calls. The model will generate responses that conform to the provided schema.",
52
+ },
53
+ {
54
+ name: "instructions",
55
+ type: "string",
56
+ isOptional: true,
57
+ description: "Custom instructions that override the agent's default instructions for this specific generation. Useful for dynamically modifying agent behavior without creating a new agent instance.",
58
+ },
59
+ {
60
+ name: "maxSteps",
61
+ type: "number",
62
+ isOptional: true,
63
+ defaultValue: "5",
64
+ description: "Maximum number of steps allowed during streaming.",
65
+ },
66
+ {
67
+ name: "memoryOptions",
68
+ type: "MemoryConfig",
69
+ isOptional: true,
70
+ description: "Configuration options for memory management. See MemoryConfig section below for details.",
71
+ },
72
+ {
73
+ name: "onFinish",
74
+ type: "(result: string) => Promise<void> | void",
75
+ isOptional: true,
76
+ description: "Callback function called when streaming is complete.",
77
+ },
78
+ {
79
+ name: "onStepFinish",
80
+ type: "(step: string) => void",
81
+ isOptional: true,
82
+ description: "Callback function called after each step during streaming.",
83
+ },
84
+ {
85
+ name: "output",
86
+ type: "Zod schema | JsonSchema7",
87
+ isOptional: true,
88
+ description: "Defines the expected structure of the output. Can be a JSON Schema object or a Zod schema.",
89
+ },
90
+ {
91
+ name: "resourceId",
92
+ type: "string",
93
+ isOptional: true,
94
+ description: "Identifier for the user or resource interacting with the agent. Must be provided if threadId is provided.",
95
+ },
96
+ {
97
+ name: "telemetry",
98
+ type: "TelemetrySettings",
99
+ isOptional: true,
100
+ description: "Settings for telemetry collection during streaming. See TelemetrySettings section below for details.",
101
+ },
102
+ {
103
+ name: "temperature",
104
+ type: "number",
105
+ isOptional: true,
106
+ description: "Controls randomness in the model's output. Higher values (e.g., 0.8) make the output more random, lower values (e.g., 0.2) make it more focused and deterministic.",
107
+ },
108
+ {
109
+ name: "threadId",
110
+ type: "string",
111
+ isOptional: true,
112
+ description: "Identifier for the conversation thread. Allows for maintaining context across multiple interactions. Must be provided if resourceId is provided.",
113
+ },
114
+ {
115
+ name: "toolChoice",
116
+ type: "'auto' | 'none' | 'required' | { type: 'tool'; toolName: string }",
117
+ isOptional: true,
118
+ defaultValue: "'auto'",
119
+ description: "Controls how the agent uses tools during streaming.",
120
+ },
121
+ {
122
+ name: "toolsets",
123
+ type: "ToolsetsInput",
124
+ isOptional: true,
125
+ description: "Additional toolsets to make available to the agent during this stream.",
126
+ }
127
+ ]}
128
+ />
129
+
130
+ #### MemoryConfig
131
+
132
+ Configuration options for memory management:
133
+
134
+ <PropertiesTable
135
+ content={[
136
+ {
137
+ name: "lastMessages",
138
+ type: "number | false",
139
+ isOptional: true,
140
+ description: "Number of most recent messages to include in context. Set to false to disable.",
141
+ },
142
+ {
143
+ name: "semanticRecall",
144
+ type: "boolean | object",
145
+ isOptional: true,
146
+ description: "Configuration for semantic memory recall. Can be boolean or detailed config.",
147
+ properties: [
148
+ {
149
+ type: "number",
150
+ parameters: [
151
+ {
152
+ name: "topK",
153
+ type: "number",
154
+ isOptional: true,
155
+ description: "Number of most semantically similar messages to retrieve.",
156
+ }
157
+ ]
158
+ },
159
+ {
160
+ type: "number | object",
161
+ parameters: [
162
+ {
163
+ name: "messageRange",
164
+ type: "number | { before: number; after: number }",
165
+ isOptional: true,
166
+ description: "Range of messages to consider for semantic search. Can be a single number or before/after configuration.",
167
+ }
168
+ ]
169
+ }
170
+ ]
171
+ },
172
+ {
173
+ name: "workingMemory",
174
+ type: "object",
175
+ isOptional: true,
176
+ description: "Configuration for working memory.",
177
+ properties: [
178
+ {
179
+ type: "boolean",
180
+ parameters: [
181
+ {
182
+ name: "enabled",
183
+ type: "boolean",
184
+ isOptional: true,
185
+ description: "Whether to enable working memory."
186
+ }
187
+ ]
188
+ },
189
+ {
190
+ type: "string",
191
+ parameters: [
192
+ {
193
+ name: "template",
194
+ type: "string",
195
+ isOptional: true,
196
+ description: "Template to use for working memory.",
197
+ }
198
+ ]
199
+ },
200
+ {
201
+ type: "'text-stream' | 'tool-call'",
202
+ parameters: [
203
+ {
204
+ name: "type",
205
+ type: "'text-stream' | 'tool-call'",
206
+ isOptional: true,
207
+ description: "Type of content to use for working memory.",
208
+ }
209
+ ]
210
+ }
211
+ ]
212
+ },
213
+ {
214
+ name: "threads",
215
+ type: "object",
216
+ isOptional: true,
217
+ description: "Thread-specific memory configuration.",
218
+ properties: [
219
+ {
220
+ type: "boolean",
221
+ parameters: [
222
+ {
223
+ name: "generateTitle",
224
+ type: "boolean",
225
+ isOptional: true,
226
+ description: "Whether to automatically generate titles for new threads.",
227
+ }
228
+ ]
229
+ }
230
+ ]
231
+ }
232
+ ]}
233
+ />
234
+
235
+ #### TelemetrySettings
236
+
237
+ Settings for telemetry collection during streaming:
238
+
239
+ <PropertiesTable
240
+ content={[
241
+ {
242
+ name: "functionId",
243
+ type: "string",
244
+ isOptional: true,
245
+ description: "Identifier for this function. Used to group telemetry data by function.",
246
+ },
247
+ {
248
+ name: "isEnabled",
249
+ type: "boolean",
250
+ isOptional: true,
251
+ defaultValue: "false",
252
+ description: "Enable or disable telemetry. Disabled by default while experimental.",
253
+ },
254
+ {
255
+ name: "metadata",
256
+ type: "Record<string, AttributeValue>",
257
+ isOptional: true,
258
+ description: "Additional information to include in the telemetry data. AttributeValue can be string, number, boolean, array of these types, or null.",
259
+ },
260
+ {
261
+ name: "recordInputs",
262
+ type: "boolean",
263
+ isOptional: true,
264
+ defaultValue: "true",
265
+ description: "Enable or disable input recording. You might want to disable this to avoid recording sensitive information, reduce data transfers, or increase performance.",
266
+ },
267
+ {
268
+ name: "recordOutputs",
269
+ type: "boolean",
270
+ isOptional: true,
271
+ defaultValue: "true",
272
+ description: "Enable or disable output recording. You might want to disable this to avoid recording sensitive information, reduce data transfers, or increase performance.",
273
+ },
274
+ {
275
+ name: "tracer",
276
+ type: "Tracer",
277
+ isOptional: true,
278
+ description: "A custom OpenTelemetry tracer instance to use for the telemetry data. See OpenTelemetry documentation for details.",
279
+ }
280
+ ]}
281
+ />
282
+
283
+ ## Returns
284
+
285
+ The return value of the `stream()` method depends on the options provided, specifically the `output` option.
286
+
287
+ ### PropertiesTable for Return Values
288
+
289
+ <PropertiesTable
290
+ content={[
291
+ {
292
+ name: "object",
293
+ type: "Promise<object>",
294
+ isOptional: true,
295
+ description: "Promise that resolves to the final structured output. Present when using either `output` or `experimental_output` options.",
296
+ },
297
+ {
298
+ name: "objectStream",
299
+ type: "AsyncIterable<object>",
300
+ isOptional: true,
301
+ description: "Stream of structured data. Present only when using `output` option with a schema.",
302
+ },
303
+ {
304
+ name: "partialObjectStream",
305
+ type: "AsyncIterable<object>",
306
+ isOptional: true,
307
+ description: "Stream of structured data. Present only when using `experimental_output` option.",
308
+ },
309
+ {
310
+ name: "textStream",
311
+ type: "AsyncIterable<string>",
312
+ isOptional: true,
313
+ description: "Stream of text chunks. Present when output is 'text' (no schema provided) or when using `experimental_output`.",
314
+ }
315
+ ]}
316
+ />
317
+
318
+ ## Examples
319
+
320
+ ### Basic Text Streaming
321
+
322
+ ```typescript
323
+ const stream = await myAgent.stream([
324
+ { role: "user", content: "Tell me a story." }
325
+ ]);
326
+
327
+ for await (const chunk of stream.textStream) {
328
+ process.stdout.write(chunk);
329
+ }
330
+ ```
331
+
332
+ ### Structured Output Streaming with Thread Context
333
+
334
+ ```typescript
335
+ const schema = {
336
+ type: 'object',
337
+ properties: {
338
+ summary: { type: 'string' },
339
+ nextSteps: { type: 'array', items: { type: 'string' } }
340
+ },
341
+ required: ['summary', 'nextSteps']
342
+ };
343
+
344
+ const response = await myAgent.stream(
345
+ "What should we do next?",
346
+ {
347
+ output: schema,
348
+ threadId: "project-123",
349
+ onFinish: text => console.log("Finished:", text)
350
+ }
351
+ );
352
+
353
+ for await (const chunk of response.textStream) {
354
+ console.log(chunk);
355
+ }
356
+
357
+ const result = await response.object;
358
+ console.log("Final structured result:", result);
359
+ ```
360
+
361
+ The key difference between Agent's `stream()` and LLM's `stream()` is that Agents maintain conversation context through `threadId`, can access tools, and integrate with the agent's memory system.
@@ -0,0 +1,48 @@
1
+ ---
2
+ title: "mastra build"
3
+ description: "Build your Mastra project for production deployment"
4
+ ---
5
+
6
+ The `mastra build` command bundles your Mastra project into a production-ready Hono server. Hono is a lightweight web framework that provides type-safe routing and middleware support, making it ideal for deploying Mastra agents as HTTP endpoints.
7
+
8
+ ## Usage
9
+
10
+ ```bash
11
+ mastra build [options]
12
+ ```
13
+
14
+ ## Options
15
+
16
+ - `--dir <path>`: Directory containing your Mastra project (default: current directory)
17
+
18
+ ## What It Does
19
+
20
+ 1. Locates your Mastra entry file (either `src/mastra/index.ts` or `src/mastra/index.js`)
21
+ 2. Creates a `.mastra` output directory
22
+ 3. Bundles your code using Rollup with:
23
+ - Tree shaking for optimal bundle size
24
+ - Node.js environment targeting
25
+ - Source map generation for debugging
26
+
27
+ ## Example
28
+
29
+ ```bash
30
+ # Build from current directory
31
+ mastra build
32
+
33
+ # Build from specific directory
34
+ mastra build --dir ./my-mastra-project
35
+ ```
36
+
37
+ ## Output
38
+
39
+ The command generates a production bundle in the `.mastra` directory, which includes:
40
+ - A Hono-based HTTP server with your Mastra agents exposed as endpoints
41
+ - Bundled JavaScript files optimized for production
42
+ - Source maps for debugging
43
+ - Required dependencies
44
+
45
+ This output is suitable for:
46
+ - Deploying to cloud servers (EC2, Digital Ocean)
47
+ - Running in containerized environments
48
+ - Using with container orchestration systems
@@ -0,0 +1,22 @@
1
+ ---
2
+ title: "`mastra deploy` Reference | Deployment | Mastra CLI"
3
+ description: Documentation for the mastra deploy command, which deploys Mastra projects to platforms like Vercel and Cloudflare.
4
+ ---
5
+
6
+ # `mastra deploy` Reference
7
+
8
+ ## `mastra deploy vercel`
9
+
10
+ Deploy your Mastra project to Vercel.
11
+
12
+ ## `mastra deploy cloudflare`
13
+
14
+ Deploy your Mastra project to Cloudflare.
15
+
16
+ ## `mastra deploy netlify`
17
+
18
+ Deploy your Mastra project to Netlify.
19
+
20
+ ### Flags
21
+
22
+ - `-d, --dir <dir>`: Path to your mastra folder
@@ -0,0 +1,97 @@
1
+ ---
2
+ title: "`mastra dev` Reference | Local Development | Mastra CLI"
3
+ description: Documentation for the mastra dev command, which starts a development server for agents, tools, and workflows.
4
+ ---
5
+
6
+ # `mastra dev` Reference
7
+
8
+ The `mastra dev` command starts a development server that exposes REST endpoints for your agents, tools, and workflows,
9
+
10
+ ## Parameters
11
+
12
+ <PropertiesTable
13
+ content={[
14
+ {
15
+ name: "--dir",
16
+ type: "string",
17
+ description:
18
+ "Specifies the path to your Mastra folder (containing agents, tools, and workflows). Defaults to the current working directory.",
19
+ isOptional: true,
20
+ },
21
+ {
22
+ name: "--tools",
23
+ type: "string",
24
+ description:
25
+ "Comma-separated paths to additional tool directories that should be registered. For example: 'src/tools/dbTools,src/tools/scraperTools'.",
26
+ isOptional: true,
27
+ },
28
+ {
29
+ name: "--port",
30
+ type: "number",
31
+ description:
32
+ "Specifies the port number for the development server. Defaults to 4111.",
33
+ isOptional: true,
34
+ },
35
+ ]}
36
+ />
37
+
38
+ ## Routes
39
+
40
+ Starting the server with `mastra dev` exposes a set of REST endpoints by default:
41
+
42
+ ### Agent Routes
43
+
44
+ Agents are expected to be exported from `src/mastra/agents`.
45
+
46
+ • `GET /api/agents`
47
+ - Lists the registered agents found in your Mastra folder.
48
+ • `POST /api/agents/:agentId/generate`
49
+ - Sends a text-based prompt to the specified agent, returning the agent's response.
50
+
51
+ ### Tool Routes
52
+
53
+ Tools are expected to be exported from `src/mastra/tools` (or the configured tools directory).
54
+
55
+ • `POST /api/tools/:toolName`
56
+ - Invokes a specific tool by name, passing input data in the request body.
57
+
58
+ ### Workflow Routes
59
+
60
+ Workflows are expected to be exported from `src/mastra/workflows` (or the configured workflows directory).
61
+
62
+ • `POST /api/workflows/:workflowName/start`
63
+ - Starts the specified workflow.
64
+ • `POST /api/workflows/:workflowName/:instanceId/event`
65
+ - Sends an event or trigger signal to an existing workflow instance.
66
+ • `GET /api/workflows/:workflowName/:instanceId/status`
67
+ - Returns status info for a running workflow instance.
68
+
69
+ ### OpenAPI Specification
70
+
71
+ • `GET /openapi.json`
72
+ - Returns an auto-generated OpenAPI specification for your project's endpoints.
73
+
74
+ ## Additional Notes
75
+
76
+ The port defaults to 4111.
77
+
78
+ Make sure you have your environment variables set up in your `.env.development` or `.env` file for any providers you use (e.g., `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, etc.).
79
+
80
+ ### Example request
81
+
82
+ To test an agent after running `mastra dev`:
83
+
84
+ ```bash
85
+ curl -X POST http://localhost:4111/api/agents/myAgent/generate \
86
+ -H "Content-Type: application/json" \
87
+ -d '{
88
+ "messages": [
89
+ { "role": "user", "content": "Hello, how can you assist me today?" }
90
+ ]
91
+ }'
92
+ ```
93
+
94
+ ## Related Docs
95
+
96
+ - [REST Endpoints Overview](../../local-dev/mastra-dev.mdx) – More detailed usage of the dev server and agent endpoints.
97
+ - [mastra deploy](../../deployment/deployment.mdx) – Deploy your project to Vercel or Cloudflare.
@@ -0,0 +1,43 @@
1
+ ---
2
+ title: "`mastra init` reference | Project Creation | Mastra CLI"
3
+ description: Documentation for the mastra init command, which creates a new Mastra project with interactive setup options.
4
+ ---
5
+
6
+ # `mastra init` Reference
7
+
8
+ ## `mastra init`
9
+
10
+ This creates a new Mastra project. You can run it in three different ways:
11
+
12
+ 1. **Interactive Mode (Recommended)**
13
+ Run without flags to use the interactive prompt, which will guide you through:
14
+
15
+ - Choosing a directory for Mastra files
16
+ - Selecting components to install (Agents, Tools, Workflows)
17
+ - Choosing a default LLM provider (OpenAI, Anthropic, or Groq)
18
+ - Deciding whether to include example code
19
+
20
+ 2. **Quick Start with Defaults**
21
+
22
+ ```bash
23
+ mastra init --default
24
+ ```
25
+
26
+ This sets up a project with:
27
+
28
+ - Source directory: `src/`
29
+ - All components: agents, tools, workflows
30
+ - OpenAI as the default provider
31
+ - No example code
32
+
33
+ 3. **Custom Setup**
34
+ ```bash
35
+ mastra init --dir src/mastra --components agents,tools --llm openai --example
36
+ ```
37
+ Options:
38
+ - `-d, --dir`: Directory for Mastra files (defaults to src/mastra)
39
+ - `-c, --components`: Comma-separated list of components (agents, tools, workflows)
40
+ - `-l, --llm`: Default model provider (openai, anthropic, or groq)
41
+ - `-k, --llm-api-key`: API key for the selected LLM provider (will be added to .env file)
42
+ - `-e, --example`: Include example code
43
+ - `-ne, --no-example`: Skip example code
@@ -0,0 +1,90 @@
1
+ # Agents API
2
+
3
+ The Agents API provides methods to interact with Mastra AI agents, including generating responses, streaming interactions, and managing agent tools.
4
+
5
+ ## Getting All Agents
6
+
7
+ Retrieve a list of all available agents:
8
+
9
+ ```typescript
10
+ const agents = await client.getAgents();
11
+ ```
12
+
13
+ ## Working with a Specific Agent
14
+
15
+ Get an instance of a specific agent:
16
+
17
+ ```typescript
18
+ const agent = client.getAgent("agent-id");
19
+ ```
20
+
21
+ ## Agent Methods
22
+
23
+ ### Get Agent Details
24
+
25
+ Retrieve detailed information about an agent:
26
+
27
+ ```typescript
28
+ const details = await agent.details();
29
+ ```
30
+
31
+ ### Generate Response
32
+
33
+ Generate a response from the agent:
34
+
35
+ ```typescript
36
+ const response = await agent.generate({
37
+ messages: [
38
+ {
39
+ role: "user",
40
+ content: "Hello, how are you?",
41
+ },
42
+ ],
43
+ threadId: "thread-1", // Optional: Thread ID for conversation context
44
+ resourceid: "resource-1", // Optional: Resource ID
45
+ output: {}, // Optional: Output configuration
46
+ });
47
+ ```
48
+
49
+ ### Stream Response
50
+
51
+ Stream a response from the agent for real-time interactions:
52
+
53
+ ```typescript
54
+ const response = await agent.stream({
55
+ messages: [
56
+ {
57
+ role: "user",
58
+ content: "Tell me a story",
59
+ },
60
+ ],
61
+ });
62
+
63
+ // Read from response body
64
+ const reader = response.body.getReader();
65
+ while (true) {
66
+ const { done, value } = await reader.read();
67
+ if (done) break;
68
+ console.log(new TextDecoder().decode(value));
69
+ }
70
+ ```
71
+
72
+ ### Get Agent Tool
73
+
74
+ Retrieve information about a specific tool available to the agent:
75
+
76
+ ```typescript
77
+ const tool = await agent.getTool("tool-id");
78
+ ```
79
+
80
+ ### Get Agent Evaluations
81
+
82
+ Get evaluation results for the agent:
83
+
84
+ ```typescript
85
+ // Get CI evaluations
86
+ const evals = await agent.evals();
87
+
88
+ // Get live evaluations
89
+ const liveEvals = await agent.liveEvals();
90
+ ```
@@ -0,0 +1,38 @@
1
+ # Error Handling
2
+
3
+ The Mastra Client SDK includes built-in retry mechanism and error handling capabilities.
4
+
5
+ ## Error Handling
6
+
7
+ All API methods can throw errors that you can catch and handle:
8
+
9
+ ```typescript
10
+ try {
11
+ const agent = client.getAgent("agent-id");
12
+ const response = await agent.generate({
13
+ messages: [{ role: "user", content: "Hello" }],
14
+ });
15
+ } catch (error) {
16
+ console.error("An error occurred:", error.message);
17
+ }
18
+ ```
19
+
20
+ ## Retry Mechanism
21
+
22
+ The client automatically retries failed requests with exponential backoff:
23
+
24
+ ```typescript
25
+ const client = new MastraClient({
26
+ baseUrl: "http://localhost:4111",
27
+ retries: 3, // Number of retry attempts
28
+ backoffMs: 300, // Initial backoff time
29
+ maxBackoffMs: 5000, // Maximum backoff time
30
+ });
31
+ ```
32
+
33
+ ### How Retries Work
34
+
35
+ 1. First attempt fails → Wait 300ms
36
+ 2. Second attempt fails → Wait 600ms
37
+ 3. Third attempt fails → Wait 1200ms
38
+ 4. Final attempt fails → Throw error