@mastra/mcp-docs-server 0.13.2 → 0.13.3-alpha.0

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 (114) hide show
  1. package/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +33 -0
  2. package/.docs/organized/changelogs/%40mastra%2Fagui.md +48 -0
  3. package/.docs/organized/changelogs/%40mastra%2Fastra.md +30 -30
  4. package/.docs/organized/changelogs/%40mastra%2Fchroma.md +30 -30
  5. package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +33 -33
  6. package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +85 -85
  7. package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +34 -34
  8. package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +35 -35
  9. package/.docs/organized/changelogs/%40mastra%2Fcore.md +70 -70
  10. package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +29 -29
  11. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +92 -92
  12. package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +94 -94
  13. package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +92 -92
  14. package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +104 -104
  15. package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +35 -35
  16. package/.docs/organized/changelogs/%40mastra%2Fevals.md +26 -26
  17. package/.docs/organized/changelogs/%40mastra%2Ffirecrawl.md +29 -29
  18. package/.docs/organized/changelogs/%40mastra%2Fgithub.md +26 -26
  19. package/.docs/organized/changelogs/%40mastra%2Flance.md +32 -0
  20. package/.docs/organized/changelogs/%40mastra%2Flibsql.md +35 -35
  21. package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +59 -59
  22. package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +29 -29
  23. package/.docs/organized/changelogs/%40mastra%2Fmcp.md +31 -31
  24. package/.docs/organized/changelogs/%40mastra%2Fmem0.md +26 -26
  25. package/.docs/organized/changelogs/%40mastra%2Fmemory.md +56 -56
  26. package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +37 -37
  27. package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +30 -17
  28. package/.docs/organized/changelogs/%40mastra%2Fpg.md +57 -57
  29. package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +29 -29
  30. package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +108 -108
  31. package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +29 -29
  32. package/.docs/organized/changelogs/%40mastra%2Frag.md +27 -27
  33. package/.docs/organized/changelogs/%40mastra%2Fragie.md +26 -26
  34. package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +7 -0
  35. package/.docs/organized/changelogs/%40mastra%2Fserver.md +82 -82
  36. package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +29 -29
  37. package/.docs/organized/changelogs/%40mastra%2Fupstash.md +33 -33
  38. package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +31 -31
  39. package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +28 -28
  40. package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +26 -26
  41. package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +26 -26
  42. package/.docs/organized/changelogs/%40mastra%2Fvoice-gladia.md +25 -0
  43. package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +26 -26
  44. package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +26 -26
  45. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +23 -23
  46. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +26 -26
  47. package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +26 -26
  48. package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +26 -26
  49. package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +26 -26
  50. package/.docs/organized/changelogs/create-mastra.md +37 -37
  51. package/.docs/organized/changelogs/mastra.md +115 -115
  52. package/.docs/organized/code-examples/a2a.md +1 -30
  53. package/.docs/organized/code-examples/agent-network.md +26 -115
  54. package/.docs/organized/code-examples/agent.md +1 -29
  55. package/.docs/organized/code-examples/agui.md +0 -22
  56. package/.docs/organized/code-examples/ai-sdk-useChat.md +1 -16
  57. package/.docs/organized/code-examples/assistant-ui.md +1 -16
  58. package/.docs/organized/code-examples/bird-checker-with-express.md +1 -19
  59. package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +1 -20
  60. package/.docs/organized/code-examples/bird-checker-with-nextjs.md +1 -18
  61. package/.docs/organized/code-examples/client-side-tools.md +1 -18
  62. package/.docs/organized/code-examples/crypto-chatbot.md +4 -25
  63. package/.docs/organized/code-examples/experimental-auth-weather-agent.md +1 -26
  64. package/.docs/organized/code-examples/fireworks-r1.md +1 -21
  65. package/.docs/organized/code-examples/mcp-configuration.md +1 -24
  66. package/.docs/organized/code-examples/mcp-registry-registry.md +1 -22
  67. package/.docs/organized/code-examples/memory-per-resource-example.md +0 -14
  68. package/.docs/organized/code-examples/memory-todo-agent.md +1 -20
  69. package/.docs/organized/code-examples/memory-with-context.md +1 -20
  70. package/.docs/organized/code-examples/memory-with-libsql.md +1 -21
  71. package/.docs/organized/code-examples/memory-with-mem0.md +1 -21
  72. package/.docs/organized/code-examples/memory-with-pg.md +1 -22
  73. package/.docs/organized/code-examples/memory-with-processors.md +1 -17
  74. package/.docs/organized/code-examples/memory-with-upstash.md +1 -24
  75. package/.docs/organized/code-examples/openapi-spec-writer.md +1 -21
  76. package/.docs/organized/code-examples/quick-start.md +1 -21
  77. package/.docs/organized/code-examples/stock-price-tool.md +1 -21
  78. package/.docs/organized/code-examples/weather-agent.md +1 -20
  79. package/.docs/organized/code-examples/workflow-ai-recruiter.md +1 -22
  80. package/.docs/organized/code-examples/workflow-with-inline-steps.md +1 -20
  81. package/.docs/organized/code-examples/workflow-with-memory.md +1 -21
  82. package/.docs/organized/code-examples/workflow-with-separate-steps.md +1 -22
  83. package/.docs/raw/course/01-first-agent/11-creating-transactions-tool.md +1 -1
  84. package/.docs/raw/course/03-agent-memory/24-working-memory-in-practice.md +0 -3
  85. package/.docs/raw/course/03-agent-memory/29-memory-best-practices.md +0 -6
  86. package/.docs/raw/deployment/cloud-providers/amazon-ec2.mdx +81 -0
  87. package/.docs/raw/deployment/cloud-providers/azure-app-services.mdx +136 -0
  88. package/.docs/raw/deployment/cloud-providers/index.mdx +2 -0
  89. package/.docs/raw/deployment/serverless-platforms/cloudflare-deployer.mdx +111 -0
  90. package/.docs/raw/deployment/{deployment.mdx → serverless-platforms/index.mdx} +5 -10
  91. package/.docs/raw/deployment/serverless-platforms/netlify-deployer.mdx +94 -0
  92. package/.docs/raw/deployment/serverless-platforms/vercel-deployer.mdx +91 -0
  93. package/.docs/raw/frameworks/ai-sdk-v5.mdx +91 -0
  94. package/.docs/raw/frameworks/web-frameworks/next-js.mdx +56 -18
  95. package/.docs/raw/frameworks/web-frameworks/sveltekit.mdx +456 -0
  96. package/.docs/raw/frameworks/web-frameworks/vite-react.mdx +28 -9
  97. package/.docs/raw/getting-started/model-providers.mdx +118 -127
  98. package/.docs/raw/memory/overview.mdx +30 -0
  99. package/.docs/raw/reference/agents/generate.mdx +3 -3
  100. package/.docs/raw/reference/agents/getModel.mdx +1 -1
  101. package/.docs/raw/reference/agents/stream.mdx +3 -3
  102. package/.docs/raw/reference/deployer/cloudflare.mdx +4 -119
  103. package/.docs/raw/reference/deployer/netlify.mdx +4 -83
  104. package/.docs/raw/reference/deployer/vercel.mdx +4 -51
  105. package/.docs/raw/reference/memory/Memory.mdx +71 -2
  106. package/.docs/raw/reference/observability/logger.mdx +70 -0
  107. package/.docs/raw/reference/rag/pg.mdx +15 -0
  108. package/.docs/raw/reference/storage/postgresql.mdx +17 -0
  109. package/.docs/raw/reference/workflows/step.mdx +8 -1
  110. package/.docs/raw/workflows/overview.mdx +1 -1
  111. package/dist/{chunk-P5AHYMUI.js → chunk-7QXT2IEP.js} +48 -11
  112. package/dist/prepare-docs/prepare.js +1 -1
  113. package/dist/stdio.js +1 -1
  114. package/package.json +5 -5
@@ -0,0 +1,456 @@
1
+ ---
2
+ title: "Getting Started with Mastra and SvelteKit | Mastra Guides"
3
+ description: A step-by-step guide to integrating Mastra with SvelteKit.
4
+ ---
5
+
6
+ import { Callout, Steps, Tabs } from "nextra/components";
7
+
8
+ # Integrate Mastra in your SvelteKit project
9
+
10
+ Mastra integrates with SvelteKit, making it easy to:
11
+
12
+ - Build flexible APIs to serve AI-powered features
13
+ - Simplify deployment with a unified codebase for frontend and backend
14
+ - Take advantage of SvelteKit's built-in [Actions](https://kit.svelte.dev/docs/form-actions) or [Server Endpoints](https://svelte.dev/docs/kit/routing#server) for efficient server-client workflows
15
+
16
+ Use this guide to scaffold and integrate Mastra with your SvelteKit project.
17
+
18
+ <Tabs items={["Actions", "Server Endpoints"]}>
19
+ <Tabs.Tab>
20
+
21
+ <Steps>
22
+ ## Install Mastra
23
+
24
+ Install the required Mastra packages:
25
+ {/*
26
+ LLM CONTEXT: This Tabs component shows commands for integrating a new Mastra backend project using different package managers.
27
+ Each tab displays the command for that specific package manager to create an integrated Mastra backend service.
28
+ This is part of the "Integrated Backend Integration" approach for SvelteKit projects.
29
+ All commands create the same Mastra project but use different package manager syntax.
30
+ */}
31
+
32
+ <Tabs items={["npm", "yarn", "pnpm", "bun"]}>
33
+ <Tabs.Tab>
34
+ ```bash copy
35
+ npm install mastra@latest @mastra/core@latest @mastra/libsql@latest
36
+ ```
37
+ </Tabs.Tab>
38
+ <Tabs.Tab>
39
+ ```bash copy
40
+ yarn add mastra@latest @mastra/core@latest @mastra/libsql@latest
41
+ ```
42
+ </Tabs.Tab>
43
+ <Tabs.Tab>
44
+ ```bash copy
45
+ pnpm add mastra@latest @mastra/core@latest @mastra/libsql@latest
46
+ ```
47
+ </Tabs.Tab>
48
+ <Tabs.Tab>
49
+ ```bash copy
50
+ bun add mastra@latest @mastra/core@latest @mastra/libsql@latest
51
+ ```
52
+ </Tabs.Tab>
53
+ </Tabs>
54
+
55
+ ## Integrate Mastra
56
+
57
+ To integrate Mastra into your project, you have two options:
58
+
59
+ ### 1. Use the One-Liner
60
+
61
+ Run the following command to quickly scaffold the default Weather agent with sensible defaults:
62
+
63
+ ```bash copy
64
+ npx mastra@latest init --default
65
+ ```
66
+
67
+ > See [mastra init](/reference/cli/init) for more information.
68
+
69
+ ### 2. Use the Interactive CLI
70
+
71
+ If you prefer to customize the setup, run the `init` command and choose from the options when prompted:
72
+
73
+ ```bash copy
74
+ npx mastra@latest init
75
+ ```
76
+
77
+ Add the `dev` and `build` scripts to `package.json`:
78
+
79
+ ```json filename="package.json"
80
+ {
81
+ "scripts": {
82
+ ...
83
+ "dev:mastra": "mastra dev",
84
+ "build:mastra": "mastra build"
85
+ }
86
+ }
87
+ ```
88
+
89
+ ## Configure TypeScript
90
+
91
+ Modify the `tsconfig.json` file in your project root:
92
+
93
+ ```json filename="tsconfig.json"
94
+ {
95
+ ...
96
+ "exclude": ["dist", ".mastra"]
97
+ }
98
+ ```
99
+
100
+ ## Set Up API Key
101
+
102
+ The `VITE_` prefix is required for environment variables to be accessible in the Vite environment, that SvelteKit uses.
103
+ [Read more about Vite environment variables](https://vite.dev/guide/env-and-mode.html#env-variables).
104
+
105
+ ```bash filename=".env" copy
106
+ VITE_OPENAI_API_KEY=<your-api-key>
107
+ ```
108
+
109
+ ## Update .gitignore
110
+
111
+ Add `.mastra` to your `.gitignore` file:
112
+
113
+ ```bash filename=".gitignore" copy
114
+ .mastra
115
+ ```
116
+
117
+ ## Update the Mastra Agent
118
+
119
+ ```diff filename="src/mastra/agents/weather-agent.ts"
120
+ - import { openai } from "@ai-sdk/openai";
121
+ + import { createOpenAI } from "@ai-sdk/openai";
122
+
123
+ + const openai = createOpenAI({
124
+ + apiKey: import.meta.env?.VITE_OPENAI_API_KEY || process.env.VITE_OPENAI_API_KEY,
125
+ + compatibility: "strict"
126
+ + });
127
+ ```
128
+
129
+ By reading env vars from both `import.meta.env` and `process.env`, we ensure that the API key is available in both the SvelteKit dev server and the Mastra Dev Server.
130
+
131
+ > 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.
132
+
133
+ ## Start the Mastra Dev Server
134
+
135
+ Start the Mastra Dev Server to expose your agents as REST endpoints:
136
+
137
+ <Tabs items={["npm", "CLI"]}>
138
+ <Tabs.Tab>
139
+ ```bash copy
140
+ npm run dev:mastra
141
+ ```
142
+ </Tabs.Tab>
143
+ <Tabs.Tab>
144
+ ```bash copy
145
+ mastra dev:mastra
146
+ ```
147
+ </Tabs.Tab>
148
+ </Tabs>
149
+
150
+ > Once running, your agents are available locally. See [Local Development Environment](/docs/local-dev/mastra-dev) for more information.
151
+
152
+ ## Start SvelteKit Dev Server
153
+
154
+ With the Mastra Dev Server running, you can start your SvelteKit site in the usual way.
155
+
156
+ ## Create Test Directory
157
+
158
+ ```bash copy
159
+ mkdir src/routes/test
160
+ ```
161
+
162
+ ### Create Test Action
163
+
164
+ Create a new Action, and add the example code:
165
+
166
+ ```bash copy
167
+ touch src/routes/test/+page.server.ts
168
+ ```
169
+
170
+ ```typescript filename="src/routes/test/+page.server.ts" showLineNumbers copy
171
+ import type { Actions } from './$types';
172
+ import { mastra } from '../../mastra';
173
+
174
+ export const actions = {
175
+ default: async (event) => {
176
+ const city = (await event.request.formData()).get('city')!.toString();
177
+ const agent = mastra.getAgent('weatherAgent');
178
+
179
+ const result = await agent.generate(`What's the weather like in ${city}?`);
180
+ return { result: result.text };
181
+ }
182
+ } satisfies Actions;
183
+
184
+ ```
185
+
186
+ ### Create Test Page
187
+
188
+ Create a new Page file, and add the example code:
189
+
190
+ ```bash copy
191
+ touch src/routes/test/+page.svelte
192
+ ```
193
+
194
+ ```typescript filename="src/routes/test/+page.svelte" showLineNumbers copy
195
+ <script lang="ts">
196
+ import type { PageProps } from './$types';
197
+ let { form }: PageProps = $props();
198
+ </script>
199
+
200
+ <h1>Test</h1>
201
+
202
+ <form method="POST">
203
+ <input name="city" placeholder="Enter city" required />
204
+ <button type="submit">Get Weather</button>
205
+ </form>
206
+
207
+ {#if form?.result}
208
+ <pre>{form.result}</pre>
209
+ {/if}
210
+
211
+ ```
212
+
213
+ > You can now navigate to `/test` in your browser to try it out.
214
+
215
+ Submitting **London** as the city would return a result similar to:
216
+
217
+ ```plaintext
218
+ The current weather in London is as follows:
219
+
220
+ - **Temperature:** 16°C (feels like 13.8°C)
221
+ - **Humidity:** 62%
222
+ - **Wind Speed:** 12.6 km/h
223
+ - **Wind Gusts:** 32.4 km/h
224
+ - **Conditions:** Overcast
225
+
226
+ If you need more details or information about a different location, feel free to ask!
227
+ ```
228
+ </Steps>
229
+ </Tabs.Tab>
230
+
231
+ <Tabs.Tab>
232
+
233
+ <Steps>
234
+ ## Install Mastra
235
+
236
+ Install the required Mastra packages:
237
+ {/*
238
+ LLM CONTEXT: This Tabs component shows commands for integrating a new Mastra backend project using different package managers.
239
+ Each tab displays the command for that specific package manager to create an integrated Mastra backend service.
240
+ This is part of the "Integrated Framework Integration" approach for SvelteKit projects.
241
+ All commands create the same Mastra project but use different package manager syntax.
242
+ */}
243
+
244
+ <Tabs items={["npm", "yarn", "pnpm", "bun"]}>
245
+ <Tabs.Tab>
246
+ ```bash copy
247
+ npm install mastra@latest @mastra/core@latest @mastra/libsql@latest
248
+ ```
249
+ </Tabs.Tab>
250
+ <Tabs.Tab>
251
+ ```bash copy
252
+ yarn add mastra@latest @mastra/core@latest @mastra/libsql@latest
253
+ ```
254
+ </Tabs.Tab>
255
+ <Tabs.Tab>
256
+ ```bash copy
257
+ pnpm add mastra@latest @mastra/core@latest @mastra/libsql@latest
258
+ ```
259
+ </Tabs.Tab>
260
+ <Tabs.Tab>
261
+ ```bash copy
262
+ bun add mastra@latest @mastra/core@latest @mastra/libsql@latest
263
+ ```
264
+ </Tabs.Tab>
265
+ </Tabs>
266
+
267
+ ## Integrate Mastra
268
+
269
+ To integrate Mastra into your project, you have two options:
270
+
271
+ ### 1. Use the One-Liner
272
+
273
+ Run the following command to quickly scaffold the default Weather agent with sensible defaults:
274
+
275
+ ```bash copy
276
+ npx mastra@latest init --default
277
+ ```
278
+
279
+ > See [mastra init](/reference/cli/init) for more information.
280
+
281
+ ### 2. Use the Interactive CLI
282
+
283
+ If you prefer to customize the setup, run the `init` command and choose from the options when prompted:
284
+
285
+ ```bash copy
286
+ npx mastra@latest init
287
+ ```
288
+
289
+ Add the `dev` and `build` scripts to `package.json`:
290
+
291
+ ```json filename="package.json"
292
+ {
293
+ "scripts": {
294
+ ...
295
+ "dev:mastra": "mastra dev",
296
+ "build:mastra": "mastra build"
297
+ }
298
+ }
299
+ ```
300
+
301
+ ## Configure TypeScript
302
+
303
+ Modify the `tsconfig.json` file in your project root:
304
+
305
+ ```json filename="tsconfig.json"
306
+ {
307
+ ...
308
+ "exclude": ["dist", ".mastra"]
309
+ }
310
+ ```
311
+
312
+ ## Set Up API Key
313
+
314
+ The `VITE_` prefix is required for environment variables to be accessible in the Vite environment, that SvelteKit uses.
315
+ [Read more about Vite environment variables](https://vite.dev/guide/env-and-mode.html#env-variables).
316
+
317
+ ```bash filename=".env" copy
318
+ VITE_OPENAI_API_KEY=<your-api-key>
319
+ ```
320
+
321
+ ## Update .gitignore
322
+
323
+ Add `.mastra` to your `.gitignore` file:
324
+
325
+ ```bash filename=".gitignore" copy
326
+ .mastra
327
+ ```
328
+
329
+ ## Update the Mastra Agent
330
+
331
+ ```diff filename="src/mastra/agents/weather-agent.ts"
332
+ - import { openai } from "@ai-sdk/openai";
333
+ + import { createOpenAI } from "@ai-sdk/openai";
334
+
335
+ + const openai = createOpenAI({
336
+ + apiKey: import.meta.env?.VITE_OPENAI_API_KEY || process.env.VITE_OPENAI_API_KEY,
337
+ + compatibility: "strict"
338
+ + });
339
+ ```
340
+
341
+ By reading env vars from both `import.meta.env` and `process.env`, we ensure that the API key is available in both the SvelteKit dev server and the Mastra Dev Server.
342
+
343
+ > 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.
344
+
345
+ ## Start the Mastra Dev Server
346
+
347
+ Start the Mastra Dev Server to expose your agents as REST endpoints:
348
+
349
+ <Tabs items={["npm", "CLI"]}>
350
+ <Tabs.Tab>
351
+ ```bash copy
352
+ npm run dev:mastra
353
+ ```
354
+ </Tabs.Tab>
355
+ <Tabs.Tab>
356
+ ```bash copy
357
+ mastra dev:mastra
358
+ ```
359
+ </Tabs.Tab>
360
+ </Tabs>
361
+
362
+ > Once running, your agents are available locally. See [Local Development Environment](/docs/local-dev/mastra-dev) for more information.
363
+
364
+ ## Start SvelteKit Dev Server
365
+
366
+ With the Mastra Dev Server running, you can start your SvelteKit site in the usual way.
367
+
368
+ ## Create API Directory
369
+
370
+ ```bash copy
371
+ mkdir src/routes/weather-api
372
+ ```
373
+
374
+ ### Create Test Endpoint
375
+
376
+ Create a new Endpoint, and add the example code:
377
+
378
+ ```bash copy
379
+ touch src/routes/weather-api/+server.ts
380
+ ```
381
+
382
+ ```typescript filename="src/routes/weather-api/+server.ts" showLineNumbers copy
383
+ import { json } from '@sveltejs/kit';
384
+ import { mastra } from '../../mastra';
385
+
386
+ export async function POST({ request }) {
387
+ const { city } = await request.json();
388
+
389
+ const response = await mastra
390
+ .getAgent('weatherAgent')
391
+ .generate(`What's the weather like in ${city}?`);
392
+
393
+ return json({ result: response.text });
394
+ }
395
+
396
+ ```
397
+
398
+ ### Create Test Page
399
+
400
+ Create a new Page, and add the example code:
401
+
402
+ ```bash copy
403
+ touch src/routes/weather-api-test/+page.svelte
404
+ ```
405
+
406
+ ```typescript filename="src/routes/weather-api-test/+page.svelte" showLineNumbers copy
407
+ <script lang="ts">
408
+ let result = $state<string | null>(null);
409
+ async function handleFormSubmit(event: Event) {
410
+ event.preventDefault();
411
+ const formData = new FormData(event.currentTarget);
412
+ const city = formData.get('city')?.toString();
413
+ if (city) {
414
+ const response = await fetch('/weather-api', {
415
+ method: 'POST',
416
+ headers: {
417
+ 'Content-Type': 'application/json'
418
+ },
419
+ body: JSON.stringify({ city })
420
+ });
421
+ const data = await response.json();
422
+ result = data.result;
423
+ }
424
+ }
425
+ </script>
426
+
427
+ <h1>Test</h1>
428
+ <form method="POST" onsubmit={handleFormSubmit}>
429
+ <input name="city" placeholder="Enter city" required />
430
+ <button type="submit">Get Weather</button>
431
+ </form>
432
+
433
+ {#if result}
434
+ <pre>{result}</pre>
435
+ {/if}
436
+ ```
437
+
438
+
439
+ > You can now navigate to `/weather-api-test` in your browser to try it out.
440
+
441
+ Submitting **London** as the city would return a result similar to:
442
+
443
+ ```plaintext
444
+ The current weather in London is as follows:
445
+
446
+ - **Temperature:** 16.1°C (feels like 14.2°C)
447
+ - **Humidity:** 64%
448
+ - **Wind Speed:** 11.9 km/h
449
+ - **Wind Gusts:** 30.6 km/h
450
+ - **Conditions:** Overcast
451
+
452
+ If you need more details or information about a different location, feel free to ask!
453
+ ```
454
+ </Steps>
455
+ </Tabs.Tab>
456
+ </Tabs>
@@ -75,17 +75,36 @@ If you prefer to customize the setup, run the `init` command and choose from the
75
75
  npx mastra@latest init
76
76
  ```
77
77
 
78
+ <Callout type="warning">
79
+ By default, `mastra init` suggests `src` as the install location. If you're using Vite/React at the root of your project (e.g., `app`, not `src/app`), enter `.` when prompted:
80
+ </Callout>
81
+
78
82
  Add the `dev` and `build` scripts to `package.json`:
79
83
 
80
- ```json filename="package.json"
81
- {
82
- "scripts": {
83
- ...
84
- "dev:mastra": "mastra dev --dir mastra",
85
- "build:mastra": "mastra build --dir mastra"
86
- }
87
- }
88
- ```
84
+ <Tabs items={["app", "src/app"]}>
85
+ <Tabs.Tab>
86
+ ```json filename="package.json"
87
+ {
88
+ "scripts": {
89
+ ...
90
+ "dev:mastra": "mastra dev --dir mastra",
91
+ "build:mastra": "mastra build --dir mastra"
92
+ }
93
+ }
94
+ ```
95
+ </Tabs.Tab>
96
+ <Tabs.Tab>
97
+ ```json filename="package.json"
98
+ {
99
+ "scripts": {
100
+ ...
101
+ "dev:mastra": "mastra dev --dir src/mastra",
102
+ "build:mastra": "mastra build --dir src/mastra"
103
+ }
104
+ }
105
+ ```
106
+ </Tabs.Tab>
107
+ </Tabs>
89
108
 
90
109
  ## Configure TypeScript
91
110