@mastra/mcp-docs-server 1.0.0-beta.3 → 1.0.0-beta.5

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 (219) hide show
  1. package/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +201 -1
  2. package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +201 -1
  3. package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +201 -1
  4. package/.docs/organized/changelogs/%40mastra%2Fastra.md +201 -1
  5. package/.docs/organized/changelogs/%40mastra%2Fauth.md +6 -0
  6. package/.docs/organized/changelogs/%40mastra%2Fchroma.md +201 -1
  7. package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +201 -1
  8. package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +201 -1
  9. package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +201 -1
  10. package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +201 -1
  11. package/.docs/organized/changelogs/%40mastra%2Fcore.md +370 -170
  12. package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +201 -1
  13. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +201 -1
  14. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +201 -1
  15. package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +201 -1
  16. package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +201 -1
  17. package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +201 -1
  18. package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +201 -1
  19. package/.docs/organized/changelogs/%40mastra%2Fevals.md +201 -1
  20. package/.docs/organized/changelogs/%40mastra%2Flance.md +201 -1
  21. package/.docs/organized/changelogs/%40mastra%2Flibsql.md +201 -1
  22. package/.docs/organized/changelogs/%40mastra%2Floggers.md +201 -1
  23. package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +201 -1
  24. package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +201 -1
  25. package/.docs/organized/changelogs/%40mastra%2Fmcp.md +201 -1
  26. package/.docs/organized/changelogs/%40mastra%2Fmemory.md +201 -1
  27. package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +201 -1
  28. package/.docs/organized/changelogs/%40mastra%2Fmssql.md +201 -1
  29. package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +201 -1
  30. package/.docs/organized/changelogs/%40mastra%2Fpg.md +201 -1
  31. package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +201 -1
  32. package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +201 -1
  33. package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +201 -1
  34. package/.docs/organized/changelogs/%40mastra%2Frag.md +201 -1
  35. package/.docs/organized/changelogs/%40mastra%2Freact.md +80 -1
  36. package/.docs/organized/changelogs/%40mastra%2Fs3vectors.md +9 -0
  37. package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +36 -0
  38. package/.docs/organized/changelogs/%40mastra%2Fserver.md +201 -1
  39. package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +201 -1
  40. package/.docs/organized/changelogs/%40mastra%2Fupstash.md +201 -1
  41. package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +201 -1
  42. package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +201 -1
  43. package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +201 -1
  44. package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +201 -1
  45. package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +201 -1
  46. package/.docs/organized/changelogs/%40mastra%2Fvoice-gladia.md +92 -1
  47. package/.docs/organized/changelogs/%40mastra%2Fvoice-google-gemini-live.md +67 -1
  48. package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +201 -1
  49. package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +201 -1
  50. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +201 -1
  51. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +201 -1
  52. package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +201 -1
  53. package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +201 -1
  54. package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +201 -1
  55. package/.docs/organized/changelogs/create-mastra.md +201 -1
  56. package/.docs/organized/changelogs/mastra.md +201 -1
  57. package/.docs/organized/code-examples/memory-with-processors.md +1 -1
  58. package/.docs/organized/code-examples/quick-start.md +1 -1
  59. package/.docs/raw/agents/adding-voice.mdx +55 -9
  60. package/.docs/raw/agents/guardrails.mdx +19 -20
  61. package/.docs/raw/agents/human-in-the-loop-with-tools.mdx +6 -5
  62. package/.docs/raw/agents/networks.mdx +1 -2
  63. package/.docs/raw/agents/overview.mdx +5 -5
  64. package/.docs/raw/agents/using-tools.mdx +4 -5
  65. package/.docs/raw/course/01-first-agent/05-running-playground.md +5 -5
  66. package/.docs/raw/course/01-first-agent/09-testing-your-agent.md +3 -3
  67. package/.docs/raw/course/01-first-agent/13-testing-your-tool.md +3 -3
  68. package/.docs/raw/course/01-first-agent/17-testing-memory.md +2 -2
  69. package/.docs/raw/course/04-workflows/07-using-playground.md +1 -1
  70. package/.docs/raw/deployment/building-mastra.mdx +1 -1
  71. package/.docs/raw/deployment/cloud-providers/amazon-ec2.mdx +1 -1
  72. package/.docs/raw/deployment/cloud-providers/aws-lambda.mdx +1 -1
  73. package/.docs/raw/deployment/cloud-providers/azure-app-services.mdx +1 -1
  74. package/.docs/raw/deployment/cloud-providers/digital-ocean.mdx +1 -1
  75. package/.docs/raw/deployment/cloud-providers/index.mdx +1 -1
  76. package/.docs/raw/deployment/mastra-cloud/observability.mdx +19 -17
  77. package/.docs/raw/deployment/mastra-cloud/setting-up.mdx +1 -1
  78. package/.docs/raw/deployment/overview.mdx +2 -2
  79. package/.docs/raw/deployment/web-framework.mdx +5 -5
  80. package/.docs/raw/evals/custom-scorers.mdx +3 -5
  81. package/.docs/raw/evals/overview.mdx +2 -3
  82. package/.docs/raw/getting-started/project-structure.mdx +1 -1
  83. package/.docs/raw/getting-started/start.mdx +72 -0
  84. package/.docs/raw/getting-started/studio.mdx +1 -1
  85. package/.docs/raw/{frameworks/agentic-uis/ai-sdk.mdx → guides/build-your-ui/ai-sdk-ui.mdx} +105 -11
  86. package/.docs/raw/{frameworks/web-frameworks → guides/getting-started}/astro.mdx +23 -25
  87. package/.docs/raw/{frameworks/servers → guides/getting-started}/express.mdx +3 -4
  88. package/.docs/raw/guides/{guide → getting-started}/manual-install.mdx +1 -1
  89. package/.docs/raw/guides/{quickstarts/nextjs.mdx → getting-started/next-js.mdx} +11 -11
  90. package/.docs/raw/guides/{quickstarts/standalone-server.mdx → getting-started/quickstart.mdx} +7 -7
  91. package/.docs/raw/{frameworks/web-frameworks → guides/getting-started}/sveltekit.mdx +23 -25
  92. package/.docs/raw/{frameworks/web-frameworks → guides/getting-started}/vite-react.mdx +7 -7
  93. package/.docs/raw/guides/guide/ai-recruiter.mdx +2 -3
  94. package/.docs/raw/guides/guide/chef-michel.mdx +2 -3
  95. package/.docs/raw/guides/guide/notes-mcp-server.mdx +2 -2
  96. package/.docs/raw/guides/guide/research-assistant.mdx +7 -8
  97. package/.docs/raw/guides/guide/stock-agent.mdx +4 -6
  98. package/.docs/raw/guides/guide/web-search.mdx +12 -10
  99. package/.docs/raw/guides/migrations/agentnetwork.mdx +4 -4
  100. package/.docs/raw/guides/migrations/ai-sdk-v4-to-v5.mdx +1 -1
  101. package/.docs/raw/guides/migrations/upgrade-to-v1/agent.mdx +29 -0
  102. package/.docs/raw/guides/migrations/upgrade-to-v1/tools.mdx +5 -0
  103. package/.docs/raw/guides/migrations/upgrade-to-v1/workflows.mdx +22 -0
  104. package/.docs/raw/guides/migrations/vnext-to-standard-apis.mdx +2 -2
  105. package/.docs/raw/index.mdx +2 -2
  106. package/.docs/raw/mcp/overview.mdx +3 -5
  107. package/.docs/raw/memory/memory-processors.mdx +1 -2
  108. package/.docs/raw/memory/semantic-recall.mdx +7 -7
  109. package/.docs/raw/memory/storage/memory-with-libsql.mdx +2 -4
  110. package/.docs/raw/memory/storage/memory-with-mongodb.mdx +2 -4
  111. package/.docs/raw/memory/storage/memory-with-pg.mdx +2 -4
  112. package/.docs/raw/memory/storage/memory-with-upstash.mdx +2 -4
  113. package/.docs/raw/memory/threads-and-resources.mdx +3 -3
  114. package/.docs/raw/memory/working-memory.mdx +4 -5
  115. package/.docs/raw/{logging.mdx → observability/logging.mdx} +1 -1
  116. package/.docs/raw/observability/overview.mdx +2 -2
  117. package/.docs/raw/observability/tracing/exporters/otel.mdx +21 -2
  118. package/.docs/raw/observability/tracing/exporters/posthog.mdx +107 -0
  119. package/.docs/raw/observability/tracing/overview.mdx +3 -2
  120. package/.docs/raw/rag/chunking-and-embedding.mdx +16 -17
  121. package/.docs/raw/rag/overview.mdx +3 -2
  122. package/.docs/raw/rag/retrieval.mdx +20 -32
  123. package/.docs/raw/reference/agents/agent.mdx +7 -10
  124. package/.docs/raw/reference/agents/generate.mdx +11 -92
  125. package/.docs/raw/reference/agents/generateLegacy.mdx +2 -2
  126. package/.docs/raw/reference/agents/getLLM.mdx +1 -1
  127. package/.docs/raw/reference/agents/network.mdx +5 -88
  128. package/.docs/raw/reference/cli/mastra.mdx +2 -1
  129. package/.docs/raw/reference/client-js/agents.mdx +3 -3
  130. package/.docs/raw/reference/core/getLogger.mdx +1 -1
  131. package/.docs/raw/reference/core/listLogs.mdx +1 -1
  132. package/.docs/raw/reference/core/listLogsByRunId.mdx +1 -1
  133. package/.docs/raw/reference/core/mastra-model-gateway.mdx +5 -19
  134. package/.docs/raw/reference/core/setLogger.mdx +1 -1
  135. package/.docs/raw/reference/core/setTelemetry.mdx +1 -1
  136. package/.docs/raw/reference/evals/answer-relevancy.mdx +28 -98
  137. package/.docs/raw/reference/evals/answer-similarity.mdx +12 -258
  138. package/.docs/raw/reference/evals/bias.mdx +29 -87
  139. package/.docs/raw/reference/evals/completeness.mdx +31 -90
  140. package/.docs/raw/reference/evals/content-similarity.mdx +28 -88
  141. package/.docs/raw/reference/evals/context-precision.mdx +28 -130
  142. package/.docs/raw/reference/evals/context-relevance.mdx +11 -11
  143. package/.docs/raw/reference/evals/faithfulness.mdx +28 -101
  144. package/.docs/raw/reference/evals/hallucination.mdx +28 -103
  145. package/.docs/raw/reference/evals/keyword-coverage.mdx +28 -107
  146. package/.docs/raw/reference/evals/noise-sensitivity.mdx +11 -11
  147. package/.docs/raw/reference/evals/prompt-alignment.mdx +15 -15
  148. package/.docs/raw/reference/evals/textual-difference.mdx +27 -100
  149. package/.docs/raw/reference/evals/tone-consistency.mdx +25 -98
  150. package/.docs/raw/reference/evals/tool-call-accuracy.mdx +7 -7
  151. package/.docs/raw/reference/evals/toxicity.mdx +29 -92
  152. package/.docs/raw/reference/memory/memory-class.mdx +5 -7
  153. package/.docs/raw/reference/observability/tracing/exporters/posthog.mdx +132 -0
  154. package/.docs/raw/reference/processors/batch-parts-processor.mdx +1 -1
  155. package/.docs/raw/reference/processors/language-detector.mdx +1 -1
  156. package/.docs/raw/reference/processors/moderation-processor.mdx +2 -2
  157. package/.docs/raw/reference/processors/pii-detector.mdx +2 -2
  158. package/.docs/raw/reference/processors/prompt-injection-detector.mdx +1 -1
  159. package/.docs/raw/reference/processors/system-prompt-scrubber.mdx +2 -3
  160. package/.docs/raw/reference/processors/token-limiter-processor.mdx +2 -2
  161. package/.docs/raw/reference/processors/unicode-normalizer.mdx +1 -1
  162. package/.docs/raw/reference/rag/embeddings.mdx +5 -5
  163. package/.docs/raw/reference/rag/rerank.mdx +1 -2
  164. package/.docs/raw/reference/rag/rerankWithScorer.mdx +0 -1
  165. package/.docs/raw/reference/streaming/agents/stream.mdx +11 -93
  166. package/.docs/raw/reference/templates/overview.mdx +1 -4
  167. package/.docs/raw/reference/tools/client.mdx +1 -2
  168. package/.docs/raw/reference/tools/create-tool.mdx +132 -0
  169. package/.docs/raw/reference/tools/graph-rag-tool.mdx +5 -5
  170. package/.docs/raw/reference/tools/mcp-client.mdx +2 -4
  171. package/.docs/raw/reference/tools/mcp-server.mdx +1 -2
  172. package/.docs/raw/reference/tools/vector-query-tool.mdx +14 -15
  173. package/.docs/raw/reference/vectors/chroma.mdx +81 -1
  174. package/.docs/raw/reference/vectors/couchbase.mdx +24 -17
  175. package/.docs/raw/reference/vectors/lance.mdx +38 -22
  176. package/.docs/raw/reference/vectors/libsql.mdx +35 -2
  177. package/.docs/raw/reference/vectors/mongodb.mdx +35 -2
  178. package/.docs/raw/reference/vectors/opensearch.mdx +37 -16
  179. package/.docs/raw/reference/vectors/pg.mdx +43 -36
  180. package/.docs/raw/reference/vectors/pinecone.mdx +48 -1
  181. package/.docs/raw/reference/vectors/qdrant.mdx +36 -1
  182. package/.docs/raw/reference/vectors/turbopuffer.mdx +74 -0
  183. package/.docs/raw/reference/voice/composite-voice.mdx +71 -28
  184. package/.docs/raw/reference/voice/openai-realtime.mdx +2 -2
  185. package/.docs/raw/reference/voice/voice.addInstructions.mdx +2 -3
  186. package/.docs/raw/reference/voice/voice.addTools.mdx +1 -1
  187. package/.docs/raw/reference/voice/voice.answer.mdx +1 -1
  188. package/.docs/raw/reference/voice/voice.close.mdx +1 -1
  189. package/.docs/raw/reference/voice/voice.connect.mdx +1 -1
  190. package/.docs/raw/reference/voice/voice.listen.mdx +86 -52
  191. package/.docs/raw/reference/voice/voice.off.mdx +1 -1
  192. package/.docs/raw/reference/voice/voice.on.mdx +1 -1
  193. package/.docs/raw/reference/voice/voice.send.mdx +1 -1
  194. package/.docs/raw/reference/voice/voice.speak.mdx +75 -40
  195. package/.docs/raw/reference/voice/voice.updateConfig.mdx +1 -1
  196. package/.docs/raw/server-db/mastra-client.mdx +1 -2
  197. package/.docs/raw/streaming/overview.mdx +20 -9
  198. package/.docs/raw/streaming/tool-streaming.mdx +47 -4
  199. package/.docs/raw/tools-mcp/advanced-usage.mdx +1 -2
  200. package/.docs/raw/tools-mcp/mcp-overview.mdx +3 -5
  201. package/.docs/raw/voice/overview.mdx +87 -40
  202. package/.docs/raw/voice/speech-to-speech.mdx +4 -4
  203. package/.docs/raw/voice/speech-to-text.mdx +1 -2
  204. package/.docs/raw/voice/text-to-speech.mdx +1 -2
  205. package/.docs/raw/workflows/control-flow.mdx +180 -0
  206. package/.docs/raw/workflows/overview.mdx +1 -1
  207. package/CHANGELOG.md +17 -0
  208. package/dist/{chunk-5NJC7NRO.js → chunk-4CM2BQNP.js} +24 -4
  209. package/dist/prepare-docs/package-changes.d.ts.map +1 -1
  210. package/dist/prepare-docs/prepare.js +1 -1
  211. package/dist/stdio.js +1 -1
  212. package/package.json +7 -7
  213. package/.docs/raw/frameworks/agentic-uis/cedar-os.mdx +0 -102
  214. package/.docs/raw/frameworks/agentic-uis/openrouter.mdx +0 -179
  215. package/.docs/raw/frameworks/web-frameworks/next-js.mdx +0 -379
  216. package/.docs/raw/getting-started/quickstart.mdx +0 -27
  217. package/.docs/raw/getting-started/templates.mdx +0 -73
  218. /package/.docs/raw/{frameworks/agentic-uis → guides/build-your-ui}/assistant-ui.mdx +0 -0
  219. /package/.docs/raw/{frameworks/agentic-uis → guides/build-your-ui}/copilotkit.mdx +0 -0
@@ -1,379 +0,0 @@
1
- ---
2
- title: "Integrate Mastra in your Next.js project | Frameworks"
3
- description: A step-by-step guide to integrating Mastra with Next.js.
4
- ---
5
-
6
- import Tabs from "@theme/Tabs";
7
- import TabItem from "@theme/TabItem";
8
- import Steps from "@site/src/components/Steps";
9
- import StepItem from "@site/src/components/StepItem";
10
-
11
- # Integrate Mastra in your Next.js project
12
-
13
- Mastra integrates with Next.js, making it easy to:
14
-
15
- - Build flexible APIs to serve AI-powered features
16
- - Simplify deployment with a unified codebase for frontend and backend
17
- - Take advantage of Next.js's built-in server actions (App Router) or API Routes (Pages Router) for efficient server-client workflows
18
-
19
- Use this guide to scaffold and integrate Mastra with your Next.js project.
20
-
21
- <Tabs>
22
- <TabItem value="app-router" label="App Router">
23
-
24
- :::warning
25
-
26
- This guide assumes you're using the Next.js App Router at the root of your project, e.g., `app` rather than `src/app`.
27
-
28
- :::
29
-
30
- <Steps>
31
-
32
- <StepItem>
33
-
34
- To integrate Mastra into your project, you have two options:
35
-
36
- - Use the One-Liner
37
-
38
- Run the following command to quickly scaffold the default Weather agent with sensible defaults:
39
-
40
- ```bash copy
41
- npx mastra@beta init --dir . --components agents,tools --example --llm openai
42
- ```
43
-
44
- > See [mastra init](/reference/v1/cli/create-mastra) for more information.
45
-
46
- - Use the Interactive CLI
47
-
48
- If you prefer to customize the setup, run the `init` command and choose from the options when prompted:
49
-
50
- ```bash copy
51
- npx mastra@beta init
52
- ```
53
-
54
- :::warning
55
-
56
- By default, `mastra init` suggests `src` as the install location. If you're using the App Router at the root of your project (e.g., `app`, not `src/app`), enter `.` when prompted:
57
-
58
- :::
59
-
60
- </StepItem>
61
-
62
- <StepItem>
63
-
64
- Set Up API Key
65
-
66
- ```bash title=".env" copy
67
- OPENAI_API_KEY=<your-api-key>
68
- ```
69
-
70
- > Each LLM provider uses a different env var. See [Model Capabilities](https://sdk.vercel.ai/providers) for more information.
71
-
72
- </StepItem>
73
-
74
- <StepItem>
75
-
76
- Add to your `next.config.ts`:
77
-
78
- ```typescript title="next.config.ts" showLineNumbers copy
79
- import type { NextConfig } from "next";
80
-
81
- const nextConfig: NextConfig = {
82
- serverExternalPackages: ["@mastra/*"],
83
- };
84
-
85
- export default nextConfig;
86
- ```
87
-
88
- </StepItem>
89
-
90
- <StepItem>
91
-
92
- You can start your Next.js app in the usual way.
93
-
94
- </StepItem>
95
-
96
- <StepItem>
97
-
98
- Create a new directory that will contain a Page, Action, and Form for testing purposes.
99
-
100
- ```bash copy
101
- mkdir app/test
102
- ```
103
-
104
- </StepItem>
105
-
106
- <StepItem>
107
-
108
- Create a new Action, and add the example code:
109
-
110
- ```bash copy
111
- touch app/test/action.ts
112
- ```
113
-
114
- ```typescript title="app/test/action.ts" showLineNumbers copy
115
- "use server";
116
-
117
- import { mastra } from "../../mastra";
118
-
119
- export async function getWeatherInfo(formData: FormData) {
120
- const city = formData.get("city")?.toString();
121
- const agent = mastra.getAgent("weatherAgent");
122
-
123
- const result = await agent.generate(`What's the weather like in ${city}?`);
124
-
125
- return result.text;
126
- }
127
- ```
128
-
129
- </StepItem>
130
-
131
- <StepItem>
132
-
133
- Create a new Form component, and add the example code:
134
-
135
- ```bash copy
136
- touch app/test/form.tsx
137
- ```
138
-
139
- ```typescript title="app/test/form.tsx" showLineNumbers copy
140
- "use client";
141
-
142
- import { useState } from "react";
143
- import { getWeatherInfo } from "./action";
144
-
145
- export function Form() {
146
- const [result, setResult] = useState<string | null>(null);
147
-
148
- async function handleSubmit(formData: FormData) {
149
- const res = await getWeatherInfo(formData);
150
- setResult(res);
151
- }
152
-
153
- return (
154
- <>
155
- <form action={handleSubmit}>
156
- <input name="city" placeholder="Enter city" required />
157
- <button type="submit">Get Weather</button>
158
- </form>
159
- {result && <pre>{result}</pre>}
160
- </>
161
- );
162
- }
163
- ```
164
-
165
- </StepItem>
166
-
167
- <StepItem>
168
-
169
- Create a new Page, and add the example code:
170
-
171
- ```bash copy
172
- touch app/test/page.tsx
173
- ```
174
-
175
- ```typescript title="app/test/page.tsx" showLineNumbers copy
176
- import { Form } from "./form";
177
-
178
- export default async function Page() {
179
- return (
180
- <>
181
- <h1>Test</h1>
182
- <Form />
183
- </>
184
- );
185
- }
186
- ```
187
-
188
- > You can now navigate to `/test` in your browser to try it out.
189
-
190
- Submitting **London** as the city would return a result similar to:
191
-
192
- ```plaintext
193
- Agent response: The current weather in London is as follows:
194
-
195
- - **Temperature:** 12.9°C (Feels like 9.7°C)
196
- - **Humidity:** 63%
197
- - **Wind Speed:** 14.7 km/h
198
- - **Wind Gusts:** 32.4 km/h
199
- - **Conditions:** Overcast
200
-
201
- Let me know if you need more information!
202
- ```
203
-
204
- </StepItem>
205
-
206
- </Steps>
207
- </TabItem>
208
-
209
- <TabItem value="pages-router" label="Pages Router">
210
-
211
- :::warning
212
-
213
- This guide assumes you're using the Next.js Pages Router at the root of your project, e.g., `pages` rather than `src/pages`.
214
-
215
- :::
216
-
217
- <Steps>
218
-
219
- <StepItem>
220
-
221
- To integrate Mastra into your project, you have two options:
222
-
223
- - Use the One-Liner
224
-
225
- Run the following command to quickly scaffold the default Weather agent with sensible defaults:
226
-
227
- ```bash copy
228
- npx mastra@beta init --dir . --components agents,tools --example --llm openai
229
- ```
230
-
231
- > See [mastra init](/reference/v1/cli/create-mastra) for more information.
232
-
233
- - Use the Interactive CLI
234
-
235
- If you prefer to customize the setup, run the `init` command and choose from the options when prompted:
236
-
237
- ```bash copy
238
- npx mastra@beta init
239
- ```
240
-
241
- :::warning
242
-
243
- By default, `mastra init` suggests `src` as the install location. If you're using the Pages Router at the root of your project (e.g., `pages`, not `src/pages`), enter `.` when prompted:
244
-
245
- :::
246
-
247
- </StepItem>
248
-
249
- <StepItem>
250
-
251
- Set Up API Key
252
-
253
- ```bash title=".env" copy
254
- OPENAI_API_KEY=<your-api-key>
255
- ```
256
-
257
- > Each LLM provider uses a different env var. See [Model Capabilities](https://sdk.vercel.ai/providers) for more information.
258
-
259
- </StepItem>
260
-
261
- <StepItem>
262
-
263
- Add to your `next.config.ts`:
264
-
265
- ```typescript title="next.config.ts" showLineNumbers copy
266
- import type { NextConfig } from "next";
267
-
268
- const nextConfig: NextConfig = {
269
- serverExternalPackages: ["@mastra/*"],
270
- };
271
-
272
- export default nextConfig;
273
- ```
274
-
275
- </StepItem>
276
-
277
- <StepItem>
278
-
279
- You can start your Next.js app in the usual way.
280
-
281
- </StepItem>
282
-
283
- <StepItem>
284
-
285
- Create a new API Route, and add the example code:
286
-
287
- ```bash copy
288
- touch pages/api/test.ts
289
- ```
290
-
291
- ```typescript title="pages/api/test.ts" showLineNumbers copy
292
- import type { NextApiRequest, NextApiResponse } from "next";
293
-
294
- import { mastra } from "../../mastra";
295
-
296
- export default async function getWeatherInfo(
297
- req: NextApiRequest,
298
- res: NextApiResponse,
299
- ) {
300
- const city = req.body.city;
301
- const agent = mastra.getAgent("weatherAgent");
302
-
303
- const result = await agent.generate(`What's the weather like in ${city}?`);
304
-
305
- return res.status(200).json(result.text);
306
- }
307
- ```
308
-
309
- </StepItem>
310
-
311
- <StepItem>
312
-
313
- Create a new Page, and add the example code:
314
-
315
- ```bash copy
316
- touch pages/test.tsx
317
- ```
318
-
319
- ```typescript title="pages/test.tsx" showLineNumbers copy
320
- import { useState } from "react";
321
-
322
- export default function Test() {
323
- const [result, setResult] = useState<string | null>(null);
324
-
325
- async function handleSubmit(event: React.FormEvent<HTMLFormElement>) {
326
- event.preventDefault();
327
-
328
- const formData = new FormData(event.currentTarget);
329
- const city = formData.get("city")?.toString();
330
-
331
- const response = await fetch("/api/test", {
332
- method: "POST",
333
- headers: { "Content-Type": "application/json" },
334
- body: JSON.stringify({ city })
335
- });
336
-
337
- const text = await response.json();
338
- setResult(text);
339
- }
340
-
341
- return (
342
- <>
343
- <h1>Test</h1>
344
- <form onSubmit={handleSubmit}>
345
- <input name="city" placeholder="Enter city" required />
346
- <button type="submit">Get Weather</button>
347
- </form>
348
- {result && <pre>{result}</pre>}
349
- </>
350
- );
351
- }
352
- ```
353
-
354
- > You can now navigate to `/test` in your browser to try it out.
355
-
356
- Submitting **London** as the city would return a result similar to:
357
-
358
- ```plaintext
359
- Agent response: The current weather in London is as follows:
360
-
361
- - **Temperature:** 12.9°C (Feels like 9.7°C)
362
- - **Humidity:** 63%
363
- - **Wind Speed:** 14.7 km/h
364
- - **Wind Gusts:** 32.4 km/h
365
- - **Conditions:** Overcast
366
-
367
- Let me know if you need more information!
368
- ```
369
-
370
- </StepItem>
371
-
372
- </Steps>
373
- </TabItem>
374
- </Tabs>
375
-
376
- ## Next Steps
377
-
378
- - [Deployment | With Next.js on Vercel](/docs/v1/deployment/web-framework#with-nextjs-on-vercel)
379
- - [Monorepo Deployment](../../deployment/monorepo)
@@ -1,27 +0,0 @@
1
- ---
2
- title: "Quickstart | Getting Started"
3
- description: Choose how to get started with Mastra - standalone server or Next.js integration.
4
- ---
5
-
6
- import { CardGrid, CardGridItem } from "@site/src/components/cards/card-grid";
7
-
8
- # Quickstart
9
-
10
- Choose how you want to get started with Mastra:
11
-
12
- <CardGrid columns={2}>
13
- <CardGridItem
14
- title="Standalone Server (Recommended)"
15
- href="/guides/v1/quickstarts/standalone-server"
16
- >
17
- The fastest way to get started - spin up a standalone Mastra server and interact with your agents in Studio
18
- </CardGridItem>
19
- <CardGridItem
20
- title="Next.js"
21
- href="/guides/v1/quickstarts/nextjs"
22
- >
23
- Integrate Mastra into a Next.js app and use the AI SDK UI to build an in-app chat interface for your agents
24
- </CardGridItem>
25
- </CardGrid>
26
-
27
- For more control over setup, or to add Mastra to an existing project, see the [manual installation guide](/guides/v1/guide/manual-install). You can also use [`mastra init`](/reference/v1/cli/mastra#mastra-init) for existing projects.
@@ -1,73 +0,0 @@
1
- ---
2
- title: "Templates | Getting Started"
3
- description: Pre-built project structures that demonstrate common Mastra use cases and patterns
4
- ---
5
-
6
- import Tabs from "@theme/Tabs";
7
- import TabItem from "@theme/TabItem";
8
-
9
- # Templates
10
-
11
- Templates are pre-built Mastra projects that demonstrate specific use cases and patterns. Browse available templates in the [templates directory](https://mastra.ai/templates).
12
-
13
- ## Using Templates
14
-
15
- Install a template using the `create-mastra` command:
16
-
17
- <Tabs>
18
- <TabItem value="npm" label="npm">
19
- ```bash copy
20
- npx create-mastra@beta --template template-name
21
- ```
22
- </TabItem>
23
- <TabItem value="yarn" label="yarn">
24
- ```bash copy
25
- yarn dlx create-mastra@beta --template template-name
26
- ```
27
- </TabItem>
28
- <TabItem value="pnpm" label="pnpm">
29
- ```bash copy
30
- pnpm create mastra@beta --template template-name
31
- ```
32
- </TabItem>
33
- <TabItem value="bun" label="bun">
34
- ```bash copy
35
- bun create mastra@beta --template template-name
36
- ```
37
- </TabItem>
38
- </Tabs>
39
-
40
- For example, to create a text-to-SQL application:
41
-
42
- ```bash copy
43
- npx create-mastra@beta --template text-to-sql
44
- ```
45
-
46
- ## Setting Up a Template
47
-
48
- After installation:
49
-
50
- 1. **Navigate to your project**:
51
-
52
- ```bash copy
53
- cd your-project-name
54
- ```
55
-
56
- 2. **Configure environment variables**:
57
-
58
- ```bash copy
59
- cp .env.example .env
60
- ```
61
-
62
- Edit `.env` with your API keys as specified in the template's README.
63
-
64
- 3. **Start development**:
65
- ```bash copy
66
- npm run dev
67
- ```
68
-
69
- :::info
70
- Each template includes a comprehensive README with specific setup instructions and usage examples.
71
- :::
72
-
73
- For detailed information on creating templates, see the [Templates Reference](/reference/v1/templates/overview).