@mastra/mcp-docs-server 1.2.8-alpha.2 → 1.2.8-alpha.25

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 (154) hide show
  1. package/.docs/docs/agent-builder/integrations.md +1 -3
  2. package/.docs/docs/agent-builder/overview.md +2 -0
  3. package/.docs/docs/agents/overview.md +17 -13
  4. package/.docs/docs/agents/skills.md +1 -3
  5. package/.docs/docs/agents/structured-output.md +14 -7
  6. package/.docs/docs/agents/using-tools.md +66 -49
  7. package/.docs/docs/browser/agent-browser.md +1 -0
  8. package/.docs/docs/browser/firecrawl.md +129 -0
  9. package/.docs/docs/browser/overview.md +16 -2
  10. package/.docs/docs/capabilities/channels/slack.md +111 -1
  11. package/.docs/docs/deployment/mastra-server.md +35 -0
  12. package/.docs/docs/deployment/monorepo.md +2 -0
  13. package/.docs/docs/deployment/overview.md +6 -0
  14. package/.docs/docs/deployment/sandbox.md +277 -0
  15. package/.docs/docs/editor/overview.md +2 -6
  16. package/.docs/docs/editor/tools.md +2 -6
  17. package/.docs/docs/evals/multi-turn.md +178 -0
  18. package/.docs/docs/evals/overview.md +1 -0
  19. package/.docs/docs/evals/running-in-ci.md +3 -9
  20. package/.docs/docs/getting-started/build-with-ai.md +2 -6
  21. package/.docs/docs/getting-started/manual-install.md +1 -1
  22. package/.docs/docs/index.md +17 -13
  23. package/.docs/docs/long-running-agents/background-tasks.md +2 -2
  24. package/.docs/docs/long-running-agents/durable-agents.md +2 -1
  25. package/.docs/docs/long-running-agents/goals.md +3 -1
  26. package/.docs/docs/mastra-platform/database.md +12 -6
  27. package/.docs/docs/mastra-platform/deploy.md +14 -7
  28. package/.docs/docs/mastra-platform/environments.md +5 -4
  29. package/.docs/docs/mastra-platform/observability.md +4 -12
  30. package/.docs/docs/mastra-platform/overview.md +1 -1
  31. package/.docs/docs/mastra-platform/regions.md +73 -0
  32. package/.docs/docs/mastra-platform/workspace.md +111 -0
  33. package/.docs/docs/mcp/overview.md +1 -1
  34. package/.docs/docs/memory/observational-memory.md +77 -2
  35. package/.docs/docs/memory/overview.md +4 -0
  36. package/.docs/docs/observability/feedback.md +4 -0
  37. package/.docs/docs/observability/integrations/bridges/otel.md +1 -3
  38. package/.docs/docs/observability/integrations/exporters/otel.md +1 -3
  39. package/.docs/docs/server/auth/fga.md +40 -0
  40. package/.docs/docs/server/auth/simple-auth.md +1 -3
  41. package/.docs/docs/server/request-context.md +2 -0
  42. package/.docs/docs/studio/overview.md +2 -0
  43. package/.docs/docs/workflows/control-flow.md +1 -3
  44. package/.docs/docs/workspace/filesystem.md +1 -0
  45. package/.docs/docs/workspace/sandbox.md +1 -0
  46. package/.docs/guides/getting-started/quickstart.md +40 -25
  47. package/.docs/guides/index.md +1 -1
  48. package/.docs/guides/migrations/vnext-to-standard-apis.md +1 -3
  49. package/.docs/models/environment-variables.md +3 -0
  50. package/.docs/models/gateways/netlify.md +3 -1
  51. package/.docs/models/gateways/openrouter.md +343 -345
  52. package/.docs/models/gateways/vercel.md +8 -5
  53. package/.docs/models/index.md +1 -1
  54. package/.docs/models/providers/aki-io.md +78 -0
  55. package/.docs/models/providers/alibaba-token-plan-cn.md +22 -21
  56. package/.docs/models/providers/alibaba-token-plan.md +22 -21
  57. package/.docs/models/providers/ambient.md +12 -10
  58. package/.docs/models/providers/baseten.md +3 -2
  59. package/.docs/models/providers/cline-pass.md +82 -0
  60. package/.docs/models/providers/crossmodel.md +2 -1
  61. package/.docs/models/providers/deepinfra.md +4 -7
  62. package/.docs/models/providers/deepseek.md +3 -1
  63. package/.docs/models/providers/empiriolabs.md +2 -1
  64. package/.docs/models/providers/evroc.md +3 -2
  65. package/.docs/models/providers/google.md +6 -4
  66. package/.docs/models/providers/inferx.md +3 -3
  67. package/.docs/models/providers/kilo.md +1 -1
  68. package/.docs/models/providers/kimi-for-coding.md +10 -11
  69. package/.docs/models/providers/llmgateway.md +5 -8
  70. package/.docs/models/providers/moonshotai-cn.md +3 -2
  71. package/.docs/models/providers/moonshotai.md +3 -2
  72. package/.docs/models/providers/nebius.md +3 -1
  73. package/.docs/models/providers/novita-ai.md +3 -1
  74. package/.docs/models/providers/ollama-cloud.md +25 -42
  75. package/.docs/models/providers/opencode-go.md +5 -3
  76. package/.docs/models/providers/opencode.md +4 -2
  77. package/.docs/models/providers/orcarouter.md +1 -1
  78. package/.docs/models/providers/privatemode-ai.md +10 -10
  79. package/.docs/models/providers/thinkingmachines.md +73 -0
  80. package/.docs/models/providers/togetherai.md +2 -6
  81. package/.docs/models/providers/wandb.md +2 -1
  82. package/.docs/models/providers/zenmux.md +3 -1
  83. package/.docs/models/providers.md +3 -0
  84. package/.docs/reference/acp/acp-agent.md +2 -0
  85. package/.docs/reference/acp/create-acp-tool.md +28 -0
  86. package/.docs/reference/agent-controller/session.md +15 -0
  87. package/.docs/reference/agents/agent.md +13 -1
  88. package/.docs/reference/agents/durable-agent.md +23 -0
  89. package/.docs/reference/agents/generate.md +19 -1
  90. package/.docs/reference/browser/firecrawl-browser.md +71 -0
  91. package/.docs/reference/cli/create-mastra.md +118 -43
  92. package/.docs/reference/cli/mastra.md +59 -5
  93. package/.docs/reference/code-sdk/mount-agent-controller.md +4 -4
  94. package/.docs/reference/core/getMCPServer.md +1 -3
  95. package/.docs/reference/core/getMCPServerById.md +1 -3
  96. package/.docs/reference/core/getWorkflow.md +1 -3
  97. package/.docs/reference/core/listMCPServers.md +2 -6
  98. package/.docs/reference/datasets/addItem.md +1 -3
  99. package/.docs/reference/datasets/addItems.md +1 -3
  100. package/.docs/reference/datasets/compareExperiments.md +1 -3
  101. package/.docs/reference/datasets/create.md +1 -3
  102. package/.docs/reference/datasets/dataset.md +2 -6
  103. package/.docs/reference/datasets/datasets-manager.md +5 -15
  104. package/.docs/reference/datasets/delete.md +1 -3
  105. package/.docs/reference/datasets/deleteExperiment.md +1 -3
  106. package/.docs/reference/datasets/deleteItem.md +1 -3
  107. package/.docs/reference/datasets/deleteItems.md +1 -3
  108. package/.docs/reference/datasets/get.md +1 -3
  109. package/.docs/reference/datasets/getDetails.md +1 -3
  110. package/.docs/reference/datasets/getExperiment.md +1 -3
  111. package/.docs/reference/datasets/getItem.md +1 -3
  112. package/.docs/reference/datasets/getItemHistory.md +1 -3
  113. package/.docs/reference/datasets/list.md +1 -3
  114. package/.docs/reference/datasets/listExperimentResults.md +1 -3
  115. package/.docs/reference/datasets/listExperiments.md +1 -3
  116. package/.docs/reference/datasets/listItems.md +1 -3
  117. package/.docs/reference/datasets/listVersions.md +1 -3
  118. package/.docs/reference/datasets/startExperiment.md +1 -3
  119. package/.docs/reference/datasets/startExperimentAsync.md +1 -3
  120. package/.docs/reference/datasets/update.md +1 -3
  121. package/.docs/reference/datasets/updateItem.md +1 -3
  122. package/.docs/reference/editor/mastra-editor.md +1 -3
  123. package/.docs/reference/evals/context-recall.md +205 -0
  124. package/.docs/reference/evals/create-scorer.md +4 -10
  125. package/.docs/reference/evals/mastra-scorer.md +1 -3
  126. package/.docs/reference/evals/run-evals.md +94 -2
  127. package/.docs/reference/file-based-agents/tools.md +7 -6
  128. package/.docs/reference/index.md +5 -0
  129. package/.docs/reference/memory/observational-memory.md +21 -0
  130. package/.docs/reference/observability/tracing/exporters/posthog.md +39 -1
  131. package/.docs/reference/observability/tracing/processors/sensitive-data-filter.md +1 -3
  132. package/.docs/reference/processors/token-limiter-processor.md +1 -3
  133. package/.docs/reference/rag/database-config.md +12 -0
  134. package/.docs/reference/streaming/agents/stream.md +3 -1
  135. package/.docs/reference/templates/overview.md +6 -32
  136. package/.docs/reference/tools/create-tool.md +78 -52
  137. package/.docs/reference/tools/mcp-client.md +104 -24
  138. package/.docs/reference/tools/mcp-server.md +143 -44
  139. package/.docs/reference/tools/tavily.md +1 -1
  140. package/.docs/reference/tools/vector-query-tool.md +22 -0
  141. package/.docs/reference/vectors/mongodb.md +2 -0
  142. package/.docs/reference/vectors/turbopuffer.md +4 -0
  143. package/.docs/reference/voice/mistral.md +127 -0
  144. package/.docs/reference/workspace/daytona-sandbox.md +2 -6
  145. package/.docs/reference/workspace/platform-filesystem.md +182 -0
  146. package/.docs/reference/workspace/platform-sandbox.md +200 -0
  147. package/.docs/reference/workspace/railway-sandbox.md +37 -1
  148. package/CHANGELOG.md +85 -0
  149. package/dist/{chunk-GLPCVXXO.js → chunk-HGADBLKG.js} +2 -2
  150. package/dist/{chunk-GLPCVXXO.js.map → chunk-HGADBLKG.js.map} +1 -1
  151. package/dist/index.js +1 -1
  152. package/dist/stdio.js +1 -1
  153. package/dist/tools/docs.d.ts.map +1 -1
  154. package/package.json +7 -7
@@ -31,6 +31,28 @@ console.log(`Average scores:`, result.scores)
31
31
  console.log(`Processed ${result.summary.totalItems} items`)
32
32
  ```
33
33
 
34
+ ### Multi-turn evaluation
35
+
36
+ ```typescript
37
+ import { runEvals } from '@mastra/core/evals'
38
+ import { checks } from '@mastra/evals/checks'
39
+ import { weatherAgent } from './agents/weather-agent'
40
+
41
+ const result = await runEvals({
42
+ target: weatherAgent,
43
+ data: [
44
+ {
45
+ inputs: [
46
+ 'What is the weather in Brooklyn?',
47
+ 'What about tomorrow?',
48
+ 'Compare the two forecasts.',
49
+ ],
50
+ },
51
+ ],
52
+ scorers: [checks.calledTool('get_weather', { times: 2 }), checks.includes('Brooklyn')],
53
+ })
54
+ ```
55
+
34
56
  ### With gates and thresholds
35
57
 
36
58
  ```typescript
@@ -60,7 +82,7 @@ result.thresholdResults // [{ id, passed, averageScore, threshold }]
60
82
 
61
83
  **gates** (`MastraScorer[]`): Scorers that must score 1.0 for the run to pass. If any gate averages below 1.0 across data items, the verdict is failed. Gates run before regular scorers on each data item. When provided, scorers may be omitted.
62
84
 
63
- **targetOptions** (`AgentExecutionOptions | WorkflowRunOptions`): Options forwarded to the target during execution. For agents: options passed to agent.generate() (e.g. maxSteps, modelSettings, instructions). For workflows: options passed to run.start() (e.g. perStep, outputOptions, initialState).
85
+ **targetOptions** (`AgentExecutionOptions | WorkflowRunOptions`): Options forwarded to the target during execution. For agents: options passed to agent.generate() (e.g. maxSteps, modelSettings, instructions). For workflows: options passed to run.start() (e.g. perStep, outputOptions, initialState). For multi-turn agent runs (inputs/turns), runEvals generates and injects the shared thread and a resource, so memory.thread is optional; provide memory.resource to reuse a specific resource.
64
86
 
65
87
  **concurrency** (`number`): Number of test cases to run concurrently. (Default: `1`)
66
88
 
@@ -68,7 +90,11 @@ result.thresholdResults // [{ id, passed, averageScore, threshold }]
68
90
 
69
91
  ## Data item structure
70
92
 
71
- **input** (`string | string[] | CoreMessage[] | any`): Input data for the target. For agents: messages or strings. For workflows: workflow input data.
93
+ **input** (`string | string[] | CoreMessage[] | any`): Input data for the target. For agents: messages or strings. For workflows: workflow input data. Optional when inputs is provided.
94
+
95
+ **inputs** (`(string | string[] | CoreMessage[] | any)[]`): Multi-turn inputs. Each entry is one turn (same shape as input) sent sequentially to the agent on the same thread. Scorers see the accumulated output from all turns. Only supported for Agent targets. When provided, input can be omitted. Mutually exclusive with turns.
96
+
97
+ **turns** (`EvalTurn[]`): Multi-turn conversation with per-turn assertions. Each turn is an object { input, gates?, scorers? } sent sequentially on the same thread; its gates/scorers evaluate only that turn's input and output. Per-turn outcomes are reported in turnResults and folded into the overall verdict. Only supported for Agent targets. Mutually exclusive with input and inputs.
72
98
 
73
99
  **groundTruth** (`any`): Expected or reference output for comparison during scoring.
74
100
 
@@ -112,6 +138,18 @@ For workflows, use `WorkflowScorerConfig` to specify scorers at different levels
112
138
 
113
139
  **thresholdResults** (`ThresholdResult[]`): Per-threshold-scorer results averaged across all data items. Each entry has id, passed, averageScore, and threshold.
114
140
 
141
+ **turnResults** (`TurnResult[]`): Present when any data item uses turns. Each entry has index (zero-based turn), optional gateResults, thresholdResults, and scores (bare-scorer averages keyed by scorer id), aggregated by turn index across data items.
142
+
143
+ ## EvalTurn
144
+
145
+ A single turn in a `turns` array. Its `gates`/`scorers` evaluate only that turn's input and output:
146
+
147
+ **input** (`string | string[] | CoreMessage[] | any`): The input sent to the agent for this turn.
148
+
149
+ **gates** (`MastraScorer[]`): Gates that must score 1.0 for this turn. A failing turn gate makes the overall verdict failed.
150
+
151
+ **scorers** (`ScorerEntry[]`): Scorers (optionally with thresholds) evaluated against this turn only. A missed per-turn threshold (with gates passing) makes the verdict scored.
152
+
115
153
  ## ScorerEntry
116
154
 
117
155
  A scorer entry in the `scorers` array can be either a bare scorer or a scorer with a threshold:
@@ -314,8 +352,62 @@ const result = await runEvals({
314
352
  })
315
353
  ```
316
354
 
355
+ ### Multi-turn conversation evaluation
356
+
357
+ Use `inputs` to send sequential turns on a shared thread. Scorers see the accumulated output from all turns:
358
+
359
+ ```typescript
360
+ const result = await runEvals({
361
+ target: chatAgent,
362
+ data: [
363
+ {
364
+ inputs: ['My favorite city is Brooklyn.', 'What is the weather in my favorite city?'],
365
+ },
366
+ ],
367
+ gates: [checks.calledTool('get_weather')],
368
+ scorers: [{ scorer: checks.similarity('Brooklyn weather forecast'), threshold: 0.5 }],
369
+ })
370
+
371
+ // result.verdict: 'passed' | 'scored' | 'failed'
372
+ ```
373
+
374
+ Each turn runs `agent.generate()` with the same `threadId`, so the agent sees the full conversation history. `runEvals` also injects a `resourceId` (Mastra memory scopes messages by resource + thread), defaulting it to the generated thread; pass `targetOptions.memory.resource` to pin a specific one. Cross-turn recall requires the agent to have a memory store configured; otherwise turns run in isolation. Mix single-turn (`input`) and multi-turn (`inputs`) items in the same `data` array. When using `inputs`, `input` can be omitted.
375
+
376
+ Scoring uses the accumulated output from all turns as `run.output`, but only the first turn as `run.input`. Prefer output-based scorers (`checks.includes`, `checks.calledTool`, `checks.similarity`) for multi-turn; input-relative scorers (e.g. faithfulness) only see the first turn's input. Trajectory scorers that read from the trace (`AgentScorerConfig.trajectory`) resolve against the last turn's span; tool-call checks that read `run.output` (like `checks.calledTool`) still see every turn.
377
+
378
+ ### Per-turn assertions
379
+
380
+ Use `turns` to attach `gates`/`scorers` to individual turns. Each per-turn assertion sees only that turn's input and output, so a later-turn regression can't be hidden by an earlier turn:
381
+
382
+ ```typescript
383
+ const result = await runEvals({
384
+ target: chatAgent,
385
+ data: [
386
+ {
387
+ turns: [
388
+ {
389
+ input: 'What is the weather in Brooklyn?',
390
+ gates: [checks.calledTool('get_weather')],
391
+ },
392
+ {
393
+ input: 'What about tomorrow?',
394
+ gates: [checks.calledTool('get_weather')], // must call again this turn
395
+ scorers: [{ scorer: checks.similarity('tomorrow forecast'), threshold: 0.5 }],
396
+ },
397
+ ],
398
+ },
399
+ ],
400
+ })
401
+
402
+ result.verdict // folds in per-turn gate/threshold outcomes
403
+ result.turnResults // [{ index, gateResults, thresholdResults, scores }]
404
+ ```
405
+
406
+ Per-turn gates/scorers evaluate only that turn (`run.input`/`run.output` are that turn's). A failing turn gate makes the verdict `failed`; a missed turn threshold (gates passing) makes it `scored`. Top-level `scorers`/`gates` still score the accumulated conversation holistically. `turns` is Agent-only and cannot be combined with `input` or `inputs`.
407
+
317
408
  ## Related
318
409
 
410
+ - [Multi-turn evals](https://mastra.ai/docs/evals/multi-turn): Conceptual guide to multi-turn evaluation
319
411
  - [Gates and Verdicts](https://mastra.ai/docs/evals/gates-and-verdicts): Conceptual guide to severity semantics
320
412
  - [Quick Checks](https://mastra.ai/reference/evals/checks): Zero-LLM composable micro-scorers
321
413
  - [createScorer()](https://mastra.ai/reference/evals/create-scorer): Create custom scorers for experiments
@@ -16,16 +16,17 @@ import { z } from 'zod'
16
16
 
17
17
  export default createTool({
18
18
  id: 'get_weather',
19
- description: 'Get the current weather for a city.',
19
+ description: 'Get the current weather for a location.',
20
20
  inputSchema: z.object({
21
- city: z.string(),
21
+ location: z.string(),
22
22
  }),
23
23
  outputSchema: z.object({
24
- city: z.string(),
25
- tempC: z.number(),
24
+ location: z.string(),
25
+ temperatureCelsius: z.number(),
26
+ conditions: z.string(),
26
27
  }),
27
- execute: async ({ context }) => {
28
- return { city: context.city, tempC: 21 }
28
+ execute: async ({ location }) => {
29
+ return { location, temperatureCelsius: 21, conditions: 'sunny' }
29
30
  },
30
31
  })
31
32
  ```
@@ -57,6 +57,7 @@ The Reference section provides documentation of Mastra's API, including paramete
57
57
  - [WorkOS](https://mastra.ai/reference/auth/workos)
58
58
  - [AgentBrowser](https://mastra.ai/reference/browser/agent-browser)
59
59
  - [BrowserViewer](https://mastra.ai/reference/browser/browser-viewer)
60
+ - [FirecrawlBrowser](https://mastra.ai/reference/browser/firecrawl-browser)
60
61
  - [MastraBrowser Class](https://mastra.ai/reference/browser/mastra-browser)
61
62
  - [StagehandBrowser](https://mastra.ai/reference/browser/stagehand-browser)
62
63
  - [ChannelProvider](https://mastra.ai/reference/channels/channel-provider)
@@ -142,6 +143,7 @@ The Reference section provides documentation of Mastra's API, including paramete
142
143
  - [Completeness](https://mastra.ai/reference/evals/completeness)
143
144
  - [Content Similarity Scorer](https://mastra.ai/reference/evals/content-similarity)
144
145
  - [Context Precision Scorer](https://mastra.ai/reference/evals/context-precision)
146
+ - [Context Recall Scorer](https://mastra.ai/reference/evals/context-recall)
145
147
  - [Context Relevance Scorer](https://mastra.ai/reference/evals/context-relevance)
146
148
  - [Faithfulness](https://mastra.ai/reference/evals/faithfulness)
147
149
  - [Hallucination](https://mastra.ai/reference/evals/hallucination)
@@ -336,6 +338,7 @@ The Reference section provides documentation of Mastra's API, including paramete
336
338
  - [Inworld Realtime](https://mastra.ai/reference/voice/inworld-realtime)
337
339
  - [LiveKit](https://mastra.ai/reference/voice/livekit)
338
340
  - [Mastra Voice](https://mastra.ai/reference/voice/mastra-voice)
341
+ - [Mistral](https://mastra.ai/reference/voice/mistral)
339
342
  - [Murf](https://mastra.ai/reference/voice/murf)
340
343
  - [OpenAI](https://mastra.ai/reference/voice/openai)
341
344
  - [OpenAI Realtime](https://mastra.ai/reference/voice/openai-realtime)
@@ -392,6 +395,8 @@ The Reference section provides documentation of Mastra's API, including paramete
392
395
  - [LocalSandbox](https://mastra.ai/reference/workspace/local-sandbox)
393
396
  - [MesaFilesystem](https://mastra.ai/reference/workspace/mesa-filesystem)
394
397
  - [ModalSandbox](https://mastra.ai/reference/workspace/modal-sandbox)
398
+ - [PlatformFilesystem](https://mastra.ai/reference/workspace/platform-filesystem)
399
+ - [PlatformSandbox](https://mastra.ai/reference/workspace/platform-sandbox)
395
400
  - [RailwaySandbox](https://mastra.ai/reference/workspace/railway-sandbox)
396
401
  - [S3Filesystem](https://mastra.ai/reference/workspace/s3-filesystem)
397
402
  - [SandboxProcessManager](https://mastra.ai/reference/workspace/process-manager)
@@ -408,6 +408,27 @@ Setting `bufferTokens: false` disables both observation and reflection async buf
408
408
 
409
409
  Observational Memory emits typed data parts during agent execution that clients can use for real-time UI feedback. These are streamed alongside the agent's response.
410
410
 
411
+ ### Read extractor results
412
+
413
+ Both completion events carry extractor output in their `data` payload. The extractor fields are:
414
+
415
+ ```typescript
416
+ interface DataOmObservationEndPart {
417
+ type: 'data-om-observation-end'
418
+ data: {
419
+ /** Whether the completed work was an observation or reflection */
420
+ operationType: 'observation' | 'reflection'
421
+ /** Values extracted during this OM operation, keyed by extractor slug */
422
+ extractedValues?: Record<string, unknown>
423
+ /** Extractor failures from this OM operation. Successful extractor values are still included */
424
+ extractionFailures?: Array<{ slug: string; error: string }>
425
+ // ...other fields documented in the tables below
426
+ }
427
+ }
428
+ ```
429
+
430
+ Both extractor fields are optional. A completion can include values, failures, both, or neither. `data-om-observation-end` reports synchronous completion. `data-om-buffering-end` reports completed background work whose buffered content still awaits activation, although extractor metadata is already persisted. `DataOmBufferingEndPart` carries the same extractor fields, and both types are exported from `@mastra/memory/processors`. See [Read extracted values from a stream](https://mastra.ai/docs/memory/observational-memory) for a consumer example.
431
+
411
432
  ### `data-om-status`
412
433
 
413
434
  Emitted once per agent loop step, before model generation. Provides a snapshot of the current memory state, including token usage for both context windows and the state of any async buffered content.
@@ -39,6 +39,14 @@ async exportTracingEvent(event: TracingEvent): Promise<void>
39
39
 
40
40
  Exports a tracing event to PostHog.
41
41
 
42
+ ### `onFeedbackEvent`
43
+
44
+ ```typescript
45
+ async onFeedbackEvent(event: FeedbackEvent): Promise<void>
46
+ ```
47
+
48
+ Exports a feedback event to PostHog. See [Feedback export](#feedback-export).
49
+
42
50
  ### flush
43
51
 
44
52
  ```typescript
@@ -92,4 +100,34 @@ const exporter = new PosthogExporter({
92
100
  | `AGENT_RUN` | `$ai_span` |
93
101
  | `WORKFLOW_RUN` | `$ai_span` |
94
102
  | All other workflows | `$ai_span` |
95
- | `GENERIC` | `$ai_span` |
103
+ | `GENERIC` | `$ai_span` |
104
+
105
+ ## Feedback export
106
+
107
+ Feedback recorded with [`addFeedback()`](https://mastra.ai/docs/observability/feedback) is exported to PostHog as a native `$ai_feedback` event. PostHog shows it as **User feedback** on the linked trace. No extra configuration is needed.
108
+
109
+ ```typescript
110
+ const trace = await mastra.observability.getRecordedTrace({ traceId })
111
+ await trace.addFeedback({
112
+ feedbackType: 'thumbs',
113
+ value: 'down',
114
+ comment: 'Wrong answer',
115
+ })
116
+ ```
117
+
118
+ Feedback events map to these PostHog properties:
119
+
120
+ | Mastra feedback field | PostHog property |
121
+ | -------------------------------------- | ------------------- |
122
+ | `traceId` | `$ai_trace_id` |
123
+ | `comment` (or `value` when no comment) | `$ai_feedback_text` |
124
+ | `feedbackId` | `feedback_id` |
125
+ | `feedbackType` | `feedback_type` |
126
+ | `value` | `feedback_value` |
127
+ | `feedbackSource` | `feedback_source` |
128
+ | `spanId` | `span_id` |
129
+ | `sourceId` | `source_id` |
130
+ | `metadata.sessionId` | `$ai_session_id` |
131
+ | `metadata` (other keys) | custom properties |
132
+
133
+ Feedback without a `traceId` is dropped because PostHog anchors feedback to a trace through `$ai_trace_id`. The event's distinct ID resolves from `feedbackUserId`, then `metadata.userId`, then `defaultDistinctId`, then `anonymous`.
@@ -14,9 +14,7 @@ To opt out or customize the auto-applied filter, use the `sensitiveDataFilter` o
14
14
  import { Observability } from '@mastra/observability'
15
15
 
16
16
  new Observability({
17
- configs: {
18
- /* ... */
19
- },
17
+ configs: {/* ... */},
20
18
  // disable the auto-applied filter
21
19
  sensitiveDataFilter: false,
22
20
  // or customize it
@@ -85,9 +85,7 @@ export const agent = new Agent({
85
85
  name: 'context-limited-agent',
86
86
  instructions: 'You are a helpful assistant',
87
87
  model: 'openai/gpt-5.5',
88
- memory: new Memory({
89
- /* ... */
90
- }),
88
+ memory: new Memory({/* ... */}),
91
89
  inputProcessors: [
92
90
  new TokenLimiterProcessor({ limit: 4000 }), // Limits historical messages to ~4000 tokens
93
91
  ],
@@ -11,6 +11,7 @@ export type DatabaseConfig = {
11
11
  pinecone?: PineconeConfig
12
12
  pgvector?: PgVectorConfig
13
13
  chroma?: ChromaConfig
14
+ turbopuffer?: TurbopufferConfig
14
15
  [key: string]: any // Extensible for future databases
15
16
  }
16
17
  ```
@@ -90,6 +91,17 @@ whereDocument: { "$contains": "API documentation" }
90
91
  - Content-based document filtering
91
92
  - Complex query combinations
92
93
 
94
+ ### `TurbopufferConfig`
95
+
96
+ Configuration options specific to Turbopuffer vector store.
97
+
98
+ **consistency** (`'strong' | 'eventual'`): The consistency level for queries. "strong" (default) guarantees queries see all data written before the query started, at the cost of higher latency. "eventual" offers lower latency, but recently written data may not be visible yet.
99
+
100
+ **Use Cases:**
101
+
102
+ - Latency-sensitive queries where slightly stale data is acceptable (`eventual`)
103
+ - Read-your-writes workflows that must see the latest data (`strong`)
104
+
93
105
  ## Usage examples
94
106
 
95
107
  **Basic Usage**:
@@ -100,7 +100,7 @@ const stream = await agent.stream('message for agent')
100
100
 
101
101
  **options.structuredOutput.instructions** (`string`): Additional instructions for the structured output model.
102
102
 
103
- **options.structuredOutput.jsonPromptInjection** (`boolean`): Injects system prompt into the main agent instructing it to return structured output, useful for when a model does not natively support structured outputs.
103
+ **options.structuredOutput.jsonPromptInjection** (`boolean | 'system' | 'inline' | 'auto'`): Controls how the JSON schema reaches the model. Set to 'auto' to use native structured output when supported and inline prompt injection otherwise.
104
104
 
105
105
  **options.structuredOutput.providerOptions** (`ProviderOptions`): Provider-specific options passed to the internal structuring agent. Use this to control model behavior like reasoning effort for thinking models (e.g., { openai: { reasoningEffort: 'low' } }).
106
106
 
@@ -124,6 +124,8 @@ const stream = await agent.stream('message for agent')
124
124
 
125
125
  **options.memory.options** (`MemoryConfig`): Configuration for memory behavior including lastMessages, readOnly, semanticRecall, workingMemory, and filterIncompleteToolCalls.
126
126
 
127
+ **options.memory.onTitleGenerated** (`(title: string) => void | Promise<void>`): Callback fired asynchronously when a thread title is generated and persisted to storage. Title generation runs in the background and may complete after the stream ends. Only fires when generateTitle is enabled in memory options and the thread has no existing title.
128
+
127
129
  **options.onFinish** (`StreamTextOnFinishCallback<any> | StreamObjectOnFinishCallback<OUTPUT>`): Callback function called when streaming completes. Receives the final result.
128
130
 
129
131
  **options.onStepFinish** (`StreamTextOnStepFinishCallback<any> | never`): Callback function called after each execution step. Receives step details as a JSON string. Unavailable for structured output
@@ -30,28 +30,28 @@ Install a template using the `create-mastra` command:
30
30
  **npm**:
31
31
 
32
32
  ```sh
33
- npx create-mastra@latest --template template-name
33
+ npx create-mastra@latest my-project --template template-name
34
34
  ```
35
35
 
36
36
  **pnpm**:
37
37
 
38
38
  ```sh
39
- pnpm dlx create-mastra@latest --template template-name
39
+ pnpm dlx create-mastra@latest my-project --template template-name
40
40
  ```
41
41
 
42
42
  **Yarn**:
43
43
 
44
44
  ```sh
45
- yarn dlx create-mastra@latest --template template-name
45
+ yarn dlx create-mastra@latest my-project --template template-name
46
46
  ```
47
47
 
48
48
  **Bun**:
49
49
 
50
50
  ```sh
51
- bun x create-mastra@latest --template template-name
51
+ bun x create-mastra@latest my-project --template template-name
52
52
  ```
53
53
 
54
- This creates a complete project with all necessary code and configuration.
54
+ This creates a complete project and installs its dependencies. The template author controls the models, provider dependencies, environment variables, and source code.
55
55
 
56
56
  ### Setup Process
57
57
 
@@ -71,33 +71,7 @@ After installation:
71
71
 
72
72
  Edit `.env` with required API keys as documented in the template's README.
73
73
 
74
- 3. **Install dependencies** (if not done automatically):
75
-
76
- **npm**:
77
-
78
- ```sh
79
- npm install
80
- ```
81
-
82
- **pnpm**:
83
-
84
- ```sh
85
- pnpm install
86
- ```
87
-
88
- **Yarn**:
89
-
90
- ```sh
91
- yarn install
92
- ```
93
-
94
- **Bun**:
95
-
96
- ```sh
97
- bun install
98
- ```
99
-
100
- 4. **Start development server**:
74
+ 3. **Start development server**:
101
75
 
102
76
  **npm**:
103
77
 
@@ -10,25 +10,29 @@ The `createTool()` function is used to define custom tools that your Mastra agen
10
10
  import { createTool } from '@mastra/core/tools'
11
11
  import { z } from 'zod'
12
12
 
13
- export const tool = createTool({
14
- id: 'test-tool',
15
- description: 'Reverse the input string',
13
+ export const weatherTool = createTool({
14
+ id: 'weather-tool',
15
+ description: 'Get the current weather for a location',
16
16
  inputSchema: z.object({
17
- input: z.string(),
17
+ location: z.string(),
18
18
  }),
19
19
  outputSchema: z.object({
20
- output: z.string(),
20
+ location: z.string(),
21
+ temperatureCelsius: z.number(),
22
+ conditions: z.string(),
21
23
  }),
22
- execute: async inputData => {
23
- const reversed = inputData.input.split('').reverse().join('')
24
-
24
+ execute: async ({ location }) => {
25
25
  return {
26
- output: reversed,
26
+ location,
27
+ temperatureCelsius: 21,
28
+ conditions: 'sunny',
27
29
  }
28
30
  },
29
31
  })
30
32
  ```
31
33
 
34
+ The first `execute` parameter is the validated value from `inputSchema`. Destructure schema fields directly in the function signature, as shown with `{ location }`. The optional second parameter contains the execution context.
35
+
32
36
  ## Parameters
33
37
 
34
38
  **id** (`string`): A unique identifier for the tool.
@@ -112,10 +116,12 @@ export const weatherTool = createTool({
112
116
  location: z.string(),
113
117
  }),
114
118
  outputSchema: z.object({
115
- weather: z.string(),
119
+ location: z.string(),
120
+ temperatureCelsius: z.number(),
121
+ conditions: z.string(),
116
122
  }),
117
- execute: async inputData => {
118
- // Fetch weather data
123
+ execute: async ({ location }) => {
124
+ return { location, temperatureCelsius: 21, conditions: 'sunny' }
119
125
  },
120
126
  })
121
127
  ```
@@ -137,11 +143,13 @@ export const weatherTool = createTool({
137
143
  ),
138
144
  outputSchema: toStandardJsonSchema(
139
145
  v.object({
140
- weather: v.string(),
146
+ location: v.string(),
147
+ temperatureCelsius: v.number(),
148
+ conditions: v.string(),
141
149
  }),
142
150
  ),
143
- execute: async inputData => {
144
- // Fetch weather data
151
+ execute: async ({ location }) => {
152
+ return { location, temperatureCelsius: 21, conditions: 'sunny' }
145
153
  },
146
154
  })
147
155
  ```
@@ -159,10 +167,12 @@ export const weatherTool = createTool({
159
167
  location: 'string',
160
168
  }),
161
169
  outputSchema: type({
162
- weather: 'string',
170
+ location: 'string',
171
+ temperatureCelsius: 'number',
172
+ conditions: 'string',
163
173
  }),
164
- execute: async inputData => {
165
- // Fetch weather data
174
+ execute: async ({ location }) => {
175
+ return { location, temperatureCelsius: 21, conditions: 'sunny' }
166
176
  },
167
177
  })
168
178
  ```
@@ -176,18 +186,22 @@ import { createTool } from '@mastra/core/tools'
176
186
  import { z } from 'zod'
177
187
 
178
188
  export const weatherTool = createTool({
179
- id: 'get-weather',
180
- description: 'Get weather for a city',
189
+ id: 'weather-tool',
190
+ description: 'Get the current weather for a location',
181
191
  strict: true,
182
192
  inputSchema: z.object({
183
- city: z.string(),
184
- units: z.enum(['metric', 'imperial']),
193
+ location: z.string(),
194
+ }),
195
+ outputSchema: z.object({
196
+ location: z.string(),
197
+ temperatureCelsius: z.number(),
198
+ conditions: z.string(),
185
199
  }),
186
- execute: async ({ city, units }) => {
200
+ execute: async ({ location }) => {
187
201
  return {
188
- city,
189
- units,
190
- forecast: 'sunny',
202
+ location,
203
+ temperatureCelsius: 21,
204
+ conditions: 'sunny',
191
205
  }
192
206
  },
193
207
  })
@@ -204,28 +218,31 @@ import { createTool } from '@mastra/core/tools'
204
218
  import { z } from 'zod'
205
219
 
206
220
  export const weatherTool = createTool({
207
- id: 'get-weather',
208
- description: 'Get weather for a city',
221
+ id: 'weather-tool',
222
+ description: 'Get the current weather for a location',
209
223
  inputSchema: z.object({
210
- city: z.string(),
224
+ location: z.string(),
211
225
  }),
212
226
  outputSchema: z.object({
213
- city: z.string(),
214
- temperature: z.number(),
215
- condition: z.string(),
227
+ location: z.string(),
228
+ temperatureCelsius: z.number(),
229
+ conditions: z.string(),
216
230
  radarImageUrl: z.string().url(),
217
231
  }),
218
- execute: async ({ city }) => ({
219
- city,
220
- temperature: 72,
221
- condition: 'sunny',
232
+ execute: async ({ location }) => ({
233
+ location,
234
+ temperatureCelsius: 21,
235
+ conditions: 'sunny',
222
236
  radarImageUrl: 'https://example.com/radar/seattle.png',
223
237
  }),
224
238
  toModelOutput: output => {
225
239
  return {
226
240
  type: 'content',
227
241
  value: [
228
- { type: 'text', text: `${output.city}: ${output.temperature}F and ${output.condition}` },
242
+ {
243
+ type: 'text',
244
+ text: `${output.location}: ${output.temperatureCelsius}°C and ${output.conditions}`,
245
+ },
229
246
  { type: 'image-url', url: output.radarImageUrl },
230
247
  ],
231
248
  }
@@ -294,11 +311,16 @@ import { createTool } from '@mastra/core/tools'
294
311
  import { z } from 'zod'
295
312
 
296
313
  export const weatherTool = createTool({
297
- id: 'get-weather',
298
- description: 'Get current weather for a location',
314
+ id: 'weather-tool',
315
+ description: 'Get the current weather for a location',
299
316
  inputSchema: z.object({
300
317
  location: z.string().describe('City name or coordinates'),
301
318
  }),
319
+ outputSchema: z.object({
320
+ location: z.string(),
321
+ temperatureCelsius: z.number(),
322
+ conditions: z.string(),
323
+ }),
302
324
  // MCP-specific properties
303
325
  mcp: {
304
326
  // Annotations for client behavior hints
@@ -315,9 +337,11 @@ export const weatherTool = createTool({
315
337
  category: 'weather',
316
338
  },
317
339
  },
318
- execute: async inputData => {
340
+ execute: async ({ location }) => {
319
341
  return {
320
- weather: `Current weather for ${inputData.location}: sunny`,
342
+ location,
343
+ temperatureCelsius: 21,
344
+ conditions: 'sunny',
321
345
  }
322
346
  },
323
347
  })
@@ -334,19 +358,21 @@ import { createTool } from '@mastra/core/tools'
334
358
  import { z } from 'zod'
335
359
 
336
360
  export const weatherTool = createTool({
337
- id: 'get-weather',
338
- description: 'Get weather for a city',
361
+ id: 'weather-tool',
362
+ description: 'Get the current weather for a location',
339
363
  inputSchema: z.object({
340
- city: z.string(),
364
+ location: z.string(),
341
365
  }),
342
366
  outputSchema: z.object({
343
- city: z.string(),
344
- forecast: z.string(),
367
+ location: z.string(),
368
+ temperatureCelsius: z.number(),
369
+ conditions: z.string(),
345
370
  }),
346
- execute: async ({ city }) => {
371
+ execute: async ({ location }) => {
347
372
  return {
348
- city,
349
- forecast: 'sunny',
373
+ location,
374
+ temperatureCelsius: 21,
375
+ conditions: 'sunny',
350
376
  }
351
377
  },
352
378
  onInputStart: ({ toolCallId }) => {
@@ -356,10 +382,10 @@ export const weatherTool = createTool({
356
382
  console.log(`Tool call ${toolCallId} received input chunk: ${inputTextDelta}`)
357
383
  },
358
384
  onInputAvailable: ({ input, toolCallId }) => {
359
- console.log(`Tool call ${toolCallId} received city: ${input.city}`)
385
+ console.log(`Tool call ${toolCallId} received location: ${input.location}`)
360
386
  },
361
387
  onOutput: ({ output, toolCallId, toolName }) => {
362
- console.log(`Tool ${toolName} call ${toolCallId} returned forecast: ${output.forecast}`)
388
+ console.log(`Tool ${toolName} call ${toolCallId} returned conditions: ${output.conditions}`)
363
389
  },
364
390
  })
365
391
  ```
@@ -403,7 +429,7 @@ export const tool = createTool({
403
429
  id: 'example-tool',
404
430
  description: 'Example tool with hooks',
405
431
  inputSchema: z.object({
406
- city: z.string(),
432
+ location: z.string(),
407
433
  }),
408
434
  onInputAvailable: ({ input, toolCallId, messages, abortSignal }) => {
409
435
  console.log(`Tool received complete input:`, input)