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

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 (79) hide show
  1. package/.docs/docs/agent-builder/overview.md +4 -3
  2. package/.docs/docs/agent-controller/overview.md +2 -1
  3. package/.docs/docs/agents/a2a.md +2 -1
  4. package/.docs/docs/agents/guardrails.md +2 -1
  5. package/.docs/docs/agents/overview.md +2 -2
  6. package/.docs/docs/agents/skills.md +1 -1
  7. package/.docs/docs/agents/supervisor-agents.md +2 -1
  8. package/.docs/docs/browser/overview.md +2 -1
  9. package/.docs/docs/capabilities/channels/discord.md +98 -0
  10. package/.docs/docs/capabilities/channels/other-adapters.md +68 -0
  11. package/.docs/docs/capabilities/channels/overview.md +257 -0
  12. package/.docs/docs/capabilities/channels/slack.md +225 -0
  13. package/.docs/docs/capabilities/channels/teams.md +100 -0
  14. package/.docs/docs/capabilities/channels/telegram.md +98 -0
  15. package/.docs/docs/capabilities/channels/whatsapp.md +99 -0
  16. package/.docs/docs/evals/datasets/overview.md +2 -1
  17. package/.docs/docs/evals/datasets/running-experiments.md +2 -0
  18. package/.docs/docs/evals/overview.md +4 -1
  19. package/.docs/docs/getting-started/file-based-agents.md +114 -0
  20. package/.docs/docs/long-running-agents/signals.md +4 -1
  21. package/.docs/docs/mastra-platform/observability.md +5 -1
  22. package/.docs/docs/memory/observational-memory.md +2 -1
  23. package/.docs/docs/memory/overview.md +2 -0
  24. package/.docs/docs/memory/semantic-recall.md +1 -1
  25. package/.docs/docs/memory/working-memory.md +3 -3
  26. package/.docs/docs/studio/overview.md +1 -1
  27. package/.docs/docs/voice/livekit.md +100 -3
  28. package/.docs/docs/workflows/control-flow.md +0 -2
  29. package/.docs/docs/workflows/overview.md +2 -3
  30. package/.docs/docs/workspace/overview.md +2 -1
  31. package/.docs/docs/workspace/sandbox.md +2 -0
  32. package/.docs/guides/getting-started/quickstart.md +3 -1
  33. package/.docs/guides/guide/chef-michel.md +0 -2
  34. package/.docs/guides/guide/slack-assistant.md +2 -2
  35. package/.docs/guides/guide/stock-agent.md +0 -2
  36. package/.docs/models/environment-variables.md +1 -0
  37. package/.docs/models/gateways/openrouter.md +3 -2
  38. package/.docs/models/gateways/vercel.md +3 -1
  39. package/.docs/models/index.md +1 -1
  40. package/.docs/models/providers/google.md +2 -1
  41. package/.docs/models/providers/llmgateway.md +180 -181
  42. package/.docs/models/providers/neon.md +40 -29
  43. package/.docs/models/providers/opencode.md +2 -1
  44. package/.docs/models/providers/wandb.md +21 -14
  45. package/.docs/models/providers/xai.md +2 -1
  46. package/.docs/models/providers/zenifra.md +73 -0
  47. package/.docs/models/providers.md +1 -0
  48. package/.docs/reference/agents/channels.md +2 -2
  49. package/.docs/reference/channels/channel-provider.md +1 -1
  50. package/.docs/reference/channels/slack-provider.md +2 -2
  51. package/.docs/reference/cli/mastra.md +1 -0
  52. package/.docs/reference/file-based-agents/config.md +97 -0
  53. package/.docs/reference/file-based-agents/instructions.md +54 -0
  54. package/.docs/reference/file-based-agents/memory.md +58 -0
  55. package/.docs/reference/file-based-agents/observability.md +32 -0
  56. package/.docs/reference/file-based-agents/processors.md +56 -0
  57. package/.docs/reference/file-based-agents/server.md +37 -0
  58. package/.docs/reference/file-based-agents/skills.md +56 -0
  59. package/.docs/reference/file-based-agents/storage.md +30 -0
  60. package/.docs/reference/file-based-agents/studio.md +56 -0
  61. package/.docs/reference/file-based-agents/subagents.md +123 -0
  62. package/.docs/reference/file-based-agents/tools.md +63 -0
  63. package/.docs/reference/file-based-agents/workflows.md +52 -0
  64. package/.docs/reference/file-based-agents/workspace.md +74 -0
  65. package/.docs/reference/index.md +15 -0
  66. package/.docs/reference/memory/memory-class.md +1 -1
  67. package/.docs/reference/memory/serialized-memory-config.md +1 -1
  68. package/.docs/reference/memory/summarizeConversation.md +99 -0
  69. package/.docs/reference/memory/summarizeThread.md +93 -0
  70. package/.docs/reference/project-structure.md +1 -1
  71. package/.docs/reference/pubsub/lease-provider.md +1 -1
  72. package/.docs/reference/storage/clickhouse.md +32 -0
  73. package/.docs/reference/storage/composite.md +27 -1
  74. package/.docs/reference/storage/retention.md +11 -0
  75. package/.docs/reference/voice/livekit.md +272 -8
  76. package/CHANGELOG.md +7 -0
  77. package/package.json +5 -5
  78. package/.docs/docs/agents/channels.md +0 -225
  79. package/.docs/docs/agents/file-based-agents.md +0 -297
@@ -0,0 +1,30 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
3
+ # Storage
4
+
5
+ Mastra sets the project's default [storage](https://mastra.ai/docs/storage/overview) from a `storage.ts` file directly under `src/mastra/`. The file default-exports a store, which replaces the built-in in-memory store used for memory, workflows, observability, and other storage domains.
6
+
7
+ Use this page for the file-based convention. For backend choice, storage domains, retention, and provider details, see [storage overview](https://mastra.ai/docs/storage/overview).
8
+
9
+ ## Quickstart
10
+
11
+ Use [`LibSQLStore`](https://mastra.ai/reference/storage/libsql) for a local file-backed store:
12
+
13
+ ```typescript
14
+ import { LibSQLStore } from '@mastra/libsql'
15
+
16
+ export default new LibSQLStore({
17
+ id: 'mastra-storage',
18
+ url: 'file:./mastra.db',
19
+ })
20
+ ```
21
+
22
+ Mastra registers the store before file-based agents and workflows, so storage-dependent primitives bind to this store instead of the default in-memory store.
23
+
24
+ ## Production backends
25
+
26
+ `storage.ts` can export any Mastra storage adapter, such as LibSQL, PostgreSQL, or MongoDB. For setup patterns, provider support, and schema details, see [storage overview](https://mastra.ai/docs/storage/overview), [observability storage](https://mastra.ai/docs/observability/storage), and the [storage reference](https://mastra.ai/reference/storage/overview).
27
+
28
+ ## Precedence with code
29
+
30
+ Code-registered storage wins over `storage.ts`. Use `storage.ts` when one project-wide store is enough; use code registration when setup depends on runtime wiring in `src/mastra/index.ts`.
@@ -0,0 +1,56 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
3
+ # Studio
4
+
5
+ Mastra configures [Studio](https://mastra.ai/docs/studio/overview) from a `studio.ts` file directly under `src/mastra/`. The file default-exports a `StudioConfig` object for Studio authentication and authorization: who can access Studio, and what authenticated users can do.
6
+
7
+ Use this page for the file-based convention. For auth providers, role-based access control (RBAC), and fine-grained authorization (FGA), see [Studio auth](https://mastra.ai/docs/studio/auth).
8
+
9
+ ## Quickstart
10
+
11
+ For local development, you don't need `studio.ts`. Start the dev server and open Studio:
12
+
13
+ **npm**:
14
+
15
+ ```bash
16
+ npm run dev
17
+ ```
18
+
19
+ **pnpm**:
20
+
21
+ ```bash
22
+ pnpm run dev
23
+ ```
24
+
25
+ **Yarn**:
26
+
27
+ ```bash
28
+ yarn dev
29
+ ```
30
+
31
+ **Bun**:
32
+
33
+ ```bash
34
+ bun run dev
35
+ ```
36
+
37
+ Studio opens without authentication in local development. Add `studio.ts` when you're ready to secure a shared or production deployment.
38
+
39
+ ## Add authentication
40
+
41
+ Use an auth provider to require sign-in before users can access Studio. This example uses [WorkOS](https://mastra.ai/docs/server/auth/workos):
42
+
43
+ ```typescript
44
+ import { MastraAuthWorkos } from '@mastra/auth-workos'
45
+ import type { StudioConfig } from '@mastra/core/server'
46
+
47
+ export default {
48
+ auth: new MastraAuthWorkos(),
49
+ } satisfies StudioConfig
50
+ ```
51
+
52
+ The auth provider handles who the user is. For what the user can do after sign-in, add RBAC or FGA in the same config. See [Studio auth](https://mastra.ai/docs/studio/auth) for full examples.
53
+
54
+ ## Precedence with code
55
+
56
+ Code-registered Studio config wins over `studio.ts`. Use `studio.ts` when one project-wide Studio config is enough; use code registration when auth depends on runtime wiring in `src/mastra/index.ts`.
@@ -0,0 +1,123 @@
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
+ ```
@@ -0,0 +1,63 @@
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.
@@ -0,0 +1,52 @@
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.
@@ -0,0 +1,74 @@
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.
@@ -175,17 +175,32 @@ The Reference section provides documentation of Mastra's API, including paramete
175
175
  - [.startExperimentAsync()](https://mastra.ai/reference/datasets/startExperimentAsync)
176
176
  - [.update()](https://mastra.ai/reference/datasets/update)
177
177
  - [.updateItem()](https://mastra.ai/reference/datasets/updateItem)
178
+ - [config.ts](https://mastra.ai/reference/file-based-agents/config)
179
+ - [Instructions](https://mastra.ai/reference/file-based-agents/instructions)
180
+ - [Memory](https://mastra.ai/reference/file-based-agents/memory)
181
+ - [Observability](https://mastra.ai/reference/file-based-agents/observability)
182
+ - [Processors](https://mastra.ai/reference/file-based-agents/processors)
183
+ - [Server](https://mastra.ai/reference/file-based-agents/server)
184
+ - [Skills](https://mastra.ai/reference/file-based-agents/skills)
185
+ - [Storage](https://mastra.ai/reference/file-based-agents/storage)
186
+ - [Studio](https://mastra.ai/reference/file-based-agents/studio)
187
+ - [Subagents](https://mastra.ai/reference/file-based-agents/subagents)
188
+ - [Tools](https://mastra.ai/reference/file-based-agents/tools)
189
+ - [Workflows](https://mastra.ai/reference/file-based-agents/workflows)
190
+ - [Workspace](https://mastra.ai/reference/file-based-agents/workspace)
178
191
  - [API Reference](https://mastra.ai/reference/mastra-platform/api)
179
192
  - [Cloned Thread Utilities](https://mastra.ai/reference/memory/clone-utilities)
180
193
  - [Memory Class](https://mastra.ai/reference/memory/memory-class)
181
194
  - [Observational Memory](https://mastra.ai/reference/memory/observational-memory)
182
195
  - [SerializedMemoryConfig](https://mastra.ai/reference/memory/serialized-memory-config)
196
+ - [summarizeConversation()](https://mastra.ai/reference/memory/summarizeConversation)
183
197
  - [.cloneThread()](https://mastra.ai/reference/memory/cloneThread)
184
198
  - [.createThread()](https://mastra.ai/reference/memory/createThread)
185
199
  - [.deleteMessages()](https://mastra.ai/reference/memory/deleteMessages)
186
200
  - [.getThreadById()](https://mastra.ai/reference/memory/getThreadById)
187
201
  - [.listThreads()](https://mastra.ai/reference/memory/listThreads)
188
202
  - [.recall()](https://mastra.ai/reference/memory/recall)
203
+ - [.summarizeThread()](https://mastra.ai/reference/memory/summarizeThread)
189
204
  - [Feedback](https://mastra.ai/reference/observability/feedback)
190
205
  - [PinoLogger](https://mastra.ai/reference/logging/pino-logger)
191
206
  - [Automatic Metrics](https://mastra.ai/reference/observability/metrics/automatic-metrics)
@@ -37,7 +37,7 @@ export const agent = new Agent({
37
37
 
38
38
  **options** (`MemoryConfig`): Memory configuration options.
39
39
 
40
- **options.lastMessages** (`number | false`): Number of most recent messages to include in context. Set to false to disable loading conversation history into context. Use Number.MAX\_SAFE\_INTEGER to retrieve all messages with no limit. To prevent saving new messages, use the readOnly option instead.
40
+ **options.lastMessages** (`number | false`): Number of most recent messages to include in context. Set to false to disable the message history feature entirely (messages are not loaded into context or saved). Use Number.MAX\_SAFE\_INTEGER to retrieve all messages with no limit. To load messages without saving new ones, use the readOnly option.
41
41
 
42
42
  **options.readOnly** (`boolean`): When true, prevents memory from saving new messages and provides working memory as read-only context (without the updateWorkingMemory tool). Useful for read-only operations like previews, internal routing agents, or sub agents that should reference but not modify memory.
43
43
 
@@ -38,7 +38,7 @@ new MastraEditor({
38
38
 
39
39
  **options.readOnly** (`boolean`): Treat memory as read-only — no new messages are stored.
40
40
 
41
- **options.lastMessages** (`number | false`): Number of recent messages to include in context, or false to disable.
41
+ **options.lastMessages** (`number | false`): Number of recent messages to include in context, or false to disable message history entirely (messages are not loaded or saved).
42
42
 
43
43
  **options.semanticRecall** (`boolean | SemanticRecall`): Semantic recall configuration. See the Memory class reference for the full shape.
44
44
 
@@ -0,0 +1,99 @@
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)
@@ -0,0 +1,93 @@
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)
@@ -44,7 +44,7 @@ Mastra recommends organizing your code into the following folders:
44
44
 
45
45
  Mastra has two special folder conventions:
46
46
 
47
- - `src/mastra/agents/<name>`: You can define an agent by file convention instead of constructing it in code. Learn more in the [file-based agents](https://mastra.ai/docs/agents/file-based-agents) guide.
47
+ - `src/mastra/agents/<name>`: You can define an agent by file convention instead of constructing it in code. Learn more in the [File-based Agents](https://mastra.ai/docs/getting-started/file-based-agents) docs.
48
48
  - `src/mastra/public`: Contents are copied into the `.build/output` directory during the build process, making them available for serving at runtime.
49
49
 
50
50
  ### Top-level files