@mastra/mcp-docs-server 1.2.7-alpha.10 → 1.2.7-alpha.3

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 (157) hide show
  1. package/.docs/docs/agent-builder/overview.md +3 -4
  2. package/.docs/docs/agent-builder/skill-registries.md +3 -1
  3. package/.docs/docs/agent-controller/overview.md +2 -3
  4. package/.docs/docs/agent-controller/session.md +3 -1
  5. package/.docs/docs/agents/a2a.md +1 -2
  6. package/.docs/docs/agents/channels.md +225 -0
  7. package/.docs/docs/agents/code-mode.md +1 -1
  8. package/.docs/docs/agents/file-based-agents.md +297 -0
  9. package/.docs/docs/agents/guardrails.md +9 -10
  10. package/.docs/docs/agents/overview.md +4 -4
  11. package/.docs/docs/agents/skills.md +5 -3
  12. package/.docs/docs/agents/structured-output.md +1 -1
  13. package/.docs/docs/agents/supervisor-agents.md +4 -3
  14. package/.docs/docs/agents/using-tools.md +4 -2
  15. package/.docs/docs/browser/agent-browser.md +3 -1
  16. package/.docs/docs/browser/browser-viewer.md +3 -1
  17. package/.docs/docs/browser/overview.md +1 -2
  18. package/.docs/docs/browser/stagehand.md +1 -1
  19. package/.docs/docs/deployment/mastra-server.md +4 -2
  20. package/.docs/docs/editor/overview.md +6 -2
  21. package/.docs/docs/editor/prompts.md +1 -1
  22. package/.docs/docs/editor/tools.md +3 -1
  23. package/.docs/docs/evals/custom-scorers.md +3 -1
  24. package/.docs/docs/evals/datasets/overview.md +5 -4
  25. package/.docs/docs/evals/datasets/running-experiments.md +2 -4
  26. package/.docs/docs/evals/evals-with-memory.md +3 -1
  27. package/.docs/docs/evals/gates-and-verdicts.md +3 -1
  28. package/.docs/docs/evals/overview.md +1 -4
  29. package/.docs/docs/evals/quick-checks.md +3 -1
  30. package/.docs/docs/long-running-agents/background-tasks.md +1 -1
  31. package/.docs/docs/long-running-agents/durable-agents.md +5 -3
  32. package/.docs/docs/long-running-agents/goals.md +3 -1
  33. package/.docs/docs/long-running-agents/signal-providers.md +3 -1
  34. package/.docs/docs/long-running-agents/signals.md +22 -11
  35. package/.docs/docs/mastra-platform/observability.md +1 -5
  36. package/.docs/docs/mcp/mcp-apps.md +3 -3
  37. package/.docs/docs/mcp/overview.md +10 -6
  38. package/.docs/docs/memory/observational-memory.md +1 -2
  39. package/.docs/docs/memory/overview.md +4 -6
  40. package/.docs/docs/memory/semantic-recall.md +1 -1
  41. package/.docs/docs/memory/working-memory.md +3 -3
  42. package/.docs/docs/observability/integrations/exporters/mastra-platform.md +3 -1
  43. package/.docs/docs/observability/logging.md +1 -1
  44. package/.docs/docs/observability/tracing/overview.md +1 -1
  45. package/.docs/docs/server/auth/auth0.md +1 -1
  46. package/.docs/docs/server/auth/better-auth.md +2 -2
  47. package/.docs/docs/server/auth/clerk.md +1 -1
  48. package/.docs/docs/server/auth/firebase.md +1 -1
  49. package/.docs/docs/server/auth/google.md +2 -2
  50. package/.docs/docs/server/auth/jwt.md +2 -2
  51. package/.docs/docs/server/auth/okta.md +2 -2
  52. package/.docs/docs/server/auth/workos.md +1 -1
  53. package/.docs/docs/server/mastra-client.md +1 -1
  54. package/.docs/docs/server/mastra-server.md +1 -1
  55. package/.docs/docs/server/pubsub.md +1 -1
  56. package/.docs/docs/server/request-context.md +4 -4
  57. package/.docs/docs/server/server-adapters.md +8 -8
  58. package/.docs/docs/studio/auth.md +3 -1
  59. package/.docs/docs/studio/overview.md +1 -1
  60. package/.docs/docs/voice/livekit.md +3 -100
  61. package/.docs/docs/workflows/agents-and-tools.md +5 -3
  62. package/.docs/docs/workflows/control-flow.md +3 -1
  63. package/.docs/docs/workflows/overview.md +7 -6
  64. package/.docs/docs/workspace/overview.md +1 -2
  65. package/.docs/docs/workspace/sandbox.md +0 -2
  66. package/.docs/guides/build-your-ui/assistant-ui.md +1 -1
  67. package/.docs/guides/build-your-ui/copilotkit/overview.md +1 -1
  68. package/.docs/guides/concepts/streaming.md +3 -3
  69. package/.docs/guides/getting-started/quickstart.md +1 -3
  70. package/.docs/guides/guide/chef-michel.md +2 -0
  71. package/.docs/guides/guide/slack-assistant.md +2 -2
  72. package/.docs/guides/guide/stock-agent.md +2 -0
  73. package/.docs/models/environment-variables.md +0 -3
  74. package/.docs/models/gateways/netlify.md +1 -4
  75. package/.docs/models/gateways/openrouter.md +6 -10
  76. package/.docs/models/gateways/vercel.md +1 -7
  77. package/.docs/models/index.md +1 -1
  78. package/.docs/models/providers/google.md +1 -2
  79. package/.docs/models/providers/llmgateway.md +181 -184
  80. package/.docs/models/providers/nano-gpt.md +2 -2
  81. package/.docs/models/providers/neon.md +29 -40
  82. package/.docs/models/providers/openai.md +1 -5
  83. package/.docs/models/providers/opencode.md +1 -2
  84. package/.docs/models/providers/poolside.md +5 -6
  85. package/.docs/models/providers/routing-run.md +34 -20
  86. package/.docs/models/providers/the-grid-ai.md +3 -3
  87. package/.docs/models/providers/wandb.md +14 -21
  88. package/.docs/models/providers/xai.md +1 -2
  89. package/.docs/models/providers.md +0 -3
  90. package/.docs/reference/agents/channels.md +2 -2
  91. package/.docs/reference/channels/channel-provider.md +1 -1
  92. package/.docs/reference/channels/slack-provider.md +2 -2
  93. package/.docs/reference/cli/mastra.md +10 -117
  94. package/.docs/reference/evals/create-scorer.md +0 -8
  95. package/.docs/reference/index.md +0 -15
  96. package/.docs/reference/memory/memory-class.md +1 -1
  97. package/.docs/reference/memory/serialized-memory-config.md +1 -1
  98. package/.docs/reference/project-structure.md +1 -1
  99. package/.docs/reference/pubsub/lease-provider.md +1 -1
  100. package/.docs/reference/server/express-adapter.md +3 -1
  101. package/.docs/reference/server/fastify-adapter.md +3 -1
  102. package/.docs/reference/server/hono-adapter.md +3 -1
  103. package/.docs/reference/server/koa-adapter.md +3 -1
  104. package/.docs/reference/server/nestjs-adapter.md +3 -1
  105. package/.docs/reference/storage/clickhouse.md +0 -32
  106. package/.docs/reference/storage/composite.md +1 -27
  107. package/.docs/reference/storage/retention.md +0 -11
  108. package/.docs/reference/tools/mcp-client.md +0 -22
  109. package/.docs/reference/tools/mcp-server.md +4 -161
  110. package/.docs/reference/voice/livekit.md +8 -272
  111. package/.docs/reference/workspace/agentcore-runtime-sandbox.md +3 -1
  112. package/.docs/reference/workspace/agentfs-filesystem.md +3 -1
  113. package/.docs/reference/workspace/apple-container-sandbox.md +3 -1
  114. package/.docs/reference/workspace/archil-filesystem.md +3 -1
  115. package/.docs/reference/workspace/azure-blob-filesystem.md +3 -1
  116. package/.docs/reference/workspace/blaxel-sandbox.md +3 -1
  117. package/.docs/reference/workspace/daytona-sandbox.md +3 -1
  118. package/.docs/reference/workspace/docker-sandbox.md +3 -1
  119. package/.docs/reference/workspace/e2b-sandbox.md +3 -1
  120. package/.docs/reference/workspace/files-sdk-filesystem.md +3 -1
  121. package/.docs/reference/workspace/gcs-filesystem.md +3 -1
  122. package/.docs/reference/workspace/google-drive-filesystem.md +3 -1
  123. package/.docs/reference/workspace/local-filesystem.md +3 -1
  124. package/.docs/reference/workspace/local-sandbox.md +3 -1
  125. package/.docs/reference/workspace/modal-sandbox.md +3 -1
  126. package/.docs/reference/workspace/railway-sandbox.md +3 -1
  127. package/.docs/reference/workspace/s3-filesystem.md +3 -1
  128. package/.docs/reference/workspace/vercel-sandbox.md +7 -5
  129. package/.docs/reference/workspace/vercel-serverless.md +3 -1
  130. package/CHANGELOG.md +0 -22
  131. package/package.json +5 -5
  132. package/.docs/docs/capabilities/channels/discord.md +0 -98
  133. package/.docs/docs/capabilities/channels/other-adapters.md +0 -68
  134. package/.docs/docs/capabilities/channels/overview.md +0 -255
  135. package/.docs/docs/capabilities/channels/slack.md +0 -225
  136. package/.docs/docs/capabilities/channels/teams.md +0 -100
  137. package/.docs/docs/capabilities/channels/telegram.md +0 -98
  138. package/.docs/docs/capabilities/channels/whatsapp.md +0 -99
  139. package/.docs/docs/getting-started/file-based-agents.md +0 -114
  140. package/.docs/models/providers/crossmodel.md +0 -109
  141. package/.docs/models/providers/meta.md +0 -101
  142. package/.docs/models/providers/zenifra.md +0 -73
  143. package/.docs/reference/file-based-agents/config.md +0 -97
  144. package/.docs/reference/file-based-agents/instructions.md +0 -54
  145. package/.docs/reference/file-based-agents/memory.md +0 -58
  146. package/.docs/reference/file-based-agents/observability.md +0 -32
  147. package/.docs/reference/file-based-agents/processors.md +0 -56
  148. package/.docs/reference/file-based-agents/server.md +0 -37
  149. package/.docs/reference/file-based-agents/skills.md +0 -56
  150. package/.docs/reference/file-based-agents/storage.md +0 -30
  151. package/.docs/reference/file-based-agents/studio.md +0 -56
  152. package/.docs/reference/file-based-agents/subagents.md +0 -123
  153. package/.docs/reference/file-based-agents/tools.md +0 -63
  154. package/.docs/reference/file-based-agents/workflows.md +0 -52
  155. package/.docs/reference/file-based-agents/workspace.md +0 -74
  156. package/.docs/reference/memory/summarizeConversation.md +0 -99
  157. package/.docs/reference/memory/summarizeThread.md +0 -93
@@ -1,123 +0,0 @@
1
- > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
-
3
- # Subagents
4
-
5
- A file-based agent can declare **subagents**, specialist child agents it delegates to. The parent model sees each subagent as a delegation tool named after the subagent directory, calls that tool to hand off a task, and receives the subagent's result back in the parent conversation.
6
-
7
- Use this page for the file-based convention. For broader delegation patterns, hooks, memory isolation, tool approval propagation, and scoring, see [Supervisor agents](https://mastra.ai/docs/agents/supervisor-agents).
8
-
9
- ## Quickstart
10
-
11
- Declare one directory per subagent under `subagents/`:
12
-
13
- ```text
14
- src/mastra/agents/
15
- └── supervisor/
16
- ├── config.ts
17
- ├── instructions.md
18
- └── subagents/
19
- └── researcher/
20
- ├── config.ts
21
- ├── instructions.md
22
- └── tools/
23
- └── search.ts
24
- ```
25
-
26
- Mastra assembles `researcher` as its own agent and wires it into the supervisor's `agents` map. The parent model can delegate to it by using the generated `researcher` delegation tool.
27
-
28
- A subagent's `config.ts` must set a non-empty `description`. The parent model reads this when deciding whether to delegate.
29
-
30
- ```typescript
31
- import { agentConfig } from '@mastra/core/agent'
32
-
33
- export default agentConfig({
34
- model: 'openai/gpt-5.5',
35
- description: 'Researches a topic and returns cited findings.',
36
- })
37
- ```
38
-
39
- ## How the model delegates
40
-
41
- A subagent's `description` is routing text for the parent model. Write it like a [tool description](https://mastra.ai/reference/file-based-agents/tools): explain what the subagent does and when to delegate to it.
42
-
43
- The build fails when a discovered subagent doesn't provide a non-empty description.
44
-
45
- ## Isolation
46
-
47
- Subagents are isolated. A subagent doesn't inherit its parent's tools, skills, workspace, memory, processors, or subagents. Each child is a self-contained agent with its own directory.
48
-
49
- If multiple agents should share the same dependency, define it in code and assign it through each agent's config.
50
-
51
- ## Nesting
52
-
53
- Subagents can declare their own `subagents/` directories, nesting up to three levels below the top-level agent. A `subagents/` directory nested deeper is ignored with a warning.
54
-
55
- ```text
56
- src/mastra/agents/
57
- └── supervisor/ # depth 0
58
- └── subagents/
59
- └── researcher/ # depth 1
60
- └── subagents/
61
- └── summarizer/ # depth 2
62
- ```
63
-
64
- ## Naming rules
65
-
66
- - A subagent id that collides with one of the parent's tool keys is a build error.
67
- - A duplicate subagent id under the same parent is a build error.
68
- - If a subagent id also exists in the parent's `config.agents`, the `config.agents` entry wins and logs a warning.
69
- - If `config.agents` is a function, discovered subagents are ignored with a warning because they can't be statically merged.
70
-
71
- ## Example
72
-
73
- This supervisor coordinates a research-and-writing flow. The `researcher` subagent owns search tools, while the `writer` subagent owns a workspace for drafting files.
74
-
75
- ```text
76
- src/mastra/agents/
77
- └── research-supervisor/
78
- ├── config.ts
79
- ├── instructions.md
80
- └── subagents/
81
- ├── researcher/
82
- │ ├── config.ts
83
- │ ├── instructions.md
84
- │ └── tools/
85
- │ └── search_web.ts
86
- └── writer/
87
- ├── config.ts
88
- ├── instructions.md
89
- └── workspace/
90
- └── draft-template.md
91
- ```
92
-
93
- ```typescript
94
- import { agentConfig } from '@mastra/core/agent'
95
-
96
- export default agentConfig({
97
- model: 'openai/gpt-5.5',
98
- })
99
- ```
100
-
101
- ```markdown
102
- You coordinate research and writing.
103
-
104
- Delegate fact gathering to `researcher`. Delegate final drafting to `writer`.
105
- ```
106
-
107
- ```typescript
108
- import { agentConfig } from '@mastra/core/agent'
109
-
110
- export default agentConfig({
111
- model: 'openai/gpt-5-mini',
112
- description: 'Use to gather facts, sources, and concise research notes for a topic.',
113
- })
114
- ```
115
-
116
- ```typescript
117
- import { agentConfig } from '@mastra/core/agent'
118
-
119
- export default agentConfig({
120
- model: 'openai/gpt-5.5',
121
- description: 'Use to turn research notes into a structured draft.',
122
- })
123
- ```
@@ -1,63 +0,0 @@
1
- > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
-
3
- # Tools
4
-
5
- A file-based agent discovers tools from `.ts` and `.js` files directly under its `tools/` directory. Each discovered file is imported at build time, the file must default-export a [`createTool()`](https://mastra.ai/reference/tools/create-tool) result, and the filename without its extension becomes the tool key the model can call.
6
-
7
- Use this page for the file-based convention. For tool schemas, execution options, output shaping, and approval options, see the [`createTool()` reference](https://mastra.ai/reference/tools/create-tool).
8
-
9
- ## Quickstart
10
-
11
- Place one tool per file under `tools/`. This file is exposed to the agent as `get_weather`.
12
-
13
- ```typescript
14
- import { createTool } from '@mastra/core/tools'
15
- import { z } from 'zod'
16
-
17
- export default createTool({
18
- id: 'get_weather',
19
- description: 'Get the current weather for a city.',
20
- inputSchema: z.object({
21
- city: z.string(),
22
- }),
23
- outputSchema: z.object({
24
- city: z.string(),
25
- tempC: z.number(),
26
- }),
27
- execute: async ({ context }) => {
28
- return { city: context.city, tempC: 21 }
29
- },
30
- })
31
- ```
32
-
33
- ## Organizing tools
34
-
35
- Use one file per tool. Name the file after the action the model should take:
36
-
37
- - Use `get_weather.ts`, `search_docs.ts`, or `create_ticket.ts`.
38
- - Avoid vague names like `helper.ts`, `api.ts`, or `utils.ts`.
39
- - Co-locate tests next to the tool as `*.test.ts` or `*.spec.ts`; discovery ignores those files.
40
- - Keep shared helper code outside `tools/` or in files that don't match the discovered extensions under `tools/`.
41
-
42
- Because nested directories aren't discovered as tools, group related tools with clear filename prefixes instead of subfolders, such as `calendar_create_event.ts` and `calendar_list_events.ts`.
43
-
44
- ## Tool options
45
-
46
- The file-based convention only controls where the tool lives and how it's registered. The tool API still comes from `createTool()`:
47
-
48
- - Use `description` to tell the model when to call the tool.
49
- - Use `inputSchema` and `outputSchema` for structured inputs and outputs.
50
- - Use `toModelOutput` when the model should see a different shape than the raw value returned from `execute`.
51
- - Use `requireApproval` when a tool needs human confirmation before execution.
52
-
53
- See the [`createTool()` reference](https://mastra.ai/reference/tools/create-tool) for all options and [tool approval](https://mastra.ai/docs/agent-controller/tool-approvals) for the approval flow.
54
-
55
- ## Runtime boundary
56
-
57
- Tool code runs in your app/server runtime when the agent calls the tool. If a tool needs filesystem or shell isolation, call [workspace](https://mastra.ai/reference/file-based-agents/workspace) or sandbox APIs explicitly.
58
-
59
- ## Precedence with config
60
-
61
- Discovered tools merge with any `tools` in [`config.ts`](https://mastra.ai/reference/file-based-agents/config). On a key collision, `config.tools` wins and a warning is logged.
62
-
63
- If `config.tools` is a function, discovered tools are ignored with a warning because function-valued tools can't be statically merged.
@@ -1,52 +0,0 @@
1
- > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
-
3
- # Workflows
4
-
5
- Mastra discovers project-level workflows from `.ts` and `.js` files under `src/mastra/workflows/`. This convention isn't scoped to one agent: every file with a default export becomes a registered workflow, and the filename becomes the workflow key.
6
-
7
- Use this page for the file-based convention. For steps, schemas, control flow, streaming, state, and workflow execution, see [Workflows overview](https://mastra.ai/docs/workflows/overview).
8
-
9
- ## Quickstart
10
-
11
- Create a file under `src/mastra/workflows/`, build the workflow with [`createWorkflow()`](https://mastra.ai/reference/workflows/workflow), and default-export it.
12
-
13
- ```typescript
14
- import { createStep, createWorkflow } from '@mastra/core/workflows'
15
- import { z } from 'zod'
16
-
17
- const collectInputs = createStep({
18
- id: 'collect-inputs',
19
- inputSchema: z.object({ topic: z.string() }),
20
- outputSchema: z.object({ topic: z.string(), audience: z.string() }),
21
- execute: async ({ inputData }) => ({
22
- topic: inputData.topic,
23
- audience: 'engineering',
24
- }),
25
- })
26
-
27
- const writeSummary = createStep({
28
- id: 'write-summary',
29
- inputSchema: z.object({ topic: z.string(), audience: z.string() }),
30
- outputSchema: z.object({ report: z.string() }),
31
- execute: async ({ inputData }) => ({
32
- report: `Daily report about ${inputData.topic} for ${inputData.audience}.`,
33
- }),
34
- })
35
-
36
- const dailyReport = createWorkflow({
37
- id: 'daily-report',
38
- inputSchema: z.object({ topic: z.string() }),
39
- outputSchema: z.object({ report: z.string() }),
40
- })
41
- .then(collectInputs)
42
- .then(writeSummary)
43
- .commit()
44
-
45
- export default dailyReport
46
- ```
47
-
48
- Mastra registers this workflow under the `daily-report` key.
49
-
50
- ## Precedence with code
51
-
52
- File-based workflows merge with workflows registered in [`new Mastra()`](https://mastra.ai/reference/core/mastra-class). On a key collision, the code-registered workflow wins.
@@ -1,74 +0,0 @@
1
- > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
-
3
- # Workspace
4
-
5
- A [workspace](https://mastra.ai/docs/workspace/overview) gives an agent filesystem access and command execution. File-based agents get a default workspace automatically when discovered through `mastra dev` or `mastra build`, so they can read and write files and run shell commands without extra configuration.
6
-
7
- Use this page for the file-based convention. For workspace providers, tools, search, lifecycle, and sandbox details, see [Workspaces](https://mastra.ai/docs/workspace/overview).
8
-
9
- ## Default workspace
10
-
11
- Without `workspace.ts`, a file-based agent gets a default [`Workspace`](https://mastra.ai/reference/workspace/workspace-class) when the build provides a per-agent workspace path. The default workspace uses:
12
-
13
- - [`LocalFilesystem`](https://mastra.ai/reference/workspace/local-filesystem) rooted at the agent's bundled workspace directory.
14
- - [`LocalSandbox`](https://mastra.ai/reference/workspace/local-sandbox) with the same working directory.
15
-
16
- This gives the agent file tools and shell tools automatically. The default workspace is per agent; subagents get nested workspace directories under their parent agent's workspace path.
17
-
18
- ## Quickstart
19
-
20
- For the default workspace, don't add a file. Start with an agent directory like this:
21
-
22
- ```text
23
- src/mastra/agents/weather/
24
- ├── config.ts
25
- └── instructions.md
26
- ```
27
-
28
- Add `workspace.ts` only when you need to customize the workspace:
29
-
30
- ```typescript
31
- import { Workspace, LocalFilesystem, LocalSandbox } from '@mastra/core/workspace'
32
-
33
- export default new Workspace({
34
- name: 'weather-workspace',
35
- filesystem: new LocalFilesystem({ basePath: './data/weather' }),
36
- sandbox: new LocalSandbox({ workingDirectory: './data/weather' }),
37
- })
38
- ```
39
-
40
- Visit the [`Workspace` reference](https://mastra.ai/reference/workspace/workspace-class) for the full config.
41
-
42
- ## When to customize the workspace
43
-
44
- Customize the workspace when the default local directory isn't enough. Common reasons include:
45
-
46
- - Point file tools at a different filesystem root.
47
- - Run shell commands in a different sandbox provider.
48
- - Add workspace search with BM25 or vector search.
49
- - Share one workspace across multiple agents.
50
-
51
- For provider patterns and runtime behavior, see the [workspace overview](https://mastra.ai/docs/workspace/overview), [sandbox guide](https://mastra.ai/docs/workspace/sandbox), and [workspace search](https://mastra.ai/docs/workspace/search).
52
-
53
- ## Runtime boundary
54
-
55
- The workspace filesystem controls what file tools can read and write. The sandbox controls where shell commands run. Application runtime code, including code in [`tools/`](https://mastra.ai/reference/file-based-agents/tools), still runs in your app/server process unless it explicitly calls workspace or sandbox APIs.
56
-
57
- ## Seed files
58
-
59
- Add a `workspace/` directory to ship starting files with the agent. Mastra mirrors files under `workspace/` into the agent's default runtime workspace at build time, so the agent starts with those files on disk.
60
-
61
- ```text
62
- src/mastra/agents/weather/
63
- ├── config.ts
64
- └── workspace/
65
- ├── README.md
66
- └── data/
67
- └── cities.json
68
- ```
69
-
70
- The files are copied into the bundled workspace path, where workspace file tools and sandbox commands can read them. Symlinked seed files are skipped during mirroring.
71
-
72
- ## Precedence with config
73
-
74
- `config.workspace` wins over `workspace.ts`; otherwise the default file-based workspace is used. See [`config.ts` precedence](https://mastra.ai/reference/file-based-agents/config) for the full merge table.
@@ -1,99 +0,0 @@
1
- > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
-
3
- # summarizeConversation()
4
-
5
- The standalone `summarizeConversation()` function summarizes a conversation in one shot. It distills the messages you pass in with the same Observer plumbing that powers [Observational Memory](https://mastra.ai/reference/memory/observational-memory) — without Observational Memory attached to an agent, and without reading from or writing to storage.
6
-
7
- Nothing is written back to memory. The summary and extracted values are returned to you (and to each extractor's `onExtracted` hook), so you decide where they go — for example your own database.
8
-
9
- Use this when you already have the messages in hand and want explicit control over what gets summarized. To summarize a stored thread by ID instead, use [`Memory.summarizeThread()`](https://mastra.ai/reference/memory/summarizeThread), which loads the messages for you.
10
-
11
- ## Usage example
12
-
13
- ```typescript
14
- import { summarizeConversation } from '@mastra/memory'
15
-
16
- const result = await summarizeConversation({
17
- model: 'openai/gpt-5-mini',
18
- messages,
19
- instructions: 'Summarize this voicemail call for the business owner.',
20
- })
21
- ```
22
-
23
- ## Parameters
24
-
25
- **model** (`string | LanguageModel | DynamicModel`): Model that runs the summarization, such as a router string like '\_\_GATEWAY\_OPENAI\_MODEL\_MINI\_\_'.
26
-
27
- **messages** (`MastraDBMessage[]`): The conversation to summarize. When empty, the function returns an empty result without calling the model.
28
-
29
- **instructions** (`string`): Extra guidance appended to the summarizer's system prompt, such as what to focus on or who the summary is for.
30
-
31
- **extract** (`Extractor[]`): Extractors to run over the conversation. Extractors with a Zod schema run as a follow-up structured output call; schema-less extractors are extracted inline. Each extractor's onExtracted hook fires with the extracted value.
32
-
33
- **threadId** (`string`): Thread the conversation belongs to. Defaults to the first threadId found on messages. Passed to extractor contexts.
34
-
35
- **resourceId** (`string`): Resource (user) the conversation belongs to. Defaults to the first resourceId found on messages. Passed to extractor contexts.
36
-
37
- **memory** (`Memory`): Memory instance forwarded to extractor contexts. Set automatically when called through Memory.summarizeThread().
38
-
39
- **mastra** (`Mastra`): Mastra instance used to resolve custom gateway models. Set automatically when called through Memory.summarizeThread().
40
-
41
- **requestContext** (`RequestContext`): Request context forwarded to the summarizer model and extractor hooks.
42
-
43
- **abortSignal** (`AbortSignal`): Signal to cancel the summarization call.
44
-
45
- ## Returns
46
-
47
- **summary** (`string`): The distilled observations produced from the conversation, in dense bullet form.
48
-
49
- **extracted** (`Record<string, unknown>`): Values produced by extract extractors, keyed by extractor slug.
50
-
51
- **extractionFailures** (`{ slug: string; error: string }[]`): Extractors that failed to produce a valid value, with the reason. Only present when at least one extractor failed.
52
-
53
- **usage** (`{ inputTokens?: number; outputTokens?: number; totalTokens?: number }`): Token usage of the summarization call.
54
-
55
- ## Extended usage example
56
-
57
- The following example summarizes an in-flight voice session from messages the application already holds, and extracts a structured record:
58
-
59
- ```typescript
60
- import { summarizeConversation, Extractor } from '@mastra/memory'
61
- import type { MastraDBMessage } from '@mastra/core/agent'
62
- import { z } from 'zod'
63
- import { sessionRecords } from './db'
64
-
65
- const sessionSummary = new Extractor({
66
- name: 'session-summary',
67
- instructions: 'Return a concise summary of the session.',
68
- schema: z.object({
69
- summary: z.string(),
70
- sentiment: z.enum(['positive', 'neutral', 'negative']),
71
- followUps: z.array(z.string()),
72
- }),
73
- metadataKeyPath: false, // don't persist into memory metadata — the hook owns storage
74
- onExtracted: async ({ current, threadId }) => {
75
- await sessionRecords.upsert({ sessionId: threadId, record: current })
76
- },
77
- })
78
-
79
- export async function onSessionEnd(messages: MastraDBMessage[]) {
80
- const { summary, extracted, extractionFailures } = await summarizeConversation({
81
- model: 'openai/gpt-5-mini',
82
- messages,
83
- instructions: 'Summarize this support session for the account manager.',
84
- extract: [sessionSummary],
85
- })
86
-
87
- if (extractionFailures?.length) {
88
- console.warn('Some extractors failed', extractionFailures)
89
- }
90
-
91
- return { summary, extracted }
92
- }
93
- ```
94
-
95
- ### Related
96
-
97
- - [.summarizeThread()](https://mastra.ai/reference/memory/summarizeThread)
98
- - [Memory Class Reference](https://mastra.ai/reference/memory/memory-class)
99
- - [Observational Memory](https://mastra.ai/reference/memory/observational-memory)
@@ -1,93 +0,0 @@
1
- > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
-
3
- # Memory.summarizeThread()
4
-
5
- The `.summarizeThread()` method summarizes a thread's conversation in one shot. It loads the thread's messages from storage and distills them with the same Observer plumbing that powers [Observational Memory](https://mastra.ai/reference/memory/observational-memory) — as a standalone call, without Observational Memory attached to an agent.
6
-
7
- Messages load page-by-page starting from the newest, bounded by `lastMessages` and `maxInputTokens`, so summarizing a long thread doesn't read its entire history from storage.
8
-
9
- Nothing is written back to memory. The summary and extracted values are returned to you (and to each extractor's `onExtracted` hook), so you decide where they go — for example your own database.
10
-
11
- Use this when a session ends and you want a summary or structured extraction of the whole conversation, such as a voice call at hang-up. To summarize messages you already have in hand (without loading them from a thread), use the standalone [`summarizeConversation()`](https://mastra.ai/reference/memory/summarizeConversation) function instead — it takes the same options with `messages` in place of `threadId`.
12
-
13
- ## Usage example
14
-
15
- ```typescript
16
- const result = await memory.summarizeThread({
17
- model: 'openai/gpt-5-mini',
18
- threadId: 'thread-123',
19
- instructions: 'Summarize this voicemail call for the business owner.',
20
- })
21
- ```
22
-
23
- ## Parameters
24
-
25
- **threadId** (`string`): The unique identifier of the thread to summarize.
26
-
27
- **model** (`string | LanguageModel | DynamicModel`): Model that runs the summarization, such as a router string like '\_\_GATEWAY\_OPENAI\_MODEL\_MINI\_\_'.
28
-
29
- **resourceId** (`string`): ID of the resource that owns the thread. If provided, validates thread ownership. Also passed to extractor contexts.
30
-
31
- **lastMessages** (`number`): Only summarize the last N messages of the thread. By default the whole thread is loaded, bounded by maxInputTokens.
32
-
33
- **maxInputTokens** (`number`): Stop loading older messages once the collected messages exceed this estimated token count. The newest message is always included. (Default: `1000000`)
34
-
35
- **instructions** (`string`): Extra guidance appended to the summarizer's system prompt, such as what to focus on or who the summary is for.
36
-
37
- **extract** (`Extractor[]`): Extractors to run over the conversation. Extractors with a Zod schema run as a follow-up structured output call; schema-less extractors are extracted inline. Each extractor's onExtracted hook fires with the extracted value.
38
-
39
- **requestContext** (`RequestContext`): Request context forwarded to the summarizer model and extractor hooks.
40
-
41
- **abortSignal** (`AbortSignal`): Signal to cancel the summarization call.
42
-
43
- ## Returns
44
-
45
- **summary** (`string`): The distilled observations produced from the conversation, in dense bullet form.
46
-
47
- **extracted** (`Record<string, unknown>`): Values produced by extract extractors, keyed by extractor slug.
48
-
49
- **extractionFailures** (`{ slug: string; error: string }[]`): Extractors that failed to produce a valid value, with the reason. Only present when at least one extractor failed.
50
-
51
- **usage** (`{ inputTokens?: number; outputTokens?: number; totalTokens?: number }`): Token usage of the summarization call.
52
-
53
- ## Extended usage example
54
-
55
- The following example summarizes a finished voice call and stores a structured record in the application's own database:
56
-
57
- ```typescript
58
- import { Extractor } from '@mastra/memory'
59
- import { z } from 'zod'
60
- import { memory } from './mastra/memory'
61
- import { callRecords } from './db'
62
-
63
- const callSummary = new Extractor({
64
- name: 'call-summary',
65
- instructions: 'Return a concise summary of the call.',
66
- schema: z.object({
67
- summary: z.string(),
68
- sentiment: z.enum(['positive', 'neutral', 'negative']),
69
- requestedServices: z.array(z.string()),
70
- }),
71
- metadataKeyPath: false, // don't persist into memory metadata — the hook owns storage
72
- onExtracted: async ({ current, threadId, resourceId }) => {
73
- await callRecords.upsert({ callId: threadId, callerId: resourceId, record: current })
74
- },
75
- })
76
-
77
- export async function onCallEnd(threadId: string, resourceId: string) {
78
- await memory.summarizeThread({
79
- model: 'openai/gpt-5-mini',
80
- threadId,
81
- resourceId,
82
- instructions: 'Summarize this voicemail call for the business owner.',
83
- extract: [callSummary],
84
- })
85
- }
86
- ```
87
-
88
- ### Related
89
-
90
- - [summarizeConversation()](https://mastra.ai/reference/memory/summarizeConversation)
91
- - [Memory Class Reference](https://mastra.ai/reference/memory/memory-class)
92
- - [Observational Memory](https://mastra.ai/reference/memory/observational-memory)
93
- - [.recall()](https://mastra.ai/reference/memory/recall)