@mastra/mcp-docs-server 0.0.0-studio-deploy-20260404182525 → 0.0.0-studio-cli-20260504022012

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 (285) hide show
  1. package/.docs/docs/agents/adding-voice.md +18 -17
  2. package/.docs/docs/agents/background-tasks.md +242 -0
  3. package/.docs/docs/agents/channels.md +2 -1
  4. package/.docs/docs/agents/overview.md +4 -0
  5. package/.docs/docs/agents/processors.md +177 -5
  6. package/.docs/docs/agents/structured-output.md +66 -1
  7. package/.docs/docs/agents/supervisor-agents.md +65 -0
  8. package/.docs/docs/agents/using-tools.md +73 -0
  9. package/.docs/docs/browser/agent-browser.md +78 -0
  10. package/.docs/docs/browser/browser-viewer.md +144 -0
  11. package/.docs/docs/browser/overview.md +168 -0
  12. package/.docs/docs/browser/stagehand.md +129 -0
  13. package/.docs/docs/deployment/cloud-providers.md +5 -1
  14. package/.docs/docs/deployment/mastra-server.md +4 -4
  15. package/.docs/docs/deployment/monorepo.md +3 -3
  16. package/.docs/docs/deployment/overview.md +11 -8
  17. package/.docs/docs/editor/overview.md +290 -0
  18. package/.docs/docs/editor/prompts.md +134 -0
  19. package/.docs/docs/editor/tools.md +152 -0
  20. package/.docs/docs/evals/custom-scorers.md +63 -3
  21. package/.docs/docs/evals/datasets/overview.md +1 -1
  22. package/.docs/docs/index.md +2 -2
  23. package/.docs/docs/mastra-platform/configuration.md +36 -0
  24. package/.docs/docs/mastra-platform/overview.md +78 -0
  25. package/.docs/docs/mcp/overview.md +17 -0
  26. package/.docs/docs/memory/memory-processors.md +3 -3
  27. package/.docs/docs/memory/message-history.md +8 -2
  28. package/.docs/docs/memory/observational-memory.md +65 -8
  29. package/.docs/docs/memory/storage.md +1 -2
  30. package/.docs/docs/memory/working-memory.md +2 -2
  31. package/.docs/docs/observability/logging.md +1 -1
  32. package/.docs/docs/observability/metrics/overview.md +2 -2
  33. package/.docs/docs/observability/overview.md +1 -1
  34. package/.docs/docs/observability/tracing/bridges/datadog.md +217 -0
  35. package/.docs/docs/observability/tracing/bridges/otel.md +2 -2
  36. package/.docs/docs/observability/tracing/exporters/arthur.md +163 -0
  37. package/.docs/docs/observability/tracing/exporters/cloud.md +135 -63
  38. package/.docs/docs/observability/tracing/exporters/datadog.md +3 -1
  39. package/.docs/docs/observability/tracing/exporters/default.md +5 -5
  40. package/.docs/docs/observability/tracing/exporters/laminar.md +22 -14
  41. package/.docs/docs/observability/tracing/exporters/langfuse.md +50 -33
  42. package/.docs/docs/observability/tracing/overview.md +87 -20
  43. package/.docs/docs/server/custom-adapters.md +5 -5
  44. package/.docs/docs/server/custom-api-routes.md +3 -3
  45. package/.docs/docs/server/mastra-client.md +2 -2
  46. package/.docs/docs/server/mastra-server.md +1 -1
  47. package/.docs/docs/server/middleware.md +46 -42
  48. package/.docs/docs/server/request-context.md +13 -2
  49. package/.docs/docs/server/server-adapters.md +91 -8
  50. package/.docs/docs/streaming/background-task-streaming.md +80 -0
  51. package/.docs/docs/streaming/overview.md +3 -0
  52. package/.docs/docs/studio/deployment.md +24 -6
  53. package/.docs/docs/studio/observability.md +1 -1
  54. package/.docs/docs/studio/overview.md +4 -4
  55. package/.docs/docs/voice/overview.md +74 -5
  56. package/.docs/docs/voice/speech-to-speech.md +45 -1
  57. package/.docs/docs/voice/speech-to-text.md +7 -7
  58. package/.docs/docs/voice/text-to-speech.md +10 -10
  59. package/.docs/docs/workflows/agents-and-tools.md +1 -1
  60. package/.docs/docs/workflows/overview.md +105 -4
  61. package/.docs/docs/workflows/scheduled-workflows.md +181 -0
  62. package/.docs/docs/workspace/filesystem.md +64 -6
  63. package/.docs/docs/workspace/lsp.md +76 -4
  64. package/.docs/docs/workspace/overview.md +62 -15
  65. package/.docs/docs/workspace/sandbox.md +3 -1
  66. package/.docs/docs/workspace/search.md +41 -2
  67. package/.docs/docs/workspace/skills.md +19 -19
  68. package/.docs/guides/agent-frameworks/ai-sdk.md +4 -4
  69. package/.docs/guides/build-your-ui/ai-sdk-ui.md +56 -9
  70. package/.docs/guides/build-your-ui/assistant-ui.md +1 -1
  71. package/.docs/guides/deployment/mastra-platform.md +191 -0
  72. package/.docs/guides/deployment/netlify.md +16 -1
  73. package/.docs/guides/getting-started/nestjs.md +238 -0
  74. package/.docs/guides/getting-started/next-js.md +0 -4
  75. package/.docs/guides/guide/code-review-bot.md +2 -2
  76. package/.docs/guides/guide/dev-assistant.md +4 -4
  77. package/.docs/{docs/mcp → guides/guide}/publishing-mcp-server.md +21 -1
  78. package/.docs/guides/guide/slack-assistant.md +191 -0
  79. package/.docs/guides/migrations/mastra-cloud.md +368 -0
  80. package/.docs/guides/migrations/upgrade-to-v1/tracing.md +1 -1
  81. package/.docs/models/embeddings.md +3 -3
  82. package/.docs/models/gateways/azure-openai.md +74 -35
  83. package/.docs/models/gateways/mastra.md +64 -0
  84. package/.docs/models/gateways/netlify.md +7 -3
  85. package/.docs/models/gateways/openrouter.md +28 -12
  86. package/.docs/models/gateways/vercel.md +22 -2
  87. package/.docs/models/gateways.md +1 -0
  88. package/.docs/models/index.md +43 -8
  89. package/.docs/models/providers/302ai.md +37 -4
  90. package/.docs/models/providers/abliteration-ai.md +71 -0
  91. package/.docs/models/providers/alibaba-cn.md +8 -2
  92. package/.docs/models/providers/alibaba-coding-plan-cn.md +3 -2
  93. package/.docs/models/providers/alibaba-coding-plan.md +3 -2
  94. package/.docs/models/providers/alibaba.md +8 -1
  95. package/.docs/models/providers/anthropic.md +18 -5
  96. package/.docs/models/providers/baseten.md +3 -1
  97. package/.docs/models/providers/berget.md +10 -12
  98. package/.docs/models/providers/chutes.md +4 -2
  99. package/.docs/models/providers/cloudflare-workers-ai.md +14 -48
  100. package/.docs/models/providers/cortecs.md +22 -2
  101. package/.docs/models/providers/deepinfra.md +8 -2
  102. package/.docs/models/providers/deepseek.md +6 -4
  103. package/.docs/models/providers/digitalocean.md +133 -0
  104. package/.docs/models/providers/fireworks-ai.md +6 -1
  105. package/.docs/models/providers/firmware.md +12 -10
  106. package/.docs/models/providers/friendli.md +6 -7
  107. package/.docs/models/providers/google.md +9 -3
  108. package/.docs/models/providers/helicone.md +1 -2
  109. package/.docs/models/providers/hpc-ai.md +73 -0
  110. package/.docs/models/providers/huggingface.md +6 -2
  111. package/.docs/models/providers/inception.md +9 -11
  112. package/.docs/models/providers/kilo.md +359 -339
  113. package/.docs/models/providers/kimi-for-coding.md +2 -1
  114. package/.docs/models/providers/llmgateway.md +67 -77
  115. package/.docs/models/providers/mistral.md +3 -2
  116. package/.docs/models/providers/mixlayer.md +75 -0
  117. package/.docs/models/providers/moonshotai-cn.md +3 -2
  118. package/.docs/models/providers/moonshotai.md +3 -2
  119. package/.docs/models/providers/nano-gpt.md +8 -2
  120. package/.docs/models/providers/neuralwatt.md +84 -0
  121. package/.docs/models/providers/novita-ai.md +19 -4
  122. package/.docs/models/providers/nvidia.md +8 -1
  123. package/.docs/models/providers/ollama-cloud.md +7 -2
  124. package/.docs/models/providers/openai.md +7 -2
  125. package/.docs/models/providers/opencode-go.md +21 -13
  126. package/.docs/models/providers/opencode.md +11 -4
  127. package/.docs/models/providers/ovhcloud.md +6 -8
  128. package/.docs/models/providers/poe.md +10 -15
  129. package/.docs/models/providers/regolo-ai.md +83 -0
  130. package/.docs/models/providers/siliconflow-cn.md +5 -2
  131. package/.docs/models/providers/siliconflow.md +6 -3
  132. package/.docs/models/providers/stepfun.md +8 -7
  133. package/.docs/models/providers/synthetic.md +5 -2
  134. package/.docs/models/providers/tencent-token-plan.md +71 -0
  135. package/.docs/models/providers/tencent-tokenhub.md +71 -0
  136. package/.docs/models/providers/togetherai.md +8 -7
  137. package/.docs/models/providers/vivgrid.md +7 -3
  138. package/.docs/models/providers/vultr.md +7 -6
  139. package/.docs/models/providers/wafer.ai.md +73 -0
  140. package/.docs/models/providers/wandb.md +3 -2
  141. package/.docs/models/providers/xai.md +6 -1
  142. package/.docs/models/providers/xiaomi-token-plan-ams.md +75 -0
  143. package/.docs/models/providers/xiaomi-token-plan-cn.md +75 -0
  144. package/.docs/models/providers/xiaomi-token-plan-sgp.md +75 -0
  145. package/.docs/models/providers/xiaomi.md +4 -2
  146. package/.docs/models/providers/zai-coding-plan.md +11 -19
  147. package/.docs/models/providers/zai.md +2 -1
  148. package/.docs/models/providers/zenmux.md +17 -6
  149. package/.docs/models/providers/zhipuai-coding-plan.md +11 -21
  150. package/.docs/models/providers/zhipuai.md +2 -1
  151. package/.docs/models/providers.md +11 -0
  152. package/.docs/reference/agents/agent.md +1 -1
  153. package/.docs/reference/agents/channels.md +3 -3
  154. package/.docs/reference/agents/generate.md +88 -6
  155. package/.docs/reference/agents/generateLegacy.md +1 -1
  156. package/.docs/reference/ai-sdk/chat-route.md +2 -0
  157. package/.docs/reference/ai-sdk/handle-chat-stream.md +19 -0
  158. package/.docs/reference/ai-sdk/handle-network-stream.md +2 -0
  159. package/.docs/reference/ai-sdk/network-route.md +2 -0
  160. package/.docs/reference/ai-sdk/to-ai-sdk-messages.md +95 -0
  161. package/.docs/reference/ai-sdk/to-ai-sdk-stream.md +15 -0
  162. package/.docs/reference/browser/agent-browser.md +375 -0
  163. package/.docs/reference/browser/browser-viewer.md +228 -0
  164. package/.docs/reference/browser/mastra-browser.md +286 -0
  165. package/.docs/reference/browser/stagehand-browser.md +286 -0
  166. package/.docs/reference/cli/mastra.md +703 -0
  167. package/.docs/reference/client-js/agents.md +166 -0
  168. package/.docs/reference/client-js/conversations.md +1 -1
  169. package/.docs/reference/client-js/mastra-client.md +23 -0
  170. package/.docs/reference/client-js/observability.md +2 -2
  171. package/.docs/reference/client-js/responses.md +1 -1
  172. package/.docs/reference/client-js/workflows.md +62 -1
  173. package/.docs/reference/configuration.md +67 -1
  174. package/.docs/reference/core/addGateway.md +5 -5
  175. package/.docs/reference/core/getEditor.md +35 -0
  176. package/.docs/reference/core/getGateway.md +5 -5
  177. package/.docs/reference/core/getGatewayById.md +5 -5
  178. package/.docs/reference/core/getMCPServer.md +2 -2
  179. package/.docs/reference/core/getMCPServerById.md +2 -2
  180. package/.docs/reference/core/getScorer.md +3 -3
  181. package/.docs/reference/core/getScorerById.md +3 -3
  182. package/.docs/reference/core/listGateways.md +5 -5
  183. package/.docs/reference/core/listMCPServers.md +2 -2
  184. package/.docs/reference/core/listScorers.md +3 -3
  185. package/.docs/reference/core/mastra-class.md +11 -1
  186. package/.docs/reference/core/mastra-model-gateway.md +5 -5
  187. package/.docs/reference/datasets/create.md +4 -4
  188. package/.docs/reference/datasets/startExperiment.md +28 -2
  189. package/.docs/reference/datasets/update.md +4 -4
  190. package/.docs/reference/deployer/cloudflare.md +14 -1
  191. package/.docs/reference/deployer/netlify.md +50 -2
  192. package/.docs/reference/editor/mastra-editor.md +168 -0
  193. package/.docs/reference/editor/tool-provider.md +85 -0
  194. package/.docs/reference/evals/context-precision.md +3 -3
  195. package/.docs/reference/evals/context-relevance.md +3 -3
  196. package/.docs/reference/evals/create-scorer.md +5 -3
  197. package/.docs/reference/evals/filter-run.md +117 -0
  198. package/.docs/reference/evals/mastra-scorer.md +4 -4
  199. package/.docs/reference/evals/noise-sensitivity.md +6 -6
  200. package/.docs/reference/evals/prompt-alignment.md +12 -12
  201. package/.docs/reference/evals/run-evals.md +6 -6
  202. package/.docs/reference/evals/scorer-utils.md +3 -3
  203. package/.docs/reference/evals/trajectory-accuracy.md +3 -3
  204. package/.docs/reference/harness/harness-class.md +152 -53
  205. package/.docs/reference/index.md +25 -0
  206. package/.docs/reference/logging/pino-logger.md +0 -2
  207. package/.docs/reference/mastra-platform/api.md +108 -0
  208. package/.docs/reference/memory/clone-utilities.md +4 -2
  209. package/.docs/reference/memory/cloneThread.md +4 -2
  210. package/.docs/reference/memory/observational-memory.md +4 -0
  211. package/.docs/reference/observability/metrics/automatic-metrics.md +3 -3
  212. package/.docs/reference/observability/tracing/bridges/datadog.md +211 -0
  213. package/.docs/reference/observability/tracing/bridges/otel.md +3 -3
  214. package/.docs/reference/observability/tracing/configuration.md +18 -11
  215. package/.docs/reference/observability/tracing/exporters/arthur.md +122 -0
  216. package/.docs/reference/observability/tracing/exporters/cloud-exporter.md +102 -21
  217. package/.docs/reference/observability/tracing/exporters/console-exporter.md +8 -8
  218. package/.docs/reference/observability/tracing/exporters/datadog.md +3 -1
  219. package/.docs/reference/observability/tracing/exporters/default-exporter.md +8 -8
  220. package/.docs/reference/observability/tracing/exporters/langfuse.md +25 -32
  221. package/.docs/reference/observability/tracing/exporters/otel.md +3 -3
  222. package/.docs/reference/observability/tracing/instances.md +7 -7
  223. package/.docs/reference/observability/tracing/interfaces.md +23 -6
  224. package/.docs/reference/observability/tracing/span-filtering.md +95 -0
  225. package/.docs/reference/observability/tracing/spans.md +6 -6
  226. package/.docs/reference/processors/prefill-error-handler.md +70 -0
  227. package/.docs/reference/processors/processor-interface.md +400 -40
  228. package/.docs/reference/processors/skill-search-processor.md +20 -1
  229. package/.docs/reference/processors/stream-error-retry-processor.md +54 -0
  230. package/.docs/reference/processors/tool-call-filter.md +23 -0
  231. package/.docs/reference/server/create-route.md +3 -3
  232. package/.docs/reference/server/express-adapter.md +4 -4
  233. package/.docs/reference/server/fastify-adapter.md +4 -4
  234. package/.docs/reference/server/hono-adapter.md +4 -4
  235. package/.docs/reference/server/koa-adapter.md +4 -4
  236. package/.docs/reference/server/mastra-server.md +3 -3
  237. package/.docs/reference/server/nestjs-adapter.md +169 -0
  238. package/.docs/reference/server/register-api-route.md +4 -4
  239. package/.docs/reference/server/routes.md +11 -10
  240. package/.docs/reference/storage/clickhouse.md +300 -0
  241. package/.docs/reference/storage/cloudflare-d1.md +42 -42
  242. package/.docs/reference/storage/composite.md +5 -3
  243. package/.docs/reference/storage/duckdb.md +150 -0
  244. package/.docs/reference/storage/overview.md +1 -1
  245. package/.docs/reference/storage/redis.md +266 -0
  246. package/.docs/reference/streaming/ChunkType.md +143 -3
  247. package/.docs/reference/streaming/agents/MastraModelOutput.md +2 -2
  248. package/.docs/reference/streaming/agents/stream.md +10 -2
  249. package/.docs/reference/streaming/agents/streamUntilIdle.md +94 -0
  250. package/.docs/reference/streaming/workflows/resumeStream.md +2 -0
  251. package/.docs/reference/templates/overview.md +88 -14
  252. package/.docs/reference/tools/create-tool.md +107 -5
  253. package/.docs/reference/tools/mcp-client.md +45 -0
  254. package/.docs/reference/tools/mcp-server.md +1 -3
  255. package/.docs/reference/tools/perplexity.md +155 -0
  256. package/.docs/reference/tools/tavily.md +307 -0
  257. package/.docs/reference/vectors/mongodb.md +0 -2
  258. package/.docs/reference/voice/aws-nova-sonic.md +247 -0
  259. package/.docs/reference/voice/cloudflare.md +3 -3
  260. package/.docs/reference/voice/sarvam.md +29 -23
  261. package/.docs/reference/voice/voice.connect.md +4 -4
  262. package/.docs/reference/voice/voice.listen.md +3 -3
  263. package/.docs/reference/workflows/run-methods/resume.md +24 -0
  264. package/.docs/reference/workflows/run-methods/startAsync.md +1 -1
  265. package/.docs/reference/workflows/step.md +88 -7
  266. package/.docs/reference/workflows/workflow-methods/foreach.md +14 -1
  267. package/.docs/reference/workflows/workflow.md +88 -4
  268. package/.docs/reference/workspace/azure-blob-filesystem.md +219 -0
  269. package/.docs/reference/workspace/docker-sandbox.md +196 -0
  270. package/.docs/reference/workspace/gcs-filesystem.md +1 -0
  271. package/.docs/reference/workspace/google-drive-filesystem.md +185 -0
  272. package/.docs/reference/workspace/modal-sandbox.md +168 -0
  273. package/.docs/reference/workspace/process-manager.md +1 -1
  274. package/.docs/reference/workspace/s3-filesystem.md +80 -5
  275. package/.docs/reference/workspace/vercel.md +1 -1
  276. package/.docs/reference/workspace/workspace-class.md +37 -6
  277. package/CHANGELOG.md +500 -4
  278. package/dist/stdio.js.map +1 -1
  279. package/dist/utils.d.ts +1 -4
  280. package/dist/utils.d.ts.map +1 -1
  281. package/package.json +11 -11
  282. package/.docs/docs/mastra-cloud/deployment.md +0 -77
  283. package/.docs/docs/mastra-cloud/observability.md +0 -38
  284. package/.docs/docs/mastra-cloud/overview.md +0 -23
  285. package/.docs/docs/mastra-cloud/setup.md +0 -42
@@ -167,6 +167,22 @@ const stream = await supervisor.stream('Research AI trends', {
167
167
 
168
168
  The callback receives `messages` (the full conversation history), `primitiveId` (the subagent ID), and `prompt` (the delegation prompt). Return the filtered array of messages.
169
169
 
170
+ ## Subagent result context
171
+
172
+ When a subagent completes, the supervisor model receives the subagent's text response in later iterations. Nested tool calls and subagent metadata, such as thread and resource IDs, are not added to the supervisor model context.
173
+
174
+ Application code and UI integrations can still inspect the raw delegation result, including `subAgentToolResults`, from the tool result payload. This keeps debugging and display data available without sending nested tool arguments or outputs back into the supervisor's next model call.
175
+
176
+ Set `includeSubAgentToolResultsInModelContext` to include the full subagent result, including nested tool results and subagent metadata, in the supervisor model context.
177
+
178
+ ```typescript
179
+ await supervisor.generate('Research AI trends', {
180
+ delegation: {
181
+ includeSubAgentToolResultsInModelContext: true,
182
+ },
183
+ })
184
+ ```
185
+
170
186
  ## Iteration monitoring
171
187
 
172
188
  `onIterationComplete` is called after each iteration of the supervisor loop. Use it to log progress, inject feedback, or stop execution early.
@@ -300,10 +316,59 @@ Success criteria:
300
316
  })
301
317
  ```
302
318
 
319
+ ## Running subagents in the background
320
+
321
+ Subagent invocations are dispatched as tool calls, so they can run as [background tasks](https://mastra.ai/docs/agents/background-tasks). This is useful when one or more delegations are long-running and you don't want them to block the supervisor's response.
322
+
323
+ Enable the [backgroundTasks manager](https://mastra.ai/reference/configuration) on the Mastra instance, then opt subagents in on the supervisor:
324
+
325
+ ```typescript
326
+ const supervisor = new Agent({
327
+ id: 'supervisor',
328
+ instructions: 'Coordinate research and writing using the available agents.',
329
+ model: 'openai/gpt-5.4',
330
+ agents: { researchAgent, writingAgent },
331
+ backgroundTasks: {
332
+ tools: {
333
+ researchAgent: { enabled: true, timeoutMs: 900_000 },
334
+ writingAgent: { enabled: true, timeoutMs: 900_000 },
335
+ },
336
+ },
337
+ })
338
+
339
+ const stream = await supervisor.streamUntilIdle('Research AI in education and write an article', {
340
+ memory: { thread: 't1', resource: 'u1' },
341
+ })
342
+ ```
343
+
344
+ Use [`streamUntilIdle()`](https://mastra.ai/reference/streaming/agents/streamUntilIdle) instead of `stream()` so the stream stays open until the subagents complete and the supervisor has had a chance to respond to their results.
345
+
346
+ If a subagent isn't listed on the supervisor but has its own background-eligible tools, the supervisor still dispatches the subagent as a background task and inherits its config. See [Inheriting from the subagent](https://mastra.ai/docs/agents/background-tasks) for details.
347
+
348
+ ## Subagent versioning
349
+
350
+ When using the [editor](https://mastra.ai/docs/editor/overview), you can control which stored version of each subagent the supervisor uses at runtime. Set version overrides on the Mastra instance or per invocation:
351
+
352
+ ```typescript
353
+ const result = await supervisor.generate('Research and write about AI safety', {
354
+ versions: {
355
+ agents: {
356
+ 'research-agent': { status: 'published' },
357
+ 'writing-agent': { versionId: 'draft-456' },
358
+ },
359
+ },
360
+ })
361
+ ```
362
+
363
+ Version overrides propagate automatically through delegation. See [Subagent versioning](https://mastra.ai/docs/editor/overview) for details on resolution order and server API usage.
364
+
303
365
  ## Related
304
366
 
367
+ - [Background tasks](https://mastra.ai/docs/agents/background-tasks)
368
+ - [Subagent versioning](https://mastra.ai/docs/editor/overview)
305
369
  - [Guide: Research coordinator](https://mastra.ai/guides/guide/research-coordinator)
306
370
  - [Agent.stream() reference](https://mastra.ai/reference/streaming/agents/stream)
371
+ - [Agent.streamUntilIdle() reference](https://mastra.ai/reference/streaming/agents/streamUntilIdle)
307
372
  - [Agent.generate() reference](https://mastra.ai/reference/agents/generate)
308
373
  - [Agent approval](https://mastra.ai/docs/agents/agent-approval)
309
374
  - [Memory in multi-agent systems](https://mastra.ai/docs/memory/overview)
@@ -57,6 +57,78 @@ export const weatherAgent = new Agent({
57
57
  })
58
58
  ```
59
59
 
60
+ ## Define schemas
61
+
62
+ You can define the tool's `inputSchema` and `outputSchema` with any library that supports [Standard JSON Schema](https://standardschema.dev/json-schema). This includes libraries like [Zod](https://zod.dev/), [Valibot](https://valibot.dev/), and [ArkType](https://arktype.io/).
63
+
64
+ **Zod**:
65
+
66
+ ```typescript
67
+ import { createTool } from '@mastra/core/tools'
68
+ import { z } from 'zod'
69
+
70
+ export const weatherTool = createTool({
71
+ id: 'weather-tool',
72
+ description: 'Fetches weather for a location',
73
+ inputSchema: z.object({
74
+ location: z.string(),
75
+ }),
76
+ outputSchema: z.object({
77
+ weather: z.string(),
78
+ }),
79
+ execute: async inputData => {
80
+ // Fetch weather data
81
+ },
82
+ })
83
+ ```
84
+
85
+ **Valibot**:
86
+
87
+ ```typescript
88
+ import { createTool } from '@mastra/core/tools'
89
+ import * as v from 'valibot'
90
+ import { toStandardJsonSchema } from '@valibot/to-json-schema'
91
+
92
+ export const weatherTool = createTool({
93
+ id: 'weather-tool',
94
+ description: 'Fetches weather for a location',
95
+ inputSchema: toStandardJsonSchema(
96
+ v.object({
97
+ location: v.string(),
98
+ }),
99
+ ),
100
+ outputSchema: toStandardJsonSchema(
101
+ v.object({
102
+ weather: v.string(),
103
+ }),
104
+ ),
105
+ execute: async inputData => {
106
+ // Fetch weather data
107
+ },
108
+ })
109
+ ```
110
+
111
+ **ArkType**:
112
+
113
+ ```typescript
114
+ import { createTool } from '@mastra/core/tools'
115
+ import { type } from 'arktype'
116
+
117
+ export const weatherTool = createTool({
118
+ id: 'weather-tool',
119
+ description: 'Fetches weather for a location',
120
+ inputSchema: type({
121
+ location: 'string',
122
+ }),
123
+ outputSchema: type({
124
+ weather: 'string',
125
+ }),
126
+ execute: async inputData => {
127
+ // Fetch weather data
128
+ },
129
+ })
130
+ ```
131
+
60
132
  ## Multiple tools
61
133
 
62
134
  An agent can use multiple tools to handle more complex tasks by delegating specific parts to individual tools. The agent decides which tools to use based on the user's message, the agent's instructions, and the tool descriptions and schemas.
@@ -218,6 +290,7 @@ Note that for subagents, you'll see two different identifiers in stream response
218
290
 
219
291
  - [`createTool` reference](https://mastra.ai/reference/tools/create-tool)
220
292
  - [`Agent.generate()` reference](https://mastra.ai/reference/agents/generate): Runtime options for tool selection, steps, and callbacks
293
+ - [Background tasks](https://mastra.ai/docs/agents/background-tasks): Run long-running tools without blocking the agent loop
221
294
  - [MCP overview](https://mastra.ai/docs/mcp/overview)
222
295
  - [Dynamic tool search](https://mastra.ai/reference/processors/tool-search-processor): Load tools on demand for agents with large tool libraries
223
296
  - [Tools with structured output](https://mastra.ai/docs/agents/structured-output): Model compatibility when combining tools and structured output
@@ -0,0 +1,78 @@
1
+ # AgentBrowser
2
+
3
+ The `@mastra/agent-browser` package provides browser automation using Playwright with accessibility-first element targeting. Elements are identified by refs from the page's accessibility tree, making interactions reliable across different page layouts.
4
+
5
+ ## When to use AgentBrowser
6
+
7
+ Use AgentBrowser when you need:
8
+
9
+ - Reliable element targeting through accessibility refs
10
+ - Fine-grained control over browser actions
11
+ - Playwright's robust automation capabilities
12
+ - Support for keyboard shortcuts and complex interactions
13
+
14
+ ## Quickstart
15
+
16
+ Install the package:
17
+
18
+ **npm**:
19
+
20
+ ```bash
21
+ npm install @mastra/agent-browser
22
+ ```
23
+
24
+ **pnpm**:
25
+
26
+ ```bash
27
+ pnpm add @mastra/agent-browser
28
+ ```
29
+
30
+ **Yarn**:
31
+
32
+ ```bash
33
+ yarn add @mastra/agent-browser
34
+ ```
35
+
36
+ **Bun**:
37
+
38
+ ```bash
39
+ bun add @mastra/agent-browser
40
+ ```
41
+
42
+ Create a browser instance and assign it to an agent:
43
+
44
+ ```typescript
45
+ import { Agent } from '@mastra/core/agent'
46
+ import { AgentBrowser } from '@mastra/agent-browser'
47
+
48
+ const browser = new AgentBrowser({
49
+ headless: false,
50
+ })
51
+
52
+ export const browserAgent = new Agent({
53
+ id: 'browser-agent',
54
+ name: 'Browser Agent',
55
+ model: 'openai/gpt-5.4',
56
+ browser,
57
+ instructions: `You are a web automation assistant.
58
+
59
+ When interacting with pages:
60
+ 1. Use browser_snapshot to get the current page state and element refs
61
+ 2. Use the refs (like @e1, @e2) to target elements for clicks and typing
62
+ 3. After actions, take another snapshot to verify the result`,
63
+ })
64
+ ```
65
+
66
+ > **Note:** For local launches (the default), AgentBrowser requires a Chromium binary installed via Playwright. This is normally downloaded automatically when you install `@mastra/agent-browser`. If launching the browser fails with `"browser executable is missing"`, run `npx playwright install chromium`. If you connect to a remote browser using the [`cdpUrl`](https://mastra.ai/reference/browser/agent-browser) option, no local Chromium is needed.
67
+
68
+ ## Element refs
69
+
70
+ AgentBrowser uses accessibility tree refs to identify elements. When an agent calls `browser_snapshot`, it receives a text representation of the page with refs like `@e1`, `@e2`, etc. The agent then uses these refs with other tools to interact with elements.
71
+
72
+ > **Note:** See [AgentBrowser reference](https://mastra.ai/reference/browser/agent-browser) for all configuration options and tool details.
73
+
74
+ ## Related
75
+
76
+ - [Browser overview](https://mastra.ai/docs/browser/overview)
77
+ - [Stagehand](https://mastra.ai/docs/browser/stagehand)
78
+ - [AgentBrowser reference](https://mastra.ai/reference/browser/agent-browser)
@@ -0,0 +1,144 @@
1
+ # BrowserViewer
2
+
3
+ The `@mastra/browser-viewer` package provides browser automation for CLI-based tools like [agent-browser](https://www.npmjs.com/package/agent-browser), [browser-use](https://pypi.org/project/browser-use/), and [browse](https://www.npmjs.com/package/@browserbasehq/browse-cli). BrowserViewer launches Chrome via Playwright, exposes a Chrome DevTools Protocol (CDP) URL, and automatically injects it into CLI commands run through [workspace tools](https://mastra.ai/docs/workspace/overview).
4
+
5
+ ## When to use BrowserViewer
6
+
7
+ Use BrowserViewer when your agent drives a browser through a CLI tool rather than an SDK. BrowserViewer handles:
8
+
9
+ - Launching and managing Chrome for CLI tools to connect to
10
+ - Automatic CDP URL injection into `workspace_execute_command` calls
11
+ - Live screencast streaming to Studio
12
+ - Thread-scoped browser isolation
13
+
14
+ For SDK-based browser automation, use [AgentBrowser](https://mastra.ai/docs/browser/agent-browser) or [Stagehand](https://mastra.ai/docs/browser/stagehand) instead.
15
+
16
+ ## Quickstart
17
+
18
+ Install `@mastra/browser-viewer` and the CLI tool your agent will use. BrowserViewer manages Chrome, but the CLI tool itself must be installed separately.
19
+
20
+ **npm**:
21
+
22
+ ```bash
23
+ npm install @mastra/browser-viewer
24
+ ```
25
+
26
+ **pnpm**:
27
+
28
+ ```bash
29
+ pnpm add @mastra/browser-viewer
30
+ ```
31
+
32
+ **Yarn**:
33
+
34
+ ```bash
35
+ yarn add @mastra/browser-viewer
36
+ ```
37
+
38
+ **Bun**:
39
+
40
+ ```bash
41
+ bun add @mastra/browser-viewer
42
+ ```
43
+
44
+ Install the CLI tool in your workspace environment. This example uses `browser-use`:
45
+
46
+ ```bash
47
+ pip install browser-use
48
+ ```
49
+
50
+ Install the corresponding [skill](https://mastra.ai/docs/workspace/skills) so the agent knows how to use the CLI:
51
+
52
+ ```bash
53
+ npx skills add browser-use/browser-use --skill browser-use
54
+ ```
55
+
56
+ Create a workspace with BrowserViewer and assign it to an agent:
57
+
58
+ ```typescript
59
+ import { Mastra } from '@mastra/core/mastra'
60
+ import { Agent } from '@mastra/core/agent'
61
+ import { Workspace, LocalSandbox } from '@mastra/core/workspace'
62
+ import { BrowserViewer } from '@mastra/browser-viewer'
63
+
64
+ const workspace = new Workspace({
65
+ sandbox: new LocalSandbox({
66
+ workingDirectory: './workspace',
67
+ }),
68
+ browser: new BrowserViewer({
69
+ cli: 'browser-use',
70
+ headless: false,
71
+ }),
72
+ })
73
+
74
+ const browserAgent = new Agent({
75
+ id: 'browser-agent',
76
+ model: 'openai/gpt-5.4',
77
+ workspace,
78
+ instructions: `You are a web automation assistant.
79
+ Use browser-use commands to navigate and interact with websites.`,
80
+ })
81
+
82
+ export const mastra = new Mastra({
83
+ agents: { browserAgent },
84
+ })
85
+ ```
86
+
87
+ When the agent runs a CLI command like `browser-use open https://example.com`, Mastra automatically launches Chrome, injects the CDP connection, and starts streaming the screencast to Studio.
88
+
89
+ ## How it works
90
+
91
+ 1. The agent calls `workspace_execute_command` with a browser CLI command.
92
+ 2. Mastra detects the CLI command and launches Chrome via Playwright (if not already running).
93
+ 3. The CDP URL is injected into the command so the CLI connects to the managed browser.
94
+ 4. Screencast frames stream from page-level CDP sessions to Studio.
95
+
96
+ ## Supported CLIs
97
+
98
+ BrowserViewer supports three CLI providers. Each CLI must be installed separately in your workspace environment. Each CLI also publishes a [skill](https://mastra.ai/docs/workspace/skills) that teaches the agent its commands and workflows.
99
+
100
+ ### agent-browser
101
+
102
+ ```bash
103
+ npm install -g agent-browser
104
+ npx skills add vercel-labs/agent-browser
105
+ ```
106
+
107
+ CDP flag: `--cdp`
108
+
109
+ ### browser-use
110
+
111
+ ```bash
112
+ pip install browser-use
113
+ npx skills add browser-use/browser-use --skill browser-use
114
+ ```
115
+
116
+ CDP flag: `--cdp-url`
117
+
118
+ ### browse-cli
119
+
120
+ ```bash
121
+ npm install -g @browserbasehq/browse-cli
122
+ npx skills add browserbase/skills
123
+ ```
124
+
125
+ CDP flag: `--ws`
126
+
127
+ Set the `cli` option to match the CLI your agent uses:
128
+
129
+ ```typescript
130
+ const viewer = new BrowserViewer({
131
+ cli: 'browser-use',
132
+ headless: false,
133
+ })
134
+ ```
135
+
136
+ > **Note:** See [BrowserViewer reference](https://mastra.ai/reference/browser/browser-viewer) for all configuration options, advanced connection modes, and method details.
137
+
138
+ ## Related
139
+
140
+ - [Browser overview](https://mastra.ai/docs/browser/overview)
141
+ - [AgentBrowser](https://mastra.ai/docs/browser/agent-browser)
142
+ - [Stagehand](https://mastra.ai/docs/browser/stagehand)
143
+ - [Workspace overview](https://mastra.ai/docs/workspace/overview)
144
+ - [Workspace skills](https://mastra.ai/docs/workspace/skills)
@@ -0,0 +1,168 @@
1
+ # Browser overview
2
+
3
+ Browser support enables agents to navigate websites, interact with page elements, fill forms, and extract data. Mastra provides browser capabilities through SDK providers that wrap browser automation libraries and a CLI provider for agents that drive browsers through command-line tools.
4
+
5
+ Mastra supports two SDK providers and one CLI provider:
6
+
7
+ - [**AgentBrowser**](https://mastra.ai/docs/browser/agent-browser): A Playwright-based provider with accessibility-first element targeting. Best for general web automation and scraping.
8
+ - [**Stagehand**](https://mastra.ai/docs/browser/stagehand): A Browserbase provider with AI-powered element detection. Best for complex interactions that benefit from natural language selectors.
9
+ - [**BrowserViewer**](https://mastra.ai/docs/browser/browser-viewer): A CLI provider that launches Chrome and injects CDP URLs into CLI tools like agent-browser, browser-use, and browse. Best for workspace agents that drive browsers through shell commands.
10
+
11
+ ## When to use browser
12
+
13
+ Use browser when your agent needs to:
14
+
15
+ - Navigate websites and interact with page elements
16
+ - Fill out forms and submit data
17
+ - Extract structured data from web pages
18
+ - Automate multi-step web workflows
19
+ - Take actions that require a real browser (JavaScript rendering, authentication flows)
20
+
21
+ ## How it works
22
+
23
+ When you assign a browser to an agent, Mastra includes the provider's tools in the agent's toolset. The agent uses these tools to control the browser: navigating to URLs, selecting elements, typing text, and reading page content.
24
+
25
+ Each provider offers a different set of tools optimized for its approach.
26
+
27
+ ## Quickstart
28
+
29
+ Install your provider of choice, for this example you'll use the AgentBrowser provider.
30
+
31
+ **npm**:
32
+
33
+ ```bash
34
+ npm install @mastra/agent-browser
35
+ ```
36
+
37
+ **pnpm**:
38
+
39
+ ```bash
40
+ pnpm add @mastra/agent-browser
41
+ ```
42
+
43
+ **Yarn**:
44
+
45
+ ```bash
46
+ yarn add @mastra/agent-browser
47
+ ```
48
+
49
+ **Bun**:
50
+
51
+ ```bash
52
+ bun add @mastra/agent-browser
53
+ ```
54
+
55
+ Create a new browser instance:
56
+
57
+ ```typescript
58
+ import { AgentBrowser } from '@mastra/agent-browser'
59
+
60
+ export const browser = new AgentBrowser({
61
+ headless: false,
62
+ })
63
+ ```
64
+
65
+ Assign the browser to an agent:
66
+
67
+ ```typescript
68
+ import { Agent } from '@mastra/core/agent'
69
+ import { browser } from '../browsers'
70
+
71
+ export const webAgent = new Agent({
72
+ id: 'web-agent',
73
+ name: 'Web Agent',
74
+ description: 'A web automation assistant that can navigate websites and complete tasks.',
75
+ model: 'openai/gpt-5.4',
76
+ browser,
77
+ instructions:
78
+ 'You are a web automation assistant. Use browser tools to navigate websites and complete tasks.',
79
+ })
80
+ ```
81
+
82
+ The agent automatically receives all browser tools from the provider.
83
+
84
+ ## Cloud providers
85
+
86
+ Both SDK providers support connecting to cloud browser services instead of launching a local browser.
87
+
88
+ ### Browserbase (Stagehand native)
89
+
90
+ Stagehand has native Browserbase integration:
91
+
92
+ ```typescript
93
+ import { StagehandBrowser } from '@mastra/stagehand'
94
+
95
+ const browser = new StagehandBrowser({
96
+ env: 'BROWSERBASE',
97
+ apiKey: process.env.BROWSERBASE_API_KEY,
98
+ projectId: process.env.BROWSERBASE_PROJECT_ID,
99
+ })
100
+ ```
101
+
102
+ ### CDP URL (any provider)
103
+
104
+ Connect to any browser exposing a Chrome DevTools Protocol (CDP) endpoint:
105
+
106
+ ```typescript
107
+ import { AgentBrowser } from '@mastra/agent-browser'
108
+
109
+ const browser = new AgentBrowser({
110
+ cdpUrl: process.env.BROWSER_CDP_URL,
111
+ headless: true,
112
+ })
113
+ ```
114
+
115
+ This works with any [CDP-compatible](https://chromedevtools.github.io/devtools-protocol/) browser service.
116
+
117
+ ## Screencast
118
+
119
+ Browser providers stream a live video feed of the browser to the Mastra Studio UI. This lets you watch the agent interact with pages in real-time.
120
+
121
+ Screencast requires WebSocket support. Install these packages in your project:
122
+
123
+ **npm**:
124
+
125
+ ```bash
126
+ npm install ws @hono/node-ws
127
+ ```
128
+
129
+ **pnpm**:
130
+
131
+ ```bash
132
+ pnpm add ws @hono/node-ws
133
+ ```
134
+
135
+ **Yarn**:
136
+
137
+ ```bash
138
+ yarn add ws @hono/node-ws
139
+ ```
140
+
141
+ **Bun**:
142
+
143
+ ```bash
144
+ bun add ws @hono/node-ws
145
+ ```
146
+
147
+ > **Note:** These packages are not included by default because they are incompatible with serverless environments like Cloudflare Workers. If they are not installed, screencast is disabled but all other browser functionality works normally.
148
+
149
+ Screencast is enabled by default and can be configured:
150
+
151
+ ```typescript
152
+ const browser = new AgentBrowser({
153
+ screencast: {
154
+ enabled: true,
155
+ format: 'jpeg',
156
+ quality: 80,
157
+ maxWidth: 1280,
158
+ maxHeight: 720,
159
+ },
160
+ })
161
+ ```
162
+
163
+ ## Next steps
164
+
165
+ - [AgentBrowser](https://mastra.ai/docs/browser/agent-browser)
166
+ - [Stagehand](https://mastra.ai/docs/browser/stagehand)
167
+ - [BrowserViewer](https://mastra.ai/docs/browser/browser-viewer)
168
+ - [MastraBrowser reference](https://mastra.ai/reference/browser/mastra-browser)
@@ -0,0 +1,129 @@
1
+ # Stagehand
2
+
3
+ The `@mastra/stagehand` package provides browser automation using the [Stagehand SDK](https://docs.browserbase.com/stagehand/introduction) from Browserbase. Stagehand uses AI to understand page context and locate elements, enabling natural language descriptions instead of explicit selectors.
4
+
5
+ ## When to use Stagehand
6
+
7
+ Use Stagehand when you need:
8
+
9
+ - Natural language element targeting ("select the login button")
10
+ - AI-powered data extraction from pages
11
+ - Native Browserbase cloud integration
12
+ - Simpler tool interface for common actions
13
+
14
+ ## Quickstart
15
+
16
+ Install the package:
17
+
18
+ **npm**:
19
+
20
+ ```bash
21
+ npm install @mastra/stagehand
22
+ ```
23
+
24
+ **pnpm**:
25
+
26
+ ```bash
27
+ pnpm add @mastra/stagehand
28
+ ```
29
+
30
+ **Yarn**:
31
+
32
+ ```bash
33
+ yarn add @mastra/stagehand
34
+ ```
35
+
36
+ **Bun**:
37
+
38
+ ```bash
39
+ bun add @mastra/stagehand
40
+ ```
41
+
42
+ Create a browser instance and assign it to an agent:
43
+
44
+ ```typescript
45
+ import { Agent } from '@mastra/core/agent'
46
+ import { StagehandBrowser } from '@mastra/stagehand'
47
+
48
+ const browser = new StagehandBrowser({
49
+ headless: false,
50
+ model: 'openai/gpt-5.4',
51
+ })
52
+
53
+ export const stagehandAgent = new Agent({
54
+ id: 'stagehand-agent',
55
+ name: 'Stagehand Agent',
56
+ model: 'openai/gpt-5.4',
57
+ browser,
58
+ instructions: `You are a web automation assistant.
59
+
60
+ Use stagehand tools to interact with pages:
61
+ - stagehand_navigate to go to URLs
62
+ - stagehand_act to perform actions described in natural language
63
+ - stagehand_extract to get structured data from the page
64
+ - stagehand_observe to find available actions on the page`,
65
+ })
66
+ ```
67
+
68
+ ## Natural language actions
69
+
70
+ When the agent uses the `stagehand_act` tool, it accepts natural language descriptions of actions:
71
+
72
+ - "Press the Sign In button"
73
+ - "Type `'[user@example.com](mailto:user@example.com)'` in the email field"
74
+ - "Select 'United States' from the country dropdown"
75
+
76
+ Stagehand's AI interprets the action and finds the appropriate element on the page.
77
+
78
+ ## Data extraction
79
+
80
+ When the agent uses the `stagehand_extract` tool, it can pull structured data from pages.
81
+
82
+ Example instruction: "Extract the product name, price, and availability"
83
+
84
+ The tool returns structured data based on page content:
85
+
86
+ ```json
87
+ {
88
+ "name": "Widget Pro",
89
+ "price": "$29.99",
90
+ "availability": "In Stock"
91
+ }
92
+ ```
93
+
94
+ ## Observing actions
95
+
96
+ When the agent uses the `stagehand_observe` tool, it analyzes the current page and returns possible actions.
97
+
98
+ Example instruction: "What actions can I take on this login form?"
99
+
100
+ Returns a list of available actions:
101
+
102
+ ```json
103
+ [
104
+ { "action": "Press 'Sign In' button", "element": "button" },
105
+ { "action": "Type in 'Email' field", "element": "input" },
106
+ { "action": "Open 'Forgot Password' link", "element": "a" }
107
+ ]
108
+ ```
109
+
110
+ ## Browserbase
111
+
112
+ Stagehand has native Browserbase integration for cloud browser infrastructure:
113
+
114
+ ```typescript
115
+ const browser = new StagehandBrowser({
116
+ env: 'BROWSERBASE',
117
+ apiKey: process.env.BROWSERBASE_API_KEY,
118
+ projectId: process.env.BROWSERBASE_PROJECT_ID,
119
+ model: 'openai/gpt-5.4',
120
+ })
121
+ ```
122
+
123
+ > **Note:** See [StagehandBrowser reference](https://mastra.ai/reference/browser/stagehand-browser) for all configuration options.
124
+
125
+ ## Related
126
+
127
+ - [Browser overview](https://mastra.ai/docs/browser/overview)
128
+ - [AgentBrowser](https://mastra.ai/docs/browser/agent-browser)
129
+ - [StagehandBrowser reference](https://mastra.ai/reference/browser/stagehand-browser)
@@ -2,7 +2,11 @@
2
2
 
3
3
  Mastra applications can be deployed to cloud providers and serverless platforms. Mastra includes optional built-in deployers for Vercel, Netlify, and Cloudflare to automate the deployment process.
4
4
 
5
- ## Supported cloud providers
5
+ ## Mastra platform
6
+
7
+ Mastra provides a platform to deploy your server to the cloud. Read the [Mastra platform deployment guide](https://mastra.ai/guides/deployment/mastra-platform) to learn more.
8
+
9
+ ## Cloud providers
6
10
 
7
11
  The following guides show how to deploy Mastra to specific cloud providers:
8
12