@mastra/mcp-docs-server 1.2.7-alpha.4 → 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.
- package/.docs/docs/agent-builder/overview.md +4 -3
- package/.docs/docs/agent-controller/overview.md +2 -1
- package/.docs/docs/agents/a2a.md +2 -1
- package/.docs/docs/agents/guardrails.md +2 -1
- package/.docs/docs/agents/overview.md +2 -2
- package/.docs/docs/agents/skills.md +1 -1
- package/.docs/docs/agents/supervisor-agents.md +2 -1
- package/.docs/docs/browser/overview.md +2 -1
- package/.docs/docs/capabilities/channels/discord.md +98 -0
- package/.docs/docs/capabilities/channels/other-adapters.md +68 -0
- package/.docs/docs/capabilities/channels/overview.md +257 -0
- package/.docs/docs/capabilities/channels/slack.md +225 -0
- package/.docs/docs/capabilities/channels/teams.md +100 -0
- package/.docs/docs/capabilities/channels/telegram.md +98 -0
- package/.docs/docs/capabilities/channels/whatsapp.md +99 -0
- package/.docs/docs/evals/datasets/overview.md +2 -1
- package/.docs/docs/evals/datasets/running-experiments.md +2 -0
- package/.docs/docs/evals/overview.md +4 -1
- package/.docs/docs/getting-started/file-based-agents.md +114 -0
- package/.docs/docs/long-running-agents/signals.md +4 -1
- package/.docs/docs/mastra-platform/observability.md +5 -1
- package/.docs/docs/memory/observational-memory.md +2 -1
- package/.docs/docs/memory/overview.md +2 -0
- package/.docs/docs/memory/semantic-recall.md +1 -1
- package/.docs/docs/memory/working-memory.md +3 -3
- package/.docs/docs/studio/overview.md +1 -1
- package/.docs/docs/workflows/control-flow.md +0 -2
- package/.docs/docs/workflows/overview.md +2 -3
- package/.docs/docs/workspace/overview.md +2 -1
- package/.docs/docs/workspace/sandbox.md +2 -0
- package/.docs/guides/getting-started/quickstart.md +3 -1
- package/.docs/guides/guide/chef-michel.md +0 -2
- package/.docs/guides/guide/slack-assistant.md +2 -2
- package/.docs/guides/guide/stock-agent.md +0 -2
- package/.docs/models/gateways/openrouter.md +1 -2
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/llmgateway.md +180 -181
- package/.docs/models/providers/neon.md +40 -29
- package/.docs/reference/agents/channels.md +2 -2
- package/.docs/reference/channels/channel-provider.md +1 -1
- package/.docs/reference/channels/slack-provider.md +2 -2
- package/.docs/reference/cli/mastra.md +1 -0
- package/.docs/reference/file-based-agents/config.md +97 -0
- package/.docs/reference/file-based-agents/instructions.md +54 -0
- package/.docs/reference/file-based-agents/memory.md +58 -0
- package/.docs/reference/file-based-agents/observability.md +32 -0
- package/.docs/reference/file-based-agents/processors.md +56 -0
- package/.docs/reference/file-based-agents/server.md +37 -0
- package/.docs/reference/file-based-agents/skills.md +56 -0
- package/.docs/reference/file-based-agents/storage.md +30 -0
- package/.docs/reference/file-based-agents/studio.md +56 -0
- package/.docs/reference/file-based-agents/subagents.md +123 -0
- package/.docs/reference/file-based-agents/tools.md +63 -0
- package/.docs/reference/file-based-agents/workflows.md +52 -0
- package/.docs/reference/file-based-agents/workspace.md +74 -0
- package/.docs/reference/index.md +13 -0
- package/.docs/reference/memory/memory-class.md +1 -1
- package/.docs/reference/memory/serialized-memory-config.md +1 -1
- package/.docs/reference/project-structure.md +1 -1
- package/.docs/reference/pubsub/lease-provider.md +1 -1
- package/.docs/reference/storage/clickhouse.md +32 -0
- package/.docs/reference/storage/composite.md +27 -1
- package/.docs/reference/storage/retention.md +11 -0
- package/CHANGELOG.md +7 -0
- package/package.json +4 -4
- package/.docs/docs/agents/channels.md +0 -225
- package/.docs/docs/agents/file-based-agents.md +0 -297
|
@@ -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.
|
package/.docs/reference/index.md
CHANGED
|
@@ -175,6 +175,19 @@ 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)
|
|
@@ -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
|
|
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
|
|
|
@@ -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 [
|
|
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
|
|
@@ -130,4 +130,4 @@ When the configured pub/sub backend doesn't implement `LeaseProvider`, the runti
|
|
|
130
130
|
- [PubSub](https://mastra.ai/reference/pubsub/base): The event delivery contract, separate from leasing
|
|
131
131
|
- [RedisStreamsPubSub](https://mastra.ai/reference/pubsub/redis-streams): The built-in backend that implements `LeaseProvider`
|
|
132
132
|
- [Signals](https://mastra.ai/docs/long-running-agents/signals): The runtime that uses leasing to coordinate thread runs across processes
|
|
133
|
-
- [Channels](https://mastra.ai/docs/
|
|
133
|
+
- [Channels](https://mastra.ai/docs/capabilities/channels/overview): Uses leasing to coordinate agent runs in serverless and multi-instance deployments
|
|
@@ -101,6 +101,38 @@ const observabilityStore = new ObservabilityStorageClickhouse({
|
|
|
101
101
|
|
|
102
102
|
New projects should use `ObservabilityStorageClickhouseVNext` instead.
|
|
103
103
|
|
|
104
|
+
### Migrating from legacy to vNext
|
|
105
|
+
|
|
106
|
+
To migrate historical spans from the legacy `mastra_ai_spans` table to the vNext schema, run:
|
|
107
|
+
|
|
108
|
+
**npm**:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
npx mastra migrate
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**pnpm**:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
pnpm dlx mastra migrate
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**Yarn**:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
yarn dlx mastra migrate
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**Bun**:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
bun x mastra migrate
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
The migration copies span data from `mastra_ai_spans` into `mastra_span_events` in day-sized batches. It handles column mapping, deduplicates legacy rows, and preserves the original table as a backup. After migration, traces appear in Studio through the vNext adapter.
|
|
133
|
+
|
|
134
|
+
> **Note:** The legacy table is not deleted. Drop it manually after verifying the migration.
|
|
135
|
+
|
|
104
136
|
### ClickHouse for every domain
|
|
105
137
|
|
|
106
138
|
`ClickhouseStoreVNext` backs the `memory`, `workflows`, and `observability` domains with ClickHouse and uses the vNext observability adapter automatically. Use it when you want ClickHouse to back the entire application without wiring a composite store manually.
|
|
@@ -156,6 +156,32 @@ export const mastra = new Mastra({
|
|
|
156
156
|
})
|
|
157
157
|
```
|
|
158
158
|
|
|
159
|
+
### Disabling a domain
|
|
160
|
+
|
|
161
|
+
Set a domain to `false` to disable it. A disabled domain doesn't fall back to `default`, so data for that domain isn't persisted:
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
import { MastraCompositeStore } from '@mastra/core/storage'
|
|
165
|
+
import { PostgresStore } from '@mastra/pg'
|
|
166
|
+
import { Mastra } from '@mastra/core'
|
|
167
|
+
|
|
168
|
+
const pgStore = new PostgresStore({
|
|
169
|
+
id: 'pg',
|
|
170
|
+
connectionString: process.env.DATABASE_URL,
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
export const mastra = new Mastra({
|
|
174
|
+
storage: new MastraCompositeStore({
|
|
175
|
+
id: 'composite',
|
|
176
|
+
default: pgStore,
|
|
177
|
+
domains: {
|
|
178
|
+
// don't persist traces and spans
|
|
179
|
+
observability: false,
|
|
180
|
+
},
|
|
181
|
+
}),
|
|
182
|
+
})
|
|
183
|
+
```
|
|
184
|
+
|
|
159
185
|
## Options
|
|
160
186
|
|
|
161
187
|
**id** (`string`): Unique identifier for this storage instance.
|
|
@@ -164,7 +190,7 @@ export const mastra = new Mastra({
|
|
|
164
190
|
|
|
165
191
|
**disableInit** (`boolean`): When true, automatic initialization is disabled. You must call init() explicitly.
|
|
166
192
|
|
|
167
|
-
**domains** (`object`): Individual domain overrides. Each domain can come from a different storage adapter. These take precedence over both editor and default storage.
|
|
193
|
+
**domains** (`object`): Individual domain overrides. Each domain can come from a different storage adapter. These take precedence over both editor and default storage. Set a domain to false to disable it entirely; a disabled domain does not fall back to editor or default.
|
|
168
194
|
|
|
169
195
|
**domains.memory** (`MemoryStorage`): Storage for threads, messages, and resources.
|
|
170
196
|
|
|
@@ -105,6 +105,8 @@ Deletes rows older than their configured `maxAge` across every domain that has a
|
|
|
105
105
|
|
|
106
106
|
`prune()` is designed to be safe on tables with millions of rows. It deletes in bounded, batched chunks — each batch is its own transaction — so it never takes a long lock or bloats the transaction log. It never runs a `VACUUM`.
|
|
107
107
|
|
|
108
|
+
Pass `options.retention` to replace the configured policies for that call only — for example to skip a domain (keep chat history) or prune more aggressively than the standing config. The store's configured `retention` is unchanged.
|
|
109
|
+
|
|
108
110
|
Anchor-column indexes are created lazily on the first `prune()` call for each table with a policy — never at `init()` — so deployments that don't configure retention pay no extra index write or disk overhead. The first prune of an existing large table pays a one-time index build; subsequent prunes reuse the index.
|
|
109
111
|
|
|
110
112
|
```typescript
|
|
@@ -116,6 +118,13 @@ const results = await storage.prune({
|
|
|
116
118
|
for (const r of results) {
|
|
117
119
|
console.log(`${r.domain}.${r.table}: deleted ${r.deleted}, done=${r.done}`)
|
|
118
120
|
}
|
|
121
|
+
|
|
122
|
+
// One-off pass with different policies (configured retention untouched):
|
|
123
|
+
await storage.prune({
|
|
124
|
+
retention: {
|
|
125
|
+
observability: { spans: { maxAge: '1d' } },
|
|
126
|
+
},
|
|
127
|
+
})
|
|
119
128
|
```
|
|
120
129
|
|
|
121
130
|
Returns: `Promise<PruneResult[]>`
|
|
@@ -130,6 +139,8 @@ Returns: `Promise<PruneResult[]>`
|
|
|
130
139
|
|
|
131
140
|
**signal** (`AbortSignal`): Cooperative cancellation. The batch loop checks it between batches and stops cleanly, returning partial results with done: false.
|
|
132
141
|
|
|
142
|
+
**retention** (`RetentionConfig`): Replaces the store's configured retention policies for this call only — e.g. to skip a domain or prune more aggressively. The configured retention is unchanged.
|
|
143
|
+
|
|
133
144
|
##### PruneResult
|
|
134
145
|
|
|
135
146
|
Each result describes one table's progress:
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @mastra/mcp-docs-server
|
|
2
2
|
|
|
3
|
+
## 1.2.7-alpha.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`e955965`](https://github.com/mastra-ai/mastra/commit/e955965dce575a903e37cf054d28ea99aa48785e), [`860ef7e`](https://github.com/mastra-ai/mastra/commit/860ef7e77d92b63469cbe5857aa1e626197e43e9), [`17e818c`](https://github.com/mastra-ai/mastra/commit/17e818c51a958ba90641b1a959dc38faf8c034e9), [`4451dfe`](https://github.com/mastra-ai/mastra/commit/4451dfe857428e7abcc0261a507a2e186dae6d47), [`1d39058`](https://github.com/mastra-ai/mastra/commit/1d39058e548efd691799985d5c8af2737f1c3bd2)]:
|
|
8
|
+
- @mastra/core@1.51.0-alpha.2
|
|
9
|
+
|
|
3
10
|
## 1.2.7-alpha.2
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mcp-docs-server",
|
|
3
|
-
"version": "1.2.7-alpha.
|
|
3
|
+
"version": "1.2.7-alpha.6",
|
|
4
4
|
"description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"jsdom": "^26.1.0",
|
|
29
29
|
"local-pkg": "^1.1.2",
|
|
30
30
|
"zod": "^4.4.3",
|
|
31
|
-
"@mastra/
|
|
32
|
-
"@mastra/
|
|
31
|
+
"@mastra/mcp": "^1.13.1",
|
|
32
|
+
"@mastra/core": "1.51.0-alpha.2"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@hono/node-server": "^1.19.11",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"vitest": "4.1.9",
|
|
48
48
|
"@internal/lint": "0.0.113",
|
|
49
49
|
"@internal/types-builder": "0.0.88",
|
|
50
|
-
"@mastra/core": "1.
|
|
50
|
+
"@mastra/core": "1.51.0-alpha.2"
|
|
51
51
|
},
|
|
52
52
|
"homepage": "https://mastra.ai",
|
|
53
53
|
"repository": {
|
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
-
|
|
3
|
-
# Channels
|
|
4
|
-
|
|
5
|
-
**Added in:** `@mastra/core@1.22.0`
|
|
6
|
-
|
|
7
|
-
Channels connect your agents to messaging platforms like Slack, Discord, and Telegram. When a user sends a message on a platform, the agent receives it, processes it through the normal agent pipeline, and streams the response back to the conversation.
|
|
8
|
-
|
|
9
|
-
## When to use channels
|
|
10
|
-
|
|
11
|
-
Use channels when you want your agent to:
|
|
12
|
-
|
|
13
|
-
- Respond to messages in Slack workspaces, Discord servers, or Telegram chats
|
|
14
|
-
- Handle both direct messages and mentions in group conversations
|
|
15
|
-
|
|
16
|
-
## Quickstart
|
|
17
|
-
|
|
18
|
-
Configure channels directly on your agent using adapters from the [Chat SDK](https://chat-sdk.dev/adapters):
|
|
19
|
-
|
|
20
|
-
```typescript
|
|
21
|
-
import { Agent } from '@mastra/core/agent'
|
|
22
|
-
import { createSlackAdapter } from '@chat-adapter/slack'
|
|
23
|
-
|
|
24
|
-
export const supportAgent = new Agent({
|
|
25
|
-
id: 'support-agent',
|
|
26
|
-
name: 'Support Agent',
|
|
27
|
-
instructions: 'You are a helpful support assistant.',
|
|
28
|
-
model: 'openai/gpt-5.5',
|
|
29
|
-
channels: {
|
|
30
|
-
adapters: {
|
|
31
|
-
slack: createSlackAdapter(),
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
})
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
Register the agent in your Mastra instance with storage so channel state persists across restarts:
|
|
38
|
-
|
|
39
|
-
```typescript
|
|
40
|
-
import { Mastra } from '@mastra/core'
|
|
41
|
-
import { LibSQLStore } from '@mastra/libsql'
|
|
42
|
-
import { supportAgent } from './agents/support-agent'
|
|
43
|
-
|
|
44
|
-
export const mastra = new Mastra({
|
|
45
|
-
agents: { supportAgent },
|
|
46
|
-
storage: new LibSQLStore({
|
|
47
|
-
url: process.env.DATABASE_URL,
|
|
48
|
-
}),
|
|
49
|
-
})
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
Each adapter reads credentials from environment variables by default.
|
|
53
|
-
|
|
54
|
-
## Platform setup
|
|
55
|
-
|
|
56
|
-
Each platform requires credentials and event configuration. See the Chat SDK adapter docs for full setup: [Slack](https://chat-sdk.dev/adapters/slack), [Discord](https://chat-sdk.dev/adapters/discord), [Telegram](https://chat-sdk.dev/adapters/telegram).
|
|
57
|
-
|
|
58
|
-
Mastra generates a webhook route for each platform at:
|
|
59
|
-
|
|
60
|
-
```text
|
|
61
|
-
/api/agents/{agentId}/channels/{platform}/webhook
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
For example: `/api/agents/support-agent/channels/slack/webhook`
|
|
65
|
-
|
|
66
|
-
Point your platform's webhook or interactions URL to this path.
|
|
67
|
-
|
|
68
|
-
### Local development
|
|
69
|
-
|
|
70
|
-
Platform webhooks need a public URL to reach your local server. Use a tunnel to expose `localhost:4111`:
|
|
71
|
-
|
|
72
|
-
```bash
|
|
73
|
-
# ngrok
|
|
74
|
-
ngrok http 4111
|
|
75
|
-
|
|
76
|
-
# cloudflared
|
|
77
|
-
npx cloudflared tunnel --url http://localhost:4111
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
Copy the generated URL and use it as the base for your webhook paths (e.g. `https://abc123.ngrok.io/api/agents/support-agent/channels/slack/webhook`).
|
|
81
|
-
|
|
82
|
-
## Thread context
|
|
83
|
-
|
|
84
|
-
When a user mentions the agent mid-conversation in a channel thread, the agent may not have prior context. By default, Mastra fetches the last 10 messages from the platform on the first mention.
|
|
85
|
-
|
|
86
|
-
1. On the **first mention** in a thread, the agent fetches recent messages from the platform.
|
|
87
|
-
2. These messages are prepended to the user's message as conversation context.
|
|
88
|
-
3. After responding, the agent subscribes to the thread and has full history via Mastra's memory.
|
|
89
|
-
4. Subsequent messages in that thread **don't** re-fetch from the platform.
|
|
90
|
-
|
|
91
|
-
Set `threadContext: { maxMessages: 0 }` to disable this behavior. This only applies to non-DM threads.
|
|
92
|
-
|
|
93
|
-
Mastra also adds a short system message telling the agent which channel and platform the request came from (DM vs public channel, platform name, bot display name). Set `threadContext: { addSystemMessage: false }` to skip it.
|
|
94
|
-
|
|
95
|
-
## Tool approval
|
|
96
|
-
|
|
97
|
-
Tools with `requireApproval: true` render as interactive cards with Approve and Deny buttons:
|
|
98
|
-
|
|
99
|
-
```typescript
|
|
100
|
-
import { createTool } from '@mastra/core/tools'
|
|
101
|
-
import { z } from 'zod'
|
|
102
|
-
|
|
103
|
-
const deleteFile = createTool({
|
|
104
|
-
id: 'delete-file',
|
|
105
|
-
description: 'Delete a file from the system',
|
|
106
|
-
inputSchema: z.object({
|
|
107
|
-
path: z.string().describe('Path to the file to delete'),
|
|
108
|
-
}),
|
|
109
|
-
requireApproval: true,
|
|
110
|
-
execute: async ({ path }) => {
|
|
111
|
-
await fs.unlink(path)
|
|
112
|
-
return { deleted: path }
|
|
113
|
-
},
|
|
114
|
-
})
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
When the agent calls this tool, users see a card with the tool name, arguments, and Approve/Deny buttons. The tool only executes after approval.
|
|
118
|
-
|
|
119
|
-
Set `toolDisplay: 'text'` on an adapter to render tool calls as plain text instead of interactive cards. In `'hidden'` mode the agent uses `autoResumeSuspendedTools` to let the LLM decide based on the conversation context, since hidden mode doesn't post approval buttons.
|
|
120
|
-
|
|
121
|
-
## Multi-user awareness
|
|
122
|
-
|
|
123
|
-
In group conversations, Mastra automatically prefixes each message with the sender's name and platform ID so the agent can distinguish between speakers:
|
|
124
|
-
|
|
125
|
-
```text
|
|
126
|
-
[Alice (@U123ABC)]: Can you help me with this?
|
|
127
|
-
[Bob (@U456DEF)]: I have a question too.
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
## Multimodal content
|
|
131
|
-
|
|
132
|
-
Models like Gemini can natively process images, video, and audio. Combine `inlineMedia` and `inlineLinks` to let users share rich content with your agent across platforms:
|
|
133
|
-
|
|
134
|
-
```typescript
|
|
135
|
-
import { Agent } from '@mastra/core/agent'
|
|
136
|
-
import { createDiscordAdapter } from '@chat-adapter/discord'
|
|
137
|
-
import { google } from '@ai-sdk/google'
|
|
138
|
-
|
|
139
|
-
export const visionAgent = new Agent({
|
|
140
|
-
id: 'vision-agent',
|
|
141
|
-
name: 'Vision Agent',
|
|
142
|
-
instructions: 'You can see images, watch videos, and listen to audio.',
|
|
143
|
-
model: google('gemini-3.1-flash-image-preview'),
|
|
144
|
-
channels: {
|
|
145
|
-
adapters: {
|
|
146
|
-
discord: createDiscordAdapter(),
|
|
147
|
-
},
|
|
148
|
-
inlineMedia: ['image/*', 'video/*', 'audio/*'],
|
|
149
|
-
inlineLinks: [
|
|
150
|
-
// Gemini treats YouTube URLs as native video file parts
|
|
151
|
-
{ match: 'youtube.com', mimeType: 'video/*' },
|
|
152
|
-
{ match: 'youtu.be', mimeType: 'video/*' },
|
|
153
|
-
'imgur.com', // HEAD-check imgur links; inline as file part if mimeType matches inlineMedia
|
|
154
|
-
],
|
|
155
|
-
},
|
|
156
|
-
})
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
With this configuration:
|
|
160
|
-
|
|
161
|
-
- A user uploads a screenshot and the agent describes what it sees
|
|
162
|
-
- A user uploads an `.mp4` clip and the agent summarizes the video
|
|
163
|
-
- A user pastes a YouTube link and the agent watches and discusses the video
|
|
164
|
-
- A user pastes an imgur link and the agent sees the image directly
|
|
165
|
-
|
|
166
|
-
By default, only images are sent inline (`inlineMedia: ['image/*']`). Unsupported types are described as text summaries so the agent knows about the file without crashing models that reject them.
|
|
167
|
-
|
|
168
|
-
> **Note:** See [Channels reference](https://mastra.ai/reference/agents/channels) for all `inlineMedia` patterns and [inlineLinks reference](https://mastra.ai/reference/agents/channels) for domain matching, HEAD detection, and forced mime types.
|
|
169
|
-
|
|
170
|
-
## Serverless deployment
|
|
171
|
-
|
|
172
|
-
On serverless platforms like Vercel, each request runs in a separate, short-lived instance. Channels need two things to work reliably in that environment: a way to keep the function alive while the agent responds, and a shared pub/sub so instances can coordinate.
|
|
173
|
-
|
|
174
|
-
### Keep the function alive with `waitUntil`
|
|
175
|
-
|
|
176
|
-
A channel webhook returns a `200` response right away, then the agent runs in the background to post its reply. On most serverless platforms the function is frozen as soon as it responds, which kills the run before the agent answers. Pass a `waitUntil` function so the platform keeps the instance alive until the run finishes.
|
|
177
|
-
|
|
178
|
-
On Vercel, pass `waitUntil` from `@vercel/functions`:
|
|
179
|
-
|
|
180
|
-
```typescript
|
|
181
|
-
import { Agent } from '@mastra/core/agent'
|
|
182
|
-
import { createSlackAdapter } from '@chat-adapter/slack'
|
|
183
|
-
import { waitUntil } from '@vercel/functions'
|
|
184
|
-
|
|
185
|
-
export const agent = new Agent({
|
|
186
|
-
id: 'agent',
|
|
187
|
-
channels: {
|
|
188
|
-
adapters: {
|
|
189
|
-
slack: createSlackAdapter(),
|
|
190
|
-
},
|
|
191
|
-
waitUntil,
|
|
192
|
-
},
|
|
193
|
-
})
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
Vercel and AWS Lambda require `waitUntil`, since they freeze the function as soon as the response is sent. Cloudflare Workers and Netlify Functions are detected automatically from the request context, so they don't need it. For runtimes where `waitUntil` lives on the request context but isn't detected automatically, use `resolveWaitUntil`. See the [Channels reference](https://mastra.ai/reference/agents/channels) for details.
|
|
197
|
-
|
|
198
|
-
### Coordinate instances with a shared pub/sub
|
|
199
|
-
|
|
200
|
-
Channels route messages through the agent's signal pipeline, and each run acquires a lease on its thread so a single run owns the conversation at a time. The default in-memory pub/sub can't cross instance boundaries, so on serverless a follow-up message can land on a different instance than the one running the agent. Without a shared pub/sub, that instance can't reach the active run and starts its own, leaving the original run untouched and the thread processed twice.
|
|
201
|
-
|
|
202
|
-
Configure a shared pub/sub backed by Redis Streams on the `Mastra` instance so leases and signals coordinate across instances:
|
|
203
|
-
|
|
204
|
-
```typescript
|
|
205
|
-
import { Mastra } from '@mastra/core'
|
|
206
|
-
import { RedisStreamsPubSub } from '@mastra/redis-streams'
|
|
207
|
-
|
|
208
|
-
export const mastra = new Mastra({
|
|
209
|
-
agents: { agent },
|
|
210
|
-
pubsub: new RedisStreamsPubSub({
|
|
211
|
-
url: process.env.REDIS_URL,
|
|
212
|
-
keyPrefix: 'mastra:my-app',
|
|
213
|
-
}),
|
|
214
|
-
})
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
Vercel's managed Redis integration and Upstash Redis both work well. For more on when a distributed pub/sub is needed, see the [PubSub guide](https://mastra.ai/docs/server/pubsub) and the [`RedisStreamsPubSub` reference](https://mastra.ai/reference/pubsub/redis-streams).
|
|
218
|
-
|
|
219
|
-
## Related
|
|
220
|
-
|
|
221
|
-
- [Guide: Building a Slack assistant](https://mastra.ai/guides/guide/slack-assistant)
|
|
222
|
-
- [Agent overview](https://mastra.ai/docs/agents/overview)
|
|
223
|
-
- [Tool approval](https://mastra.ai/docs/agents/agent-approval)
|
|
224
|
-
- [Channels reference](https://mastra.ai/reference/agents/channels)
|
|
225
|
-
- [Chat SDK adapters](https://chat-sdk.dev/adapters)
|