@mastra/mcp-docs-server 1.0.0-beta.13 → 1.0.0-beta.15

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 (321) hide show
  1. package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +27 -27
  2. package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +78 -78
  3. package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +195 -195
  4. package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +173 -173
  5. package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +195 -195
  6. package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +195 -195
  7. package/.docs/organized/changelogs/%40mastra%2Fconvex.md +248 -0
  8. package/.docs/organized/changelogs/%40mastra%2Fcore.md +338 -338
  9. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +33 -33
  10. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +16 -16
  11. package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +41 -41
  12. package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +195 -195
  13. package/.docs/organized/changelogs/%40mastra%2Fevals.md +10 -10
  14. package/.docs/organized/changelogs/%40mastra%2Ffastembed.md +6 -0
  15. package/.docs/organized/changelogs/%40mastra%2Flance.md +195 -195
  16. package/.docs/organized/changelogs/%40mastra%2Flibsql.md +195 -195
  17. package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +17 -17
  18. package/.docs/organized/changelogs/%40mastra%2Fmemory.md +139 -139
  19. package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +219 -219
  20. package/.docs/organized/changelogs/%40mastra%2Fmssql.md +219 -219
  21. package/.docs/organized/changelogs/%40mastra%2Fpg.md +235 -235
  22. package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +102 -102
  23. package/.docs/organized/changelogs/%40mastra%2Frag.md +17 -17
  24. package/.docs/organized/changelogs/%40mastra%2Freact.md +77 -70
  25. package/.docs/organized/changelogs/%40mastra%2Fserver.md +218 -218
  26. package/.docs/organized/changelogs/%40mastra%2Fupstash.md +195 -195
  27. package/.docs/organized/changelogs/create-mastra.md +13 -13
  28. package/.docs/organized/changelogs/mastra.md +56 -56
  29. package/.docs/organized/code-examples/agent-v6.md +210 -0
  30. package/.docs/organized/code-examples/ai-elements.md +1 -1
  31. package/.docs/organized/code-examples/client-side-tools.md +1 -1
  32. package/.docs/raw/agents/adding-voice.mdx +10 -6
  33. package/.docs/raw/agents/agent-approval.mdx +5 -6
  34. package/.docs/raw/agents/agent-memory.mdx +22 -30
  35. package/.docs/raw/agents/guardrails.mdx +60 -50
  36. package/.docs/raw/agents/networks.mdx +8 -12
  37. package/.docs/raw/agents/overview.mdx +39 -23
  38. package/.docs/raw/agents/processors.mdx +20 -19
  39. package/.docs/raw/agents/structured-output.mdx +11 -7
  40. package/.docs/raw/agents/using-tools.mdx +4 -5
  41. package/.docs/raw/deployment/mastra-server.mdx +3 -3
  42. package/.docs/raw/deployment/overview.mdx +7 -1
  43. package/.docs/raw/deployment/web-framework.mdx +4 -6
  44. package/.docs/raw/deployment/workflow-runners.mdx +14 -0
  45. package/.docs/raw/evals/custom-scorers.mdx +9 -6
  46. package/.docs/raw/evals/overview.mdx +3 -6
  47. package/.docs/raw/evals/running-in-ci.mdx +2 -2
  48. package/.docs/raw/getting-started/manual-install.mdx +20 -20
  49. package/.docs/raw/getting-started/mcp-docs-server.mdx +2 -2
  50. package/.docs/raw/getting-started/studio.mdx +1 -1
  51. package/.docs/raw/guides/agent-frameworks/ai-sdk.mdx +4 -4
  52. package/.docs/raw/guides/build-your-ui/ai-sdk-ui.mdx +30 -30
  53. package/.docs/raw/guides/build-your-ui/assistant-ui.mdx +8 -8
  54. package/.docs/raw/guides/build-your-ui/copilotkit.mdx +11 -11
  55. package/.docs/raw/guides/deployment/amazon-ec2.mdx +9 -9
  56. package/.docs/raw/guides/deployment/aws-lambda.mdx +11 -11
  57. package/.docs/raw/guides/deployment/azure-app-services.mdx +2 -2
  58. package/.docs/raw/guides/deployment/cloudflare-deployer.mdx +5 -6
  59. package/.docs/raw/guides/deployment/digital-ocean.mdx +10 -10
  60. package/.docs/raw/guides/deployment/index.mdx +1 -1
  61. package/.docs/raw/guides/deployment/inngest.mdx +444 -0
  62. package/.docs/raw/guides/deployment/netlify-deployer.mdx +4 -4
  63. package/.docs/raw/guides/deployment/vercel-deployer.mdx +5 -6
  64. package/.docs/raw/guides/getting-started/astro.mdx +292 -451
  65. package/.docs/raw/guides/getting-started/express.mdx +7 -7
  66. package/.docs/raw/guides/getting-started/hono.mdx +18 -18
  67. package/.docs/raw/guides/getting-started/next-js.mdx +19 -20
  68. package/.docs/raw/guides/getting-started/quickstart.mdx +4 -4
  69. package/.docs/raw/guides/getting-started/sveltekit.mdx +238 -409
  70. package/.docs/raw/guides/getting-started/vite-react.mdx +21 -21
  71. package/.docs/raw/guides/guide/ai-recruiter.mdx +10 -10
  72. package/.docs/raw/guides/guide/chef-michel.mdx +9 -11
  73. package/.docs/raw/guides/guide/notes-mcp-server.mdx +15 -15
  74. package/.docs/raw/guides/guide/research-assistant.mdx +13 -13
  75. package/.docs/raw/guides/guide/stock-agent.mdx +5 -5
  76. package/.docs/raw/guides/guide/web-search.mdx +8 -8
  77. package/.docs/raw/guides/guide/whatsapp-chat-bot.mdx +7 -7
  78. package/.docs/raw/guides/migrations/ai-sdk-v4-to-v5.mdx +2 -2
  79. package/.docs/raw/guides/migrations/upgrade-to-v1/agent.mdx +1 -1
  80. package/.docs/raw/guides/migrations/upgrade-to-v1/memory.mdx +11 -3
  81. package/.docs/raw/guides/migrations/upgrade-to-v1/processors.mdx +11 -0
  82. package/.docs/raw/guides/migrations/upgrade-to-v1/storage.mdx +41 -0
  83. package/.docs/raw/guides/migrations/upgrade-to-v1/workflows.mdx +0 -2
  84. package/.docs/raw/guides/migrations/vnext-to-standard-apis.mdx +21 -23
  85. package/.docs/raw/index.mdx +2 -2
  86. package/.docs/raw/mastra-cloud/deployment.mdx +39 -0
  87. package/.docs/raw/mastra-cloud/observability.mdx +9 -15
  88. package/.docs/raw/mastra-cloud/overview.mdx +14 -44
  89. package/.docs/raw/mastra-cloud/setup.mdx +64 -0
  90. package/.docs/raw/mastra-cloud/studio.mdx +35 -0
  91. package/.docs/raw/mcp/overview.mdx +31 -13
  92. package/.docs/raw/mcp/publishing-mcp-server.mdx +2 -2
  93. package/.docs/raw/memory/memory-processors.mdx +9 -9
  94. package/.docs/raw/memory/message-history.mdx +69 -0
  95. package/.docs/raw/memory/overview.mdx +34 -76
  96. package/.docs/raw/memory/semantic-recall.mdx +58 -49
  97. package/.docs/raw/memory/storage.mdx +188 -0
  98. package/.docs/raw/memory/working-memory.mdx +7 -7
  99. package/.docs/raw/observability/logging.mdx +9 -10
  100. package/.docs/raw/observability/overview.mdx +0 -1
  101. package/.docs/raw/observability/tracing/bridges/otel.mdx +2 -2
  102. package/.docs/raw/observability/tracing/exporters/default.mdx +3 -3
  103. package/.docs/raw/observability/tracing/exporters/langfuse.mdx +1 -2
  104. package/.docs/raw/observability/tracing/overview.mdx +23 -25
  105. package/.docs/raw/observability/tracing/processors/sensitive-data-filter.mdx +3 -3
  106. package/.docs/raw/rag/chunking-and-embedding.mdx +6 -6
  107. package/.docs/raw/rag/graph-rag.mdx +7 -7
  108. package/.docs/raw/rag/overview.mdx +1 -1
  109. package/.docs/raw/rag/retrieval.mdx +21 -22
  110. package/.docs/raw/rag/vector-databases.mdx +22 -22
  111. package/.docs/raw/reference/agents/agent.mdx +3 -3
  112. package/.docs/raw/reference/agents/generate.mdx +1 -1
  113. package/.docs/raw/reference/agents/generateLegacy.mdx +2 -2
  114. package/.docs/raw/reference/agents/getDefaultGenerateOptions.mdx +2 -2
  115. package/.docs/raw/reference/agents/getDefaultOptions.mdx +2 -2
  116. package/.docs/raw/reference/agents/getDefaultStreamOptions.mdx +2 -2
  117. package/.docs/raw/reference/agents/getDescription.mdx +1 -1
  118. package/.docs/raw/reference/agents/getInstructions.mdx +2 -2
  119. package/.docs/raw/reference/agents/getLLM.mdx +2 -2
  120. package/.docs/raw/reference/agents/getMemory.mdx +2 -2
  121. package/.docs/raw/reference/agents/getModel.mdx +2 -2
  122. package/.docs/raw/reference/agents/getTools.mdx +2 -2
  123. package/.docs/raw/reference/agents/getVoice.mdx +2 -2
  124. package/.docs/raw/reference/agents/listAgents.mdx +2 -2
  125. package/.docs/raw/reference/agents/listScorers.mdx +2 -2
  126. package/.docs/raw/reference/agents/listTools.mdx +2 -2
  127. package/.docs/raw/reference/agents/listWorkflows.mdx +2 -2
  128. package/.docs/raw/reference/agents/network.mdx +1 -1
  129. package/.docs/raw/reference/ai-sdk/chat-route.mdx +2 -2
  130. package/.docs/raw/reference/ai-sdk/handle-chat-stream.mdx +1 -1
  131. package/.docs/raw/reference/ai-sdk/handle-network-stream.mdx +1 -1
  132. package/.docs/raw/reference/ai-sdk/handle-workflow-stream.mdx +1 -1
  133. package/.docs/raw/reference/ai-sdk/network-route.mdx +2 -2
  134. package/.docs/raw/reference/ai-sdk/to-ai-sdk-stream.mdx +6 -6
  135. package/.docs/raw/reference/ai-sdk/to-ai-sdk-v4-messages.mdx +3 -3
  136. package/.docs/raw/reference/ai-sdk/to-ai-sdk-v5-messages.mdx +3 -3
  137. package/.docs/raw/reference/ai-sdk/with-mastra.mdx +1 -1
  138. package/.docs/raw/reference/ai-sdk/workflow-route.mdx +2 -2
  139. package/.docs/raw/reference/auth/auth0.mdx +1 -2
  140. package/.docs/raw/reference/auth/clerk.mdx +1 -2
  141. package/.docs/raw/reference/auth/firebase.mdx +2 -4
  142. package/.docs/raw/reference/auth/jwt.mdx +1 -2
  143. package/.docs/raw/reference/auth/supabase.mdx +1 -2
  144. package/.docs/raw/reference/auth/workos.mdx +1 -2
  145. package/.docs/raw/reference/cli/create-mastra.mdx +10 -10
  146. package/.docs/raw/reference/cli/mastra.mdx +9 -9
  147. package/.docs/raw/reference/client-js/agents.mdx +1 -2
  148. package/.docs/raw/reference/client-js/mastra-client.mdx +1 -1
  149. package/.docs/raw/reference/core/getAgent.mdx +1 -1
  150. package/.docs/raw/reference/core/getAgentById.mdx +1 -1
  151. package/.docs/raw/reference/core/getDeployer.mdx +1 -1
  152. package/.docs/raw/reference/core/getLogger.mdx +1 -1
  153. package/.docs/raw/reference/core/getMCPServer.mdx +1 -1
  154. package/.docs/raw/reference/core/getMCPServerById.mdx +1 -1
  155. package/.docs/raw/reference/core/getMemory.mdx +2 -2
  156. package/.docs/raw/reference/core/getServer.mdx +1 -1
  157. package/.docs/raw/reference/core/getStorage.mdx +2 -2
  158. package/.docs/raw/reference/core/getStoredAgentById.mdx +3 -3
  159. package/.docs/raw/reference/core/getTelemetry.mdx +1 -1
  160. package/.docs/raw/reference/core/getVector.mdx +1 -1
  161. package/.docs/raw/reference/core/getWorkflow.mdx +1 -1
  162. package/.docs/raw/reference/core/listAgents.mdx +1 -1
  163. package/.docs/raw/reference/core/listLogs.mdx +1 -1
  164. package/.docs/raw/reference/core/listLogsByRunId.mdx +1 -1
  165. package/.docs/raw/reference/core/listMCPServers.mdx +1 -1
  166. package/.docs/raw/reference/core/listMemory.mdx +2 -2
  167. package/.docs/raw/reference/core/listStoredAgents.mdx +4 -4
  168. package/.docs/raw/reference/core/listVectors.mdx +1 -1
  169. package/.docs/raw/reference/core/listWorkflows.mdx +1 -1
  170. package/.docs/raw/reference/core/setLogger.mdx +1 -1
  171. package/.docs/raw/reference/core/setStorage.mdx +2 -2
  172. package/.docs/raw/reference/core/setTelemetry.mdx +1 -1
  173. package/.docs/raw/reference/deployer/cloudflare.mdx +1 -2
  174. package/.docs/raw/reference/deployer/deployer.mdx +0 -1
  175. package/.docs/raw/reference/deployer/netlify.mdx +1 -1
  176. package/.docs/raw/reference/deployer/vercel.mdx +2 -4
  177. package/.docs/raw/reference/evals/answer-relevancy.mdx +1 -1
  178. package/.docs/raw/reference/evals/answer-similarity.mdx +1 -1
  179. package/.docs/raw/reference/evals/bias.mdx +1 -1
  180. package/.docs/raw/reference/evals/completeness.mdx +1 -1
  181. package/.docs/raw/reference/evals/content-similarity.mdx +1 -1
  182. package/.docs/raw/reference/evals/context-precision.mdx +1 -1
  183. package/.docs/raw/reference/evals/faithfulness.mdx +1 -1
  184. package/.docs/raw/reference/evals/hallucination.mdx +1 -1
  185. package/.docs/raw/reference/evals/keyword-coverage.mdx +1 -1
  186. package/.docs/raw/reference/evals/prompt-alignment.mdx +7 -7
  187. package/.docs/raw/reference/evals/textual-difference.mdx +1 -1
  188. package/.docs/raw/reference/evals/tone-consistency.mdx +1 -1
  189. package/.docs/raw/reference/evals/tool-call-accuracy.mdx +10 -10
  190. package/.docs/raw/reference/evals/toxicity.mdx +1 -1
  191. package/.docs/raw/reference/logging/pino-logger.mdx +7 -8
  192. package/.docs/raw/reference/memory/createThread.mdx +2 -2
  193. package/.docs/raw/reference/memory/deleteMessages.mdx +2 -2
  194. package/.docs/raw/reference/memory/listThreadsByResourceId.mdx +2 -2
  195. package/.docs/raw/reference/memory/memory-class.mdx +3 -3
  196. package/.docs/raw/reference/memory/query.mdx +2 -2
  197. package/.docs/raw/reference/memory/recall.mdx +2 -2
  198. package/.docs/raw/reference/observability/tracing/exporters/langfuse.mdx +1 -1
  199. package/.docs/raw/reference/processors/batch-parts-processor.mdx +2 -2
  200. package/.docs/raw/reference/processors/language-detector.mdx +2 -2
  201. package/.docs/raw/reference/processors/message-history-processor.mdx +2 -2
  202. package/.docs/raw/reference/processors/moderation-processor.mdx +3 -3
  203. package/.docs/raw/reference/processors/pii-detector.mdx +3 -3
  204. package/.docs/raw/reference/processors/processor-interface.mdx +13 -13
  205. package/.docs/raw/reference/processors/prompt-injection-detector.mdx +2 -2
  206. package/.docs/raw/reference/processors/semantic-recall-processor.mdx +2 -2
  207. package/.docs/raw/reference/processors/system-prompt-scrubber.mdx +2 -2
  208. package/.docs/raw/reference/processors/token-limiter-processor.mdx +40 -19
  209. package/.docs/raw/reference/processors/tool-call-filter.mdx +3 -3
  210. package/.docs/raw/reference/processors/unicode-normalizer.mdx +2 -2
  211. package/.docs/raw/reference/processors/working-memory-processor.mdx +3 -3
  212. package/.docs/raw/reference/rag/chunk.mdx +1 -1
  213. package/.docs/raw/reference/rag/extract-params.mdx +2 -2
  214. package/.docs/raw/reference/rag/metadata-filters.mdx +7 -7
  215. package/.docs/raw/reference/server/create-route.mdx +13 -13
  216. package/.docs/raw/reference/server/express-adapter.mdx +6 -7
  217. package/.docs/raw/reference/server/hono-adapter.mdx +6 -7
  218. package/.docs/raw/reference/server/mastra-server.mdx +20 -20
  219. package/.docs/raw/reference/storage/cloudflare-d1.mdx +7 -5
  220. package/.docs/raw/reference/storage/cloudflare.mdx +2 -2
  221. package/.docs/raw/reference/storage/convex.mdx +6 -6
  222. package/.docs/raw/reference/storage/dynamodb.mdx +4 -4
  223. package/.docs/raw/reference/storage/lance.mdx +6 -5
  224. package/.docs/raw/reference/storage/libsql.mdx +72 -54
  225. package/.docs/raw/reference/storage/mongodb.mdx +84 -9
  226. package/.docs/raw/reference/storage/mssql.mdx +8 -6
  227. package/.docs/raw/{memory → reference}/storage/overview.mdx +12 -110
  228. package/.docs/raw/reference/storage/postgresql.mdx +82 -9
  229. package/.docs/raw/reference/storage/upstash.mdx +74 -2
  230. package/.docs/raw/reference/streaming/agents/stream.mdx +5 -5
  231. package/.docs/raw/reference/streaming/agents/streamLegacy.mdx +2 -2
  232. package/.docs/raw/reference/streaming/workflows/observeStream.mdx +1 -1
  233. package/.docs/raw/reference/streaming/workflows/resumeStream.mdx +1 -1
  234. package/.docs/raw/reference/streaming/workflows/stream.mdx +2 -2
  235. package/.docs/raw/reference/streaming/workflows/timeTravelStream.mdx +4 -4
  236. package/.docs/raw/reference/templates/overview.mdx +1 -2
  237. package/.docs/raw/reference/tools/create-tool.mdx +1 -4
  238. package/.docs/raw/reference/tools/vector-query-tool.mdx +1 -1
  239. package/.docs/raw/reference/vectors/astra.mdx +3 -3
  240. package/.docs/raw/reference/vectors/chroma.mdx +3 -3
  241. package/.docs/raw/reference/vectors/convex.mdx +12 -12
  242. package/.docs/raw/reference/vectors/couchbase.mdx +5 -5
  243. package/.docs/raw/reference/vectors/duckdb.mdx +10 -10
  244. package/.docs/raw/reference/vectors/elasticsearch.mdx +4 -4
  245. package/.docs/raw/reference/vectors/lance.mdx +4 -4
  246. package/.docs/raw/reference/vectors/libsql.mdx +61 -11
  247. package/.docs/raw/reference/vectors/mongodb.mdx +58 -5
  248. package/.docs/raw/reference/vectors/pg.mdx +53 -6
  249. package/.docs/raw/reference/vectors/pinecone.mdx +3 -3
  250. package/.docs/raw/reference/vectors/qdrant.mdx +3 -3
  251. package/.docs/raw/reference/vectors/s3vectors.mdx +6 -6
  252. package/.docs/raw/reference/vectors/turbopuffer.mdx +4 -4
  253. package/.docs/raw/reference/vectors/upstash.mdx +55 -6
  254. package/.docs/raw/reference/vectors/vectorize.mdx +3 -3
  255. package/.docs/raw/reference/workflows/run-methods/cancel.mdx +2 -2
  256. package/.docs/raw/reference/workflows/run-methods/restart.mdx +1 -3
  257. package/.docs/raw/reference/workflows/run-methods/resume.mdx +2 -2
  258. package/.docs/raw/reference/workflows/run-methods/start.mdx +2 -2
  259. package/.docs/raw/reference/workflows/run-methods/startAsync.mdx +2 -2
  260. package/.docs/raw/reference/workflows/run-methods/timeTravel.mdx +5 -5
  261. package/.docs/raw/reference/workflows/run.mdx +1 -1
  262. package/.docs/raw/reference/workflows/step.mdx +3 -3
  263. package/.docs/raw/reference/workflows/workflow-methods/branch.mdx +1 -1
  264. package/.docs/raw/reference/workflows/workflow-methods/commit.mdx +1 -1
  265. package/.docs/raw/reference/workflows/workflow-methods/create-run.mdx +3 -3
  266. package/.docs/raw/reference/workflows/workflow-methods/dountil.mdx +1 -1
  267. package/.docs/raw/reference/workflows/workflow-methods/dowhile.mdx +1 -1
  268. package/.docs/raw/reference/workflows/workflow-methods/foreach.mdx +6 -6
  269. package/.docs/raw/reference/workflows/workflow-methods/map.mdx +7 -7
  270. package/.docs/raw/reference/workflows/workflow-methods/parallel.mdx +1 -1
  271. package/.docs/raw/reference/workflows/workflow-methods/sendEvent.mdx +2 -2
  272. package/.docs/raw/reference/workflows/workflow-methods/sleep.mdx +2 -2
  273. package/.docs/raw/reference/workflows/workflow-methods/sleepUntil.mdx +2 -2
  274. package/.docs/raw/reference/workflows/workflow-methods/then.mdx +1 -1
  275. package/.docs/raw/reference/workflows/workflow-methods/waitForEvent.mdx +2 -2
  276. package/.docs/raw/reference/workflows/workflow.mdx +3 -3
  277. package/.docs/raw/server/auth/auth0.mdx +20 -14
  278. package/.docs/raw/server/auth/clerk.mdx +16 -9
  279. package/.docs/raw/server/auth/firebase.mdx +21 -15
  280. package/.docs/raw/server/auth/jwt.mdx +14 -7
  281. package/.docs/raw/server/auth/supabase.mdx +16 -9
  282. package/.docs/raw/server/auth/workos.mdx +19 -13
  283. package/.docs/raw/server/custom-adapters.mdx +10 -10
  284. package/.docs/raw/server/custom-api-routes.mdx +2 -4
  285. package/.docs/raw/server/mastra-client.mdx +24 -13
  286. package/.docs/raw/server/mastra-server.mdx +3 -3
  287. package/.docs/raw/server/middleware.mdx +7 -7
  288. package/.docs/raw/server/request-context.mdx +31 -30
  289. package/.docs/raw/server/server-adapters.mdx +6 -6
  290. package/.docs/raw/streaming/events.mdx +14 -7
  291. package/.docs/raw/streaming/overview.mdx +21 -10
  292. package/.docs/raw/streaming/tool-streaming.mdx +6 -6
  293. package/.docs/raw/streaming/workflow-streaming.mdx +6 -8
  294. package/.docs/raw/tools-mcp/advanced-usage.mdx +2 -2
  295. package/.docs/raw/tools-mcp/mcp-overview.mdx +31 -12
  296. package/.docs/raw/tools-mcp/overview.mdx +9 -10
  297. package/.docs/raw/voice/overview.mdx +2 -2
  298. package/.docs/raw/workflows/agents-and-tools.mdx +28 -19
  299. package/.docs/raw/workflows/control-flow.mdx +27 -40
  300. package/.docs/raw/workflows/error-handling.mdx +15 -22
  301. package/.docs/raw/workflows/human-in-the-loop.mdx +6 -7
  302. package/.docs/raw/workflows/input-data-mapping.mdx +7 -7
  303. package/.docs/raw/workflows/overview.mdx +34 -23
  304. package/.docs/raw/workflows/snapshots.mdx +16 -45
  305. package/.docs/raw/workflows/suspend-and-resume.mdx +7 -7
  306. package/.docs/raw/workflows/time-travel.mdx +16 -16
  307. package/.docs/raw/workflows/workflow-state.mdx +5 -8
  308. package/CHANGELOG.md +16 -0
  309. package/dist/logger.d.ts +3 -0
  310. package/dist/logger.d.ts.map +1 -1
  311. package/dist/stdio.js +53 -0
  312. package/package.json +3 -3
  313. package/.docs/raw/mastra-cloud/dashboard.mdx +0 -96
  314. package/.docs/raw/mastra-cloud/setting-up.mdx +0 -102
  315. package/.docs/raw/memory/conversation-history.mdx +0 -24
  316. package/.docs/raw/memory/storage/memory-with-libsql.mdx +0 -140
  317. package/.docs/raw/memory/storage/memory-with-mongodb.mdx +0 -150
  318. package/.docs/raw/memory/storage/memory-with-pg.mdx +0 -138
  319. package/.docs/raw/memory/storage/memory-with-upstash.mdx +0 -146
  320. package/.docs/raw/memory/threads-and-resources.mdx +0 -95
  321. package/.docs/raw/workflows/inngest-workflow.mdx +0 -363
@@ -1,600 +1,441 @@
1
1
  ---
2
- title: "Integrate Mastra in your Astro project | Frameworks"
3
- description: A step-by-step guide to integrating Mastra with Astro.
2
+ title: "Astro | Frameworks"
3
+ description: "Get started with Mastra and Astro"
4
4
  ---
5
5
 
6
6
  import Tabs from "@theme/Tabs";
7
7
  import TabItem from "@theme/TabItem";
8
- import Steps from "@site/src/components/Steps";
9
- import StepItem from "@site/src/components/StepItem";
10
8
 
11
9
  # Integrate Mastra in your Astro project
12
10
 
13
- Mastra integrates with Astro, making it easy to:
11
+ In this guide, you'll build a tool-calling AI agent using Mastra, then connect it to Astro by importing and calling the agent directly from your routes.
14
12
 
15
- - Build flexible APIs to serve AI-powered features
16
- - Simplify deployment with a unified codebase for frontend and backend
17
- - Take advantage of Astro's built-in [Actions](https://docs.astro.build/en/guides/actions/) or [Server Endpoints](https://docs.astro.build/en/guides/endpoints/#server-endpoints-api-routes) for efficient server-client workflows
13
+ You'll use [AI SDK UI](https://ai-sdk.dev/docs/ai-sdk-ui/overview) and [AI Elements](https://ai-sdk.dev/elements) to create a beautiful, interactive chat experience.
18
14
 
19
- Use this guide to scaffold and integrate Mastra with your Astro project.
15
+ :::note
20
16
 
21
- <Tabs>
22
- <TabItem value="actions" label="Actions">
23
-
24
- :::warning
25
-
26
- This guide assumes you're using Astro's Actions with React and the Vercel adapter.
17
+ While this guide shows you how to use Astro with React and full server-side rendering (SSR), there are many ways to use Astro with Mastra. You can [opt-in to SSR](https://docs.astro.build/en/guides/on-demand-rendering/#enabling-on-demand-rendering) on a per-file basis and use other frameworks like Svelte, Vue, Solid, or Preact. You can use Astro to build out a chat interface and call endpoints [natively in Astro](https://docs.astro.build/en/recipes/call-endpoints/).
27
18
 
28
19
  :::
29
20
 
30
- <Steps>
21
+ ## Before you begin
31
22
 
32
- <StepItem>
23
+ - You'll need an API key from a supported [model provider](/models/v1). If you don't have a preference, use [OpenAI](/models/v1/providers/openai).
24
+ - Install Node.js `v22.13.0` or later
33
25
 
34
- Install the required packages:
26
+ ## Create a new Astro app (optional)
35
27
 
36
- <Tabs>
37
- <TabItem value="npm" label="npm">
28
+ If you already have an Astro app, skip to the next step. Your Astro app should be setup like this:
38
29
 
39
- ```bash copy
40
- npm install mastra@beta @mastra/core@beta @mastra/libsql@beta @ai-sdk/openai
41
- ```
30
+ - Use SSR (`output: "server"` in `astro.config.mjs`)
31
+ - Use the [React integration](https://docs.astro.build/en/guides/integrations-guide/react/)
32
+ - Tailwind installed
42
33
 
43
- </TabItem>
44
- <TabItem value="yarn" label="yarn">
34
+ To support [on-demand rendering](https://docs.astro.build/en/guides/on-demand-rendering/) this guide will use the [Node.js adapter](https://docs.astro.build/en/guides/integrations-guide/node/) but any of the supported server adapters will work.
45
35
 
46
- ```bash copy
47
- yarn add mastra@beta @mastra/core@beta @mastra/libsql@beta @ai-sdk/openai
36
+ <Tabs groupId="pm">
37
+ <TabItem value="npm" label="npm">
38
+ ```bash
39
+ npm create astro@latest mastra-astro -- --add node --add react --add tailwind --install --skip-houston --template minimal --git
48
40
  ```
49
-
50
41
  </TabItem>
51
42
  <TabItem value="pnpm" label="pnpm">
52
-
53
- ```bash copy
54
- pnpm add mastra@beta @mastra/core@beta @mastra/libsql@beta @ai-sdk/openai
43
+ ```bash
44
+ pnpm create astro@latest mastra-astro --add node --add react --add tailwind --install --skip-houston --template minimal --git
45
+ ```
46
+ </TabItem>
47
+ <TabItem value="yarn" label="yarn">
48
+ ```bash
49
+ yarn create astro@latest mastra-astro --add node --add react --add tailwind --install --skip-houston --template minimal --git
55
50
  ```
56
-
57
51
  </TabItem>
58
52
  <TabItem value="bun" label="bun">
59
-
60
- ```bash copy
61
- bun add mastra@beta @mastra/core@beta @mastra/libsql@beta @ai-sdk/openai
53
+ ```bash
54
+ bun create astro@latest mastra-astro --add node --add react --add tailwind --install --skip-houston --template minimal --git
62
55
  ```
63
-
64
56
  </TabItem>
65
57
  </Tabs>
66
58
 
67
- </StepItem>
68
-
69
- <StepItem>
70
-
71
- To integrate Mastra into your project, you have two options:
59
+ This creates a project called `mastra-astro`, but you can replace it with any name you want.
72
60
 
73
- - Use the One-Liner
61
+ `cd` into your project and edit the `astro.config.mjs` file to set the [`output` setting](https://docs.astro.build/en/reference/configuration-reference/#output) to `"server"`:
74
62
 
75
- Run the following command to quickly scaffold the default Weather agent with sensible defaults:
63
+ ```js title="astro.config.mjs {10}
64
+ // @ts-check
65
+ import { defineConfig } from 'astro/config';
76
66
 
77
- ```bash copy
78
- npx mastra@beta init --default
79
- ```
67
+ import node from '@astrojs/node';
68
+ import react from '@astrojs/react';
69
+ import tailwindcss from '@tailwindcss/vite';
80
70
 
81
- > See [mastra init](/reference/v1/cli/create-mastra) for more information.
82
-
83
- - Use the Interactive CLI
84
-
85
- If you prefer to customize the setup, run the `init` command and choose from the options when prompted:
86
-
87
- ```bash copy
88
- npx mastra@beta init
89
- ```
71
+ // https://astro.build/config
72
+ export default defineConfig({
73
+ output: 'server',
74
+ adapter: node({
75
+ mode: 'standalone'
76
+ }),
90
77
 
91
- Add the `dev` and `build` scripts to `package.json`:
78
+ integrations: [react()],
92
79
 
93
- ```json title="package.json"
94
- {
95
- "scripts": {
96
- ...
97
- "dev:mastra": "mastra dev",
98
- "build:mastra": "mastra build"
80
+ vite: {
81
+ plugins: [tailwindcss()]
99
82
  }
100
- }
83
+ });
101
84
  ```
102
85
 
103
- </StepItem>
104
-
105
- <StepItem>
106
-
107
- Modify the `tsconfig.json` file in your project root:
86
+ Lastly, edit the `tsconfig.json` to resolve paths:
108
87
 
109
- ```json title="tsconfig.json"
88
+ ```ts title="tsconfig.json"
110
89
  {
111
- ...
112
- "exclude": ["dist", ".mastra"]
90
+ "compilerOptions": {
91
+ // ...
92
+ "baseUrl": ".",
93
+ "paths": {
94
+ "@/*": [
95
+ "./src/*"
96
+ ]
97
+ }
98
+ // ...
99
+ }
113
100
  }
114
101
  ```
115
102
 
116
- </StepItem>
117
-
118
- <StepItem>
119
-
120
- Setup your API key in a `.env` file:
121
-
122
- ```bash title=".env" copy
123
- OPENAI_API_KEY=<your-api-key>
124
- ```
125
-
126
- </StepItem>
127
-
128
- <StepItem>
129
-
130
- Add `.mastra` and `.vercel` to your `.gitignore` file:
131
-
132
- ```bash title=".gitignore" copy
133
- .mastra
134
- .vercel
135
- ```
136
-
137
- </StepItem>
138
-
139
- <StepItem>
140
-
141
- Astro uses Vite, which accesses environment variables via `import.meta.env` rather than `process.env`. As a result, the model constructor must explicitly receive the `apiKey` from the Vite environment like this:
142
-
143
- ```typescript title="src/mastra/agents/weather-agent.ts"
144
- import { createOpenAI } from "@ai-sdk/openai";
145
-
146
- const openai = createOpenAI({
147
- apiKey: import.meta.env?.OPENAI_API_KEY,
148
- compatibility: "strict"
149
- });
150
- ```
151
-
152
- > More configuration details are available in the AI SDK docs. See [Provider Instance](https://ai-sdk.dev/providers/ai-sdk-providers/openai#provider-instance) for more information.
153
-
154
- </StepItem>
155
-
156
- <StepItem>
103
+ ## Initialize Mastra
157
104
 
158
- Start the Mastra Dev Server to expose your agents as REST endpoints:
105
+ Run [`mastra init`](/reference/v1/cli/mastra#mastra-init). When prompted, choose a provider (e.g. OpenAI) and enter your key:
159
106
 
160
- <Tabs>
107
+ <Tabs groupId="pm">
161
108
  <TabItem value="npm" label="npm">
162
109
 
163
- ```bash copy
164
- npm run dev:mastra
110
+ ```bash
111
+ npx mastra@beta init
165
112
  ```
166
113
 
167
114
  </TabItem>
168
- <TabItem value="cli" label="CLI">
115
+ <TabItem value="pnpm" label="pnpm">
169
116
 
170
- ```bash copy
171
- mastra dev:mastra
117
+ ```bash
118
+ pnpm dlx mastra@beta init
172
119
  ```
173
120
 
174
121
  </TabItem>
175
- </Tabs>
176
-
177
- > Once running, your agents are available locally. See [Local Development Environment](/docs/v1/getting-started/studio) for more information.
178
-
179
- </StepItem>
180
-
181
- <StepItem>
182
-
183
- With the Mastra Dev Server running, you can start your Astro site in the usual way.
184
-
185
- </StepItem>
186
-
187
- <StepItem>
188
-
189
- Create an `actions` directory:
190
-
191
- ```bash copy
192
- mkdir src/actions
193
- ```
194
-
195
- </StepItem>
196
-
197
- <StepItem>
198
-
199
- Create a new Action, and add the example code:
200
-
201
- ```bash copy
202
- touch src/actions/index.ts
203
- ```
204
-
205
- ```typescript title="src/actions/index.ts" showLineNumbers copy
206
- import { defineAction } from "astro:actions";
207
- import { z } from "astro:schema";
208
-
209
- import { mastra } from "../mastra";
210
-
211
- export const server = {
212
- getWeatherInfo: defineAction({
213
- input: z.object({
214
- city: z.string(),
215
- }),
216
- handler: async (input) => {
217
- const city = inputData.city;
218
- const agent = mastra.getAgent("weatherAgent");
219
-
220
- const result = await agent.generate(
221
- `What's the weather like in ${city}?`,
222
- );
223
-
224
- return result.text;
225
- },
226
- }),
227
- };
228
- ```
229
-
230
- </StepItem>
231
-
232
- <StepItem>
233
-
234
- Create a new Form component, and add the example code:
235
-
236
- ```bash copy
237
- touch src/components/form.tsx
238
- ```
239
-
240
- ```typescript title="src/components/form.tsx" showLineNumbers copy
241
- import { actions } from "astro:actions";
242
- import { useState } from "react";
243
-
244
- export const Form = () => {
245
- const [result, setResult] = useState<string | null>(null);
246
-
247
- async function handleSubmit(formData: FormData) {
248
- const city = formData.get("city")!.toString();
249
- const { data } = await actions.getWeatherInfo({ city });
250
-
251
- setResult(data || null);
252
- }
253
-
254
- return (
255
- <>
256
- <form action={handleSubmit}>
257
- <input name="city" placeholder="Enter city" required />
258
- <button type="submit">Get Weather</button>
259
- </form>
260
- {result && <pre>{result}</pre>}
261
- </>
262
- );
263
- };
264
- ```
265
-
266
- </StepItem>
267
-
268
- <StepItem>
269
-
270
- Create a new Page, and add the example code:
271
-
272
- ```bash copy
273
- touch src/pages/test.astro
274
- ```
275
-
276
- ```astro title="src/pages/test.astro" showLineNumbers copy
277
- ---
278
- import { Form } from '../components/form'
279
- ---
122
+ <TabItem value="yarn" label="yarn">
280
123
 
281
- <h1>Test</h1>
282
- <Form client:load />
124
+ ```bash
125
+ yarn dlx mastra@beta init
283
126
  ```
284
127
 
285
- > You can now navigate to `/test` in your browser to try it out.
286
-
287
- Submitting **London** as the city would return a result similar to:
288
-
289
- ```plaintext
290
- Agent response: The current weather in London is as follows:
291
-
292
- - **Temperature:** 12.9°C (Feels like 9.7°C)
293
- - **Humidity:** 63%
294
- - **Wind Speed:** 14.7 km/h
295
- - **Wind Gusts:** 32.4 km/h
296
- - **Conditions:** Overcast
128
+ </TabItem>
129
+ <TabItem value="bun" label="bun">
297
130
 
298
- Let me know if you need more information!
131
+ ```bash
132
+ bunx mastra@beta init
299
133
  ```
300
134
 
301
- </StepItem>
302
-
303
- </Steps>
304
- </TabItem>
305
-
306
- <TabItem value="server-endpoints" label="Server Endpoints">
307
-
308
- :::warning
309
-
310
- This guide assumes you're using Astro's Endpoints with React and the Vercel adapter, and your output is set to server.
311
-
312
- :::
313
-
314
- ## Prerequisites
135
+ </TabItem>
136
+ </Tabs>
315
137
 
316
- Before proceeding, ensure your Astro project is configured as follows:
138
+ This creates a `src/mastra` folder with an example weather agent and the following files:
317
139
 
318
- - Astro React integration: [@astrojs/react](https://docs.astro.build/en/guides/integrations-guide/react/)
319
- - Vercel adapter: [@astrojs/vercel](https://docs.astro.build/en/guides/integrations-guide/vercel/)
320
- - `astro.config.mjs` is set to `output: "server"`
140
+ - `index.ts` - Mastra config, including memory
141
+ - `tools/weather-tool.ts` - a tool to fetch weather for a given location
142
+ - `agents/weather-agent.ts`- a weather agent with a prompt that uses the tool
321
143
 
322
- <Steps>
144
+ You'll call `weather-agent.ts` from your Astro routes in the next steps.
323
145
 
324
- <StepItem>
146
+ ## Install AI SDK UI & AI Elements
325
147
 
326
- Install the required packages:
148
+ Install AI SDK UI along with the Mastra adapter:
327
149
 
328
- <Tabs>
150
+ <Tabs groupId="pm">
329
151
  <TabItem value="npm" label="npm">
330
152
 
331
- ```bash copy
332
- npm install mastra@beta @mastra/core@beta @mastra/libsql@beta @ai-sdk/openai
153
+ ```bash
154
+ npm install @mastra/ai-sdk@beta @ai-sdk/react ai
333
155
  ```
334
156
 
335
157
  </TabItem>
336
- <TabItem value="yarn" label="yarn">
158
+ <TabItem value="pnpm" label="pnpm">
337
159
 
338
- ```bash copy
339
- yarn add mastra@beta @mastra/core@beta @mastra/libsql@beta @ai-sdk/openai
160
+ ```bash
161
+ pnpm add @mastra/ai-sdk@beta @ai-sdk/react ai
340
162
  ```
341
163
 
342
164
  </TabItem>
343
- <TabItem value="pnpm" label="pnpm">
165
+ <TabItem value="yarn" label="yarn">
344
166
 
345
- ```bash copy
346
- pnpm add mastra@beta @mastra/core@beta @mastra/libsql@beta @ai-sdk/openai
167
+ ```bash
168
+ yarn add @mastra/ai-sdk@beta @ai-sdk/react ai
347
169
  ```
348
170
 
349
171
  </TabItem>
350
172
  <TabItem value="bun" label="bun">
351
173
 
352
- ```bash copy
353
- bun add mastra@beta @mastra/core@beta @mastra/libsql@beta @ai-sdk/openai
174
+ ```bash
175
+ bun add @mastra/ai-sdk@beta @ai-sdk/react ai
354
176
  ```
355
177
 
356
178
  </TabItem>
357
179
  </Tabs>
358
180
 
359
- </StepItem>
360
-
361
- <StepItem>
362
-
363
- To integrate Mastra into your project, you have two options:
364
-
365
- - Use the One-Liner
366
-
367
- Run the following command to quickly scaffold the default Weather agent with sensible defaults:
368
-
369
- ```bash copy
370
- npx mastra@beta init --default
371
- ```
372
-
373
- > See [mastra init](/reference/v1/cli/create-mastra) for more information.
374
-
375
- - Use the Interactive CLI
376
-
377
- If you prefer to customize the setup, run the `init` command and choose from the options when prompted:
378
-
379
- ```bash copy
380
- npx mastra@beta init
381
- ```
382
-
383
- Add the `dev` and `build` scripts to `package.json`:
384
-
385
- ```json title="package.json"
386
- {
387
- "scripts": {
388
- ...
389
- "dev:mastra": "mastra dev",
390
- "build:mastra": "mastra build"
391
- }
392
- }
393
- ```
394
-
395
- </StepItem>
396
-
397
- <StepItem>
398
-
399
- Modify the `tsconfig.json` file in your project root:
400
-
401
- ```json title="tsconfig.json"
402
- {
403
- ...
404
- "exclude": ["dist", ".mastra"]
405
- }
406
- ```
407
-
408
- </StepItem>
409
-
410
- <StepItem>
411
-
412
- Setup your API key in a `.env` file:
413
-
414
- ```bash title=".env" copy
415
- OPENAI_API_KEY=<your-api-key>
416
- ```
181
+ Next, initialize AI Elements. When prompted, choose the default options:
417
182
 
418
- </StepItem>
419
-
420
- <StepItem>
421
-
422
- Add `.mastra` to your `.gitignore` file:
183
+ <Tabs groupId="pm">
184
+ <TabItem value="npm" label="npm">
423
185
 
424
- ```bash title=".gitignore" copy
425
- .mastra
426
- .vercel
186
+ ```bash
187
+ npx ai-elements@latest
427
188
  ```
428
189
 
429
- </StepItem>
430
-
431
- <StepItem>
432
-
433
- Astro uses Vite, which accesses environment variables via `import.meta.env` rather than `process.env`. As a result, the model constructor must explicitly receive the `apiKey` from the Vite environment like this:
434
-
435
- ```typescript title="src/mastra/agents/weather-agent.ts"
436
- import { createOpenAI } from "@ai-sdk/openai";
190
+ </TabItem>
191
+ <TabItem value="pnpm" label="pnpm">
437
192
 
438
- const openai = createOpenAI({
439
- apiKey: import.meta.env?.OPENAI_API_KEY,
440
- compatibility: "strict"
441
- });
193
+ ```bash
194
+ pnpm dlx ai-elements@latest
442
195
  ```
443
196
 
444
- > More configuration details are available in the AI SDK docs. See [Provider Instance](https://ai-sdk.dev/providers/ai-sdk-providers/openai#provider-instance) for more information.
445
-
446
- </StepItem>
447
-
448
- <StepItem>
449
-
450
- Start the Mastra Dev Server to expose your agents as REST endpoints:
451
-
452
- <Tabs>
453
- <TabItem value="npm" label="npm">
197
+ </TabItem>
198
+ <TabItem value="yarn" label="yarn">
454
199
 
455
- ```bash copy
456
- npm run dev:mastra
200
+ ```bash
201
+ yarn dlx ai-elements@latest
457
202
  ```
458
203
 
459
204
  </TabItem>
460
- <TabItem value="cli" label="CLI">
205
+ <TabItem value="bun" label="bun">
461
206
 
462
- ```bash copy
463
- mastra dev:mastra
207
+ ```bash
208
+ bunx ai-elements@latest
464
209
  ```
465
210
 
466
211
  </TabItem>
467
212
  </Tabs>
468
213
 
469
- > Once running, your agents are available locally. See [Local Development Environment](/docs/v1/getting-started/studio) for more information.
214
+ This downloads the entire AI Elements UI component library into a `@/components/ai-elements` folder.
470
215
 
471
- </StepItem>
216
+ ## Create a chat route
472
217
 
473
- <StepItem>
218
+ Create `src/pages/api/chat.ts`:
474
219
 
475
- With the Mastra Dev Server running, you can start your Astro site in the usual way.
476
-
477
- </StepItem>
478
-
479
- <StepItem>
480
-
481
- Create an `api` directory:
220
+ ```ts title="src/pages/api/chat.ts"
221
+ import type { APIRoute } from "astro";
222
+ import { handleChatStream } from '@mastra/ai-sdk';
223
+ import { toAISdkV5Messages } from '@mastra/ai-sdk/ui'
224
+ import { createUIMessageStreamResponse } from 'ai';
225
+ import { mastra } from '@/mastra';
482
226
 
483
- ```bash copy
484
- mkdir src/pages/api
485
- ```
227
+ const THREAD_ID = 'example-user-id';
228
+ const RESOURCE_ID = 'weather-chat';
486
229
 
487
- </StepItem>
230
+ export const POST: APIRoute = async ({ request }) => {
231
+ const params = await request.json();
232
+ const stream = await handleChatStream({
233
+ mastra,
234
+ agentId: 'weather-agent',
235
+ params: {
236
+ ...params,
237
+ memory: {
238
+ ...params.memory,
239
+ thread: THREAD_ID,
240
+ resource: RESOURCE_ID,
241
+ }
242
+ }
243
+ })
244
+
245
+ return createUIMessageStreamResponse({ stream })
246
+ }
488
247
 
489
- <StepItem>
248
+ export const GET: APIRoute = async () => {
249
+ const memory = await mastra.getAgentById('weather-agent').getMemory()
250
+ let response = null
251
+
252
+ try {
253
+ response = await memory?.recall({
254
+ threadId: THREAD_ID,
255
+ resourceId: RESOURCE_ID,
256
+ })
257
+ } catch {
258
+ console.log('No previous messages found.')
259
+ }
490
260
 
491
- Create a new Endpoint, and add the example code:
261
+ const uiMessages = toAISdkV5Messages(response?.messages || []);
492
262
 
493
- ```bash copy
494
- touch src/pages/api/test.ts
263
+ return Response.json(uiMessages)
264
+ }
495
265
  ```
496
266
 
497
- ```typescript title="src/pages/api/test.ts" showLineNumbers copy
498
- import type { APIRoute } from "astro";
267
+ The `POST` route accepts a prompt and streams the agent's response back in AI SDK format, while the `GET` route fetches message history from memory so the UI can be hydrated when the client reloads.
499
268
 
500
- import { mastra } from "../../mastra";
269
+ ## Create a chat component
501
270
 
502
- export const POST: APIRoute = async ({ request }) => {
503
- const { city } = await new Response(request.body).json();
504
- const agent = mastra.getAgent("weatherAgent");
271
+ Create `src/components/chat.tsx`:
505
272
 
506
- const result = await agent.generate(`What's the weather like in ${city}?`);
273
+ ```tsx title="src/components/chat.tsx"
274
+ import '@/styles/global.css';
275
+ import { useEffect, useState } from 'react';
276
+ import { DefaultChatTransport, type ToolUIPart } from 'ai';
277
+ import { useChat } from '@ai-sdk/react';
507
278
 
508
- return new Response(JSON.stringify(result.text));
509
- };
510
- ```
511
-
512
- </StepItem>
279
+ import {
280
+ PromptInput,
281
+ PromptInputBody,
282
+ PromptInputTextarea,
283
+ } from '@/components/ai-elements/prompt-input';
513
284
 
514
- <StepItem>
285
+ import {
286
+ Conversation,
287
+ ConversationContent,
288
+ ConversationScrollButton,
289
+ } from '@/components/ai-elements/conversation';
515
290
 
516
- Create a new Form component, and add the example code:
291
+ import { Message, MessageContent, MessageResponse } from '@/components/ai-elements/message';
517
292
 
518
- ```bash copy
519
- touch src/components/form.tsx
520
- ```
293
+ import {
294
+ Tool,
295
+ ToolHeader,
296
+ ToolContent,
297
+ ToolInput,
298
+ ToolOutput,
299
+ } from '@/components/ai-elements/tool';
521
300
 
522
- ```typescript title="src/components/form.tsx" showLineNumbers copy
523
- import { useState } from "react";
524
301
 
525
- export const Form = () => {
526
- const [result, setResult] = useState<string | null>(null);
302
+ function Chat() {
303
+ const [input, setInput] = useState<string>('');
527
304
 
528
- async function handleSubmit(event: React.FormEvent<HTMLFormElement>) {
529
- event.preventDefault();
305
+ const { messages, setMessages, sendMessage, status } = useChat({
306
+ transport: new DefaultChatTransport({
307
+ api: '/api/chat',
308
+ }),
309
+ });
530
310
 
531
- const formData = new FormData(event.currentTarget);
532
- const city = formData.get("city")?.toString();
311
+ useEffect(() => {
312
+ const fetchMessages = async () => {
313
+ const res = await fetch('/api/chat');
314
+ const data = await res.json();
315
+ setMessages([...data]);
316
+ };
317
+ fetchMessages();
318
+ }, [setMessages]);
533
319
 
534
- const response = await fetch("/api/test", {
535
- method: "POST",
536
- headers: { "Content-Type": "application/json" },
537
- body: JSON.stringify({ city })
538
- });
320
+ const handleSubmit = async () => {
321
+ if (!input.trim()) return;
539
322
 
540
- const text = await response.json();
541
- setResult(text);
542
- }
323
+ sendMessage({ text: input });
324
+ setInput('');
325
+ };
543
326
 
544
327
  return (
545
- <>
546
- <form onSubmit={handleSubmit}>
547
- <input name="city" placeholder="Enter city" required />
548
- <button type="submit">Get Weather</button>
549
- </form>
550
- {result && <pre>{result}</pre>}
551
- </>
328
+ <div className="w-full p-6 relative size-full h-screen">
329
+ <div className="flex flex-col h-full">
330
+ <Conversation className="h-full">
331
+ <ConversationContent>
332
+ {messages.map((message) => (
333
+ <div key={message.id}>
334
+ {message.parts?.map((part, i) => {
335
+ if (part.type === 'text') {
336
+ return (
337
+ <Message
338
+ key={`${message.id}-${i}`}
339
+ from={message.role}>
340
+ <MessageContent>
341
+ <MessageResponse>{part.text}</MessageResponse>
342
+ </MessageContent>
343
+ </Message>
344
+ );
345
+ }
346
+
347
+ if (part.type?.startsWith('tool-')) {
348
+ return (
349
+ <Tool key={`${message.id}-${i}`}>
350
+ <ToolHeader
351
+ type={(part as ToolUIPart).type}
352
+ state={(part as ToolUIPart).state || 'output-available'}
353
+ className="cursor-pointer"
354
+ />
355
+ <ToolContent>
356
+ <ToolInput input={(part as ToolUIPart).input || {}} />
357
+ <ToolOutput
358
+ output={(part as ToolUIPart).output}
359
+ errorText={(part as ToolUIPart).errorText}
360
+ />
361
+ </ToolContent>
362
+ </Tool>
363
+ );
364
+ }
365
+
366
+ return null;
367
+ })}
368
+ </div>
369
+ ))}
370
+ <ConversationScrollButton />
371
+ </ConversationContent>
372
+ </Conversation>
373
+
374
+ <PromptInput onSubmit={handleSubmit} className="mt-20">
375
+ <PromptInputBody>
376
+ <PromptInputTextarea
377
+ onChange={(e) => setInput(e.target.value)}
378
+ className="md:leading-10"
379
+ value={input}
380
+ placeholder="Type your message..."
381
+ disabled={status !== 'ready'}
382
+ />
383
+ </PromptInputBody>
384
+ </PromptInput>
385
+ </div>
386
+ </div>
552
387
  );
553
- };
388
+ }
389
+
390
+ export default Chat;
554
391
  ```
555
392
 
556
- </StepItem>
393
+ This component connects [`useChat()`](https://ai-sdk.dev/docs/reference/ai-sdk-ui/use-chat) to the `api/chat` endpoint, sending prompts there and streaming the response back in chunks.
557
394
 
558
- <StepItem>
395
+ It renders the response text using the [`<MessageResponse>`](https://ai-sdk.dev/elements/components/message#messageresponse-) component, and shows any tool invocations with the [`<Tool>`](https://ai-sdk.dev/elements/components/tool) component.
559
396
 
560
- Create a new Page, and add the example code:
397
+ ## Render the chat component
561
398
 
562
- ```bash copy
563
- touch src/pages/test.astro
564
- ```
399
+ The last step is to render the chat component on your index page. Edit `src/pages/index.astro`:
565
400
 
566
- ```astro title="src/pages/test.astro" showLineNumbers copy
401
+ ```html title="src/pages/index.astro" {2,14}
567
402
  ---
568
- import { Form } from '../components/form'
403
+ import Chat from '@/components/chat';
569
404
  ---
570
405
 
571
- <h1>Test</h1>
572
- <Form client:load />
406
+ <html lang="en">
407
+ <head>
408
+ <meta charset="utf-8" />
409
+ <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
410
+ <meta name="viewport" content="width=device-width" />
411
+ <meta name="generator" content={Astro.generator} />
412
+ <title>Astro</title>
413
+ </head>
414
+ <body>
415
+ <Chat client:load />
416
+ </body>
417
+ </html>
573
418
  ```
574
419
 
575
- > You can now navigate to `/test` in your browser to try it out.
420
+ Import the `Chat` component and add it to the body with the `client:load` [directive](https://docs.astro.build/en/reference/directives-reference/#client-directives) so it runs on the client side.
576
421
 
577
- Submitting **London** as the city would return a result similar to:
422
+ ## Test your agent
578
423
 
579
- ```plaintext
580
- Agent response: The current weather in London is as follows:
424
+ 1. Run your Astro app with `npm run dev`
425
+ 2. Open the chat at http://localhost:4321
426
+ 3. Try asking about the weather. If your API key is set up correctly, you'll get a response
581
427
 
582
- - **Temperature:** 12.9°C (Feels like 9.7°C)
583
- - **Humidity:** 63%
584
- - **Wind Speed:** 14.7 km/h
585
- - **Wind Gusts:** 32.4 km/h
586
- - **Conditions:** Overcast
428
+ ## Next steps
587
429
 
588
- Let me know if you need more information!
589
- ```
430
+ Congratulations on building your Mastra agent with Astro! 🎉
590
431
 
591
- </StepItem>
432
+ From here, you can extend the project with your own tools and logic:
592
433
 
593
- </Steps>
594
- </TabItem>
595
- </Tabs>
434
+ - Learn more about [agents](/docs/v1/agents/overview)
435
+ - Give your agent its own [tools](/docs/v1/agents/using-tools)
436
+ - Add human-like [memory](/docs/v1/agents/agent-memory) to your agent
596
437
 
597
- ## Next Steps
438
+ When you're ready, read more about how Mastra integrates with AI SDK UI and how to deploy your agent anywhere:
598
439
 
599
- - [Deployment | With Astro on Vercel](/docs/v1/deployment/web-framework#with-astro-on-vercel)
600
- - [Monorepo Deployment](/docs/v1/deployment/monorepo)
440
+ - Integrate Mastra with [AI SDK UI](/guides/v1/build-your-ui/ai-sdk-ui)
441
+ - Deploy your agent [anywhere](/docs/v1/deployment/overview)